aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-07-11 05:13:30 -0400
committerThierry Reding <treding@nvidia.com>2014-07-17 08:58:42 -0400
commit24fa5af81059af90c723bec6aacc3cd2b2809d14 (patch)
tree237415a8a7af0c683d68f10c9fd1957965fbc3b4
parentc090e111633cd82e4e0f72c7e964460676ad1250 (diff)
soc/tegra: fuse: Set up in early initcall
Rather than rely on explicit initialization order called from SoC setup code, use a plain initcall and rely on initcall ordering to take care of dependencies. This driver exposes some functionality (querying the chip ID) needed at very early stages of the boot process. An early initcall is good enough provided that some of the dependencies are deferred to later stages. To make sure any abuses are easily caught, output a warning message if the chip ID is queried while it can't be read yet. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--arch/arm/mach-tegra/tegra.c1
-rw-r--r--drivers/soc/tegra/fuse/fuse-tegra.c11
-rw-r--r--drivers/soc/tegra/fuse/tegra-apbmisc.c7
-rw-r--r--include/soc/tegra/fuse.h1
4 files changed, 14 insertions, 6 deletions
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index e5733fa78911..c9176db0b9c0 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -73,7 +73,6 @@ u32 tegra_uart_config[3] = {
73static void __init tegra_init_early(void) 73static void __init tegra_init_early(void)
74{ 74{
75 of_register_trusted_foundations(); 75 of_register_trusted_foundations();
76 tegra_init_fuse();
77 tegra_cpu_reset_handler_init(); 76 tegra_cpu_reset_handler_init();
78 tegra_powergate_init(); 77 tegra_powergate_init();
79} 78}
diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 03742edcfe83..11a5043959dc 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -23,6 +23,7 @@
23#include <linux/of_address.h> 23#include <linux/of_address.h>
24#include <linux/io.h> 24#include <linux/io.h>
25 25
26#include <soc/tegra/common.h>
26#include <soc/tegra/fuse.h> 27#include <soc/tegra/fuse.h>
27 28
28#include "fuse.h" 29#include "fuse.h"
@@ -125,11 +126,14 @@ int tegra_fuse_create_sysfs(struct device *dev, int size,
125 return device_create_bin_file(dev, &fuse_bin_attr); 126 return device_create_bin_file(dev, &fuse_bin_attr);
126} 127}
127 128
128void __init tegra_init_fuse(void) 129static int __init tegra_init_fuse(void)
129{ 130{
130 struct device_node *np; 131 struct device_node *np;
131 void __iomem *car_base; 132 void __iomem *car_base;
132 133
134 if (!soc_is_tegra())
135 return 0;
136
133 tegra_init_apbmisc(); 137 tegra_init_apbmisc();
134 138
135 np = of_find_matching_node(NULL, car_match); 139 np = of_find_matching_node(NULL, car_match);
@@ -139,7 +143,7 @@ void __init tegra_init_fuse(void)
139 iounmap(car_base); 143 iounmap(car_base);
140 } else { 144 } else {
141 pr_err("Could not enable fuse clk. ioremap tegra car failed.\n"); 145 pr_err("Could not enable fuse clk. ioremap tegra car failed.\n");
142 return; 146 return -ENXIO;
143 } 147 }
144 148
145 if (tegra_get_chip_id() == TEGRA20) 149 if (tegra_get_chip_id() == TEGRA20)
@@ -153,4 +157,7 @@ void __init tegra_init_fuse(void)
153 tegra_sku_info.core_process_id); 157 tegra_sku_info.core_process_id);
154 pr_debug("Tegra CPU Speedo ID %d, Soc Speedo ID %d\n", 158 pr_debug("Tegra CPU Speedo ID %d, Soc Speedo ID %d\n",
155 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id); 159 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);
160
161 return 0;
156} 162}
163early_initcall(tegra_init_fuse);
diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
index bfc1d54ac4ad..3bf5aba4caaa 100644
--- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
+++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
@@ -38,9 +38,12 @@ u32 tegra_read_chipid(void)
38 38
39u8 tegra_get_chip_id(void) 39u8 tegra_get_chip_id(void)
40{ 40{
41 u32 id = tegra_read_chipid(); 41 if (!apbmisc_base) {
42 WARN(1, "Tegra Chip ID not yet available\n");
43 return 0;
44 }
42 45
43 return (id >> 8) & 0xff; 46 return (tegra_read_chipid() >> 8) & 0xff;
44} 47}
45 48
46u32 tegra_read_straps(void) 49u32 tegra_read_straps(void)
diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index 738712d75cfe..8e1249474e84 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -56,7 +56,6 @@ struct tegra_sku_info {
56 56
57u32 tegra_read_straps(void); 57u32 tegra_read_straps(void);
58u32 tegra_read_chipid(void); 58u32 tegra_read_chipid(void);
59void tegra_init_fuse(void);
60int tegra_fuse_readl(unsigned long offset, u32 *value); 59int tegra_fuse_readl(unsigned long offset, u32 *value);
61 60
62extern struct tegra_sku_info tegra_sku_info; 61extern struct tegra_sku_info tegra_sku_info;