diff options
author | Kukjin Kim <kgene.kim@samsung.com> | 2011-08-19 13:18:18 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2011-08-21 18:14:07 -0400 |
commit | c06af3cc6a27991187fd513765fed943684d41bf (patch) | |
tree | 1bdcaab50fd7ba121218c8ee23f19df9caaf149b | |
parent | 93ee7a9340d64f20295aacc3fb6a22b759323280 (diff) |
ARM: SAMSUNG: Add support for detecting CPU at runtime
The soc_is_[name]() can be used to distinguish cpu at runtime.
This patch was originally from Changhwan Youn <chaos.youn@samsung.com>
Acked-by: Changhwan Youn <chaos.youn@samsung.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
-rw-r--r-- | arch/arm/mach-s3c64xx/cpu.c | 18 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/cpu.c | 8 | ||||
-rw-r--r-- | arch/arm/plat-s5p/cpu.c | 26 | ||||
-rw-r--r-- | arch/arm/plat-samsung/include/plat/cpu.h | 87 | ||||
-rw-r--r-- | arch/arm/plat-samsung/init.c | 1 |
5 files changed, 110 insertions, 30 deletions
diff --git a/arch/arm/mach-s3c64xx/cpu.c b/arch/arm/mach-s3c64xx/cpu.c index 374e45e566b8..7b665f3e2e1f 100644 --- a/arch/arm/mach-s3c64xx/cpu.c +++ b/arch/arm/mach-s3c64xx/cpu.c | |||
@@ -43,16 +43,16 @@ static const char name_s3c6410[] = "S3C6410"; | |||
43 | 43 | ||
44 | static struct cpu_table cpu_ids[] __initdata = { | 44 | static struct cpu_table cpu_ids[] __initdata = { |
45 | { | 45 | { |
46 | .idcode = 0x36400000, | 46 | .idcode = S3C6400_CPU_ID, |
47 | .idmask = 0xfffff000, | 47 | .idmask = S3C64XX_CPU_MASK, |
48 | .map_io = s3c6400_map_io, | 48 | .map_io = s3c6400_map_io, |
49 | .init_clocks = s3c6400_init_clocks, | 49 | .init_clocks = s3c6400_init_clocks, |
50 | .init_uarts = s3c6400_init_uarts, | 50 | .init_uarts = s3c6400_init_uarts, |
51 | .init = s3c6400_init, | 51 | .init = s3c6400_init, |
52 | .name = name_s3c6400, | 52 | .name = name_s3c6400, |
53 | }, { | 53 | }, { |
54 | .idcode = 0x36410100, | 54 | .idcode = S3C6410_CPU_ID, |
55 | .idmask = 0xffffff00, | 55 | .idmask = S3C64XX_CPU_MASK, |
56 | .map_io = s3c6410_map_io, | 56 | .map_io = s3c6410_map_io, |
57 | .init_clocks = s3c6410_init_clocks, | 57 | .init_clocks = s3c6410_init_clocks, |
58 | .init_uarts = s3c6410_init_uarts, | 58 | .init_uarts = s3c6410_init_uarts, |
@@ -140,22 +140,20 @@ void __init s3c6400_common_init_uarts(struct s3c2410_uartcfg *cfg, int no) | |||
140 | 140 | ||
141 | void __init s3c64xx_init_io(struct map_desc *mach_desc, int size) | 141 | void __init s3c64xx_init_io(struct map_desc *mach_desc, int size) |
142 | { | 142 | { |
143 | unsigned long idcode; | ||
144 | |||
145 | /* initialise the io descriptors we need for initialisation */ | 143 | /* initialise the io descriptors we need for initialisation */ |
146 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); | 144 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); |
147 | iotable_init(mach_desc, size); | 145 | iotable_init(mach_desc, size); |
148 | 146 | ||
149 | idcode = __raw_readl(S3C_VA_SYS + 0x118); | 147 | samsung_cpu_id = __raw_readl(S3C_VA_SYS + 0x118); |
150 | if (!idcode) { | 148 | if (!samsung_cpu_id) { |
151 | /* S3C6400 has the ID register in a different place, | 149 | /* S3C6400 has the ID register in a different place, |
152 | * and needs a write before it can be read. */ | 150 | * and needs a write before it can be read. */ |
153 | 151 | ||
154 | __raw_writel(0x0, S3C_VA_SYS + 0xA1C); | 152 | __raw_writel(0x0, S3C_VA_SYS + 0xA1C); |
155 | idcode = __raw_readl(S3C_VA_SYS + 0xA1C); | 153 | samsung_cpu_id = __raw_readl(S3C_VA_SYS + 0xA1C); |
156 | } | 154 | } |
157 | 155 | ||
158 | s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids)); | 156 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
159 | } | 157 | } |
160 | 158 | ||
161 | static __init int s3c64xx_sysdev_init(void) | 159 | static __init int s3c64xx_sysdev_init(void) |
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c index c1fc6c6fac72..ead21a4a7f8a 100644 --- a/arch/arm/plat-s3c24xx/cpu.c +++ b/arch/arm/plat-s3c24xx/cpu.c | |||
@@ -215,19 +215,17 @@ static void s3c24xx_pm_restart(char mode, const char *cmd) | |||
215 | 215 | ||
216 | void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) | 216 | void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) |
217 | { | 217 | { |
218 | unsigned long idcode = 0x0; | ||
219 | |||
220 | /* initialise the io descriptors we need for initialisation */ | 218 | /* initialise the io descriptors we need for initialisation */ |
221 | iotable_init(mach_desc, size); | 219 | iotable_init(mach_desc, size); |
222 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); | 220 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); |
223 | 221 | ||
224 | if (cpu_architecture() >= CPU_ARCH_ARMv5) { | 222 | if (cpu_architecture() >= CPU_ARCH_ARMv5) { |
225 | idcode = s3c24xx_read_idcode_v5(); | 223 | samsung_cpu_id = s3c24xx_read_idcode_v5(); |
226 | } else { | 224 | } else { |
227 | idcode = s3c24xx_read_idcode_v4(); | 225 | samsung_cpu_id = s3c24xx_read_idcode_v4(); |
228 | } | 226 | } |
229 | 227 | ||
230 | arm_pm_restart = s3c24xx_pm_restart; | 228 | arm_pm_restart = s3c24xx_pm_restart; |
231 | 229 | ||
232 | s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids)); | 230 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
233 | } | 231 | } |
diff --git a/arch/arm/plat-s5p/cpu.c b/arch/arm/plat-s5p/cpu.c index bbc2aa7449ca..3ef673482111 100644 --- a/arch/arm/plat-s5p/cpu.c +++ b/arch/arm/plat-s5p/cpu.c | |||
@@ -36,40 +36,40 @@ static const char name_exynos4210[] = "EXYNOS4210"; | |||
36 | 36 | ||
37 | static struct cpu_table cpu_ids[] __initdata = { | 37 | static struct cpu_table cpu_ids[] __initdata = { |
38 | { | 38 | { |
39 | .idcode = 0x56440100, | 39 | .idcode = S5P6440_CPU_ID, |
40 | .idmask = 0xfffff000, | 40 | .idmask = S5P64XX_CPU_MASK, |
41 | .map_io = s5p6440_map_io, | 41 | .map_io = s5p6440_map_io, |
42 | .init_clocks = s5p6440_init_clocks, | 42 | .init_clocks = s5p6440_init_clocks, |
43 | .init_uarts = s5p6440_init_uarts, | 43 | .init_uarts = s5p6440_init_uarts, |
44 | .init = s5p64x0_init, | 44 | .init = s5p64x0_init, |
45 | .name = name_s5p6440, | 45 | .name = name_s5p6440, |
46 | }, { | 46 | }, { |
47 | .idcode = 0x36450000, | 47 | .idcode = S5P6450_CPU_ID, |
48 | .idmask = 0xfffff000, | 48 | .idmask = S5P64XX_CPU_MASK, |
49 | .map_io = s5p6450_map_io, | 49 | .map_io = s5p6450_map_io, |
50 | .init_clocks = s5p6450_init_clocks, | 50 | .init_clocks = s5p6450_init_clocks, |
51 | .init_uarts = s5p6450_init_uarts, | 51 | .init_uarts = s5p6450_init_uarts, |
52 | .init = s5p64x0_init, | 52 | .init = s5p64x0_init, |
53 | .name = name_s5p6450, | 53 | .name = name_s5p6450, |
54 | }, { | 54 | }, { |
55 | .idcode = 0x43100000, | 55 | .idcode = S5PC100_CPU_ID, |
56 | .idmask = 0xfffff000, | 56 | .idmask = S5PC100_CPU_MASK, |
57 | .map_io = s5pc100_map_io, | 57 | .map_io = s5pc100_map_io, |
58 | .init_clocks = s5pc100_init_clocks, | 58 | .init_clocks = s5pc100_init_clocks, |
59 | .init_uarts = s5pc100_init_uarts, | 59 | .init_uarts = s5pc100_init_uarts, |
60 | .init = s5pc100_init, | 60 | .init = s5pc100_init, |
61 | .name = name_s5pc100, | 61 | .name = name_s5pc100, |
62 | }, { | 62 | }, { |
63 | .idcode = 0x43110000, | 63 | .idcode = S5PV210_CPU_ID, |
64 | .idmask = 0xfffff000, | 64 | .idmask = S5PV210_CPU_MASK, |
65 | .map_io = s5pv210_map_io, | 65 | .map_io = s5pv210_map_io, |
66 | .init_clocks = s5pv210_init_clocks, | 66 | .init_clocks = s5pv210_init_clocks, |
67 | .init_uarts = s5pv210_init_uarts, | 67 | .init_uarts = s5pv210_init_uarts, |
68 | .init = s5pv210_init, | 68 | .init = s5pv210_init, |
69 | .name = name_s5pv210, | 69 | .name = name_s5pv210, |
70 | }, { | 70 | }, { |
71 | .idcode = 0x43210000, | 71 | .idcode = EXYNOS4210_CPU_ID, |
72 | .idmask = 0xfffe0000, | 72 | .idmask = EXYNOS4_CPU_MASK, |
73 | .map_io = exynos4_map_io, | 73 | .map_io = exynos4_map_io, |
74 | .init_clocks = exynos4_init_clocks, | 74 | .init_clocks = exynos4_init_clocks, |
75 | .init_uarts = exynos4_init_uarts, | 75 | .init_uarts = exynos4_init_uarts, |
@@ -114,13 +114,11 @@ static struct map_desc s5p_iodesc[] __initdata = { | |||
114 | void __init s5p_init_io(struct map_desc *mach_desc, | 114 | void __init s5p_init_io(struct map_desc *mach_desc, |
115 | int size, void __iomem *cpuid_addr) | 115 | int size, void __iomem *cpuid_addr) |
116 | { | 116 | { |
117 | unsigned long idcode; | ||
118 | |||
119 | /* initialize the io descriptors we need for initialization */ | 117 | /* initialize the io descriptors we need for initialization */ |
120 | iotable_init(s5p_iodesc, ARRAY_SIZE(s5p_iodesc)); | 118 | iotable_init(s5p_iodesc, ARRAY_SIZE(s5p_iodesc)); |
121 | if (mach_desc) | 119 | if (mach_desc) |
122 | iotable_init(mach_desc, size); | 120 | iotable_init(mach_desc, size); |
123 | 121 | ||
124 | idcode = __raw_readl(cpuid_addr); | 122 | samsung_cpu_id = __raw_readl(cpuid_addr); |
125 | s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids)); | 123 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
126 | } | 124 | } |
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h index c0a5741b23e6..bdf43ad3b5ec 100644 --- a/arch/arm/plat-samsung/include/plat/cpu.h +++ b/arch/arm/plat-samsung/include/plat/cpu.h | |||
@@ -1,9 +1,12 @@ | |||
1 | /* linux/arch/arm/plat-samsung/include/plat/cpu.h | 1 | /* linux/arch/arm/plat-samsung/include/plat/cpu.h |
2 | * | 2 | * |
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com/ | ||
5 | * | ||
3 | * Copyright (c) 2004-2005 Simtec Electronics | 6 | * Copyright (c) 2004-2005 Simtec Electronics |
4 | * Ben Dooks <ben@simtec.co.uk> | 7 | * Ben Dooks <ben@simtec.co.uk> |
5 | * | 8 | * |
6 | * Header file for S3C24XX CPU support | 9 | * Header file for Samsung CPU support |
7 | * | 10 | * |
8 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 2 as | 12 | * it under the terms of the GNU General Public License version 2 as |
@@ -15,6 +18,88 @@ | |||
15 | #ifndef __SAMSUNG_PLAT_CPU_H | 18 | #ifndef __SAMSUNG_PLAT_CPU_H |
16 | #define __SAMSUNG_PLAT_CPU_H | 19 | #define __SAMSUNG_PLAT_CPU_H |
17 | 20 | ||
21 | extern unsigned long samsung_cpu_id; | ||
22 | |||
23 | #define S3C24XX_CPU_ID 0x32400000 | ||
24 | #define S3C24XX_CPU_MASK 0xFFF00000 | ||
25 | |||
26 | #define S3C6400_CPU_ID 0x36400000 | ||
27 | #define S3C6410_CPU_ID 0x36410000 | ||
28 | #define S3C64XX_CPU_ID (S3C6400_CPU_ID & S3C6410_CPU_ID) | ||
29 | #define S3C64XX_CPU_MASK 0x1FF40000 | ||
30 | |||
31 | #define S5P6440_CPU_ID 0x56440000 | ||
32 | #define S5P6450_CPU_ID 0x36450000 | ||
33 | #define S5P64XX_CPU_MASK 0x1FF40000 | ||
34 | |||
35 | #define S5PC100_CPU_ID 0x43100000 | ||
36 | #define S5PC100_CPU_MASK 0xFFFFF000 | ||
37 | |||
38 | #define S5PV210_CPU_ID 0x43110000 | ||
39 | #define S5PV210_CPU_MASK 0xFFFFF000 | ||
40 | |||
41 | #define EXYNOS4210_CPU_ID 0x43210000 | ||
42 | #define EXYNOS4_CPU_MASK 0xFFFE0000 | ||
43 | |||
44 | #define IS_SAMSUNG_CPU(name, id, mask) \ | ||
45 | static inline int is_samsung_##name(void) \ | ||
46 | { \ | ||
47 | return ((samsung_cpu_id & mask) == (id & mask)); \ | ||
48 | } | ||
49 | |||
50 | IS_SAMSUNG_CPU(s3c24xx, S3C24XX_CPU_ID, S3C24XX_CPU_MASK) | ||
51 | IS_SAMSUNG_CPU(s3c64xx, S3C64XX_CPU_ID, S3C64XX_CPU_MASK) | ||
52 | IS_SAMSUNG_CPU(s5p6440, S5P6440_CPU_ID, S5P64XX_CPU_MASK) | ||
53 | IS_SAMSUNG_CPU(s5p6450, S5P6450_CPU_ID, S5P64XX_CPU_MASK) | ||
54 | IS_SAMSUNG_CPU(s5pc100, S5PC100_CPU_ID, S5PC100_CPU_MASK) | ||
55 | IS_SAMSUNG_CPU(s5pv210, S5PV210_CPU_ID, S5PV210_CPU_MASK) | ||
56 | IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK) | ||
57 | |||
58 | #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \ | ||
59 | defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2440) || \ | ||
60 | defined(CONFIG_CPU_S3C2442) || defined(CONFIG_CPU_S3C244X) || \ | ||
61 | defined(CONFIG_CPU_S3C2443) | ||
62 | # define soc_is_s3c24xx() is_samsung_s3c24xx() | ||
63 | #else | ||
64 | # define soc_is_s3c24xx() 0 | ||
65 | #endif | ||
66 | |||
67 | #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410) | ||
68 | # define soc_is_s3c64xx() is_samsung_s3c64xx() | ||
69 | #else | ||
70 | # define soc_is_s3c64xx() 0 | ||
71 | #endif | ||
72 | |||
73 | #if defined(CONFIG_CPU_S5P6440) | ||
74 | # define soc_is_s5p6440() is_samsung_s5p6440() | ||
75 | #else | ||
76 | # define soc_is_s5p6440() 0 | ||
77 | #endif | ||
78 | |||
79 | #if defined(CONFIG_CPU_S5P6450) | ||
80 | # define soc_is_s5p6450() is_samsung_s5p6450() | ||
81 | #else | ||
82 | # define soc_is_s5p6450() 0 | ||
83 | #endif | ||
84 | |||
85 | #if defined(CONFIG_CPU_S5PC100) | ||
86 | # define soc_is_s5pc100() is_samsung_s5pc100() | ||
87 | #else | ||
88 | # define soc_is_s5pc100() 0 | ||
89 | #endif | ||
90 | |||
91 | #if defined(CONFIG_CPU_S5PV210) | ||
92 | # define soc_is_s5pv210() is_samsung_s5pv210() | ||
93 | #else | ||
94 | # define soc_is_s5pv210() 0 | ||
95 | #endif | ||
96 | |||
97 | #if defined(CONFIG_CPU_EXYNOS4210) | ||
98 | # define soc_is_exynos4210() is_samsung_exynos4210() | ||
99 | #else | ||
100 | # define soc_is_exynos4210() 0 | ||
101 | #endif | ||
102 | |||
18 | #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } | 103 | #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } |
19 | 104 | ||
20 | #ifndef MHZ | 105 | #ifndef MHZ |
diff --git a/arch/arm/plat-samsung/init.c b/arch/arm/plat-samsung/init.c index 79d10fca9090..40b1228adb88 100644 --- a/arch/arm/plat-samsung/init.c +++ b/arch/arm/plat-samsung/init.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <plat/regs-serial.h> | 30 | #include <plat/regs-serial.h> |
31 | 31 | ||
32 | static struct cpu_table *cpu; | 32 | static struct cpu_table *cpu; |
33 | unsigned long samsung_cpu_id; | ||
33 | 34 | ||
34 | static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode, | 35 | static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode, |
35 | struct cpu_table *tab, | 36 | struct cpu_table *tab, |