blob: 31f8cb0f6374ac71d517fb04c058a99b3a7f0642 [file] [log] [blame]
Paul Mundtd1839132007-11-20 18:27:20 +09001/*
2 * arch/sh/kernel/cpu/sh5/probe.c
3 *
4 * CPU Subtype Probing for SH-5.
5 *
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 * Copyright (C) 2003 - 2007 Paul Mundt
8 *
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
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/string.h>
16#include <asm/processor.h>
17#include <asm/cache.h>
18
19int __init detect_cpu_and_cache_system(void)
20{
21 unsigned long long cir;
22
Paul Mundt38350e02008-02-13 20:14:10 +090023 /*
24 * Do peeks in real mode to avoid having to set up a mapping for
25 * the WPC registers. On SH5-101 cut2, such a mapping would be
26 * exposed to an address translation erratum which would make it
27 * hard to set up correctly.
28 */
Paul Mundtd1839132007-11-20 18:27:20 +090029 cir = peek_real_address_q(0x0d000008);
Paul Mundt38350e02008-02-13 20:14:10 +090030 if ((cir & 0xffff) == 0x5103)
Paul Mundtd1839132007-11-20 18:27:20 +090031 boot_cpu_data.type = CPU_SH5_103;
Paul Mundt38350e02008-02-13 20:14:10 +090032 else if (((cir >> 32) & 0xffff) == 0x51e2)
Paul Mundtd1839132007-11-20 18:27:20 +090033 /* CPU.VCR aliased at CIR address on SH5-101 */
34 boot_cpu_data.type = CPU_SH5_101;
Paul Mundtd1839132007-11-20 18:27:20 +090035
36 /*
37 * First, setup some sane values for the I-cache.
38 */
39 boot_cpu_data.icache.ways = 4;
40 boot_cpu_data.icache.sets = 256;
41 boot_cpu_data.icache.linesz = L1_CACHE_BYTES;
Paul Mundt38350e02008-02-13 20:14:10 +090042 boot_cpu_data.icache.way_incr = (1 << 13);
Paul Mundtd1839132007-11-20 18:27:20 +090043 boot_cpu_data.icache.entry_shift = 5;
Paul Mundt38350e02008-02-13 20:14:10 +090044 boot_cpu_data.icache.way_size = boot_cpu_data.icache.sets *
45 boot_cpu_data.icache.linesz;
46 boot_cpu_data.icache.entry_mask = 0x1fe0;
Paul Mundtd1839132007-11-20 18:27:20 +090047 boot_cpu_data.icache.flags = 0;
48
Paul Mundt38350e02008-02-13 20:14:10 +090049 /*
50 * Next, setup some sane values for the D-cache.
51 *
52 * On the SH5, these are pretty consistent with the I-cache settings,
53 * so we just copy over the existing definitions.. these can be fixed
54 * up later, especially if we add runtime CPU probing.
55 *
56 * Though in the meantime it saves us from having to duplicate all of
57 * the above definitions..
58 */
59 boot_cpu_data.dcache = boot_cpu_data.icache;
60
61 /*
62 * Setup any cache-related flags here
63 */
64#if defined(CONFIG_CACHE_WRITETHROUGH)
65 set_bit(SH_CACHE_MODE_WT, &(boot_cpu_data.dcache.flags));
66#elif defined(CONFIG_CACHE_WRITEBACK)
67 set_bit(SH_CACHE_MODE_WB, &(boot_cpu_data.dcache.flags));
68#endif
Paul Mundtd1839132007-11-20 18:27:20 +090069
70 return 0;
71}