aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2015-08-20 21:43:15 -0400
committerOlof Johansson <olof@lixom.net>2015-08-20 21:43:15 -0400
commit5378e4665f226e3b5b460793397eff32b4de9daa (patch)
treec9f2efeecd2a98aa0cdfce9a8a42cd70da96fc9e
parentbd90f11589181adad1b32b16a34df52d17dd4961 (diff)
parent1ec0e115f8604940491861d207cc1e1478db97b3 (diff)
Merge tag 'tegra-for-4.3-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into next/drivers
ARM: tegra: Core SoC changes for v4.3-rc1 This contains a bit more of Tegra210 support, which is shaping up pretty nicely. Other than that there are a couple of cleanup patches here, too. * tag 'tegra-for-4.3-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: ARM: tegra: cpuidle: implement cpuidle_state.enter_freeze() ARM: tegra: Disable cpuidle if PSCI is available soc/tegra: pmc: Use existing pclk reference soc/tegra: pmc: Remove unnecessary return statement soc: tegra: Remove redundant $(CONFIG_ARCH_TEGRA) in Makefile soc/tegra: fuse: Add spare bit offset for Tegra210 soc/tegra: fuse: Add spare bit offset for Tegra124 soc/tegra: fuse: Add spare bit offset for Tegra114 soc/tegra: fuse: Rename core_* to soc_* soc/tegra: fuse: Add Tegra210 support soc/tegra: fuse: Unify Tegra20 and Tegra30 drivers soc/tegra: fuse: Restrict legacy code to 32-bit ARM soc/tegra: pmc: Add Tegra210 support soc/tegra: pmc: Restrict legacy code to 32-bit ARM soc/tegra: pmc: Avoid usage of uninitialized variable soc/tegra: Add Tegra210 support soc/tegra: Add Tegra132 support Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--arch/arm/mach-tegra/cpuidle-tegra114.c19
-rw-r--r--arch/arm/mach-tegra/iomap.h3
-rw-r--r--drivers/soc/tegra/Makefile6
-rw-r--r--drivers/soc/tegra/common.c2
-rw-r--r--drivers/soc/tegra/fuse/Makefile2
-rw-r--r--drivers/soc/tegra/fuse/fuse-tegra.c257
-rw-r--r--drivers/soc/tegra/fuse/fuse-tegra20.c175
-rw-r--r--drivers/soc/tegra/fuse/fuse-tegra30.c232
-rw-r--r--drivers/soc/tegra/fuse/fuse.h95
-rw-r--r--drivers/soc/tegra/fuse/speedo-tegra114.c22
-rw-r--r--drivers/soc/tegra/fuse/speedo-tegra124.c26
-rw-r--r--drivers/soc/tegra/fuse/speedo-tegra20.c28
-rw-r--r--drivers/soc/tegra/fuse/speedo-tegra210.c184
-rw-r--r--drivers/soc/tegra/fuse/speedo-tegra30.c48
-rw-r--r--drivers/soc/tegra/fuse/tegra-apbmisc.c76
-rw-r--r--drivers/soc/tegra/pmc.c125
-rw-r--r--include/soc/tegra/fuse.h6
-rw-r--r--include/soc/tegra/pmc.h5
18 files changed, 853 insertions, 458 deletions
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index 155807fa6fdd..9157546fe68c 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -24,6 +24,7 @@
24#include <asm/cpuidle.h> 24#include <asm/cpuidle.h>
25#include <asm/smp_plat.h> 25#include <asm/smp_plat.h>
26#include <asm/suspend.h> 26#include <asm/suspend.h>
27#include <asm/psci.h>
27 28
28#include "pm.h" 29#include "pm.h"
29#include "sleep.h" 30#include "sleep.h"
@@ -44,16 +45,12 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev,
44 tegra_set_cpu_in_lp2(); 45 tegra_set_cpu_in_lp2();
45 cpu_pm_enter(); 46 cpu_pm_enter();
46 47
47 tick_broadcast_enter();
48
49 call_firmware_op(prepare_idle); 48 call_firmware_op(prepare_idle);
50 49
51 /* Do suspend by ourselves if the firmware does not implement it */ 50 /* Do suspend by ourselves if the firmware does not implement it */
52 if (call_firmware_op(do_idle, 0) == -ENOSYS) 51 if (call_firmware_op(do_idle, 0) == -ENOSYS)
53 cpu_suspend(0, tegra30_sleep_cpu_secondary_finish); 52 cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
54 53
55 tick_broadcast_exit();
56
57 cpu_pm_exit(); 54 cpu_pm_exit();
58 tegra_clear_cpu_in_lp2(); 55 tegra_clear_cpu_in_lp2();
59 56
@@ -61,6 +58,13 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev,
61 58
62 return index; 59 return index;
63} 60}
61
62static void tegra114_idle_enter_freeze(struct cpuidle_device *dev,
63 struct cpuidle_driver *drv,
64 int index)
65{
66 tegra114_idle_power_down(dev, drv, index);
67}
64#endif 68#endif
65 69
66static struct cpuidle_driver tegra_idle_driver = { 70static struct cpuidle_driver tegra_idle_driver = {
@@ -72,8 +76,10 @@ static struct cpuidle_driver tegra_idle_driver = {
72#ifdef CONFIG_PM_SLEEP 76#ifdef CONFIG_PM_SLEEP
73 [1] = { 77 [1] = {
74 .enter = tegra114_idle_power_down, 78 .enter = tegra114_idle_power_down,
79 .enter_freeze = tegra114_idle_enter_freeze,
75 .exit_latency = 500, 80 .exit_latency = 500,
76 .target_residency = 1000, 81 .target_residency = 1000,
82 .flags = CPUIDLE_FLAG_TIMER_STOP,
77 .power_usage = 0, 83 .power_usage = 0,
78 .name = "powered-down", 84 .name = "powered-down",
79 .desc = "CPU power gated", 85 .desc = "CPU power gated",
@@ -84,5 +90,8 @@ static struct cpuidle_driver tegra_idle_driver = {
84 90
85int __init tegra114_cpuidle_init(void) 91int __init tegra114_cpuidle_init(void)
86{ 92{
87 return cpuidle_register(&tegra_idle_driver, NULL); 93 if (!psci_smp_available())
94 return cpuidle_register(&tegra_idle_driver, NULL);
95
96 return 0;
88} 97}
diff --git a/arch/arm/mach-tegra/iomap.h b/arch/arm/mach-tegra/iomap.h
index 81dc950b4881..9e5b2f869fc8 100644
--- a/arch/arm/mach-tegra/iomap.h
+++ b/arch/arm/mach-tegra/iomap.h
@@ -82,9 +82,6 @@
82#define TEGRA_EMC_BASE 0x7000F400 82#define TEGRA_EMC_BASE 0x7000F400
83#define TEGRA_EMC_SIZE SZ_1K 83#define TEGRA_EMC_SIZE SZ_1K
84 84
85#define TEGRA_FUSE_BASE 0x7000F800
86#define TEGRA_FUSE_SIZE SZ_1K
87
88#define TEGRA_EMC0_BASE 0x7001A000 85#define TEGRA_EMC0_BASE 0x7001A000
89#define TEGRA_EMC0_SIZE SZ_2K 86#define TEGRA_EMC0_SIZE SZ_2K
90 87
diff --git a/drivers/soc/tegra/Makefile b/drivers/soc/tegra/Makefile
index cdaad9d53a05..ae857ff7d53d 100644
--- a/drivers/soc/tegra/Makefile
+++ b/drivers/soc/tegra/Makefile
@@ -1,4 +1,4 @@
1obj-$(CONFIG_ARCH_TEGRA) += fuse/ 1obj-y += fuse/
2 2
3obj-$(CONFIG_ARCH_TEGRA) += common.o 3obj-y += common.o
4obj-$(CONFIG_ARCH_TEGRA) += pmc.o 4obj-y += pmc.o
diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
index a71cb74f3674..cd8f41351add 100644
--- a/drivers/soc/tegra/common.c
+++ b/drivers/soc/tegra/common.c
@@ -15,6 +15,8 @@ static const struct of_device_id tegra_machine_match[] = {
15 { .compatible = "nvidia,tegra30", }, 15 { .compatible = "nvidia,tegra30", },
16 { .compatible = "nvidia,tegra114", }, 16 { .compatible = "nvidia,tegra114", },
17 { .compatible = "nvidia,tegra124", }, 17 { .compatible = "nvidia,tegra124", },
18 { .compatible = "nvidia,tegra132", },
19 { .compatible = "nvidia,tegra210", },
18 { } 20 { }
19}; 21};
20 22
diff --git a/drivers/soc/tegra/fuse/Makefile b/drivers/soc/tegra/fuse/Makefile
index 3af357da91f3..21bc27580178 100644
--- a/drivers/soc/tegra/fuse/Makefile
+++ b/drivers/soc/tegra/fuse/Makefile
@@ -6,3 +6,5 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += speedo-tegra20.o
6obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += speedo-tegra30.o 6obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += speedo-tegra30.o
7obj-$(CONFIG_ARCH_TEGRA_114_SOC) += speedo-tegra114.o 7obj-$(CONFIG_ARCH_TEGRA_114_SOC) += speedo-tegra114.o
8obj-$(CONFIG_ARCH_TEGRA_124_SOC) += speedo-tegra124.o 8obj-$(CONFIG_ARCH_TEGRA_124_SOC) += speedo-tegra124.o
9obj-$(CONFIG_ARCH_TEGRA_132_SOC) += speedo-tegra124.o
10obj-$(CONFIG_ARCH_TEGRA_210_SOC) += speedo-tegra210.o
diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index c0d660f1aaac..de2c1bfe28b5 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -15,9 +15,10 @@
15 * 15 *
16 */ 16 */
17 17
18#include <linux/clk.h>
18#include <linux/device.h> 19#include <linux/device.h>
19#include <linux/kobject.h> 20#include <linux/kobject.h>
20#include <linux/kernel.h> 21#include <linux/module.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <linux/of.h> 23#include <linux/of.h>
23#include <linux/of_address.h> 24#include <linux/of_address.h>
@@ -28,8 +29,6 @@
28 29
29#include "fuse.h" 30#include "fuse.h"
30 31
31static u32 (*fuse_readl)(const unsigned int offset);
32static int fuse_size;
33struct tegra_sku_info tegra_sku_info; 32struct tegra_sku_info tegra_sku_info;
34EXPORT_SYMBOL(tegra_sku_info); 33EXPORT_SYMBOL(tegra_sku_info);
35 34
@@ -42,11 +41,11 @@ static const char *tegra_revision_name[TEGRA_REVISION_MAX] = {
42 [TEGRA_REVISION_A04] = "A04", 41 [TEGRA_REVISION_A04] = "A04",
43}; 42};
44 43
45static u8 fuse_readb(const unsigned int offset) 44static u8 fuse_readb(struct tegra_fuse *fuse, unsigned int offset)
46{ 45{
47 u32 val; 46 u32 val;
48 47
49 val = fuse_readl(round_down(offset, 4)); 48 val = fuse->read(fuse, round_down(offset, 4));
50 val >>= (offset % 4) * 8; 49 val >>= (offset % 4) * 8;
51 val &= 0xff; 50 val &= 0xff;
52 51
@@ -54,19 +53,21 @@ static u8 fuse_readb(const unsigned int offset)
54} 53}
55 54
56static ssize_t fuse_read(struct file *fd, struct kobject *kobj, 55static ssize_t fuse_read(struct file *fd, struct kobject *kobj,
57 struct bin_attribute *attr, char *buf, 56 struct bin_attribute *attr, char *buf,
58 loff_t pos, size_t size) 57 loff_t pos, size_t size)
59{ 58{
59 struct device *dev = kobj_to_dev(kobj);
60 struct tegra_fuse *fuse = dev_get_drvdata(dev);
60 int i; 61 int i;
61 62
62 if (pos < 0 || pos >= fuse_size) 63 if (pos < 0 || pos >= attr->size)
63 return 0; 64 return 0;
64 65
65 if (size > fuse_size - pos) 66 if (size > attr->size - pos)
66 size = fuse_size - pos; 67 size = attr->size - pos;
67 68
68 for (i = 0; i < size; i++) 69 for (i = 0; i < size; i++)
69 buf[i] = fuse_readb(pos + i); 70 buf[i] = fuse_readb(fuse, pos + i);
70 71
71 return i; 72 return i;
72} 73}
@@ -76,89 +77,239 @@ static struct bin_attribute fuse_bin_attr = {
76 .read = fuse_read, 77 .read = fuse_read,
77}; 78};
78 79
80static int tegra_fuse_create_sysfs(struct device *dev, unsigned int size,
81 const struct tegra_fuse_info *info)
82{
83 fuse_bin_attr.size = size;
84
85 return device_create_bin_file(dev, &fuse_bin_attr);
86}
87
79static const struct of_device_id car_match[] __initconst = { 88static const struct of_device_id car_match[] __initconst = {
80 { .compatible = "nvidia,tegra20-car", }, 89 { .compatible = "nvidia,tegra20-car", },
81 { .compatible = "nvidia,tegra30-car", }, 90 { .compatible = "nvidia,tegra30-car", },
82 { .compatible = "nvidia,tegra114-car", }, 91 { .compatible = "nvidia,tegra114-car", },
83 { .compatible = "nvidia,tegra124-car", }, 92 { .compatible = "nvidia,tegra124-car", },
84 { .compatible = "nvidia,tegra132-car", }, 93 { .compatible = "nvidia,tegra132-car", },
94 { .compatible = "nvidia,tegra210-car", },
85 {}, 95 {},
86}; 96};
87 97
88static void tegra_enable_fuse_clk(void __iomem *base) 98static struct tegra_fuse *fuse = &(struct tegra_fuse) {
99 .base = NULL,
100 .soc = NULL,
101};
102
103static const struct of_device_id tegra_fuse_match[] = {
104#ifdef CONFIG_ARCH_TEGRA_210_SOC
105 { .compatible = "nvidia,tegra210-efuse", .data = &tegra210_fuse_soc },
106#endif
107#ifdef CONFIG_ARCH_TEGRA_132_SOC
108 { .compatible = "nvidia,tegra132-efuse", .data = &tegra124_fuse_soc },
109#endif
110#ifdef CONFIG_ARCH_TEGRA_124_SOC
111 { .compatible = "nvidia,tegra124-efuse", .data = &tegra124_fuse_soc },
112#endif
113#ifdef CONFIG_ARCH_TEGRA_114_SOC
114 { .compatible = "nvidia,tegra114-efuse", .data = &tegra114_fuse_soc },
115#endif
116#ifdef CONFIG_ARCH_TEGRA_3x_SOC
117 { .compatible = "nvidia,tegra30-efuse", .data = &tegra30_fuse_soc },
118#endif
119#ifdef CONFIG_ARCH_TEGRA_2x_SOC
120 { .compatible = "nvidia,tegra20-efuse", .data = &tegra20_fuse_soc },
121#endif
122 { /* sentinel */ }
123};
124
125static int tegra_fuse_probe(struct platform_device *pdev)
89{ 126{
90 u32 reg; 127 void __iomem *base = fuse->base;
128 struct resource *res;
129 int err;
130
131 /* take over the memory region from the early initialization */
132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
133 fuse->base = devm_ioremap_resource(&pdev->dev, res);
134 if (IS_ERR(fuse->base))
135 return PTR_ERR(fuse->base);
136
137 fuse->clk = devm_clk_get(&pdev->dev, "fuse");
138 if (IS_ERR(fuse->clk)) {
139 dev_err(&pdev->dev, "failed to get FUSE clock: %ld",
140 PTR_ERR(fuse->clk));
141 return PTR_ERR(fuse->clk);
142 }
91 143
92 reg = readl_relaxed(base + 0x48); 144 platform_set_drvdata(pdev, fuse);
93 reg |= 1 << 28; 145 fuse->dev = &pdev->dev;
94 writel(reg, base + 0x48);
95 146
96 /* 147 if (fuse->soc->probe) {
97 * Enable FUSE clock. This needs to be hardcoded because the clock 148 err = fuse->soc->probe(fuse);
98 * subsystem is not active during early boot. 149 if (err < 0)
99 */ 150 return err;
100 reg = readl(base + 0x14); 151 }
101 reg |= 1 << 7; 152
102 writel(reg, base + 0x14); 153 if (tegra_fuse_create_sysfs(&pdev->dev, fuse->soc->info->size,
154 fuse->soc->info))
155 return -ENODEV;
156
157 /* release the early I/O memory mapping */
158 iounmap(base);
159
160 return 0;
161}
162
163static struct platform_driver tegra_fuse_driver = {
164 .driver = {
165 .name = "tegra-fuse",
166 .of_match_table = tegra_fuse_match,
167 .suppress_bind_attrs = true,
168 },
169 .probe = tegra_fuse_probe,
170};
171module_platform_driver(tegra_fuse_driver);
172
173bool __init tegra_fuse_read_spare(unsigned int spare)
174{
175 unsigned int offset = fuse->soc->info->spare + spare * 4;
176
177 return fuse->read_early(fuse, offset) & 1;
178}
179
180u32 __init tegra_fuse_read_early(unsigned int offset)
181{
182 return fuse->read_early(fuse, offset);
103} 183}
104 184
105int tegra_fuse_readl(unsigned long offset, u32 *value) 185int tegra_fuse_readl(unsigned long offset, u32 *value)
106{ 186{
107 if (!fuse_readl) 187 if (!fuse->read)
108 return -EPROBE_DEFER; 188 return -EPROBE_DEFER;
109 189
110 *value = fuse_readl(offset); 190 *value = fuse->read(fuse, offset);
111 191
112 return 0; 192 return 0;
113} 193}
114EXPORT_SYMBOL(tegra_fuse_readl); 194EXPORT_SYMBOL(tegra_fuse_readl);
115 195
116int tegra_fuse_create_sysfs(struct device *dev, int size, 196static void tegra_enable_fuse_clk(void __iomem *base)
117 u32 (*readl)(const unsigned int offset))
118{ 197{
119 if (fuse_size) 198 u32 reg;
120 return -ENODEV;
121
122 fuse_bin_attr.size = size;
123 fuse_bin_attr.read = fuse_read;
124 199
125 fuse_size = size; 200 reg = readl_relaxed(base + 0x48);
126 fuse_readl = readl; 201 reg |= 1 << 28;
202 writel(reg, base + 0x48);
127 203
128 return device_create_bin_file(dev, &fuse_bin_attr); 204 /*
205 * Enable FUSE clock. This needs to be hardcoded because the clock
206 * subsystem is not active during early boot.
207 */
208 reg = readl(base + 0x14);
209 reg |= 1 << 7;
210 writel(reg, base + 0x14);
129} 211}
130 212
131static int __init tegra_init_fuse(void) 213static int __init tegra_init_fuse(void)
132{ 214{
215 const struct of_device_id *match;
133 struct device_node *np; 216 struct device_node *np;
134 void __iomem *car_base; 217 struct resource regs;
135
136 if (!soc_is_tegra())
137 return 0;
138 218
139 tegra_init_apbmisc(); 219 tegra_init_apbmisc();
140 220
141 np = of_find_matching_node(NULL, car_match); 221 np = of_find_matching_node_and_match(NULL, tegra_fuse_match, &match);
142 car_base = of_iomap(np, 0); 222 if (!np) {
143 if (car_base) { 223 /*
144 tegra_enable_fuse_clk(car_base); 224 * Fall back to legacy initialization for 32-bit ARM only. All
145 iounmap(car_base); 225 * 64-bit ARM device tree files for Tegra are required to have
226 * a FUSE node.
227 *
228 * This is for backwards-compatibility with old device trees
229 * that didn't contain a FUSE node.
230 */
231 if (IS_ENABLED(CONFIG_ARM) && soc_is_tegra()) {
232 u8 chip = tegra_get_chip_id();
233
234 regs.start = 0x7000f800;
235 regs.end = 0x7000fbff;
236 regs.flags = IORESOURCE_MEM;
237
238 switch (chip) {
239#ifdef CONFIG_ARCH_TEGRA_2x_SOC
240 case TEGRA20:
241 fuse->soc = &tegra20_fuse_soc;
242 break;
243#endif
244
245#ifdef CONFIG_ARCH_TEGRA_3x_SOC
246 case TEGRA30:
247 fuse->soc = &tegra30_fuse_soc;
248 break;
249#endif
250
251#ifdef CONFIG_ARCH_TEGRA_114_SOC
252 case TEGRA114:
253 fuse->soc = &tegra114_fuse_soc;
254 break;
255#endif
256
257#ifdef CONFIG_ARCH_TEGRA_124_SOC
258 case TEGRA124:
259 fuse->soc = &tegra124_fuse_soc;
260 break;
261#endif
262
263 default:
264 pr_warn("Unsupported SoC: %02x\n", chip);
265 break;
266 }
267 } else {
268 /*
269 * At this point we're not running on Tegra, so play
270 * nice with multi-platform kernels.
271 */
272 return 0;
273 }
146 } else { 274 } else {
147 pr_err("Could not enable fuse clk. ioremap tegra car failed.\n"); 275 /*
276 * Extract information from the device tree if we've found a
277 * matching node.
278 */
279 if (of_address_to_resource(np, 0, &regs) < 0) {
280 pr_err("failed to get FUSE register\n");
281 return -ENXIO;
282 }
283
284 fuse->soc = match->data;
285 }
286
287 np = of_find_matching_node(NULL, car_match);
288 if (np) {
289 void __iomem *base = of_iomap(np, 0);
290 if (base) {
291 tegra_enable_fuse_clk(base);
292 iounmap(base);
293 } else {
294 pr_err("failed to map clock registers\n");
295 return -ENXIO;
296 }
297 }
298
299 fuse->base = ioremap_nocache(regs.start, resource_size(&regs));
300 if (!fuse->base) {
301 pr_err("failed to map FUSE registers\n");
148 return -ENXIO; 302 return -ENXIO;
149 } 303 }
150 304
151 if (tegra_get_chip_id() == TEGRA20) 305 fuse->soc->init(fuse);
152 tegra20_init_fuse_early();
153 else
154 tegra30_init_fuse_early();
155 306
156 pr_info("Tegra Revision: %s SKU: %d CPU Process: %d Core Process: %d\n", 307 pr_info("Tegra Revision: %s SKU: %d CPU Process: %d SoC Process: %d\n",
157 tegra_revision_name[tegra_sku_info.revision], 308 tegra_revision_name[tegra_sku_info.revision],
158 tegra_sku_info.sku_id, tegra_sku_info.cpu_process_id, 309 tegra_sku_info.sku_id, tegra_sku_info.cpu_process_id,
159 tegra_sku_info.core_process_id); 310 tegra_sku_info.soc_process_id);
160 pr_debug("Tegra CPU Speedo ID %d, Soc Speedo ID %d\n", 311 pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n",
161 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id); 312 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);
162 313
163 return 0; 314 return 0;
164} 315}
diff --git a/drivers/soc/tegra/fuse/fuse-tegra20.c b/drivers/soc/tegra/fuse/fuse-tegra20.c
index 6acc2c44ee2c..294413a969a0 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra20.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra20.c
@@ -34,159 +34,107 @@
34#include "fuse.h" 34#include "fuse.h"
35 35
36#define FUSE_BEGIN 0x100 36#define FUSE_BEGIN 0x100
37#define FUSE_SIZE 0x1f8
38#define FUSE_UID_LOW 0x08 37#define FUSE_UID_LOW 0x08
39#define FUSE_UID_HIGH 0x0c 38#define FUSE_UID_HIGH 0x0c
40 39
41static phys_addr_t fuse_phys; 40static u32 tegra20_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
42static struct clk *fuse_clk; 41{
43static void __iomem __initdata *fuse_base; 42 return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
44 43}
45static DEFINE_MUTEX(apb_dma_lock);
46static DECLARE_COMPLETION(apb_dma_wait);
47static struct dma_chan *apb_dma_chan;
48static struct dma_slave_config dma_sconfig;
49static u32 *apb_buffer;
50static dma_addr_t apb_buffer_phys;
51 44
52static void apb_dma_complete(void *args) 45static void apb_dma_complete(void *args)
53{ 46{
54 complete(&apb_dma_wait); 47 struct tegra_fuse *fuse = args;
48
49 complete(&fuse->apbdma.wait);
55} 50}
56 51
57static u32 tegra20_fuse_readl(const unsigned int offset) 52static u32 tegra20_fuse_read(struct tegra_fuse *fuse, unsigned int offset)
58{ 53{
59 int ret; 54 unsigned long flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
60 u32 val = 0;
61 struct dma_async_tx_descriptor *dma_desc; 55 struct dma_async_tx_descriptor *dma_desc;
62 unsigned long time_left; 56 unsigned long time_left;
57 u32 value = 0;
58 int err;
59
60 mutex_lock(&fuse->apbdma.lock);
63 61
64 mutex_lock(&apb_dma_lock); 62 fuse->apbdma.config.src_addr = fuse->apbdma.phys + FUSE_BEGIN + offset;
65 63
66 dma_sconfig.src_addr = fuse_phys + FUSE_BEGIN + offset; 64 err = dmaengine_slave_config(fuse->apbdma.chan, &fuse->apbdma.config);
67 ret = dmaengine_slave_config(apb_dma_chan, &dma_sconfig); 65 if (err)
68 if (ret)
69 goto out; 66 goto out;
70 67
71 dma_desc = dmaengine_prep_slave_single(apb_dma_chan, apb_buffer_phys, 68 dma_desc = dmaengine_prep_slave_single(fuse->apbdma.chan,
72 sizeof(u32), DMA_DEV_TO_MEM, 69 fuse->apbdma.phys,
73 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 70 sizeof(u32), DMA_DEV_TO_MEM,
71 flags);
74 if (!dma_desc) 72 if (!dma_desc)
75 goto out; 73 goto out;
76 74
77 dma_desc->callback = apb_dma_complete; 75 dma_desc->callback = apb_dma_complete;
78 dma_desc->callback_param = NULL; 76 dma_desc->callback_param = fuse;
79 77
80 reinit_completion(&apb_dma_wait); 78 reinit_completion(&fuse->apbdma.wait);
81 79
82 clk_prepare_enable(fuse_clk); 80 clk_prepare_enable(fuse->clk);
83 81
84 dmaengine_submit(dma_desc); 82 dmaengine_submit(dma_desc);
85 dma_async_issue_pending(apb_dma_chan); 83 dma_async_issue_pending(fuse->apbdma.chan);
86 time_left = wait_for_completion_timeout(&apb_dma_wait, 84 time_left = wait_for_completion_timeout(&fuse->apbdma.wait,
87 msecs_to_jiffies(50)); 85 msecs_to_jiffies(50));
88 86
89 if (WARN(time_left == 0, "apb read dma timed out")) 87 if (WARN(time_left == 0, "apb read dma timed out"))
90 dmaengine_terminate_all(apb_dma_chan); 88 dmaengine_terminate_all(fuse->apbdma.chan);
91 else 89 else
92 val = *apb_buffer; 90 value = *fuse->apbdma.virt;
93 91
94 clk_disable_unprepare(fuse_clk); 92 clk_disable_unprepare(fuse->clk);
95out:
96 mutex_unlock(&apb_dma_lock);
97 93
98 return val; 94out:
95 mutex_unlock(&fuse->apbdma.lock);
96 return value;
99} 97}
100 98
101static const struct of_device_id tegra20_fuse_of_match[] = { 99static int tegra20_fuse_probe(struct tegra_fuse *fuse)
102 { .compatible = "nvidia,tegra20-efuse" },
103 {},
104};
105
106static int apb_dma_init(void)
107{ 100{
108 dma_cap_mask_t mask; 101 dma_cap_mask_t mask;
109 102
110 dma_cap_zero(mask); 103 dma_cap_zero(mask);
111 dma_cap_set(DMA_SLAVE, mask); 104 dma_cap_set(DMA_SLAVE, mask);
112 apb_dma_chan = dma_request_channel(mask, NULL, NULL); 105
113 if (!apb_dma_chan) 106 fuse->apbdma.chan = dma_request_channel(mask, NULL, NULL);
107 if (!fuse->apbdma.chan)
114 return -EPROBE_DEFER; 108 return -EPROBE_DEFER;
115 109
116 apb_buffer = dma_alloc_coherent(NULL, sizeof(u32), &apb_buffer_phys, 110 fuse->apbdma.virt = dma_alloc_coherent(fuse->dev, sizeof(u32),
117 GFP_KERNEL); 111 &fuse->apbdma.phys,
118 if (!apb_buffer) { 112 GFP_KERNEL);
119 dma_release_channel(apb_dma_chan); 113 if (!fuse->apbdma.virt) {
114 dma_release_channel(fuse->apbdma.chan);
120 return -ENOMEM; 115 return -ENOMEM;
121 } 116 }
122 117
123 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 118 fuse->apbdma.config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
124 dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 119 fuse->apbdma.config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
125 dma_sconfig.src_maxburst = 1; 120 fuse->apbdma.config.src_maxburst = 1;
126 dma_sconfig.dst_maxburst = 1; 121 fuse->apbdma.config.dst_maxburst = 1;
127 122
128 return 0; 123 init_completion(&fuse->apbdma.wait);
129} 124 mutex_init(&fuse->apbdma.lock);
130 125 fuse->read = tegra20_fuse_read;
131static int tegra20_fuse_probe(struct platform_device *pdev)
132{
133 struct resource *res;
134 int err;
135
136 fuse_clk = devm_clk_get(&pdev->dev, NULL);
137 if (IS_ERR(fuse_clk)) {
138 dev_err(&pdev->dev, "missing clock");
139 return PTR_ERR(fuse_clk);
140 }
141
142 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
143 if (!res)
144 return -EINVAL;
145 fuse_phys = res->start;
146
147 err = apb_dma_init();
148 if (err)
149 return err;
150
151 if (tegra_fuse_create_sysfs(&pdev->dev, FUSE_SIZE, tegra20_fuse_readl))
152 return -ENODEV;
153
154 dev_dbg(&pdev->dev, "loaded\n");
155 126
156 return 0; 127 return 0;
157} 128}
158 129
159static struct platform_driver tegra20_fuse_driver = { 130static const struct tegra_fuse_info tegra20_fuse_info = {
160 .probe = tegra20_fuse_probe, 131 .read = tegra20_fuse_read,
161 .driver = { 132 .size = 0x1f8,
162 .name = "tegra20_fuse", 133 .spare = 0x100,
163 .of_match_table = tegra20_fuse_of_match,
164 }
165}; 134};
166 135
167static int __init tegra20_fuse_init(void)
168{
169 return platform_driver_register(&tegra20_fuse_driver);
170}
171postcore_initcall(tegra20_fuse_init);
172
173/* Early boot code. This code is called before the devices are created */ 136/* Early boot code. This code is called before the devices are created */
174 137
175u32 __init tegra20_fuse_early(const unsigned int offset)
176{
177 return readl_relaxed(fuse_base + FUSE_BEGIN + offset);
178}
179
180bool __init tegra20_spare_fuse_early(int spare_bit)
181{
182 u32 offset = spare_bit * 4;
183 bool value;
184
185 value = tegra20_fuse_early(offset + 0x100);
186
187 return value;
188}
189
190static void __init tegra20_fuse_add_randomness(void) 138static void __init tegra20_fuse_add_randomness(void)
191{ 139{
192 u32 randomness[7]; 140 u32 randomness[7];
@@ -195,22 +143,27 @@ static void __init tegra20_fuse_add_randomness(void)
195 randomness[1] = tegra_read_straps(); 143 randomness[1] = tegra_read_straps();
196 randomness[2] = tegra_read_chipid(); 144 randomness[2] = tegra_read_chipid();
197 randomness[3] = tegra_sku_info.cpu_process_id << 16; 145 randomness[3] = tegra_sku_info.cpu_process_id << 16;
198 randomness[3] |= tegra_sku_info.core_process_id; 146 randomness[3] |= tegra_sku_info.soc_process_id;
199 randomness[4] = tegra_sku_info.cpu_speedo_id << 16; 147 randomness[4] = tegra_sku_info.cpu_speedo_id << 16;
200 randomness[4] |= tegra_sku_info.soc_speedo_id; 148 randomness[4] |= tegra_sku_info.soc_speedo_id;
201 randomness[5] = tegra20_fuse_early(FUSE_UID_LOW); 149 randomness[5] = tegra_fuse_read_early(FUSE_UID_LOW);
202 randomness[6] = tegra20_fuse_early(FUSE_UID_HIGH); 150 randomness[6] = tegra_fuse_read_early(FUSE_UID_HIGH);
203 151
204 add_device_randomness(randomness, sizeof(randomness)); 152 add_device_randomness(randomness, sizeof(randomness));
205} 153}
206 154
207void __init tegra20_init_fuse_early(void) 155static void __init tegra20_fuse_init(struct tegra_fuse *fuse)
208{ 156{
209 fuse_base = ioremap(TEGRA_FUSE_BASE, TEGRA_FUSE_SIZE); 157 fuse->read_early = tegra20_fuse_read_early;
210 158
211 tegra_init_revision(); 159 tegra_init_revision();
212 tegra20_init_speedo_data(&tegra_sku_info); 160 fuse->soc->speedo_init(&tegra_sku_info);
213 tegra20_fuse_add_randomness(); 161 tegra20_fuse_add_randomness();
214
215 iounmap(fuse_base);
216} 162}
163
164const struct tegra_fuse_soc tegra20_fuse_soc = {
165 .init = tegra20_fuse_init,
166 .speedo_init = tegra20_init_speedo_data,
167 .probe = tegra20_fuse_probe,
168 .info = &tegra20_fuse_info,
169};
diff --git a/drivers/soc/tegra/fuse/fuse-tegra30.c b/drivers/soc/tegra/fuse/fuse-tegra30.c
index 4d2f71bf65c5..882607bcaa6c 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra30.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra30.c
@@ -42,113 +42,33 @@
42 42
43#define FUSE_HAS_REVISION_INFO BIT(0) 43#define FUSE_HAS_REVISION_INFO BIT(0)
44 44
45enum speedo_idx { 45#if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \
46 SPEEDO_TEGRA30 = 0, 46 defined(CONFIG_ARCH_TEGRA_114_SOC) || \
47 SPEEDO_TEGRA114, 47 defined(CONFIG_ARCH_TEGRA_124_SOC) || \
48 SPEEDO_TEGRA124, 48 defined(CONFIG_ARCH_TEGRA_132_SOC) || \
49}; 49 defined(CONFIG_ARCH_TEGRA_210_SOC)
50 50static u32 tegra30_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
51struct tegra_fuse_info {
52 int size;
53 int spare_bit;
54 enum speedo_idx speedo_idx;
55};
56
57static void __iomem *fuse_base;
58static struct clk *fuse_clk;
59static const struct tegra_fuse_info *fuse_info;
60
61u32 tegra30_fuse_readl(const unsigned int offset)
62{ 51{
63 u32 val; 52 return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
64
65 /*
66 * early in the boot, the fuse clock will be enabled by
67 * tegra_init_fuse()
68 */
69
70 if (fuse_clk)
71 clk_prepare_enable(fuse_clk);
72
73 val = readl_relaxed(fuse_base + FUSE_BEGIN + offset);
74
75 if (fuse_clk)
76 clk_disable_unprepare(fuse_clk);
77
78 return val;
79} 53}
80 54
81static const struct tegra_fuse_info tegra30_info = { 55static u32 tegra30_fuse_read(struct tegra_fuse *fuse, unsigned int offset)
82 .size = 0x2a4,
83 .spare_bit = 0x144,
84 .speedo_idx = SPEEDO_TEGRA30,
85};
86
87static const struct tegra_fuse_info tegra114_info = {
88 .size = 0x2a0,
89 .speedo_idx = SPEEDO_TEGRA114,
90};
91
92static const struct tegra_fuse_info tegra124_info = {
93 .size = 0x300,
94 .speedo_idx = SPEEDO_TEGRA124,
95};
96
97static const struct of_device_id tegra30_fuse_of_match[] = {
98 { .compatible = "nvidia,tegra30-efuse", .data = &tegra30_info },
99 { .compatible = "nvidia,tegra114-efuse", .data = &tegra114_info },
100 { .compatible = "nvidia,tegra124-efuse", .data = &tegra124_info },
101 {},
102};
103
104static int tegra30_fuse_probe(struct platform_device *pdev)
105{ 56{
106 const struct of_device_id *of_dev_id; 57 u32 value;
107 58 int err;
108 of_dev_id = of_match_device(tegra30_fuse_of_match, &pdev->dev);
109 if (!of_dev_id)
110 return -ENODEV;
111 59
112 fuse_clk = devm_clk_get(&pdev->dev, NULL); 60 err = clk_prepare_enable(fuse->clk);
113 if (IS_ERR(fuse_clk)) { 61 if (err < 0) {
114 dev_err(&pdev->dev, "missing clock"); 62 dev_err(fuse->dev, "failed to enable FUSE clock: %d\n", err);
115 return PTR_ERR(fuse_clk); 63 return 0;
116 } 64 }
117 65
118 platform_set_drvdata(pdev, NULL); 66 value = readl_relaxed(fuse->base + FUSE_BEGIN + offset);
119
120 if (tegra_fuse_create_sysfs(&pdev->dev, fuse_info->size,
121 tegra30_fuse_readl))
122 return -ENODEV;
123 67
124 dev_dbg(&pdev->dev, "loaded\n"); 68 clk_disable_unprepare(fuse->clk);
125 69
126 return 0; 70 return value;
127}
128
129static struct platform_driver tegra30_fuse_driver = {
130 .probe = tegra30_fuse_probe,
131 .driver = {
132 .name = "tegra_fuse",
133 .of_match_table = tegra30_fuse_of_match,
134 }
135};
136
137static int __init tegra30_fuse_init(void)
138{
139 return platform_driver_register(&tegra30_fuse_driver);
140} 71}
141postcore_initcall(tegra30_fuse_init);
142
143/* Early boot code. This code is called before the devices are created */
144
145typedef void (*speedo_f)(struct tegra_sku_info *sku_info);
146
147static speedo_f __initdata speedo_tbl[] = {
148 [SPEEDO_TEGRA30] = tegra30_init_speedo_data,
149 [SPEEDO_TEGRA114] = tegra114_init_speedo_data,
150 [SPEEDO_TEGRA124] = tegra124_init_speedo_data,
151};
152 72
153static void __init tegra30_fuse_add_randomness(void) 73static void __init tegra30_fuse_add_randomness(void)
154{ 74{
@@ -158,67 +78,83 @@ static void __init tegra30_fuse_add_randomness(void)
158 randomness[1] = tegra_read_straps(); 78 randomness[1] = tegra_read_straps();
159 randomness[2] = tegra_read_chipid(); 79 randomness[2] = tegra_read_chipid();
160 randomness[3] = tegra_sku_info.cpu_process_id << 16; 80 randomness[3] = tegra_sku_info.cpu_process_id << 16;
161 randomness[3] |= tegra_sku_info.core_process_id; 81 randomness[3] |= tegra_sku_info.soc_process_id;
162 randomness[4] = tegra_sku_info.cpu_speedo_id << 16; 82 randomness[4] = tegra_sku_info.cpu_speedo_id << 16;
163 randomness[4] |= tegra_sku_info.soc_speedo_id; 83 randomness[4] |= tegra_sku_info.soc_speedo_id;
164 randomness[5] = tegra30_fuse_readl(FUSE_VENDOR_CODE); 84 randomness[5] = tegra_fuse_read_early(FUSE_VENDOR_CODE);
165 randomness[6] = tegra30_fuse_readl(FUSE_FAB_CODE); 85 randomness[6] = tegra_fuse_read_early(FUSE_FAB_CODE);
166 randomness[7] = tegra30_fuse_readl(FUSE_LOT_CODE_0); 86 randomness[7] = tegra_fuse_read_early(FUSE_LOT_CODE_0);
167 randomness[8] = tegra30_fuse_readl(FUSE_LOT_CODE_1); 87 randomness[8] = tegra_fuse_read_early(FUSE_LOT_CODE_1);
168 randomness[9] = tegra30_fuse_readl(FUSE_WAFER_ID); 88 randomness[9] = tegra_fuse_read_early(FUSE_WAFER_ID);
169 randomness[10] = tegra30_fuse_readl(FUSE_X_COORDINATE); 89 randomness[10] = tegra_fuse_read_early(FUSE_X_COORDINATE);
170 randomness[11] = tegra30_fuse_readl(FUSE_Y_COORDINATE); 90 randomness[11] = tegra_fuse_read_early(FUSE_Y_COORDINATE);
171 91
172 add_device_randomness(randomness, sizeof(randomness)); 92 add_device_randomness(randomness, sizeof(randomness));
173} 93}
174 94
175static void __init legacy_fuse_init(void) 95static void __init tegra30_fuse_init(struct tegra_fuse *fuse)
176{ 96{
177 switch (tegra_get_chip_id()) { 97 fuse->read_early = tegra30_fuse_read_early;
178 case TEGRA30: 98 fuse->read = tegra30_fuse_read;
179 fuse_info = &tegra30_info;
180 break;
181 case TEGRA114:
182 fuse_info = &tegra114_info;
183 break;
184 case TEGRA124:
185 case TEGRA132:
186 fuse_info = &tegra124_info;
187 break;
188 default:
189 return;
190 }
191 99
192 fuse_base = ioremap(TEGRA_FUSE_BASE, TEGRA_FUSE_SIZE); 100 tegra_init_revision();
101 fuse->soc->speedo_init(&tegra_sku_info);
102 tegra30_fuse_add_randomness();
193} 103}
104#endif
194 105
195bool __init tegra30_spare_fuse(int spare_bit) 106#ifdef CONFIG_ARCH_TEGRA_3x_SOC
196{ 107static const struct tegra_fuse_info tegra30_fuse_info = {
197 u32 offset = fuse_info->spare_bit + spare_bit * 4; 108 .read = tegra30_fuse_read,
109 .size = 0x2a4,
110 .spare = 0x144,
111};
198 112
199 return tegra30_fuse_readl(offset) & 1; 113const struct tegra_fuse_soc tegra30_fuse_soc = {
200} 114 .init = tegra30_fuse_init,
115 .speedo_init = tegra30_init_speedo_data,
116 .info = &tegra30_fuse_info,
117};
118#endif
201 119
202void __init tegra30_init_fuse_early(void) 120#ifdef CONFIG_ARCH_TEGRA_114_SOC
203{ 121static const struct tegra_fuse_info tegra114_fuse_info = {
204 struct device_node *np; 122 .read = tegra30_fuse_read,
205 const struct of_device_id *of_match; 123 .size = 0x2a0,
206 124 .spare = 0x180,
207 np = of_find_matching_node_and_match(NULL, tegra30_fuse_of_match, 125};
208 &of_match);
209 if (np) {
210 fuse_base = of_iomap(np, 0);
211 fuse_info = (struct tegra_fuse_info *)of_match->data;
212 } else
213 legacy_fuse_init();
214
215 if (!fuse_base) {
216 pr_warn("fuse DT node missing and unknown chip id: 0x%02x\n",
217 tegra_get_chip_id());
218 return;
219 }
220 126
221 tegra_init_revision(); 127const struct tegra_fuse_soc tegra114_fuse_soc = {
222 speedo_tbl[fuse_info->speedo_idx](&tegra_sku_info); 128 .init = tegra30_fuse_init,
223 tegra30_fuse_add_randomness(); 129 .speedo_init = tegra114_init_speedo_data,
224} 130 .info = &tegra114_fuse_info,
131};
132#endif
133
134#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
135static const struct tegra_fuse_info tegra124_fuse_info = {
136 .read = tegra30_fuse_read,
137 .size = 0x300,
138 .spare = 0x200,
139};
140
141const struct tegra_fuse_soc tegra124_fuse_soc = {
142 .init = tegra30_fuse_init,
143 .speedo_init = tegra124_init_speedo_data,
144 .info = &tegra124_fuse_info,
145};
146#endif
147
148#if defined(CONFIG_ARCH_TEGRA_210_SOC)
149static const struct tegra_fuse_info tegra210_fuse_info = {
150 .read = tegra30_fuse_read,
151 .size = 0x300,
152 .spare = 0x280,
153};
154
155const struct tegra_fuse_soc tegra210_fuse_soc = {
156 .init = tegra30_fuse_init,
157 .speedo_init = tegra210_init_speedo_data,
158 .info = &tegra210_fuse_info,
159};
160#endif
diff --git a/drivers/soc/tegra/fuse/fuse.h b/drivers/soc/tegra/fuse/fuse.h
index 3a398bf3572c..10c2076d5089 100644
--- a/drivers/soc/tegra/fuse/fuse.h
+++ b/drivers/soc/tegra/fuse/fuse.h
@@ -19,53 +19,90 @@
19#ifndef __DRIVERS_MISC_TEGRA_FUSE_H 19#ifndef __DRIVERS_MISC_TEGRA_FUSE_H
20#define __DRIVERS_MISC_TEGRA_FUSE_H 20#define __DRIVERS_MISC_TEGRA_FUSE_H
21 21
22#define TEGRA_FUSE_BASE 0x7000f800 22#include <linux/dmaengine.h>
23#define TEGRA_FUSE_SIZE 0x400 23#include <linux/types.h>
24 24
25int tegra_fuse_create_sysfs(struct device *dev, int size, 25struct tegra_fuse;
26 u32 (*readl)(const unsigned int offset)); 26
27struct tegra_fuse_info {
28 u32 (*read)(struct tegra_fuse *fuse, unsigned int offset);
29 unsigned int size;
30 unsigned int spare;
31};
32
33struct tegra_fuse_soc {
34 void (*init)(struct tegra_fuse *fuse);
35 void (*speedo_init)(struct tegra_sku_info *info);
36 int (*probe)(struct tegra_fuse *fuse);
37
38 const struct tegra_fuse_info *info;
39};
40
41struct tegra_fuse {
42 struct device *dev;
43 void __iomem *base;
44 phys_addr_t phys;
45 struct clk *clk;
46
47 u32 (*read_early)(struct tegra_fuse *fuse, unsigned int offset);
48 u32 (*read)(struct tegra_fuse *fuse, unsigned int offset);
49 const struct tegra_fuse_soc *soc;
50
51 /* APBDMA on Tegra20 */
52 struct {
53 struct mutex lock;
54 struct completion wait;
55 struct dma_chan *chan;
56 struct dma_slave_config config;
57 dma_addr_t phys;
58 u32 *virt;
59 } apbdma;
60};
27 61
28bool tegra30_spare_fuse(int bit);
29u32 tegra30_fuse_readl(const unsigned int offset);
30void tegra30_init_fuse_early(void);
31void tegra_init_revision(void); 62void tegra_init_revision(void);
32void tegra_init_apbmisc(void); 63void tegra_init_apbmisc(void);
33 64
65bool __init tegra_fuse_read_spare(unsigned int spare);
66u32 __init tegra_fuse_read_early(unsigned int offset);
67
34#ifdef CONFIG_ARCH_TEGRA_2x_SOC 68#ifdef CONFIG_ARCH_TEGRA_2x_SOC
35void tegra20_init_speedo_data(struct tegra_sku_info *sku_info); 69void tegra20_init_speedo_data(struct tegra_sku_info *sku_info);
36bool tegra20_spare_fuse_early(int spare_bit);
37void tegra20_init_fuse_early(void);
38u32 tegra20_fuse_early(const unsigned int offset);
39#else
40static inline void tegra20_init_speedo_data(struct tegra_sku_info *sku_info) {}
41static inline bool tegra20_spare_fuse_early(int spare_bit)
42{
43 return false;
44}
45static inline void tegra20_init_fuse_early(void) {}
46static inline u32 tegra20_fuse_early(const unsigned int offset)
47{
48 return 0;
49}
50#endif 70#endif
51 71
52
53#ifdef CONFIG_ARCH_TEGRA_3x_SOC 72#ifdef CONFIG_ARCH_TEGRA_3x_SOC
54void tegra30_init_speedo_data(struct tegra_sku_info *sku_info); 73void tegra30_init_speedo_data(struct tegra_sku_info *sku_info);
55#else
56static inline void tegra30_init_speedo_data(struct tegra_sku_info *sku_info) {}
57#endif 74#endif
58 75
59#ifdef CONFIG_ARCH_TEGRA_114_SOC 76#ifdef CONFIG_ARCH_TEGRA_114_SOC
60void tegra114_init_speedo_data(struct tegra_sku_info *sku_info); 77void tegra114_init_speedo_data(struct tegra_sku_info *sku_info);
61#else
62static inline void tegra114_init_speedo_data(struct tegra_sku_info *sku_info) {}
63#endif 78#endif
64 79
65#ifdef CONFIG_ARCH_TEGRA_124_SOC 80#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
66void tegra124_init_speedo_data(struct tegra_sku_info *sku_info); 81void tegra124_init_speedo_data(struct tegra_sku_info *sku_info);
67#else 82#endif
68static inline void tegra124_init_speedo_data(struct tegra_sku_info *sku_info) {} 83
84#ifdef CONFIG_ARCH_TEGRA_210_SOC
85void tegra210_init_speedo_data(struct tegra_sku_info *sku_info);
86#endif
87
88#ifdef CONFIG_ARCH_TEGRA_2x_SOC
89extern const struct tegra_fuse_soc tegra20_fuse_soc;
90#endif
91
92#ifdef CONFIG_ARCH_TEGRA_3x_SOC
93extern const struct tegra_fuse_soc tegra30_fuse_soc;
94#endif
95
96#ifdef CONFIG_ARCH_TEGRA_114_SOC
97extern const struct tegra_fuse_soc tegra114_fuse_soc;
98#endif
99
100#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
101extern const struct tegra_fuse_soc tegra124_fuse_soc;
102#endif
103
104#ifdef CONFIG_ARCH_TEGRA_210_SOC
105extern const struct tegra_fuse_soc tegra210_fuse_soc;
69#endif 106#endif
70 107
71#endif 108#endif
diff --git a/drivers/soc/tegra/fuse/speedo-tegra114.c b/drivers/soc/tegra/fuse/speedo-tegra114.c
index 2a6ca036f09f..1ba41ebbb23d 100644
--- a/drivers/soc/tegra/fuse/speedo-tegra114.c
+++ b/drivers/soc/tegra/fuse/speedo-tegra114.c
@@ -22,7 +22,7 @@
22 22
23#include "fuse.h" 23#include "fuse.h"
24 24
25#define CORE_PROCESS_CORNERS 2 25#define SOC_PROCESS_CORNERS 2
26#define CPU_PROCESS_CORNERS 2 26#define CPU_PROCESS_CORNERS 2
27 27
28enum { 28enum {
@@ -31,7 +31,7 @@ enum {
31 THRESHOLD_INDEX_COUNT, 31 THRESHOLD_INDEX_COUNT,
32}; 32};
33 33
34static const u32 __initconst core_process_speedos[][CORE_PROCESS_CORNERS] = { 34static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS] = {
35 {1123, UINT_MAX}, 35 {1123, UINT_MAX},
36 {0, UINT_MAX}, 36 {0, UINT_MAX},
37}; 37};
@@ -74,8 +74,8 @@ static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info,
74 } 74 }
75 75
76 if (rev == TEGRA_REVISION_A01) { 76 if (rev == TEGRA_REVISION_A01) {
77 tmp = tegra30_fuse_readl(0x270) << 1; 77 tmp = tegra_fuse_read_early(0x270) << 1;
78 tmp |= tegra30_fuse_readl(0x26c); 78 tmp |= tegra_fuse_read_early(0x26c);
79 if (!tmp) 79 if (!tmp)
80 sku_info->cpu_speedo_id = 0; 80 sku_info->cpu_speedo_id = 0;
81 } 81 }
@@ -84,27 +84,27 @@ static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info,
84void __init tegra114_init_speedo_data(struct tegra_sku_info *sku_info) 84void __init tegra114_init_speedo_data(struct tegra_sku_info *sku_info)
85{ 85{
86 u32 cpu_speedo_val; 86 u32 cpu_speedo_val;
87 u32 core_speedo_val; 87 u32 soc_speedo_val;
88 int threshold; 88 int threshold;
89 int i; 89 int i;
90 90
91 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != 91 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) !=
92 THRESHOLD_INDEX_COUNT); 92 THRESHOLD_INDEX_COUNT);
93 BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != 93 BUILD_BUG_ON(ARRAY_SIZE(soc_process_speedos) !=
94 THRESHOLD_INDEX_COUNT); 94 THRESHOLD_INDEX_COUNT);
95 95
96 rev_sku_to_speedo_ids(sku_info, &threshold); 96 rev_sku_to_speedo_ids(sku_info, &threshold);
97 97
98 cpu_speedo_val = tegra30_fuse_readl(0x12c) + 1024; 98 cpu_speedo_val = tegra_fuse_read_early(0x12c) + 1024;
99 core_speedo_val = tegra30_fuse_readl(0x134); 99 soc_speedo_val = tegra_fuse_read_early(0x134);
100 100
101 for (i = 0; i < CPU_PROCESS_CORNERS; i++) 101 for (i = 0; i < CPU_PROCESS_CORNERS; i++)
102 if (cpu_speedo_val < cpu_process_speedos[threshold][i]) 102 if (cpu_speedo_val < cpu_process_speedos[threshold][i])
103 break; 103 break;
104 sku_info->cpu_process_id = i; 104 sku_info->cpu_process_id = i;
105 105
106 for (i = 0; i < CORE_PROCESS_CORNERS; i++) 106 for (i = 0; i < SOC_PROCESS_CORNERS; i++)
107 if (core_speedo_val < core_process_speedos[threshold][i]) 107 if (soc_speedo_val < soc_process_speedos[threshold][i])
108 break; 108 break;
109 sku_info->core_process_id = i; 109 sku_info->soc_process_id = i;
110} 110}
diff --git a/drivers/soc/tegra/fuse/speedo-tegra124.c b/drivers/soc/tegra/fuse/speedo-tegra124.c
index 46362387d974..a63a134101ab 100644
--- a/drivers/soc/tegra/fuse/speedo-tegra124.c
+++ b/drivers/soc/tegra/fuse/speedo-tegra124.c
@@ -24,7 +24,7 @@
24 24
25#define CPU_PROCESS_CORNERS 2 25#define CPU_PROCESS_CORNERS 2
26#define GPU_PROCESS_CORNERS 2 26#define GPU_PROCESS_CORNERS 2
27#define CORE_PROCESS_CORNERS 2 27#define SOC_PROCESS_CORNERS 2
28 28
29#define FUSE_CPU_SPEEDO_0 0x14 29#define FUSE_CPU_SPEEDO_0 0x14
30#define FUSE_CPU_SPEEDO_1 0x2c 30#define FUSE_CPU_SPEEDO_1 0x2c
@@ -53,7 +53,7 @@ static const u32 __initconst gpu_process_speedos[][GPU_PROCESS_CORNERS] = {
53 {0, UINT_MAX}, 53 {0, UINT_MAX},
54}; 54};
55 55
56static const u32 __initconst core_process_speedos[][CORE_PROCESS_CORNERS] = { 56static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS] = {
57 {2101, UINT_MAX}, 57 {2101, UINT_MAX},
58 {0, UINT_MAX}, 58 {0, UINT_MAX},
59}; 59};
@@ -119,19 +119,19 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info)
119 THRESHOLD_INDEX_COUNT); 119 THRESHOLD_INDEX_COUNT);
120 BUILD_BUG_ON(ARRAY_SIZE(gpu_process_speedos) != 120 BUILD_BUG_ON(ARRAY_SIZE(gpu_process_speedos) !=
121 THRESHOLD_INDEX_COUNT); 121 THRESHOLD_INDEX_COUNT);
122 BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != 122 BUILD_BUG_ON(ARRAY_SIZE(soc_process_speedos) !=
123 THRESHOLD_INDEX_COUNT); 123 THRESHOLD_INDEX_COUNT);
124 124
125 cpu_speedo_0_value = tegra30_fuse_readl(FUSE_CPU_SPEEDO_0); 125 cpu_speedo_0_value = tegra_fuse_read_early(FUSE_CPU_SPEEDO_0);
126 126
127 /* GPU Speedo is stored in CPU_SPEEDO_2 */ 127 /* GPU Speedo is stored in CPU_SPEEDO_2 */
128 sku_info->gpu_speedo_value = tegra30_fuse_readl(FUSE_CPU_SPEEDO_2); 128 sku_info->gpu_speedo_value = tegra_fuse_read_early(FUSE_CPU_SPEEDO_2);
129 129
130 soc_speedo_0_value = tegra30_fuse_readl(FUSE_SOC_SPEEDO_0); 130 soc_speedo_0_value = tegra_fuse_read_early(FUSE_SOC_SPEEDO_0);
131 131
132 cpu_iddq_value = tegra30_fuse_readl(FUSE_CPU_IDDQ); 132 cpu_iddq_value = tegra_fuse_read_early(FUSE_CPU_IDDQ);
133 soc_iddq_value = tegra30_fuse_readl(FUSE_SOC_IDDQ); 133 soc_iddq_value = tegra_fuse_read_early(FUSE_SOC_IDDQ);
134 gpu_iddq_value = tegra30_fuse_readl(FUSE_GPU_IDDQ); 134 gpu_iddq_value = tegra_fuse_read_early(FUSE_GPU_IDDQ);
135 135
136 sku_info->cpu_speedo_value = cpu_speedo_0_value; 136 sku_info->cpu_speedo_value = cpu_speedo_0_value;
137 137
@@ -143,7 +143,7 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info)
143 143
144 rev_sku_to_speedo_ids(sku_info, &threshold); 144 rev_sku_to_speedo_ids(sku_info, &threshold);
145 145
146 sku_info->cpu_iddq_value = tegra30_fuse_readl(FUSE_CPU_IDDQ); 146 sku_info->cpu_iddq_value = tegra_fuse_read_early(FUSE_CPU_IDDQ);
147 147
148 for (i = 0; i < GPU_PROCESS_CORNERS; i++) 148 for (i = 0; i < GPU_PROCESS_CORNERS; i++)
149 if (sku_info->gpu_speedo_value < 149 if (sku_info->gpu_speedo_value <
@@ -157,11 +157,11 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info)
157 break; 157 break;
158 sku_info->cpu_process_id = i; 158 sku_info->cpu_process_id = i;
159 159
160 for (i = 0; i < CORE_PROCESS_CORNERS; i++) 160 for (i = 0; i < SOC_PROCESS_CORNERS; i++)
161 if (soc_speedo_0_value < 161 if (soc_speedo_0_value <
162 core_process_speedos[threshold][i]) 162 soc_process_speedos[threshold][i])
163 break; 163 break;
164 sku_info->core_process_id = i; 164 sku_info->soc_process_id = i;
165 165
166 pr_debug("Tegra GPU Speedo ID=%d, Speedo Value=%d\n", 166 pr_debug("Tegra GPU Speedo ID=%d, Speedo Value=%d\n",
167 sku_info->gpu_speedo_id, sku_info->gpu_speedo_value); 167 sku_info->gpu_speedo_id, sku_info->gpu_speedo_value);
diff --git a/drivers/soc/tegra/fuse/speedo-tegra20.c b/drivers/soc/tegra/fuse/speedo-tegra20.c
index eff1b63f330d..5f7818bf6072 100644
--- a/drivers/soc/tegra/fuse/speedo-tegra20.c
+++ b/drivers/soc/tegra/fuse/speedo-tegra20.c
@@ -28,11 +28,11 @@
28#define CPU_SPEEDO_REDUND_MSBIT 39 28#define CPU_SPEEDO_REDUND_MSBIT 39
29#define CPU_SPEEDO_REDUND_OFFS (CPU_SPEEDO_REDUND_MSBIT - CPU_SPEEDO_MSBIT) 29#define CPU_SPEEDO_REDUND_OFFS (CPU_SPEEDO_REDUND_MSBIT - CPU_SPEEDO_MSBIT)
30 30
31#define CORE_SPEEDO_LSBIT 40 31#define SOC_SPEEDO_LSBIT 40
32#define CORE_SPEEDO_MSBIT 47 32#define SOC_SPEEDO_MSBIT 47
33#define CORE_SPEEDO_REDUND_LSBIT 48 33#define SOC_SPEEDO_REDUND_LSBIT 48
34#define CORE_SPEEDO_REDUND_MSBIT 55 34#define SOC_SPEEDO_REDUND_MSBIT 55
35#define CORE_SPEEDO_REDUND_OFFS (CORE_SPEEDO_REDUND_MSBIT - CORE_SPEEDO_MSBIT) 35#define SOC_SPEEDO_REDUND_OFFS (SOC_SPEEDO_REDUND_MSBIT - SOC_SPEEDO_MSBIT)
36 36
37#define SPEEDO_MULT 4 37#define SPEEDO_MULT 4
38 38
@@ -56,7 +56,7 @@ static const u32 __initconst cpu_process_speedos[][PROCESS_CORNERS_NUM] = {
56 {316, 331, 383, UINT_MAX}, 56 {316, 331, 383, UINT_MAX},
57}; 57};
58 58
59static const u32 __initconst core_process_speedos[][PROCESS_CORNERS_NUM] = { 59static const u32 __initconst soc_process_speedos[][PROCESS_CORNERS_NUM] = {
60 {165, 195, 224, UINT_MAX}, 60 {165, 195, 224, UINT_MAX},
61 {165, 195, 224, UINT_MAX}, 61 {165, 195, 224, UINT_MAX},
62 {165, 195, 224, UINT_MAX}, 62 {165, 195, 224, UINT_MAX},
@@ -69,7 +69,7 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info)
69 int i; 69 int i;
70 70
71 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != SPEEDO_ID_COUNT); 71 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != SPEEDO_ID_COUNT);
72 BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != SPEEDO_ID_COUNT); 72 BUILD_BUG_ON(ARRAY_SIZE(soc_process_speedos) != SPEEDO_ID_COUNT);
73 73
74 if (SPEEDO_ID_SELECT_0(sku_info->revision)) 74 if (SPEEDO_ID_SELECT_0(sku_info->revision))
75 sku_info->soc_speedo_id = SPEEDO_ID_0; 75 sku_info->soc_speedo_id = SPEEDO_ID_0;
@@ -80,8 +80,8 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info)
80 80
81 val = 0; 81 val = 0;
82 for (i = CPU_SPEEDO_MSBIT; i >= CPU_SPEEDO_LSBIT; i--) { 82 for (i = CPU_SPEEDO_MSBIT; i >= CPU_SPEEDO_LSBIT; i--) {
83 reg = tegra20_spare_fuse_early(i) | 83 reg = tegra_fuse_read_spare(i) |
84 tegra20_spare_fuse_early(i + CPU_SPEEDO_REDUND_OFFS); 84 tegra_fuse_read_spare(i + CPU_SPEEDO_REDUND_OFFS);
85 val = (val << 1) | (reg & 0x1); 85 val = (val << 1) | (reg & 0x1);
86 } 86 }
87 val = val * SPEEDO_MULT; 87 val = val * SPEEDO_MULT;
@@ -94,17 +94,17 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info)
94 sku_info->cpu_process_id = i; 94 sku_info->cpu_process_id = i;
95 95
96 val = 0; 96 val = 0;
97 for (i = CORE_SPEEDO_MSBIT; i >= CORE_SPEEDO_LSBIT; i--) { 97 for (i = SOC_SPEEDO_MSBIT; i >= SOC_SPEEDO_LSBIT; i--) {
98 reg = tegra20_spare_fuse_early(i) | 98 reg = tegra_fuse_read_spare(i) |
99 tegra20_spare_fuse_early(i + CORE_SPEEDO_REDUND_OFFS); 99 tegra_fuse_read_spare(i + SOC_SPEEDO_REDUND_OFFS);
100 val = (val << 1) | (reg & 0x1); 100 val = (val << 1) | (reg & 0x1);
101 } 101 }
102 val = val * SPEEDO_MULT; 102 val = val * SPEEDO_MULT;
103 pr_debug("Core speedo value %u\n", val); 103 pr_debug("Core speedo value %u\n", val);
104 104
105 for (i = 0; i < (PROCESS_CORNERS_NUM - 1); i++) { 105 for (i = 0; i < (PROCESS_CORNERS_NUM - 1); i++) {
106 if (val <= core_process_speedos[sku_info->soc_speedo_id][i]) 106 if (val <= soc_process_speedos[sku_info->soc_speedo_id][i])
107 break; 107 break;
108 } 108 }
109 sku_info->core_process_id = i; 109 sku_info->soc_process_id = i;
110} 110}
diff --git a/drivers/soc/tegra/fuse/speedo-tegra210.c b/drivers/soc/tegra/fuse/speedo-tegra210.c
new file mode 100644
index 000000000000..5373f4c16b54
--- /dev/null
+++ b/drivers/soc/tegra/fuse/speedo-tegra210.c
@@ -0,0 +1,184 @@
1/*
2 * Copyright (c) 2013-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/device.h>
18#include <linux/kernel.h>
19#include <linux/bug.h>
20
21#include <soc/tegra/fuse.h>
22
23#include "fuse.h"
24
25#define CPU_PROCESS_CORNERS 2
26#define GPU_PROCESS_CORNERS 2
27#define SOC_PROCESS_CORNERS 3
28
29#define FUSE_CPU_SPEEDO_0 0x014
30#define FUSE_CPU_SPEEDO_1 0x02c
31#define FUSE_CPU_SPEEDO_2 0x030
32#define FUSE_SOC_SPEEDO_0 0x034
33#define FUSE_SOC_SPEEDO_1 0x038
34#define FUSE_SOC_SPEEDO_2 0x03c
35#define FUSE_CPU_IDDQ 0x018
36#define FUSE_SOC_IDDQ 0x040
37#define FUSE_GPU_IDDQ 0x128
38#define FUSE_FT_REV 0x028
39
40enum {
41 THRESHOLD_INDEX_0,
42 THRESHOLD_INDEX_1,
43 THRESHOLD_INDEX_COUNT,
44};
45
46static const u32 __initconst cpu_process_speedos[][CPU_PROCESS_CORNERS] = {
47 { 2119, UINT_MAX },
48 { 2119, UINT_MAX },
49};
50
51static const u32 __initconst gpu_process_speedos[][GPU_PROCESS_CORNERS] = {
52 { UINT_MAX, UINT_MAX },
53 { UINT_MAX, UINT_MAX },
54};
55
56static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS] = {
57 { 1950, 2100, UINT_MAX },
58 { 1950, 2100, UINT_MAX },
59};
60
61static u8 __init get_speedo_revision(void)
62{
63 return tegra_fuse_read_spare(4) << 2 |
64 tegra_fuse_read_spare(3) << 1 |
65 tegra_fuse_read_spare(2) << 0;
66}
67
68static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info,
69 u8 speedo_rev, int *threshold)
70{
71 int sku = sku_info->sku_id;
72
73 /* Assign to default */
74 sku_info->cpu_speedo_id = 0;
75 sku_info->soc_speedo_id = 0;
76 sku_info->gpu_speedo_id = 0;
77 *threshold = THRESHOLD_INDEX_0;
78
79 switch (sku) {
80 case 0x00: /* Engineering SKU */
81 case 0x01: /* Engineering SKU */
82 case 0x07:
83 case 0x17:
84 case 0x27:
85 if (speedo_rev >= 2)
86 sku_info->gpu_speedo_id = 1;
87 break;
88
89 case 0x13:
90 if (speedo_rev >= 2)
91 sku_info->gpu_speedo_id = 1;
92
93 sku_info->cpu_speedo_id = 1;
94 break;
95
96 default:
97 pr_err("Tegra210: unknown SKU %#04x\n", sku);
98 /* Using the default for the error case */
99 break;
100 }
101}
102
103static int get_process_id(int value, const u32 *speedos, unsigned int num)
104{
105 unsigned int i;
106
107 for (i = 0; i < num; i++)
108 if (value < speedos[num])
109 return i;
110
111 return -EINVAL;
112}
113
114void __init tegra210_init_speedo_data(struct tegra_sku_info *sku_info)
115{
116 int cpu_speedo[3], soc_speedo[3], cpu_iddq, gpu_iddq, soc_iddq;
117 unsigned int index;
118 u8 speedo_revision;
119
120 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) !=
121 THRESHOLD_INDEX_COUNT);
122 BUILD_BUG_ON(ARRAY_SIZE(gpu_process_speedos) !=
123 THRESHOLD_INDEX_COUNT);
124 BUILD_BUG_ON(ARRAY_SIZE(soc_process_speedos) !=
125 THRESHOLD_INDEX_COUNT);
126
127 /* Read speedo/IDDQ fuses */
128 cpu_speedo[0] = tegra_fuse_read_early(FUSE_CPU_SPEEDO_0);
129 cpu_speedo[1] = tegra_fuse_read_early(FUSE_CPU_SPEEDO_1);
130 cpu_speedo[2] = tegra_fuse_read_early(FUSE_CPU_SPEEDO_2);
131
132 soc_speedo[0] = tegra_fuse_read_early(FUSE_SOC_SPEEDO_0);
133 soc_speedo[1] = tegra_fuse_read_early(FUSE_SOC_SPEEDO_1);
134 soc_speedo[2] = tegra_fuse_read_early(FUSE_CPU_SPEEDO_2);
135
136 cpu_iddq = tegra_fuse_read_early(FUSE_CPU_IDDQ) * 4;
137 soc_iddq = tegra_fuse_read_early(FUSE_SOC_IDDQ) * 4;
138 gpu_iddq = tegra_fuse_read_early(FUSE_GPU_IDDQ) * 5;
139
140 /*
141 * Determine CPU, GPU and SoC speedo values depending on speedo fusing
142 * revision. Note that GPU speedo value is fused in CPU_SPEEDO_2.
143 */
144 speedo_revision = get_speedo_revision();
145 pr_info("Speedo Revision %u\n", speedo_revision);
146
147 if (speedo_revision >= 3) {
148 sku_info->cpu_speedo_value = cpu_speedo[0];
149 sku_info->gpu_speedo_value = cpu_speedo[2];
150 sku_info->soc_speedo_value = soc_speedo[0];
151 } else if (speedo_revision == 2) {
152 sku_info->cpu_speedo_value = (-1938 + (1095 * cpu_speedo[0] / 100)) / 10;
153 sku_info->gpu_speedo_value = (-1662 + (1082 * cpu_speedo[2] / 100)) / 10;
154 sku_info->soc_speedo_value = ( -705 + (1037 * soc_speedo[0] / 100)) / 10;
155 } else {
156 sku_info->cpu_speedo_value = 2100;
157 sku_info->gpu_speedo_value = cpu_speedo[2] - 75;
158 sku_info->soc_speedo_value = 1900;
159 }
160
161 if ((sku_info->cpu_speedo_value <= 0) ||
162 (sku_info->gpu_speedo_value <= 0) ||
163 (sku_info->soc_speedo_value <= 0)) {
164 WARN(1, "speedo value not fused\n");
165 return;
166 }
167
168 rev_sku_to_speedo_ids(sku_info, speedo_revision, &index);
169
170 sku_info->gpu_process_id = get_process_id(sku_info->gpu_speedo_value,
171 gpu_process_speedos[index],
172 GPU_PROCESS_CORNERS);
173
174 sku_info->cpu_process_id = get_process_id(sku_info->cpu_speedo_value,
175 cpu_process_speedos[index],
176 CPU_PROCESS_CORNERS);
177
178 sku_info->soc_process_id = get_process_id(sku_info->soc_speedo_value,
179 soc_process_speedos[index],
180 SOC_PROCESS_CORNERS);
181
182 pr_debug("Tegra GPU Speedo ID=%d, Speedo Value=%d\n",
183 sku_info->gpu_speedo_id, sku_info->gpu_speedo_value);
184}
diff --git a/drivers/soc/tegra/fuse/speedo-tegra30.c b/drivers/soc/tegra/fuse/speedo-tegra30.c
index b17f0dcdfebe..9b010b3ef009 100644
--- a/drivers/soc/tegra/fuse/speedo-tegra30.c
+++ b/drivers/soc/tegra/fuse/speedo-tegra30.c
@@ -22,7 +22,7 @@
22 22
23#include "fuse.h" 23#include "fuse.h"
24 24
25#define CORE_PROCESS_CORNERS 1 25#define SOC_PROCESS_CORNERS 1
26#define CPU_PROCESS_CORNERS 6 26#define CPU_PROCESS_CORNERS 6
27 27
28#define FUSE_SPEEDO_CALIB_0 0x14 28#define FUSE_SPEEDO_CALIB_0 0x14
@@ -54,7 +54,7 @@ enum {
54 THRESHOLD_INDEX_COUNT, 54 THRESHOLD_INDEX_COUNT,
55}; 55};
56 56
57static const u32 __initconst core_process_speedos[][CORE_PROCESS_CORNERS] = { 57static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS] = {
58 {180}, 58 {180},
59 {170}, 59 {170},
60 {195}, 60 {195},
@@ -93,25 +93,25 @@ static void __init fuse_speedo_calib(u32 *speedo_g, u32 *speedo_lp)
93 int bit_minus1; 93 int bit_minus1;
94 int bit_minus2; 94 int bit_minus2;
95 95
96 reg = tegra30_fuse_readl(FUSE_SPEEDO_CALIB_0); 96 reg = tegra_fuse_read_early(FUSE_SPEEDO_CALIB_0);
97 97
98 *speedo_lp = (reg & 0xFFFF) * 4; 98 *speedo_lp = (reg & 0xFFFF) * 4;
99 *speedo_g = ((reg >> 16) & 0xFFFF) * 4; 99 *speedo_g = ((reg >> 16) & 0xFFFF) * 4;
100 100
101 ate_ver = tegra30_fuse_readl(FUSE_TEST_PROG_VER); 101 ate_ver = tegra_fuse_read_early(FUSE_TEST_PROG_VER);
102 pr_debug("Tegra ATE prog ver %d.%d\n", ate_ver/10, ate_ver%10); 102 pr_debug("Tegra ATE prog ver %d.%d\n", ate_ver/10, ate_ver%10);
103 103
104 if (ate_ver >= 26) { 104 if (ate_ver >= 26) {
105 bit_minus1 = tegra30_spare_fuse(LP_SPEEDO_BIT_MINUS1); 105 bit_minus1 = tegra_fuse_read_spare(LP_SPEEDO_BIT_MINUS1);
106 bit_minus1 |= tegra30_spare_fuse(LP_SPEEDO_BIT_MINUS1_R); 106 bit_minus1 |= tegra_fuse_read_spare(LP_SPEEDO_BIT_MINUS1_R);
107 bit_minus2 = tegra30_spare_fuse(LP_SPEEDO_BIT_MINUS2); 107 bit_minus2 = tegra_fuse_read_spare(LP_SPEEDO_BIT_MINUS2);
108 bit_minus2 |= tegra30_spare_fuse(LP_SPEEDO_BIT_MINUS2_R); 108 bit_minus2 |= tegra_fuse_read_spare(LP_SPEEDO_BIT_MINUS2_R);
109 *speedo_lp |= (bit_minus1 << 1) | bit_minus2; 109 *speedo_lp |= (bit_minus1 << 1) | bit_minus2;
110 110
111 bit_minus1 = tegra30_spare_fuse(G_SPEEDO_BIT_MINUS1); 111 bit_minus1 = tegra_fuse_read_spare(G_SPEEDO_BIT_MINUS1);
112 bit_minus1 |= tegra30_spare_fuse(G_SPEEDO_BIT_MINUS1_R); 112 bit_minus1 |= tegra_fuse_read_spare(G_SPEEDO_BIT_MINUS1_R);
113 bit_minus2 = tegra30_spare_fuse(G_SPEEDO_BIT_MINUS2); 113 bit_minus2 = tegra_fuse_read_spare(G_SPEEDO_BIT_MINUS2);
114 bit_minus2 |= tegra30_spare_fuse(G_SPEEDO_BIT_MINUS2_R); 114 bit_minus2 |= tegra_fuse_read_spare(G_SPEEDO_BIT_MINUS2_R);
115 *speedo_g |= (bit_minus1 << 1) | bit_minus2; 115 *speedo_g |= (bit_minus1 << 1) | bit_minus2;
116 } else { 116 } else {
117 *speedo_lp |= 0x3; 117 *speedo_lp |= 0x3;
@@ -121,7 +121,7 @@ static void __init fuse_speedo_calib(u32 *speedo_g, u32 *speedo_lp)
121 121
122static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info) 122static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info)
123{ 123{
124 int package_id = tegra30_fuse_readl(FUSE_PACKAGE_INFO) & 0x0F; 124 int package_id = tegra_fuse_read_early(FUSE_PACKAGE_INFO) & 0x0F;
125 125
126 switch (sku_info->revision) { 126 switch (sku_info->revision) {
127 case TEGRA_REVISION_A01: 127 case TEGRA_REVISION_A01:
@@ -246,19 +246,19 @@ static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info)
246void __init tegra30_init_speedo_data(struct tegra_sku_info *sku_info) 246void __init tegra30_init_speedo_data(struct tegra_sku_info *sku_info)
247{ 247{
248 u32 cpu_speedo_val; 248 u32 cpu_speedo_val;
249 u32 core_speedo_val; 249 u32 soc_speedo_val;
250 int i; 250 int i;
251 251
252 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != 252 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) !=
253 THRESHOLD_INDEX_COUNT); 253 THRESHOLD_INDEX_COUNT);
254 BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != 254 BUILD_BUG_ON(ARRAY_SIZE(soc_process_speedos) !=
255 THRESHOLD_INDEX_COUNT); 255 THRESHOLD_INDEX_COUNT);
256 256
257 257
258 rev_sku_to_speedo_ids(sku_info); 258 rev_sku_to_speedo_ids(sku_info);
259 fuse_speedo_calib(&cpu_speedo_val, &core_speedo_val); 259 fuse_speedo_calib(&cpu_speedo_val, &soc_speedo_val);
260 pr_debug("Tegra CPU speedo value %u\n", cpu_speedo_val); 260 pr_debug("Tegra CPU speedo value %u\n", cpu_speedo_val);
261 pr_debug("Tegra Core speedo value %u\n", core_speedo_val); 261 pr_debug("Tegra Core speedo value %u\n", soc_speedo_val);
262 262
263 for (i = 0; i < CPU_PROCESS_CORNERS; i++) { 263 for (i = 0; i < CPU_PROCESS_CORNERS; i++) {
264 if (cpu_speedo_val < cpu_process_speedos[threshold_index][i]) 264 if (cpu_speedo_val < cpu_process_speedos[threshold_index][i])
@@ -273,16 +273,16 @@ void __init tegra30_init_speedo_data(struct tegra_sku_info *sku_info)
273 sku_info->cpu_speedo_id = 1; 273 sku_info->cpu_speedo_id = 1;
274 } 274 }
275 275
276 for (i = 0; i < CORE_PROCESS_CORNERS; i++) { 276 for (i = 0; i < SOC_PROCESS_CORNERS; i++) {
277 if (core_speedo_val < core_process_speedos[threshold_index][i]) 277 if (soc_speedo_val < soc_process_speedos[threshold_index][i])
278 break; 278 break;
279 } 279 }
280 sku_info->core_process_id = i - 1; 280 sku_info->soc_process_id = i - 1;
281 281
282 if (sku_info->core_process_id == -1) { 282 if (sku_info->soc_process_id == -1) {
283 pr_warn("Tegra CORE speedo value %3d out of range", 283 pr_warn("Tegra SoC speedo value %3d out of range",
284 core_speedo_val); 284 soc_speedo_val);
285 sku_info->core_process_id = 0; 285 sku_info->soc_process_id = 0;
286 sku_info->soc_speedo_id = 1; 286 sku_info->soc_speedo_id = 1;
287 } 287 }
288} 288}
diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
index 73fad05d8f2c..5b18f6ffa45c 100644
--- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
+++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
@@ -21,11 +21,10 @@
21#include <linux/io.h> 21#include <linux/io.h>
22 22
23#include <soc/tegra/fuse.h> 23#include <soc/tegra/fuse.h>
24#include <soc/tegra/common.h>
24 25
25#include "fuse.h" 26#include "fuse.h"
26 27
27#define APBMISC_BASE 0x70000800
28#define APBMISC_SIZE 0x64
29#define FUSE_SKU_INFO 0x10 28#define FUSE_SKU_INFO 0x10
30 29
31#define PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT 4 30#define PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT 4
@@ -95,8 +94,8 @@ void __init tegra_init_revision(void)
95 rev = TEGRA_REVISION_A02; 94 rev = TEGRA_REVISION_A02;
96 break; 95 break;
97 case 3: 96 case 3:
98 if (chip_id == TEGRA20 && (tegra20_spare_fuse_early(18) || 97 if (chip_id == TEGRA20 && (tegra_fuse_read_spare(18) ||
99 tegra20_spare_fuse_early(19))) 98 tegra_fuse_read_spare(19)))
100 rev = TEGRA_REVISION_A03p; 99 rev = TEGRA_REVISION_A03p;
101 else 100 else
102 rev = TEGRA_REVISION_A03; 101 rev = TEGRA_REVISION_A03;
@@ -110,27 +109,74 @@ void __init tegra_init_revision(void)
110 109
111 tegra_sku_info.revision = rev; 110 tegra_sku_info.revision = rev;
112 111
113 if (chip_id == TEGRA20) 112 tegra_sku_info.sku_id = tegra_fuse_read_early(FUSE_SKU_INFO);
114 tegra_sku_info.sku_id = tegra20_fuse_early(FUSE_SKU_INFO);
115 else
116 tegra_sku_info.sku_id = tegra30_fuse_readl(FUSE_SKU_INFO);
117} 113}
118 114
119void __init tegra_init_apbmisc(void) 115void __init tegra_init_apbmisc(void)
120{ 116{
117 struct resource apbmisc, straps;
121 struct device_node *np; 118 struct device_node *np;
122 119
123 np = of_find_matching_node(NULL, apbmisc_match); 120 np = of_find_matching_node(NULL, apbmisc_match);
124 apbmisc_base = of_iomap(np, 0); 121 if (!np) {
125 if (!apbmisc_base) { 122 /*
126 pr_warn("ioremap tegra apbmisc failed. using %08x instead\n", 123 * Fall back to legacy initialization for 32-bit ARM only. All
127 APBMISC_BASE); 124 * 64-bit ARM device tree files for Tegra are required to have
128 apbmisc_base = ioremap(APBMISC_BASE, APBMISC_SIZE); 125 * an APBMISC node.
126 *
127 * This is for backwards-compatibility with old device trees
128 * that didn't contain an APBMISC node.
129 */
130 if (IS_ENABLED(CONFIG_ARM) && soc_is_tegra()) {
131 /* APBMISC registers (chip revision, ...) */
132 apbmisc.start = 0x70000800;
133 apbmisc.end = 0x70000863;
134 apbmisc.flags = IORESOURCE_MEM;
135
136 /* strapping options */
137 if (tegra_get_chip_id() == TEGRA124) {
138 straps.start = 0x7000e864;
139 straps.end = 0x7000e867;
140 } else {
141 straps.start = 0x70000008;
142 straps.end = 0x7000000b;
143 }
144
145 straps.flags = IORESOURCE_MEM;
146
147 pr_warn("Using APBMISC region %pR\n", &apbmisc);
148 pr_warn("Using strapping options registers %pR\n",
149 &straps);
150 } else {
151 /*
152 * At this point we're not running on Tegra, so play
153 * nice with multi-platform kernels.
154 */
155 return;
156 }
157 } else {
158 /*
159 * Extract information from the device tree if we've found a
160 * matching node.
161 */
162 if (of_address_to_resource(np, 0, &apbmisc) < 0) {
163 pr_err("failed to get APBMISC registers\n");
164 return;
165 }
166
167 if (of_address_to_resource(np, 1, &straps) < 0) {
168 pr_err("failed to get strapping options registers\n");
169 return;
170 }
129 } 171 }
130 172
131 strapping_base = of_iomap(np, 1); 173 apbmisc_base = ioremap_nocache(apbmisc.start, resource_size(&apbmisc));
174 if (!apbmisc_base)
175 pr_err("failed to map APBMISC registers\n");
176
177 strapping_base = ioremap_nocache(straps.start, resource_size(&straps));
132 if (!strapping_base) 178 if (!strapping_base)
133 pr_err("ioremap tegra strapping_base failed\n"); 179 pr_err("failed to map strapping options registers\n");
134 180
135 long_ram_code = of_property_read_bool(np, "nvidia,long-ram-code"); 181 long_ram_code = of_property_read_bool(np, "nvidia,long-ram-code");
136} 182}
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 75d0457a77b7..bc34cf7482fb 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -17,6 +17,8 @@
17 * 17 *
18 */ 18 */
19 19
20#define pr_fmt(fmt) "tegra-pmc: " fmt
21
20#include <linux/kernel.h> 22#include <linux/kernel.h>
21#include <linux/clk.h> 23#include <linux/clk.h>
22#include <linux/clk/tegra.h> 24#include <linux/clk/tegra.h>
@@ -457,7 +459,6 @@ static int tegra_io_rail_prepare(int id, unsigned long *request,
457 unsigned long *status, unsigned int *bit) 459 unsigned long *status, unsigned int *bit)
458{ 460{
459 unsigned long rate, value; 461 unsigned long rate, value;
460 struct clk *clk;
461 462
462 *bit = id % 32; 463 *bit = id % 32;
463 464
@@ -476,12 +477,7 @@ static int tegra_io_rail_prepare(int id, unsigned long *request,
476 *request = IO_DPD2_REQ; 477 *request = IO_DPD2_REQ;
477 } 478 }
478 479
479 clk = clk_get_sys(NULL, "pclk"); 480 rate = clk_get_rate(pmc->clk);
480 if (IS_ERR(clk))
481 return PTR_ERR(clk);
482
483 rate = clk_get_rate(clk);
484 clk_put(clk);
485 481
486 tegra_pmc_writel(DPD_SAMPLE_ENABLE, DPD_SAMPLE); 482 tegra_pmc_writel(DPD_SAMPLE_ENABLE, DPD_SAMPLE);
487 483
@@ -535,8 +531,10 @@ int tegra_io_rail_power_on(int id)
535 tegra_pmc_writel(value, request); 531 tegra_pmc_writel(value, request);
536 532
537 err = tegra_io_rail_poll(status, mask, 0, 250); 533 err = tegra_io_rail_poll(status, mask, 0, 250);
538 if (err < 0) 534 if (err < 0) {
535 pr_info("tegra_io_rail_poll() failed: %d\n", err);
539 return err; 536 return err;
537 }
540 538
541 tegra_io_rail_unprepare(); 539 tegra_io_rail_unprepare();
542 540
@@ -551,8 +549,10 @@ int tegra_io_rail_power_off(int id)
551 int err; 549 int err;
552 550
553 err = tegra_io_rail_prepare(id, &request, &status, &bit); 551 err = tegra_io_rail_prepare(id, &request, &status, &bit);
554 if (err < 0) 552 if (err < 0) {
553 pr_info("tegra_io_rail_prepare() failed: %d\n", err);
555 return err; 554 return err;
555 }
556 556
557 mask = 1 << bit; 557 mask = 1 << bit;
558 558
@@ -736,12 +736,12 @@ void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
736 u32 value, checksum; 736 u32 value, checksum;
737 737
738 if (!pmc->soc->has_tsense_reset) 738 if (!pmc->soc->has_tsense_reset)
739 goto out; 739 return;
740 740
741 np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip"); 741 np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip");
742 if (!np) { 742 if (!np) {
743 dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled); 743 dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled);
744 goto out; 744 return;
745 } 745 }
746 746
747 if (of_property_read_u32(np, "nvidia,i2c-controller-id", &ctrl_id)) { 747 if (of_property_read_u32(np, "nvidia,i2c-controller-id", &ctrl_id)) {
@@ -801,7 +801,6 @@ void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
801 801
802out: 802out:
803 of_node_put(np); 803 of_node_put(np);
804 return;
805} 804}
806 805
807static int tegra_pmc_probe(struct platform_device *pdev) 806static int tegra_pmc_probe(struct platform_device *pdev)
@@ -1002,7 +1001,56 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = {
1002 .has_gpu_clamps = true, 1001 .has_gpu_clamps = true,
1003}; 1002};
1004 1003
1004static const char * const tegra210_powergates[] = {
1005 [TEGRA_POWERGATE_CPU] = "crail",
1006 [TEGRA_POWERGATE_3D] = "3d",
1007 [TEGRA_POWERGATE_VENC] = "venc",
1008 [TEGRA_POWERGATE_PCIE] = "pcie",
1009 [TEGRA_POWERGATE_L2] = "l2",
1010 [TEGRA_POWERGATE_MPE] = "mpe",
1011 [TEGRA_POWERGATE_HEG] = "heg",
1012 [TEGRA_POWERGATE_SATA] = "sata",
1013 [TEGRA_POWERGATE_CPU1] = "cpu1",
1014 [TEGRA_POWERGATE_CPU2] = "cpu2",
1015 [TEGRA_POWERGATE_CPU3] = "cpu3",
1016 [TEGRA_POWERGATE_CELP] = "celp",
1017 [TEGRA_POWERGATE_CPU0] = "cpu0",
1018 [TEGRA_POWERGATE_C0NC] = "c0nc",
1019 [TEGRA_POWERGATE_C1NC] = "c1nc",
1020 [TEGRA_POWERGATE_SOR] = "sor",
1021 [TEGRA_POWERGATE_DIS] = "dis",
1022 [TEGRA_POWERGATE_DISB] = "disb",
1023 [TEGRA_POWERGATE_XUSBA] = "xusba",
1024 [TEGRA_POWERGATE_XUSBB] = "xusbb",
1025 [TEGRA_POWERGATE_XUSBC] = "xusbc",
1026 [TEGRA_POWERGATE_VIC] = "vic",
1027 [TEGRA_POWERGATE_IRAM] = "iram",
1028 [TEGRA_POWERGATE_NVDEC] = "nvdec",
1029 [TEGRA_POWERGATE_NVJPG] = "nvjpg",
1030 [TEGRA_POWERGATE_AUD] = "aud",
1031 [TEGRA_POWERGATE_DFD] = "dfd",
1032 [TEGRA_POWERGATE_VE2] = "ve2",
1033};
1034
1035static const u8 tegra210_cpu_powergates[] = {
1036 TEGRA_POWERGATE_CPU0,
1037 TEGRA_POWERGATE_CPU1,
1038 TEGRA_POWERGATE_CPU2,
1039 TEGRA_POWERGATE_CPU3,
1040};
1041
1042static const struct tegra_pmc_soc tegra210_pmc_soc = {
1043 .num_powergates = ARRAY_SIZE(tegra210_powergates),
1044 .powergates = tegra210_powergates,
1045 .num_cpu_powergates = ARRAY_SIZE(tegra210_cpu_powergates),
1046 .cpu_powergates = tegra210_cpu_powergates,
1047 .has_tsense_reset = true,
1048 .has_gpu_clamps = true,
1049};
1050
1005static const struct of_device_id tegra_pmc_match[] = { 1051static const struct of_device_id tegra_pmc_match[] = {
1052 { .compatible = "nvidia,tegra210-pmc", .data = &tegra210_pmc_soc },
1053 { .compatible = "nvidia,tegra132-pmc", .data = &tegra124_pmc_soc },
1006 { .compatible = "nvidia,tegra124-pmc", .data = &tegra124_pmc_soc }, 1054 { .compatible = "nvidia,tegra124-pmc", .data = &tegra124_pmc_soc },
1007 { .compatible = "nvidia,tegra114-pmc", .data = &tegra114_pmc_soc }, 1055 { .compatible = "nvidia,tegra114-pmc", .data = &tegra114_pmc_soc },
1008 { .compatible = "nvidia,tegra30-pmc", .data = &tegra30_pmc_soc }, 1056 { .compatible = "nvidia,tegra30-pmc", .data = &tegra30_pmc_soc },
@@ -1035,25 +1083,44 @@ static int __init tegra_pmc_early_init(void)
1035 bool invert; 1083 bool invert;
1036 u32 value; 1084 u32 value;
1037 1085
1038 if (!soc_is_tegra())
1039 return 0;
1040
1041 np = of_find_matching_node_and_match(NULL, tegra_pmc_match, &match); 1086 np = of_find_matching_node_and_match(NULL, tegra_pmc_match, &match);
1042 if (!np) { 1087 if (!np) {
1043 pr_warn("PMC device node not found, disabling powergating\n"); 1088 /*
1044 1089 * Fall back to legacy initialization for 32-bit ARM only. All
1045 regs.start = 0x7000e400; 1090 * 64-bit ARM device tree files for Tegra are required to have
1046 regs.end = 0x7000e7ff; 1091 * a PMC node.
1047 regs.flags = IORESOURCE_MEM; 1092 *
1048 1093 * This is for backwards-compatibility with old device trees
1049 pr_warn("Using memory region %pR\n", &regs); 1094 * that didn't contain a PMC node. Note that in this case the
1095 * SoC data can't be matched and therefore powergating is
1096 * disabled.
1097 */
1098 if (IS_ENABLED(CONFIG_ARM) && soc_is_tegra()) {
1099 pr_warn("DT node not found, powergating disabled\n");
1100
1101 regs.start = 0x7000e400;
1102 regs.end = 0x7000e7ff;
1103 regs.flags = IORESOURCE_MEM;
1104
1105 pr_warn("Using memory region %pR\n", &regs);
1106 } else {
1107 /*
1108 * At this point we're not running on Tegra, so play
1109 * nice with multi-platform kernels.
1110 */
1111 return 0;
1112 }
1050 } else { 1113 } else {
1051 pmc->soc = match->data; 1114 /*
1052 } 1115 * Extract information from the device tree if we've found a
1116 * matching node.
1117 */
1118 if (of_address_to_resource(np, 0, &regs) < 0) {
1119 pr_err("failed to get PMC registers\n");
1120 return -ENXIO;
1121 }
1053 1122
1054 if (of_address_to_resource(np, 0, &regs) < 0) { 1123 pmc->soc = match->data;
1055 pr_err("failed to get PMC registers\n");
1056 return -ENXIO;
1057 } 1124 }
1058 1125
1059 pmc->base = ioremap_nocache(regs.start, resource_size(&regs)); 1126 pmc->base = ioremap_nocache(regs.start, resource_size(&regs));
@@ -1064,6 +1131,10 @@ static int __init tegra_pmc_early_init(void)
1064 1131
1065 mutex_init(&pmc->powergates_lock); 1132 mutex_init(&pmc->powergates_lock);
1066 1133
1134 /*
1135 * Invert the interrupt polarity if a PMC device tree node exists and
1136 * contains the nvidia,invert-interrupt property.
1137 */
1067 invert = of_property_read_bool(np, "nvidia,invert-interrupt"); 1138 invert = of_property_read_bool(np, "nvidia,invert-interrupt");
1068 1139
1069 value = tegra_pmc_readl(PMC_CNTRL); 1140 value = tegra_pmc_readl(PMC_CNTRL);
diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index b019e3465f11..961b821b6a46 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -22,6 +22,7 @@
22#define TEGRA114 0x35 22#define TEGRA114 0x35
23#define TEGRA124 0x40 23#define TEGRA124 0x40
24#define TEGRA132 0x13 24#define TEGRA132 0x13
25#define TEGRA210 0x21
25 26
26#define TEGRA_FUSE_SKU_CALIB_0 0xf0 27#define TEGRA_FUSE_SKU_CALIB_0 0xf0
27#define TEGRA30_FUSE_SATA_CALIB 0x124 28#define TEGRA30_FUSE_SATA_CALIB 0x124
@@ -47,10 +48,11 @@ struct tegra_sku_info {
47 int cpu_speedo_id; 48 int cpu_speedo_id;
48 int cpu_speedo_value; 49 int cpu_speedo_value;
49 int cpu_iddq_value; 50 int cpu_iddq_value;
50 int core_process_id; 51 int soc_process_id;
51 int soc_speedo_id; 52 int soc_speedo_id;
52 int gpu_speedo_id; 53 int soc_speedo_value;
53 int gpu_process_id; 54 int gpu_process_id;
55 int gpu_speedo_id;
54 int gpu_speedo_value; 56 int gpu_speedo_value;
55 enum tegra_revision revision; 57 enum tegra_revision revision;
56}; 58};
diff --git a/include/soc/tegra/pmc.h b/include/soc/tegra/pmc.h
index f5c0de43a5fa..d18efe402ff1 100644
--- a/include/soc/tegra/pmc.h
+++ b/include/soc/tegra/pmc.h
@@ -67,6 +67,11 @@ int tegra_pmc_cpu_remove_clamping(int cpuid);
67#define TEGRA_POWERGATE_XUSBC 22 67#define TEGRA_POWERGATE_XUSBC 22
68#define TEGRA_POWERGATE_VIC 23 68#define TEGRA_POWERGATE_VIC 23
69#define TEGRA_POWERGATE_IRAM 24 69#define TEGRA_POWERGATE_IRAM 24
70#define TEGRA_POWERGATE_NVDEC 25
71#define TEGRA_POWERGATE_NVJPG 26
72#define TEGRA_POWERGATE_AUD 27
73#define TEGRA_POWERGATE_DFD 28
74#define TEGRA_POWERGATE_VE2 29
70 75
71#define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D 76#define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D
72 77