This source file includes following definitions.
- speculative_execution_init
- expmask_init
- l2_cache_init
- cache_init
- detect_cache_shape
- fpu_init
- release_dsp
- dsp_init
- dsp_init
- cpu_init
1
2
3
4
5
6
7
8
9
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/mm.h>
13 #include <linux/log2.h>
14 #include <asm/mmu_context.h>
15 #include <asm/processor.h>
16 #include <linux/uaccess.h>
17 #include <asm/page.h>
18 #include <asm/cacheflush.h>
19 #include <asm/cache.h>
20 #include <asm/elf.h>
21 #include <asm/io.h>
22 #include <asm/smp.h>
23 #include <asm/sh_bios.h>
24 #include <asm/setup.h>
25
26 #ifdef CONFIG_SH_FPU
27 #define cpu_has_fpu 1
28 #else
29 #define cpu_has_fpu 0
30 #endif
31
32 #ifdef CONFIG_SH_DSP
33 #define cpu_has_dsp 1
34 #else
35 #define cpu_has_dsp 0
36 #endif
37
38
39
40
41
42 #define onchip_setup(x) \
43 static int x##_disabled = !cpu_has_##x; \
44 \
45 static int x##_setup(char *opts) \
46 { \
47 x##_disabled = 1; \
48 return 1; \
49 } \
50 __setup("no" __stringify(x), x##_setup);
51
52 onchip_setup(fpu);
53 onchip_setup(dsp);
54
55 #ifdef CONFIG_SPECULATIVE_EXECUTION
56 #define CPUOPM 0xff2f0000
57 #define CPUOPM_RABD (1 << 5)
58
59 static void speculative_execution_init(void)
60 {
61
62 __raw_writel(__raw_readl(CPUOPM) & ~CPUOPM_RABD, CPUOPM);
63
64
65 (void)__raw_readl(CPUOPM);
66 ctrl_barrier();
67 }
68 #else
69 #define speculative_execution_init() do { } while (0)
70 #endif
71
72 #ifdef CONFIG_CPU_SH4A
73 #define EXPMASK 0xff2f0004
74 #define EXPMASK_RTEDS (1 << 0)
75 #define EXPMASK_BRDSSLP (1 << 1)
76 #define EXPMASK_MMCAW (1 << 4)
77
78 static void expmask_init(void)
79 {
80 unsigned long expmask = __raw_readl(EXPMASK);
81
82
83
84
85
86
87
88
89 expmask &= ~(EXPMASK_RTEDS | EXPMASK_BRDSSLP | EXPMASK_MMCAW);
90
91 __raw_writel(expmask, EXPMASK);
92 ctrl_barrier();
93 }
94 #else
95 #define expmask_init() do { } while (0)
96 #endif
97
98
99 void __attribute__ ((weak)) l2_cache_init(void)
100 {
101 }
102
103
104
105
106 #if defined(CONFIG_SUPERH32) && !defined(CONFIG_CPU_J2)
107 static void cache_init(void)
108 {
109 unsigned long ccr, flags;
110
111 jump_to_uncached();
112 ccr = __raw_readl(SH_CCR);
113
114
115
116
117
118
119
120
121
122
123
124
125 if (ccr & CCR_CACHE_ENABLE) {
126 unsigned long ways, waysize, addrstart;
127
128 waysize = current_cpu_data.dcache.sets;
129
130 #ifdef CCR_CACHE_ORA
131
132
133
134
135 if (ccr & CCR_CACHE_ORA)
136 waysize >>= 1;
137 #endif
138
139 waysize <<= current_cpu_data.dcache.entry_shift;
140
141 #ifdef CCR_CACHE_EMODE
142
143 if (!(ccr & CCR_CACHE_EMODE))
144 ways = 1;
145 else
146 #endif
147 ways = current_cpu_data.dcache.ways;
148
149 addrstart = CACHE_OC_ADDRESS_ARRAY;
150 do {
151 unsigned long addr;
152
153 for (addr = addrstart;
154 addr < addrstart + waysize;
155 addr += current_cpu_data.dcache.linesz)
156 __raw_writel(0, addr);
157
158 addrstart += current_cpu_data.dcache.way_incr;
159 } while (--ways);
160 }
161
162
163
164
165
166 flags = CCR_CACHE_ENABLE | CCR_CACHE_INVALIDATE;
167
168 #ifdef CCR_CACHE_EMODE
169
170 if (current_cpu_data.dcache.ways > 1)
171 flags |= CCR_CACHE_EMODE;
172 else
173 flags &= ~CCR_CACHE_EMODE;
174 #endif
175
176 #if defined(CONFIG_CACHE_WRITETHROUGH)
177
178 flags |= CCR_CACHE_WT;
179 #elif defined(CONFIG_CACHE_WRITEBACK)
180
181 flags |= CCR_CACHE_CB;
182 #else
183
184 flags &= ~CCR_CACHE_ENABLE;
185 #endif
186
187 l2_cache_init();
188
189 __raw_writel(flags, SH_CCR);
190 back_to_cached();
191 }
192 #else
193 #define cache_init() do { } while (0)
194 #endif
195
196 #define CSHAPE(totalsize, linesize, assoc) \
197 ((totalsize & ~0xff) | (linesize << 4) | assoc)
198
199 #define CACHE_DESC_SHAPE(desc) \
200 CSHAPE((desc).way_size * (desc).ways, ilog2((desc).linesz), (desc).ways)
201
202 static void detect_cache_shape(void)
203 {
204 l1d_cache_shape = CACHE_DESC_SHAPE(current_cpu_data.dcache);
205
206 if (current_cpu_data.dcache.flags & SH_CACHE_COMBINED)
207 l1i_cache_shape = l1d_cache_shape;
208 else
209 l1i_cache_shape = CACHE_DESC_SHAPE(current_cpu_data.icache);
210
211 if (current_cpu_data.flags & CPU_HAS_L2_CACHE)
212 l2_cache_shape = CACHE_DESC_SHAPE(current_cpu_data.scache);
213 else
214 l2_cache_shape = -1;
215 }
216
217 static void fpu_init(void)
218 {
219
220 if (fpu_disabled && (current_cpu_data.flags & CPU_HAS_FPU)) {
221 printk("FPU Disabled\n");
222 current_cpu_data.flags &= ~CPU_HAS_FPU;
223 }
224
225 disable_fpu();
226 clear_used_math();
227 }
228
229 #ifdef CONFIG_SH_DSP
230 static void release_dsp(void)
231 {
232 unsigned long sr;
233
234
235 __asm__ __volatile__ (
236 "stc\tsr, %0\n\t"
237 "and\t%1, %0\n\t"
238 "ldc\t%0, sr\n\t"
239 : "=&r" (sr)
240 : "r" (~SR_DSP)
241 );
242 }
243
244 static void dsp_init(void)
245 {
246 unsigned long sr;
247
248
249
250
251
252 __asm__ __volatile__ (
253 "stc\tsr, %0\n\t"
254 "or\t%1, %0\n\t"
255 "ldc\t%0, sr\n\t"
256 "nop\n\t"
257 "stc\tsr, %0\n\t"
258 : "=&r" (sr)
259 : "r" (SR_DSP)
260 );
261
262
263 if (sr & SR_DSP)
264 current_cpu_data.flags |= CPU_HAS_DSP;
265
266
267 if (dsp_disabled && (current_cpu_data.flags & CPU_HAS_DSP)) {
268 printk("DSP Disabled\n");
269 current_cpu_data.flags &= ~CPU_HAS_DSP;
270 }
271
272
273 release_dsp();
274 }
275 #else
276 static inline void dsp_init(void) { }
277 #endif
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295 asmlinkage void cpu_init(void)
296 {
297 current_thread_info()->cpu = hard_smp_processor_id();
298
299
300 cpu_probe();
301
302 if (current_cpu_data.type == CPU_SH_NONE)
303 panic("Unknown CPU");
304
305
306 current_cpu_data.icache.entry_mask = current_cpu_data.icache.way_incr -
307 current_cpu_data.icache.linesz;
308
309 current_cpu_data.icache.way_size = current_cpu_data.icache.sets *
310 current_cpu_data.icache.linesz;
311
312
313 current_cpu_data.dcache.entry_mask = current_cpu_data.dcache.way_incr -
314 current_cpu_data.dcache.linesz;
315
316 current_cpu_data.dcache.way_size = current_cpu_data.dcache.sets *
317 current_cpu_data.dcache.linesz;
318
319
320 cache_init();
321
322 if (raw_smp_processor_id() == 0) {
323 #ifdef CONFIG_MMU
324 shm_align_mask = max_t(unsigned long,
325 current_cpu_data.dcache.way_size - 1,
326 PAGE_SIZE - 1);
327 #else
328 shm_align_mask = PAGE_SIZE - 1;
329 #endif
330
331
332 detect_cache_shape();
333 }
334
335 fpu_init();
336 dsp_init();
337
338
339
340
341
342 current_cpu_data.asid_cache = NO_CONTEXT;
343
344 current_cpu_data.phys_bits = __in_29bit_mode() ? 29 : 32;
345
346 speculative_execution_init();
347 expmask_init();
348
349
350 if (raw_smp_processor_id() == 0) {
351
352 sh_bios_vbr_init();
353
354
355
356
357
358 per_cpu_trap_init();
359
360
361
362
363
364 init_thread_xstate();
365 }
366 }