2 * arch/sh/kernel/cpu/sh4/probe.c
4 * CPU Subtype Probing for SH-4.
6 * Copyright (C) 2001 - 2007 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>
15 #include <asm/processor.h>
16 #include <asm/cache.h>
18 int __init detect_cpu_and_cache_system(void)
20 unsigned long pvr, prr, cvr;
23 static unsigned long sizes[16] = {
31 pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffffff;
32 prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff;
33 cvr = (ctrl_inl(CCN_CVR));
36 * Setup some sane SH-4 defaults for the icache
38 boot_cpu_data.icache.way_incr = (1 << 13);
39 boot_cpu_data.icache.entry_shift = 5;
40 boot_cpu_data.icache.sets = 256;
41 boot_cpu_data.icache.ways = 1;
42 boot_cpu_data.icache.linesz = L1_CACHE_BYTES;
45 * And again for the dcache ..
47 boot_cpu_data.dcache.way_incr = (1 << 14);
48 boot_cpu_data.dcache.entry_shift = 5;
49 boot_cpu_data.dcache.sets = 512;
50 boot_cpu_data.dcache.ways = 1;
51 boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
54 * Setup some generic flags we can probe on SH-4A parts
56 if (((pvr >> 24) & 0xff) == 0x10) {
57 if ((cvr & 0x10000000) == 0)
58 boot_cpu_data.flags |= CPU_HAS_DSP;
60 boot_cpu_data.flags |= CPU_HAS_LLSC;
63 /* FPU detection works for everyone */
64 if ((cvr & 0x20000000) == 1)
65 boot_cpu_data.flags |= CPU_HAS_FPU;
67 /* Mask off the upper chip ID */
71 * Probe the underlying processor version/revision and
72 * adjust cpu_data setup accordingly.
76 boot_cpu_data.type = CPU_SH7750;
77 boot_cpu_data.flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
81 boot_cpu_data.type = CPU_SH7750S;
82 boot_cpu_data.flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
86 boot_cpu_data.type = CPU_SH7751;
87 boot_cpu_data.flags |= CPU_HAS_FPU;
91 boot_cpu_data.type = CPU_SH7770;
92 boot_cpu_data.icache.ways = 4;
93 boot_cpu_data.dcache.ways = 4;
95 boot_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_LLSC;
100 boot_cpu_data.type = CPU_SH7781;
101 else if (prr == 0xa1)
102 boot_cpu_data.type = CPU_SH7763;
104 boot_cpu_data.type = CPU_SH7780;
106 boot_cpu_data.icache.ways = 4;
107 boot_cpu_data.dcache.ways = 4;
109 boot_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_PERF_COUNTER |
115 boot_cpu_data.type = CPU_SH7343;
116 boot_cpu_data.icache.ways = 4;
117 boot_cpu_data.dcache.ways = 4;
118 boot_cpu_data.flags |= CPU_HAS_LLSC;
122 boot_cpu_data.type = CPU_SH7785;
123 boot_cpu_data.icache.ways = 4;
124 boot_cpu_data.dcache.ways = 4;
125 boot_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_PERF_COUNTER |
129 boot_cpu_data.icache.ways = 4;
130 boot_cpu_data.dcache.ways = 4;
131 boot_cpu_data.flags |= CPU_HAS_LLSC;
136 boot_cpu_data.type = CPU_SH7723;
137 boot_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_L2_CACHE;
140 boot_cpu_data.type = CPU_SH7366;
144 boot_cpu_data.type = CPU_SH7722;
148 case 0x4000: /* 1st cut */
149 case 0x4001: /* 2nd cut */
150 boot_cpu_data.type = CPU_SHX3;
151 boot_cpu_data.icache.ways = 4;
152 boot_cpu_data.dcache.ways = 4;
153 boot_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_PERF_COUNTER |
157 boot_cpu_data.type = CPU_SH4_501;
158 boot_cpu_data.icache.ways = 2;
159 boot_cpu_data.dcache.ways = 2;
162 boot_cpu_data.type = CPU_SH4_202;
163 boot_cpu_data.icache.ways = 2;
164 boot_cpu_data.dcache.ways = 2;
165 boot_cpu_data.flags |= CPU_HAS_FPU;
167 case 0x500 ... 0x501:
170 boot_cpu_data.type = CPU_SH7750R;
173 boot_cpu_data.type = CPU_SH7751R;
176 boot_cpu_data.type = CPU_SH7760;
180 boot_cpu_data.icache.ways = 2;
181 boot_cpu_data.dcache.ways = 2;
183 boot_cpu_data.flags |= CPU_HAS_FPU;
187 boot_cpu_data.type = CPU_SH_NONE;
191 #ifdef CONFIG_SH_DIRECT_MAPPED
192 boot_cpu_data.icache.ways = 1;
193 boot_cpu_data.dcache.ways = 1;
196 #ifdef CONFIG_CPU_HAS_PTEA
197 boot_cpu_data.flags |= CPU_HAS_PTEA;
201 * On anything that's not a direct-mapped cache, look to the CVR
202 * for I/D-cache specifics.
204 if (boot_cpu_data.icache.ways > 1) {
205 size = sizes[(cvr >> 20) & 0xf];
206 boot_cpu_data.icache.way_incr = (size >> 1);
207 boot_cpu_data.icache.sets = (size >> 6);
211 /* And the rest of the D-cache */
212 if (boot_cpu_data.dcache.ways > 1) {
213 size = sizes[(cvr >> 16) & 0xf];
214 boot_cpu_data.dcache.way_incr = (size >> 1);
215 boot_cpu_data.dcache.sets = (size >> 6);
219 * Setup the L2 cache desc
221 * SH-4A's have an optional PIPT L2.
223 if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) {
224 /* Bug if we can't decode the L2 info */
225 BUG_ON(!(cvr & 0xf));
227 /* Silicon and specifications have clearly never met.. */
231 * Size calculation is much more sensible
232 * than it is for the L1.
234 * Sizes are 128KB, 258KB, 512KB, and 1MB.
236 size = (cvr & 0xf) << 17;
240 boot_cpu_data.scache.way_incr = (1 << 16);
241 boot_cpu_data.scache.entry_shift = 5;
242 boot_cpu_data.scache.ways = 4;
243 boot_cpu_data.scache.linesz = L1_CACHE_BYTES;
245 boot_cpu_data.scache.entry_mask =
246 (boot_cpu_data.scache.way_incr -
247 boot_cpu_data.scache.linesz);
249 boot_cpu_data.scache.sets = size /
250 (boot_cpu_data.scache.linesz *
251 boot_cpu_data.scache.ways);
253 boot_cpu_data.scache.way_size =
254 (boot_cpu_data.scache.sets *
255 boot_cpu_data.scache.linesz);