Skip to content

Commit 304664e

Browse files
committed
ARM: tegra: Use a function to get the chip ID
Instead of using a simple variable access to get at the Tegra chip ID, use a function so that we can run additional code. This can be used to determine where the chip ID is being accessed without being available. That in turn will be handy for resolving boot sequence dependencies in order to convert more code to regular initcalls rather than a sequence fixed by Tegra SoC setup code. Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent a0524ac commit 304664e

14 files changed

Lines changed: 65 additions & 43 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
#include <linux/kernel.h>
2525
#include <linux/module.h>
2626

27-
#include "fuse.h"
27+
#include <soc/tegra/fuse.h>
28+
2829
#include "cpuidle.h"
2930

3031
void __init tegra_cpuidle_init(void)
3132
{
32-
switch (tegra_chip_id) {
33+
switch (tegra_get_chip_id()) {
3334
case TEGRA20:
3435
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
3536
tegra20_cpuidle_init();
@@ -49,7 +50,7 @@ void __init tegra_cpuidle_init(void)
4950

5051
void tegra_cpuidle_pcie_irqs_in_use(void)
5152
{
52-
switch (tegra_chip_id) {
53+
switch (tegra_get_chip_id()) {
5354
case TEGRA20:
5455
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
5556
tegra20_cpuidle_pcie_irqs_in_use();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
#include <linux/io.h>
2424
#include <linux/kernel.h>
2525

26+
#include <soc/tegra/fuse.h>
27+
2628
#include "flowctrl.h"
2729
#include "iomap.h"
28-
#include "fuse.h"
2930

3031
static u8 flowctrl_offset_halt_cpu[] = {
3132
FLOW_CTRL_HALT_CPU0_EVENTS,
@@ -76,7 +77,7 @@ void flowctrl_cpu_suspend_enter(unsigned int cpuid)
7677
int i;
7778

7879
reg = flowctrl_read_cpu_csr(cpuid);
79-
switch (tegra_chip_id) {
80+
switch (tegra_get_chip_id()) {
8081
case TEGRA20:
8182
/* clear wfe bitmap */
8283
reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP;
@@ -117,7 +118,7 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid)
117118

118119
/* Disable powergating via flow controller for CPU0 */
119120
reg = flowctrl_read_cpu_csr(cpuid);
120-
switch (tegra_chip_id) {
121+
switch (tegra_get_chip_id()) {
121122
case TEGRA20:
122123
/* clear wfe bitmap */
123124
reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP;

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
int tegra_sku_id;
5252
int tegra_cpu_process_id;
5353
int tegra_core_process_id;
54-
int tegra_chip_id;
5554
int tegra_cpu_speedo_id; /* only exist in Tegra30 and later */
5655
int tegra_soc_speedo_id;
5756
enum tegra_revision tegra_revision;
@@ -124,7 +123,7 @@ static enum tegra_revision tegra_get_revision(u32 id)
124123
case 2:
125124
return TEGRA_REVISION_A02;
126125
case 3:
127-
if (tegra_chip_id == TEGRA20 &&
126+
if (tegra_get_chip_id() == TEGRA20 &&
128127
(tegra_spare_fuse(18) || tegra_spare_fuse(19)))
129128
return TEGRA_REVISION_A03p;
130129
else
@@ -155,6 +154,13 @@ u32 tegra_read_chipid(void)
155154
return readl_relaxed(IO_ADDRESS(TEGRA_APB_MISC_BASE) + 0x804);
156155
}
157156

157+
u8 tegra_get_chip_id(void)
158+
{
159+
u32 id = tegra_read_chipid();
160+
161+
return (id >> 8) & 0xff;
162+
}
163+
158164
static void __init tegra20_fuse_init_randomness(void)
159165
{
160166
u32 randomness[2];
@@ -185,6 +191,7 @@ void __init tegra_init_fuse(void)
185191
{
186192
u32 id;
187193
u32 randomness[5];
194+
u8 chip_id;
188195

189196
u32 reg = readl(IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x48));
190197
reg |= 1 << 28;
@@ -209,9 +216,9 @@ void __init tegra_init_fuse(void)
209216

210217
id = tegra_read_chipid();
211218
randomness[2] = id;
212-
tegra_chip_id = (id >> 8) & 0xff;
219+
chip_id = (id >> 8) & 0xff;
213220

214-
switch (tegra_chip_id) {
221+
switch (chip_id) {
215222
case TEGRA20:
216223
tegra_fuse_spare_bit = TEGRA20_FUSE_SPARE_BIT;
217224
tegra_init_speedo_data = &tegra20_init_speedo_data;
@@ -224,7 +231,7 @@ void __init tegra_init_fuse(void)
224231
tegra_init_speedo_data = &tegra114_init_speedo_data;
225232
break;
226233
default:
227-
pr_warn("Tegra: unknown chip id %d\n", tegra_chip_id);
234+
pr_warn("Tegra: unknown chip id %d\n", chip_id);
228235
tegra_fuse_spare_bit = TEGRA20_FUSE_SPARE_BIT;
229236
tegra_init_speedo_data = &tegra_get_process_id;
230237
}
@@ -235,7 +242,7 @@ void __init tegra_init_fuse(void)
235242
randomness[4] = (tegra_cpu_speedo_id << 16) | tegra_soc_speedo_id;
236243

237244
add_device_randomness(randomness, sizeof(randomness));
238-
switch (tegra_chip_id) {
245+
switch (chip_id) {
239246
case TEGRA20:
240247
tegra20_fuse_init_randomness();
241248
break;

‎arch/arm/mach-tegra/fuse.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
#define SKU_ID_AP25E 27
2727
#define SKU_ID_T25E 28
2828

29-
#define TEGRA20 0x20
30-
#define TEGRA30 0x30
31-
#define TEGRA114 0x35
32-
#define TEGRA124 0x40
33-
3429
#ifndef __ASSEMBLY__
3530
enum tegra_revision {
3631
TEGRA_REVISION_UNKNOWN = 0,
@@ -45,7 +40,6 @@ enum tegra_revision {
4540
extern int tegra_sku_id;
4641
extern int tegra_cpu_process_id;
4742
extern int tegra_core_process_id;
48-
extern int tegra_chip_id;
4943
extern int tegra_cpu_speedo_id; /* only exist in Tegra30 and later */
5044
extern int tegra_soc_speedo_id;
5145
extern enum tegra_revision tegra_revision;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
#include <linux/kernel.h>
1313
#include <linux/smp.h>
1414

15+
#include <soc/tegra/fuse.h>
16+
1517
#include <asm/smp_plat.h>
1618

17-
#include "fuse.h"
1819
#include "sleep.h"
1920

2021
static void (*tegra_hotplug_shutdown)(void);
@@ -52,12 +53,12 @@ void __init tegra_hotplug_init(void)
5253
if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
5354
return;
5455

55-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20)
56+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20)
5657
tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
57-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_chip_id == TEGRA30)
58+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30)
5859
tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
59-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_chip_id == TEGRA114)
60+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114)
6061
tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
61-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_chip_id == TEGRA124)
62+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124)
6263
tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
6364
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
#include <linux/jiffies.h>
2222
#include <linux/smp.h>
2323

24+
#include <soc/tegra/fuse.h>
25+
2426
#include <asm/cacheflush.h>
2527
#include <asm/mach-types.h>
2628
#include <asm/smp_plat.h>
2729
#include <asm/smp_scu.h>
2830

2931
#include "common.h"
3032
#include "flowctrl.h"
31-
#include "fuse.h"
3233
#include "iomap.h"
3334
#include "pmc.h"
3435
#include "reset.h"
@@ -170,13 +171,13 @@ static int tegra114_boot_secondary(unsigned int cpu, struct task_struct *idle)
170171
static int tegra_boot_secondary(unsigned int cpu,
171172
struct task_struct *idle)
172173
{
173-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20)
174+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_get_chip_id() == TEGRA20)
174175
return tegra20_boot_secondary(cpu, idle);
175-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_chip_id == TEGRA30)
176+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && tegra_get_chip_id() == TEGRA30)
176177
return tegra30_boot_secondary(cpu, idle);
177-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_chip_id == TEGRA114)
178+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC) && tegra_get_chip_id() == TEGRA114)
178179
return tegra114_boot_secondary(cpu, idle);
179-
if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_chip_id == TEGRA124)
180+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) && tegra_get_chip_id() == TEGRA124)
180181
return tegra114_boot_secondary(cpu, idle);
181182

