[NETFILTER]: PPTP conntrack: simplify expectation handling
[hh.org.git] / arch / sh / kernel / cpu / init.c
blob868e68b288809a406fe01801d50c87f393ec9cf4
1 /*
2 * arch/sh/kernel/cpu/init.c
4 * CPU init code
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
10 * for more details.
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>
19 #include <asm/io.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) \
31 { \
32 x##_disabled = 1; \
33 return 1; \
34 } \
35 __setup("no" __stringify(x), x##_setup);
37 onchip_setup(fpu);
38 onchip_setup(dsp);
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)
48 panic("Unknown CPU");
50 jump_to_P2();
51 ccr = ctrl_inl(CCR);
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)
66 waysize >>= 1;
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))
73 ways = 1;
74 else
75 #endif
76 ways = cpu_data->dcache.ways;
78 addrstart = CACHE_OC_ADDRESS_ARRAY;
79 do {
80 unsigned long addr;
82 for (addr = addrstart;
83 addr < addrstart + waysize;
84 addr += cpu_data->dcache.linesz)
85 ctrl_outl(0, addr);
87 addrstart += cpu_data->dcache.way_incr;
88 } while (--ways);
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;
101 #endif
103 #ifdef CONFIG_SH_WRITETHROUGH
104 /* Turn on Write-through caching */
105 flags |= CCR_CACHE_WT;
106 #else
107 /* .. or default to Write-back */
108 flags |= CCR_CACHE_CB;
109 #endif
111 #ifdef CONFIG_SH_OCRAM
112 /* Turn on OCRAM -- halve the OC */
113 flags |= CCR_CACHE_ORA;
114 cpu_data->dcache.sets >>= 1;
115 #endif
117 ctrl_outl(flags, CCR);
118 back_to_P1();
121 #ifdef CONFIG_SH_DSP
122 static void __init release_dsp(void)
124 unsigned long sr;
126 /* Clear SR.DSP bit */
127 __asm__ __volatile__ (
128 "stc\tsr, %0\n\t"
129 "and\t%1, %0\n\t"
130 "ldc\t%0, sr\n\t"
131 : "=&r" (sr)
132 : "r" (~SR_DSP)
136 static void __init dsp_init(void)
138 unsigned long sr;
141 * Set the SR.DSP bit, wait for one instruction, and then read
142 * back the SR value.
144 __asm__ __volatile__ (
145 "stc\tsr, %0\n\t"
146 "or\t%1, %0\n\t"
147 "ldc\t%0, sr\n\t"
148 "nop\n\t"
149 "stc\tsr, %0\n\t"
150 : "=&r" (sr)
151 : "r" (SR_DSP)
154 /* If the DSP bit is still set, this CPU has a DSP */
155 if (sr & SR_DSP)
156 cpu_data->flags |= CPU_HAS_DSP;
158 /* Now that we've determined the DSP status, clear the DSP bit. */
159 release_dsp();
161 #endif /* CONFIG_SH_DSP */
164 * sh_cpu_init
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();
184 /* Init the cache */
185 cache_init();
187 /* Disable the FPU */
188 if (fpu_disabled) {
189 printk("FPU Disabled\n");
190 cpu_data->flags &= ~CPU_HAS_FPU;
191 disable_fpu();
194 /* FPU initialization */
195 if ((cpu_data->flags & CPU_HAS_FPU)) {
196 clear_thread_flag(TIF_USEDFPU);
197 clear_used_math();
200 #ifdef CONFIG_SH_DSP
201 /* Probe for DSP */
202 dsp_init();
204 /* Disable the DSP */
205 if (dsp_disabled) {
206 printk("DSP Disabled\n");
207 cpu_data->flags &= ~CPU_HAS_DSP;
208 release_dsp();
210 #endif
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.
219 ubc_wakeup();
220 #endif