2 * arch/sh/kernel/cpu/init.c
6 * Copyright (C) 2002, 2003 Paul Mundt
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <asm/processor.h>
15 #include <asm/uaccess.h>
16 #include <asm/system.h>
17 #include <asm/cacheflush.h>
18 #include <asm/cache.h>
21 extern void detect_cpu_and_cache_system(void);
24 * Generic wrapper for command line arguments to disable on-chip
25 * peripherals (nofpu, nodsp, and so forth).
27 #define onchip_setup(x) \
28 static int x##_disabled __initdata = 0; \
30 static int __init x##_setup(char *opts) \
35 __setup("no" __stringify(x), x##_setup);
41 * Generic first-level cache init
43 static void __init
cache_init(void)
45 unsigned long ccr
, flags
;
47 if (cpu_data
->type
== CPU_SH_NONE
)
54 * If the cache is already enabled .. flush it.
56 if (ccr
& CCR_CACHE_ENABLE
) {
57 unsigned long ways
, waysize
, addrstart
;
59 waysize
= cpu_data
->dcache
.sets
;
62 * If the OC is already in RAM mode, we only have
63 * half of the entries to flush..
65 if (ccr
& CCR_CACHE_ORA
)
68 waysize
<<= cpu_data
->dcache
.entry_shift
;
70 #ifdef CCR_CACHE_EMODE
71 /* If EMODE is not set, we only have 1 way to flush. */
72 if (!(ccr
& CCR_CACHE_EMODE
))
76 ways
= cpu_data
->dcache
.ways
;
78 addrstart
= CACHE_OC_ADDRESS_ARRAY
;
82 for (addr
= addrstart
;
83 addr
< addrstart
+ waysize
;
84 addr
+= cpu_data
->dcache
.linesz
)
87 addrstart
+= cpu_data
->dcache
.way_incr
;
92 * Default CCR values .. enable the caches
93 * and invalidate them immediately..
95 flags
= CCR_CACHE_ENABLE
| CCR_CACHE_INVALIDATE
;
97 #ifdef CCR_CACHE_EMODE
98 /* Force EMODE if possible */
99 if (cpu_data
->dcache
.ways
> 1)
100 flags
|= CCR_CACHE_EMODE
;
103 #ifdef CONFIG_SH_WRITETHROUGH
104 /* Turn on Write-through caching */
105 flags
|= CCR_CACHE_WT
;
107 /* .. or default to Write-back */
108 flags
|= CCR_CACHE_CB
;
111 #ifdef CONFIG_SH_OCRAM
112 /* Turn on OCRAM -- halve the OC */
113 flags
|= CCR_CACHE_ORA
;
114 cpu_data
->dcache
.sets
>>= 1;
117 ctrl_outl(flags
, CCR
);
122 static void __init
release_dsp(void)
126 /* Clear SR.DSP bit */
127 __asm__
__volatile__ (
136 static void __init
dsp_init(void)
141 * Set the SR.DSP bit, wait for one instruction, and then read
144 __asm__
__volatile__ (
154 /* If the DSP bit is still set, this CPU has a DSP */
156 cpu_data
->flags
|= CPU_HAS_DSP
;
158 /* Now that we've determined the DSP status, clear the DSP bit. */
161 #endif /* CONFIG_SH_DSP */
166 * This is our initial entry point for each CPU, and is invoked on the boot
167 * CPU prior to calling start_kernel(). For SMP, a combination of this and
168 * start_secondary() will bring up each processor to a ready state prior
169 * to hand forking the idle loop.
171 * We do all of the basic processor init here, including setting up the
172 * caches, FPU, DSP, kicking the UBC, etc. By the time start_kernel() is
173 * hit (and subsequently platform_setup()) things like determining the
174 * CPU subtype and initial configuration will all be done.
176 * Each processor family is still responsible for doing its own probing
177 * and cache configuration in detect_cpu_and_cache_system().
179 asmlinkage
void __init
sh_cpu_init(void)
181 /* First, probe the CPU */
182 detect_cpu_and_cache_system();
187 /* Disable the FPU */
189 printk("FPU Disabled\n");
190 cpu_data
->flags
&= ~CPU_HAS_FPU
;
194 /* FPU initialization */
195 if ((cpu_data
->flags
& CPU_HAS_FPU
)) {
196 clear_thread_flag(TIF_USEDFPU
);
204 /* Disable the DSP */
206 printk("DSP Disabled\n");
207 cpu_data
->flags
&= ~CPU_HAS_DSP
;
212 #ifdef CONFIG_UBC_WAKEUP
214 * Some brain-damaged loaders decided it would be a good idea to put
215 * the UBC to sleep. This causes some issues when it comes to things
216 * like PTRACE_SINGLESTEP or doing hardware watchpoints in GDB. So ..
217 * we wake it up and hope that all is well.