Skip to content

Commit 24fa5af

Browse files
committed
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>
1 parent c090e11 commit 24fa5af

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎arch/arm/mach-tegra/tegra.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ u32 tegra_uart_config[3] = {
7373
static void __init tegra_init_early(void)
7474
{
7575
of_register_trusted_foundations();
76-
tegra_init_fuse();
7776
tegra_cpu_reset_handler_init();
7877
tegra_powergate_init();
7978
}

‎drivers/soc/tegra/fuse/fuse-tegra.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/of_address.h>
2424
#include <linux/io.h>
2525

26+
#include <soc/tegra/common.h>
2627
#include <soc/tegra/fuse.h>
2728

2829
#include "fuse.h"
@@ -125,11 +126,14 @@ int tegra_fuse_create_sysfs(struct device *dev, int size,
125126
return device_create_bin_file(dev, &fuse_bin_attr);
126127
}
127128

128-
void __init tegra_init_fuse(void)
129+
static int __init tegra_init_fuse(void)
129130
{
130131
struct device_node *np;
131132
void __iomem *car_base;
132133

134+
if (!soc_is_tegra())
135+
return 0;
136+
133137
tegra_init_apbmisc();
134138

135139
np = of_find_matching_node(NULL, car_match);
@@ -139,7 +143,7 @@ void __init tegra_init_fuse(void)
139143
iounmap(car_base);
140144
} else {
141145
pr_err("Could not enable fuse clk. ioremap tegra car failed.\n");
142-
return;
146+
return -ENXIO;
143147
}
144148

145149
if (tegra_get_chip_id() == TEGRA20)
@@ -153,4 +157,7 @@ void __init tegra_init_fuse(void)
153157
tegra_sku_info.core_process_id);
154158
pr_debug("Tegra CPU Speedo ID %d, Soc Speedo ID %d\n",
155159
tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);
160+
161+
return 0;
156162
}
163+
early_initcall(tegra_init_fuse);

‎drivers/soc/tegra/fuse/tegra-apbmisc.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ u32 tegra_read_chipid(void)
3838

3939
u8 tegra_get_chip_id(void)
4040
{
41-
u32 id = tegra_read_chipid();
41+
if (!apbmisc_base) {
42+
WARN(1, "Tegra Chip ID not yet available\n");
43+
return 0;
44+
}
4245

43-
return (id >> 8) & 0xff;
46+
return (tegra_read_chipid() >> 8) & 0xff;
4447
}
4548

4649
u32 tegra_read_straps(void)

‎include/soc/tegra/fuse.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct tegra_sku_info {
5656

5757
u32 tegra_read_straps(void);
5858
u32 tegra_read_chipid(void);
59-
void tegra_init_fuse(void);
6059
int tegra_fuse_readl(unsigned long offset, u32 *value);
6160

6261
extern struct tegra_sku_info tegra_sku_info;

0 commit comments

Comments
 (0)