2 * arch/sh/kernel/cpu/init.c
6 * Copyright (C) 2002 - 2006 Paul Mundt
7 * Copyright (C) 2003 Richard Curnow
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/init.h>
14 #include <linux/kernel.h>
16 #include <asm/mmu_context.h>
17 #include <asm/processor.h>
18 #include <asm/uaccess.h>
20 #include <asm/system.h>
21 #include <asm/cacheflush.h>
22 #include <asm/cache.h>
25 extern void detect_cpu_and_cache_system(void);
28 * Generic wrapper for command line arguments to disable on-chip
29 * peripherals (nofpu, nodsp, and so forth).
31 #define onchip_setup(x) \
32 static int x##_disabled __initdata = 0; \
34 static int __init x##_setup(char *opts) \
39 __setup("no" __stringify(x), x##_setup);
45 * Generic first-level cache init
47 static void __init cache_init(void)
49 unsigned long ccr, flags;
51 if (current_cpu_data.type == CPU_SH_NONE)
58 * At this point we don't know whether the cache is enabled or not - a
59 * bootloader may have enabled it. There are at least 2 things that
60 * could be dirty in the cache at this point:
61 * 1. kernel command line set up by boot loader
62 * 2. spilled registers from the prolog of this function
63 * => before re-initialising the cache, we must do a purge of the whole
64 * cache out to memory for safety. As long as nothing is spilled
65 * during the loop to lines that have already been done, this is safe.
68 if (ccr & CCR_CACHE_ENABLE) {
69 unsigned long ways, waysize, addrstart;
71 waysize = current_cpu_data.dcache.sets;
75 * If the OC is already in RAM mode, we only have
76 * half of the entries to flush..
78 if (ccr & CCR_CACHE_ORA)
82 waysize <<= current_cpu_data.dcache.entry_shift;
84 #ifdef CCR_CACHE_EMODE
85 /* If EMODE is not set, we only have 1 way to flush. */
86 if (!(ccr & CCR_CACHE_EMODE))
90 ways = current_cpu_data.dcache.ways;
92 addrstart = CACHE_OC_ADDRESS_ARRAY;
96 for (addr = addrstart;
97 addr < addrstart + waysize;
98 addr += current_cpu_data.dcache.linesz)
101 addrstart += current_cpu_data.dcache.way_incr;
106 * Default CCR values .. enable the caches
107 * and invalidate them immediately..
109 flags = CCR_CACHE_ENABLE | CCR_CACHE_INVALIDATE;
111 #ifdef CCR_CACHE_EMODE
112 /* Force EMODE if possible */
113 if (current_cpu_data.dcache.ways > 1)
114 flags |= CCR_CACHE_EMODE;
116 flags &= ~CCR_CACHE_EMODE;
119 #ifdef CONFIG_SH_WRITETHROUGH
120 /* Turn on Write-through caching */
121 flags |= CCR_CACHE_WT;
123 /* .. or default to Write-back */
124 flags |= CCR_CACHE_CB;
127 #ifdef CONFIG_SH_OCRAM
128 /* Turn on OCRAM -- halve the OC */
129 flags |= CCR_CACHE_ORA;
130 current_cpu_data.dcache.sets >>= 1;
132 current_cpu_data.dcache.way_size = current_cpu_data.dcache.sets *
133 current_cpu_data.dcache.linesz;
136 ctrl_outl(flags, CCR);
141 static void __init release_dsp(void)
145 /* Clear SR.DSP bit */
146 __asm__ __volatile__ (
155 static void __init dsp_init(void)
160 * Set the SR.DSP bit, wait for one instruction, and then read
163 __asm__ __volatile__ (
173 /* If the DSP bit is still set, this CPU has a DSP */
175 current_cpu_data.flags |= CPU_HAS_DSP;
177 /* Now that we've determined the DSP status, clear the DSP bit. */
180 #endif /* CONFIG_SH_DSP */
185 * This is our initial entry point for each CPU, and is invoked on the boot
186 * CPU prior to calling start_kernel(). For SMP, a combination of this and
187 * start_secondary() will bring up each processor to a ready state prior
188 * to hand forking the idle loop.
190 * We do all of the basic processor init here, including setting up the
191 * caches, FPU, DSP, kicking the UBC, etc. By the time start_kernel() is
192 * hit (and subsequently platform_setup()) things like determining the
193 * CPU subtype and initial configuration will all be done.
195 * Each processor family is still responsible for doing its own probing
196 * and cache configuration in detect_cpu_and_cache_system().
198 asmlinkage void __init sh_cpu_init(void)
200 /* First, probe the CPU */
201 detect_cpu_and_cache_system();
206 shm_align_mask = max_t(unsigned long,
207 current_cpu_data.dcache.way_size - 1,
210 /* Disable the FPU */
212 printk("FPU Disabled\n");
213 current_cpu_data.flags &= ~CPU_HAS_FPU;
217 /* FPU initialization */
218 if ((current_cpu_data.flags & CPU_HAS_FPU)) {
219 clear_thread_flag(TIF_USEDFPU);
224 * Initialize the per-CPU ASID cache very early, since the
225 * TLB flushing routines depend on this being setup.
227 current_cpu_data.asid_cache = NO_CONTEXT;
233 /* Disable the DSP */
235 printk("DSP Disabled\n");
236 current_cpu_data.flags &= ~CPU_HAS_DSP;
241 #ifdef CONFIG_UBC_WAKEUP
243 * Some brain-damaged loaders decided it would be a good idea to put
244 * the UBC to sleep. This causes some issues when it comes to things
245 * like PTRACE_SINGLESTEP or doing hardware watchpoints in GDB. So ..
246 * we wake it up and hope that all is well.