diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2013-11-20 21:40:13 -0500 |
---|---|---|
committer | Stephen Warren <swarren@nvidia.com> | 2013-12-04 14:24:22 -0500 |
commit | cdcb5a074cd3e33e7bdb318487fde8a9e55d6159 (patch) | |
tree | fee59d8e1f586b2d6f957f0069eb531f757ecbd1 /arch/arm/mach-tegra/fuse.c | |
parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) |
ARM: tegra: switch FUSE clock on before usage
FUSE clock is enabled by most bootloaders, but we cannot expect it to be
on in all contexts (e.g. kexec).
Ensure the FUSE clock is enabled before any of its registers is touched.
Since FUSE is touched very early during system boot (before the clock
devices are registered), directly manipulate the clock register bit in
case the clock device cannot be acquired.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/fuse.c')
-rw-r--r-- | arch/arm/mach-tegra/fuse.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c index d4639c506622..d610a408c0e0 100644 --- a/arch/arm/mach-tegra/fuse.c +++ b/arch/arm/mach-tegra/fuse.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/export.h> | 23 | #include <linux/export.h> |
24 | #include <linux/random.h> | 24 | #include <linux/random.h> |
25 | #include <linux/clk.h> | ||
25 | #include <linux/tegra-soc.h> | 26 | #include <linux/tegra-soc.h> |
26 | 27 | ||
27 | #include "fuse.h" | 28 | #include "fuse.h" |
@@ -54,6 +55,7 @@ int tegra_cpu_speedo_id; /* only exist in Tegra30 and later */ | |||
54 | int tegra_soc_speedo_id; | 55 | int tegra_soc_speedo_id; |
55 | enum tegra_revision tegra_revision; | 56 | enum tegra_revision tegra_revision; |
56 | 57 | ||
58 | static struct clk *fuse_clk; | ||
57 | static int tegra_fuse_spare_bit; | 59 | static int tegra_fuse_spare_bit; |
58 | static void (*tegra_init_speedo_data)(void); | 60 | static void (*tegra_init_speedo_data)(void); |
59 | 61 | ||
@@ -77,6 +79,22 @@ static const char *tegra_revision_name[TEGRA_REVISION_MAX] = { | |||
77 | [TEGRA_REVISION_A04] = "A04", | 79 | [TEGRA_REVISION_A04] = "A04", |
78 | }; | 80 | }; |
79 | 81 | ||
82 | static void tegra_fuse_enable_clk(void) | ||
83 | { | ||
84 | if (IS_ERR(fuse_clk)) | ||
85 | fuse_clk = clk_get_sys(NULL, "fuse"); | ||
86 | if (IS_ERR(fuse_clk)) | ||
87 | return; | ||
88 | clk_prepare_enable(fuse_clk); | ||
89 | } | ||
90 | |||
91 | static void tegra_fuse_disable_clk(void) | ||
92 | { | ||
93 | if (IS_ERR(fuse_clk)) | ||
94 | return; | ||
95 | clk_disable_unprepare(fuse_clk); | ||
96 | } | ||
97 | |||
80 | u32 tegra_fuse_readl(unsigned long offset) | 98 | u32 tegra_fuse_readl(unsigned long offset) |
81 | { | 99 | { |
82 | return tegra_apb_readl(TEGRA_FUSE_BASE + offset); | 100 | return tegra_apb_readl(TEGRA_FUSE_BASE + offset); |
@@ -84,7 +102,15 @@ u32 tegra_fuse_readl(unsigned long offset) | |||
84 | 102 | ||
85 | bool tegra_spare_fuse(int bit) | 103 | bool tegra_spare_fuse(int bit) |
86 | { | 104 | { |
87 | return tegra_fuse_readl(tegra_fuse_spare_bit + bit * 4); | 105 | bool ret; |
106 | |||
107 | tegra_fuse_enable_clk(); | ||
108 | |||
109 | ret = tegra_fuse_readl(tegra_fuse_spare_bit + bit * 4); | ||
110 | |||
111 | tegra_fuse_disable_clk(); | ||
112 | |||
113 | return ret; | ||
88 | } | 114 | } |
89 | 115 | ||
90 | static enum tegra_revision tegra_get_revision(u32 id) | 116 | static enum tegra_revision tegra_get_revision(u32 id) |
@@ -113,10 +139,14 @@ static void tegra_get_process_id(void) | |||
113 | { | 139 | { |
114 | u32 reg; | 140 | u32 reg; |
115 | 141 | ||
142 | tegra_fuse_enable_clk(); | ||
143 | |||
116 | reg = tegra_fuse_readl(tegra_fuse_spare_bit); | 144 | reg = tegra_fuse_readl(tegra_fuse_spare_bit); |
117 | tegra_cpu_process_id = (reg >> 6) & 3; | 145 | tegra_cpu_process_id = (reg >> 6) & 3; |
118 | reg = tegra_fuse_readl(tegra_fuse_spare_bit); | 146 | reg = tegra_fuse_readl(tegra_fuse_spare_bit); |
119 | tegra_core_process_id = (reg >> 12) & 3; | 147 | tegra_core_process_id = (reg >> 12) & 3; |
148 | |||
149 | tegra_fuse_disable_clk(); | ||
120 | } | 150 | } |
121 | 151 | ||
122 | u32 tegra_read_chipid(void) | 152 | u32 tegra_read_chipid(void) |
@@ -159,6 +189,15 @@ void __init tegra_init_fuse(void) | |||
159 | reg |= 1 << 28; | 189 | reg |= 1 << 28; |
160 | writel(reg, IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x48)); | 190 | writel(reg, IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x48)); |
161 | 191 | ||
192 | /* | ||
193 | * Enable FUSE clock. This needs to be hardcoded because the clock | ||
194 | * subsystem is not active during early boot. | ||
195 | */ | ||
196 | reg = readl(IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x14)); | ||
197 | reg |= 1 << 7; | ||
198 | writel(reg, IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x14)); | ||
199 | fuse_clk = ERR_PTR(-EINVAL); | ||
200 | |||
162 | reg = tegra_fuse_readl(FUSE_SKU_INFO); | 201 | reg = tegra_fuse_readl(FUSE_SKU_INFO); |
163 | randomness[0] = reg; | 202 | randomness[0] = reg; |
164 | tegra_sku_id = reg & 0xFF; | 203 | tegra_sku_id = reg & 0xFF; |