182183
return -EINVAL;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/spinlock.h>
2828
#include <linux/suspend.h>
2929

30+
#include <soc/tegra/fuse.h>
31+
3032
#include <asm/cacheflush.h>
3133
#include <asm/idmap.h>
3234
#include <asm/proc-fns.h>
@@ -35,7 +37,6 @@
3537
#include <asm/tlbflush.h>
3638

3739
#include "flowctrl.h"
38-
#include "fuse.h"
3940
#include "iomap.h"
4041
#include "pmc.h"
4142
#include "pm.h"
@@ -53,7 +54,7 @@ static int (*tegra_sleep_func)(unsigned long v2p);
5354

5455
static void tegra_tear_down_cpu_init(void)
5556
{
56-
switch (tegra_chip_id) {
57+
switch (tegra_get_chip_id()) {
5758
case TEGRA20:
5859
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
5960
tegra_tear_down_cpu = tegra20_tear_down_cpu;
@@ -143,7 +144,7 @@ bool tegra_set_cpu_in_lp2(void)
143144

144145
if ((phy_cpu_id == 0) && cpumask_equal(cpu_lp2_mask, cpu_online_mask))
145146
last_cpu = true;
146-
else if (tegra_chip_id == TEGRA20 && phy_cpu_id == 1)
147+
else if (tegra_get_chip_id() == TEGRA20 && phy_cpu_id == 1)
147148
tegra20_cpu_set_resettable_soon();
148149

149150
spin_unlock(&tegra_lp2_lock);
@@ -212,7 +213,7 @@ static int tegra_sleep_core(unsigned long v2p)
212213
*/
213214
static bool tegra_lp1_iram_hook(void)
214215
{
215-
switch (tegra_chip_id) {
216+
switch (tegra_get_chip_id()) {
216217
case TEGRA20:
217218
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
218219
tegra20_lp1_iram_hook();
@@ -242,7 +243,7 @@ static bool tegra_lp1_iram_hook(void)
242243

243244
static bool tegra_sleep_core_init(void)
244245
{
245-
switch (tegra_chip_id) {
246+
switch (tegra_get_chip_id()) {
246247
case TEGRA20:
247248
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
248249
tegra20_sleep_core_init();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include <linux/of.h>
2222
#include <linux/of_address.h>
2323

24+
#include <soc/tegra/fuse.h>
2425
#include <soc/tegra/powergate.h>
2526

2627
#include "flowctrl.h"
27-
#include "fuse.h"
2828
#include "pm.h"
2929
#include "pmc.h"
3030
#include "sleep.h"
@@ -252,7 +252,7 @@ void tegra_pmc_pm_set(enum tegra_suspend_mode mode)
252252
reg |= TEGRA_POWER_CPU_PWRREQ_OE;
253253
reg &= ~TEGRA_POWER_EFFECT_LP0;
254254

255-
switch (tegra_chip_id) {
255+
switch (tegra_get_chip_id()) {
256256
case TEGRA20:
257257
case TEGRA30:
258258
break;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#include <linux/seq_file.h>
3131
#include <linux/spinlock.h>
3232

33+
#include <soc/tegra/fuse.h>
3334
#include <soc/tegra/powergate.h>
3435

35-
#include "fuse.h"
3636
#include "iomap.h"
3737

3838
#define DPD_SAMPLE 0x020
@@ -158,7 +158,7 @@ int tegra_powergate_remove_clamping(int id)
158158
* The Tegra124 GPU has a separate register (with different semantics)
159159
* to remove clamps.
160160
*/
161-
if (tegra_chip_id == TEGRA124) {
161+
if (tegra_get_chip_id() == TEGRA124) {
162162
if (id == TEGRA_POWERGATE_3D) {
163163
pmc_write(0, GPU_RG_CNTRL);
164164
return 0;
@@ -228,7 +228,7 @@ int tegra_cpu_powergate_id(int cpuid)
228228

229229
int __init tegra_powergate_init(void)
230230
{
231-
switch (tegra_chip_id) {
231+
switch (tegra_get_chip_id()) {
232232
case TEGRA20:
233233
tegra_num_powerdomains = 7;
234234
break;
@@ -369,7 +369,7 @@ int __init tegra_powergate_debugfs_init(void)
369369
{
370370
struct dentry *d;
371371

372-
switch (tegra_chip_id) {
372+
switch (tegra_get_chip_id()) {
373373
case TEGRA20:
374374
powergate_name = powergate_name_t20;
375375
break;

‎arch/arm/mach-tegra/reset-handler.S‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
#include <linux/init.h>
1818
#include <linux/linkage.h>
1919

20+
#include <soc/tegra/fuse.h>
21+
2022
#include <asm/asm-offsets.h>
2123
#include <asm/cache.h>
2224

2325
#include "flowctrl.h"
24-
#include "fuse.h"
2526
#include "iomap.h"
2627
#include "reset.h"
2728
#include "sleep.h"

0 commit comments

Comments
 (0)