diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2016-02-16 02:06:18 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2016-02-18 07:00:18 -0500 |
commit | a150b085b66c87bd4d362a523cb85ce2b0a2d77b (patch) | |
tree | 0a6cfee16ca44e87267e0f73d846930458aa28c0 | |
parent | 98341f7dc9d9080d7999654ab589657272559b04 (diff) |
ARCv2: boot report CCMs (Closely Coupled Memories)
- ARCv2 uses a seperate BCR for {I,D}CCM base address:
ARCompact encoded both base/size in same BCR
- Size encoding in common BCR is different for ARCompact/ARCv2
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r-- | arch/arc/include/asm/arcregs.h | 32 | ||||
-rw-r--r-- | arch/arc/kernel/setup.c | 78 |
2 files changed, 70 insertions, 40 deletions
diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h index fdc5be5b1029..f9f4c6f59fdb 100644 --- a/arch/arc/include/asm/arcregs.h +++ b/arch/arc/include/asm/arcregs.h | |||
@@ -10,7 +10,8 @@ | |||
10 | #define _ASM_ARC_ARCREGS_H | 10 | #define _ASM_ARC_ARCREGS_H |
11 | 11 | ||
12 | /* Build Configuration Registers */ | 12 | /* Build Configuration Registers */ |
13 | #define ARC_REG_DCCMBASE_BCR 0x61 /* DCCM Base Addr */ | 13 | #define ARC_REG_AUX_DCCM 0x18 /* DCCM Base Addr ARCv2 */ |
14 | #define ARC_REG_DCCM_BASE_BUILD 0x61 /* DCCM Base Addr ARCompact */ | ||
14 | #define ARC_REG_CRC_BCR 0x62 | 15 | #define ARC_REG_CRC_BCR 0x62 |
15 | #define ARC_REG_VECBASE_BCR 0x68 | 16 | #define ARC_REG_VECBASE_BCR 0x68 |
16 | #define ARC_REG_PERIBASE_BCR 0x69 | 17 | #define ARC_REG_PERIBASE_BCR 0x69 |
@@ -18,10 +19,10 @@ | |||
18 | #define ARC_REG_DPFP_BCR 0x6C /* ARCompact: Dbl Precision FPU */ | 19 | #define ARC_REG_DPFP_BCR 0x6C /* ARCompact: Dbl Precision FPU */ |
19 | #define ARC_REG_FP_V2_BCR 0xc8 /* ARCv2 FPU */ | 20 | #define ARC_REG_FP_V2_BCR 0xc8 /* ARCv2 FPU */ |
20 | #define ARC_REG_SLC_BCR 0xce | 21 | #define ARC_REG_SLC_BCR 0xce |
21 | #define ARC_REG_DCCM_BCR 0x74 /* DCCM Present + SZ */ | 22 | #define ARC_REG_DCCM_BUILD 0x74 /* DCCM size (common) */ |
22 | #define ARC_REG_TIMERS_BCR 0x75 | 23 | #define ARC_REG_TIMERS_BCR 0x75 |
23 | #define ARC_REG_AP_BCR 0x76 | 24 | #define ARC_REG_AP_BCR 0x76 |
24 | #define ARC_REG_ICCM_BCR 0x78 | 25 | #define ARC_REG_ICCM_BUILD 0x78 /* ICCM size (common) */ |
25 | #define ARC_REG_XY_MEM_BCR 0x79 | 26 | #define ARC_REG_XY_MEM_BCR 0x79 |
26 | #define ARC_REG_MAC_BCR 0x7a | 27 | #define ARC_REG_MAC_BCR 0x7a |
27 | #define ARC_REG_MUL_BCR 0x7b | 28 | #define ARC_REG_MUL_BCR 0x7b |
@@ -36,6 +37,7 @@ | |||
36 | #define ARC_REG_IRQ_BCR 0xF3 | 37 | #define ARC_REG_IRQ_BCR 0xF3 |
37 | #define ARC_REG_SMART_BCR 0xFF | 38 | #define ARC_REG_SMART_BCR 0xFF |
38 | #define ARC_REG_CLUSTER_BCR 0xcf | 39 | #define ARC_REG_CLUSTER_BCR 0xcf |
40 | #define ARC_REG_AUX_ICCM 0x208 /* ICCM Base Addr (ARCv2) */ | ||
39 | 41 | ||
40 | /* status32 Bits Positions */ | 42 | /* status32 Bits Positions */ |
41 | #define STATUS_AE_BIT 5 /* Exception active */ | 43 | #define STATUS_AE_BIT 5 /* Exception active */ |
@@ -246,7 +248,7 @@ struct bcr_perip { | |||
246 | #endif | 248 | #endif |
247 | }; | 249 | }; |
248 | 250 | ||
249 | struct bcr_iccm { | 251 | struct bcr_iccm_arcompact { |
250 | #ifdef CONFIG_CPU_BIG_ENDIAN | 252 | #ifdef CONFIG_CPU_BIG_ENDIAN |
251 | unsigned int base:16, pad:5, sz:3, ver:8; | 253 | unsigned int base:16, pad:5, sz:3, ver:8; |
252 | #else | 254 | #else |
@@ -254,17 +256,15 @@ struct bcr_iccm { | |||
254 | #endif | 256 | #endif |
255 | }; | 257 | }; |
256 | 258 | ||
257 | /* DCCM Base Address Register: ARC_REG_DCCMBASE_BCR */ | 259 | struct bcr_iccm_arcv2 { |
258 | struct bcr_dccm_base { | ||
259 | #ifdef CONFIG_CPU_BIG_ENDIAN | 260 | #ifdef CONFIG_CPU_BIG_ENDIAN |
260 | unsigned int addr:24, ver:8; | 261 | unsigned int pad:8, sz11:4, sz01:4, sz10:4, sz00:4, ver:8; |
261 | #else | 262 | #else |
262 | unsigned int ver:8, addr:24; | 263 | unsigned int ver:8, sz00:4, sz10:4, sz01:4, sz11:4, pad:8; |
263 | #endif | 264 | #endif |
264 | }; | 265 | }; |
265 | 266 | ||
266 | /* DCCM RAM Configuration Register: ARC_REG_DCCM_BCR */ | 267 | struct bcr_dccm_arcompact { |
267 | struct bcr_dccm { | ||
268 | #ifdef CONFIG_CPU_BIG_ENDIAN | 268 | #ifdef CONFIG_CPU_BIG_ENDIAN |
269 | unsigned int res:21, sz:3, ver:8; | 269 | unsigned int res:21, sz:3, ver:8; |
270 | #else | 270 | #else |
@@ -272,6 +272,14 @@ struct bcr_dccm { | |||
272 | #endif | 272 | #endif |
273 | }; | 273 | }; |
274 | 274 | ||
275 | struct bcr_dccm_arcv2 { | ||
276 | #ifdef CONFIG_CPU_BIG_ENDIAN | ||
277 | unsigned int pad2:12, cyc:3, pad1:1, sz1:4, sz0:4, ver:8; | ||
278 | #else | ||
279 | unsigned int ver:8, sz0:4, sz1:4, pad1:1, cyc:3, pad2:12; | ||
280 | #endif | ||
281 | }; | ||
282 | |||
275 | /* ARCompact: Both SP and DP FPU BCRs have same format */ | 283 | /* ARCompact: Both SP and DP FPU BCRs have same format */ |
276 | struct bcr_fp_arcompact { | 284 | struct bcr_fp_arcompact { |
277 | #ifdef CONFIG_CPU_BIG_ENDIAN | 285 | #ifdef CONFIG_CPU_BIG_ENDIAN |
@@ -315,9 +323,9 @@ struct bcr_bpu_arcv2 { | |||
315 | 323 | ||
316 | struct bcr_generic { | 324 | struct bcr_generic { |
317 | #ifdef CONFIG_CPU_BIG_ENDIAN | 325 | #ifdef CONFIG_CPU_BIG_ENDIAN |
318 | unsigned int pad:24, ver:8; | 326 | unsigned int info:24, ver:8; |
319 | #else | 327 | #else |
320 | unsigned int ver:8, pad:24; | 328 | unsigned int ver:8, info:24; |
321 | #endif | 329 | #endif |
322 | }; | 330 | }; |
323 | 331 | ||
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index 28dba569edd4..cdc821df1809 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c | |||
@@ -42,6 +42,53 @@ struct task_struct *_current_task[NR_CPUS]; /* For stack switching */ | |||
42 | 42 | ||
43 | struct cpuinfo_arc cpuinfo_arc700[NR_CPUS]; | 43 | struct cpuinfo_arc cpuinfo_arc700[NR_CPUS]; |
44 | 44 | ||
45 | static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu) | ||
46 | { | ||
47 | if (is_isa_arcompact()) { | ||
48 | struct bcr_iccm_arcompact iccm; | ||
49 | struct bcr_dccm_arcompact dccm; | ||
50 | |||
51 | READ_BCR(ARC_REG_ICCM_BUILD, iccm); | ||
52 | if (iccm.ver) { | ||
53 | cpu->iccm.sz = 4096 << iccm.sz; /* 8K to 512K */ | ||
54 | cpu->iccm.base_addr = iccm.base << 16; | ||
55 | } | ||
56 | |||
57 | READ_BCR(ARC_REG_DCCM_BUILD, dccm); | ||
58 | if (dccm.ver) { | ||
59 | unsigned long base; | ||
60 | cpu->dccm.sz = 2048 << dccm.sz; /* 2K to 256K */ | ||
61 | |||
62 | base = read_aux_reg(ARC_REG_DCCM_BASE_BUILD); | ||
63 | cpu->dccm.base_addr = base & ~0xF; | ||
64 | } | ||
65 | } else { | ||
66 | struct bcr_iccm_arcv2 iccm; | ||
67 | struct bcr_dccm_arcv2 dccm; | ||
68 | unsigned long region; | ||
69 | |||
70 | READ_BCR(ARC_REG_ICCM_BUILD, iccm); | ||
71 | if (iccm.ver) { | ||
72 | cpu->iccm.sz = 256 << iccm.sz00; /* 512B to 16M */ | ||
73 | if (iccm.sz00 == 0xF && iccm.sz01 > 0) | ||
74 | cpu->iccm.sz <<= iccm.sz01; | ||
75 | |||
76 | region = read_aux_reg(ARC_REG_AUX_ICCM); | ||
77 | cpu->iccm.base_addr = region & 0xF0000000; | ||
78 | } | ||
79 | |||
80 | READ_BCR(ARC_REG_DCCM_BUILD, dccm); | ||
81 | if (dccm.ver) { | ||
82 | cpu->dccm.sz = 256 << dccm.sz0; | ||
83 | if (dccm.sz0 == 0xF && dccm.sz1 > 0) | ||
84 | cpu->dccm.sz <<= dccm.sz1; | ||
85 | |||
86 | region = read_aux_reg(ARC_REG_AUX_DCCM); | ||
87 | cpu->dccm.base_addr = region & 0xF0000000; | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | |||
45 | static void read_arc_build_cfg_regs(void) | 92 | static void read_arc_build_cfg_regs(void) |
46 | { | 93 | { |
47 | struct bcr_perip uncached_space; | 94 | struct bcr_perip uncached_space; |
@@ -76,36 +123,11 @@ static void read_arc_build_cfg_regs(void) | |||
76 | cpu->extn.swap = read_aux_reg(ARC_REG_SWAP_BCR) ? 1 : 0; /* 1,3 */ | 123 | cpu->extn.swap = read_aux_reg(ARC_REG_SWAP_BCR) ? 1 : 0; /* 1,3 */ |
77 | cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR) ? 1 : 0; | 124 | cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR) ? 1 : 0; |
78 | cpu->extn.minmax = read_aux_reg(ARC_REG_MIXMAX_BCR) > 1 ? 1 : 0; /* 2 */ | 125 | cpu->extn.minmax = read_aux_reg(ARC_REG_MIXMAX_BCR) > 1 ? 1 : 0; /* 2 */ |
79 | |||
80 | /* Note that we read the CCM BCRs independent of kernel config | ||
81 | * This is to catch the cases where user doesn't know that | ||
82 | * CCMs are present in hardware build | ||
83 | */ | ||
84 | { | ||
85 | struct bcr_iccm iccm; | ||
86 | struct bcr_dccm dccm; | ||
87 | struct bcr_dccm_base dccm_base; | ||
88 | unsigned int bcr_32bit_val; | ||
89 | |||
90 | bcr_32bit_val = read_aux_reg(ARC_REG_ICCM_BCR); | ||
91 | if (bcr_32bit_val) { | ||
92 | iccm = *((struct bcr_iccm *)&bcr_32bit_val); | ||
93 | cpu->iccm.base_addr = iccm.base << 16; | ||
94 | cpu->iccm.sz = 0x2000 << (iccm.sz - 1); | ||
95 | } | ||
96 | |||
97 | bcr_32bit_val = read_aux_reg(ARC_REG_DCCM_BCR); | ||
98 | if (bcr_32bit_val) { | ||
99 | dccm = *((struct bcr_dccm *)&bcr_32bit_val); | ||
100 | cpu->dccm.sz = 0x800 << (dccm.sz); | ||
101 | |||
102 | READ_BCR(ARC_REG_DCCMBASE_BCR, dccm_base); | ||
103 | cpu->dccm.base_addr = dccm_base.addr << 8; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem); | 126 | READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem); |
108 | 127 | ||
128 | /* Read CCM BCRs for boot reporting even if not enabled in Kconfig */ | ||
129 | read_decode_ccm_bcr(cpu); | ||
130 | |||
109 | read_decode_mmu_bcr(); | 131 | read_decode_mmu_bcr(); |
110 | read_decode_cache_bcr(); | 132 | read_decode_cache_bcr(); |
111 | 133 | ||