blob: 98802ab282114239f0d3d4cc401ace5dcd27cbcf [file] [log] [blame]
Paul Mundt711fa802006-10-03 13:14:04 +09001/*
Paul Mundt11c19652006-12-25 10:19:56 +09002 * arch/sh/kernel/setup.c
3 *
4 * This file handles the architecture-dependent parts of initialization
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * Copyright (C) 1999 Niibe Yutaka
Paul Mundt11c19652006-12-25 10:19:56 +09007 * Copyright (C) 2002 - 2006 Paul Mundt
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
Jon Smirl894673e2006-07-10 04:44:13 -07009#include <linux/screen_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/ioport.h>
11#include <linux/init.h>
12#include <linux/initrd.h>
13#include <linux/bootmem.h>
14#include <linux/console.h>
15#include <linux/seq_file.h>
16#include <linux/root_dev.h>
17#include <linux/utsname.h>
18#include <linux/cpu.h>
Dave Hansen22a98352006-03-27 01:16:04 -080019#include <linux/pfn.h>
Paul Mundt711fa802006-10-03 13:14:04 +090020#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/uaccess.h>
22#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/sections.h>
24#include <asm/irq.h>
25#include <asm/setup.h>
Paul Mundtde027972006-02-01 03:06:02 -080026#include <asm/clock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28#ifdef CONFIG_SH_KGDB
29#include <asm/kgdb.h>
30static int kgdb_parse_options(char *options);
31#endif
32extern void * __rd_start, * __rd_end;
33/*
34 * Machine setup..
35 */
36
37/*
38 * Initialize loops_per_jiffy as 10000000 (1000MIPS).
39 * This value will be used at the very early stage of serial setup.
40 * The bigger value means no problem.
41 */
Paul Mundtde027972006-02-01 03:06:02 -080042struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, };
Paul Mundt2c7834a2006-09-27 18:17:31 +090043#ifdef CONFIG_VT
Linus Torvalds1da177e2005-04-16 15:20:36 -070044struct screen_info screen_info;
Paul Mundt2c7834a2006-09-27 18:17:31 +090045#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#if defined(CONFIG_SH_UNKNOWN)
48struct sh_machine_vector sh_mv;
49#endif
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051extern int root_mountflags;
52
53#define MV_NAME_SIZE 32
54
55static struct sh_machine_vector* __init get_mv_byname(const char* name);
56
57/*
58 * This is set up by the setup-routine at boot-time
59 */
60#define PARAM ((unsigned char *)empty_zero_page)
61
62#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
63#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
64#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))
65#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
66#define INITRD_START (*(unsigned long *) (PARAM+0x010))
67#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
68/* ... */
69#define COMMAND_LINE ((char *) (PARAM+0x100))
70
Paul Mundt65463b72005-11-07 00:58:24 -080071#define RAMDISK_IMAGE_START_MASK 0x07FF
Linus Torvalds1da177e2005-04-16 15:20:36 -070072#define RAMDISK_PROMPT_FLAG 0x8000
Paul Mundt65463b72005-11-07 00:58:24 -080073#define RAMDISK_LOAD_FLAG 0x4000
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Alon Bar-Lev53c82622007-02-12 00:54:19 -080075static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Paul Mundt2c7834a2006-09-27 18:17:31 +090077static struct resource code_resource = { .name = "Kernel code", };
78static struct resource data_resource = { .name = "Kernel data", };
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80unsigned long memory_start, memory_end;
81
82static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE],
83 struct sh_machine_vector** mvp,
Paul Mundtb641fe02006-12-12 09:00:47 +090084 unsigned long *mv_io_base)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085{
86 char c = ' ', *to = command_line, *from = COMMAND_LINE;
87 int len = 0;
88
89 /* Save unparsed command line copy for /proc/cmdline */
Alon Bar-Lev53c82622007-02-12 00:54:19 -080090 memcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
91 boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START;
94 memory_end = memory_start + __MEMORY_SIZE;
95
96 for (;;) {
97 /*
98 * "mem=XXX[kKmM]" defines a size of memory.
99 */
100 if (c == ' ' && !memcmp(from, "mem=", 4)) {
101 if (to != command_line)
102 to--;
103 {
104 unsigned long mem_size;
105
106 mem_size = memparse(from+4, &from);
107 memory_end = memory_start + mem_size;
108 }
109 }
Paul Mundta80fd212006-09-27 14:26:53 +0900110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 if (c == ' ' && !memcmp(from, "sh_mv=", 6)) {
112 char* mv_end;
113 char* mv_comma;
114 int mv_len;
115 if (to != command_line)
116 to--;
117 from += 6;
118 mv_end = strchr(from, ' ');
119 if (mv_end == NULL)
120 mv_end = from + strlen(from);
121
122 mv_comma = strchr(from, ',');
123 if ((mv_comma != NULL) && (mv_comma < mv_end)) {
124 int ints[3];
125 get_options(mv_comma+1, ARRAY_SIZE(ints), ints);
126 *mv_io_base = ints[1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 mv_len = mv_comma - from;
128 } else {
129 mv_len = mv_end - from;
130 }
131 if (mv_len > (MV_NAME_SIZE-1))
132 mv_len = MV_NAME_SIZE-1;
133 memcpy(mv_name, from, mv_len);
134 mv_name[mv_len] = '\0';
135 from = mv_end;
136
137 *mvp = get_mv_byname(mv_name);
138 }
Paul Mundtb641fe02006-12-12 09:00:47 +0900139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 c = *(from++);
141 if (!c)
142 break;
143 if (COMMAND_LINE_SIZE <= ++len)
144 break;
145 *(to++) = c;
146 }
147 *to = '\0';
148 *cmdline_p = command_line;
149}
150
151static int __init sh_mv_setup(char **cmdline_p)
152{
Paul Mundt50373c12006-02-01 03:06:03 -0800153#ifdef CONFIG_SH_UNKNOWN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 extern struct sh_machine_vector mv_unknown;
155#endif
156 struct sh_machine_vector *mv = NULL;
157 char mv_name[MV_NAME_SIZE] = "";
158 unsigned long mv_io_base = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Paul Mundtb641fe02006-12-12 09:00:47 +0900160 parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Paul Mundt50373c12006-02-01 03:06:03 -0800162#ifdef CONFIG_SH_UNKNOWN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 if (mv == NULL) {
164 mv = &mv_unknown;
165 if (*mv_name != '\0') {
166 printk("Warning: Unsupported machine %s, using unknown\n",
167 mv_name);
168 }
169 }
170 sh_mv = *mv;
171#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173 /*
174 * Manually walk the vec, fill in anything that the board hasn't yet
175 * by hand, wrapping to the generic implementation.
176 */
177#define mv_set(elem) do { \
178 if (!sh_mv.mv_##elem) \
179 sh_mv.mv_##elem = generic_##elem; \
180} while (0)
181
182 mv_set(inb); mv_set(inw); mv_set(inl);
183 mv_set(outb); mv_set(outw); mv_set(outl);
184
185 mv_set(inb_p); mv_set(inw_p); mv_set(inl_p);
186 mv_set(outb_p); mv_set(outw_p); mv_set(outl_p);
187
188 mv_set(insb); mv_set(insw); mv_set(insl);
189 mv_set(outsb); mv_set(outsw); mv_set(outsl);
190
191 mv_set(readb); mv_set(readw); mv_set(readl);
192 mv_set(writeb); mv_set(writew); mv_set(writel);
193
Paul Mundt50373c12006-02-01 03:06:03 -0800194 mv_set(ioport_map);
195 mv_set(ioport_unmap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 mv_set(irq_demux);
197
198#ifdef CONFIG_SH_UNKNOWN
199 __set_io_port_base(mv_io_base);
200#endif
201
Paul Mundt2c7834a2006-09-27 18:17:31 +0900202 if (!sh_mv.mv_nr_irqs)
203 sh_mv.mv_nr_irqs = NR_IRQS;
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 return 0;
206}
207
208void __init setup_arch(char **cmdline_p)
209{
210 unsigned long bootmap_size;
211 unsigned long start_pfn, max_pfn, max_low_pfn;
212
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213#ifdef CONFIG_CMDLINE_BOOL
214 strcpy(COMMAND_LINE, CONFIG_CMDLINE);
215#endif
216
217 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
218
219#ifdef CONFIG_BLK_DEV_RAM
220 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
221 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
222 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
223#endif
224
225 if (!MOUNT_ROOT_RDONLY)
226 root_mountflags &= ~MS_RDONLY;
227 init_mm.start_code = (unsigned long) _text;
228 init_mm.end_code = (unsigned long) _etext;
229 init_mm.end_data = (unsigned long) _edata;
230 init_mm.brk = (unsigned long) _end;
231
Paul Mundtde027972006-02-01 03:06:02 -0800232 code_resource.start = (unsigned long)virt_to_phys(_text);
233 code_resource.end = (unsigned long)virt_to_phys(_etext)-1;
234 data_resource.start = (unsigned long)virt_to_phys(_etext);
235 data_resource.end = (unsigned long)virt_to_phys(_edata)-1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 sh_mv_setup(cmdline_p);
238
Paul Mundtb641fe02006-12-12 09:00:47 +0900239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 /*
241 * Find the highest page frame number we have available
242 */
243 max_pfn = PFN_DOWN(__pa(memory_end));
244
245 /*
246 * Determine low and high memory ranges:
247 */
248 max_low_pfn = max_pfn;
249
Paul Mundt65463b72005-11-07 00:58:24 -0800250 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 * Partially used pages are not usable - thus
252 * we are rounding upwards:
Paul Mundt65463b72005-11-07 00:58:24 -0800253 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 start_pfn = PFN_UP(__pa(_end));
255
256 /*
257 * Find a proper area for the bootmem bitmap. After this
258 * bootstrap step all allocations (until the page allocator
259 * is intact) must be done via bootmem_alloc().
260 */
261 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
262 __MEMORY_START>>PAGE_SHIFT,
263 max_low_pfn);
264 /*
265 * Register fully available low RAM pages with the bootmem allocator.
266 */
267 {
268 unsigned long curr_pfn, last_pfn, pages;
269
270 /*
271 * We are rounding up the start address of usable memory:
272 */
273 curr_pfn = PFN_UP(__MEMORY_START);
274 /*
275 * ... and at the end of the usable range downwards:
276 */
277 last_pfn = PFN_DOWN(__pa(memory_end));
278
279 if (last_pfn > max_low_pfn)
280 last_pfn = max_low_pfn;
281
282 pages = last_pfn - curr_pfn;
283 free_bootmem_node(NODE_DATA(0), PFN_PHYS(curr_pfn),
284 PFN_PHYS(pages));
285 }
286
Paul Mundtb641fe02006-12-12 09:00:47 +0900287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 /*
289 * Reserve the kernel text and
290 * Reserve the bootmem bitmap. We do this in two steps (first step
291 * was init_bootmem()), because this catches the (definitely buggy)
292 * case of us accidentally initializing the bootmem allocator with
293 * an invalid RAM area.
294 */
295 reserve_bootmem_node(NODE_DATA(0), __MEMORY_START+PAGE_SIZE,
296 (PFN_PHYS(start_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START);
297
298 /*
299 * reserve physical page 0 - it's a special BIOS page on many boxes,
300 * enabling clean reboots, SMP operation, laptop functions.
301 */
302 reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE);
303
304#ifdef CONFIG_BLK_DEV_INITRD
Paul Mundt65463b72005-11-07 00:58:24 -0800305 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
306 if (&__rd_start != &__rd_end) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 LOADER_TYPE = 1;
Paul Mundt41504c32006-12-11 20:28:03 +0900308 INITRD_START = PHYSADDR((unsigned long)&__rd_start) -
309 __MEMORY_START;
310 INITRD_SIZE = (unsigned long)&__rd_end -
311 (unsigned long)&__rd_start;
Paul Mundt65463b72005-11-07 00:58:24 -0800312 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 if (LOADER_TYPE && INITRD_START) {
315 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
Paul Mundt41504c32006-12-11 20:28:03 +0900316 reserve_bootmem_node(NODE_DATA(0), INITRD_START +
317 __MEMORY_START, INITRD_SIZE);
318 initrd_start = INITRD_START + PAGE_OFFSET +
319 __MEMORY_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 initrd_end = initrd_start + INITRD_SIZE;
321 } else {
322 printk("initrd extends beyond end of memory "
323 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
324 INITRD_START + INITRD_SIZE,
325 max_low_pfn << PAGE_SHIFT);
326 initrd_start = 0;
327 }
328 }
329#endif
330
331#ifdef CONFIG_DUMMY_CONSOLE
332 conswitchp = &dummy_con;
333#endif
334
335 /* Perform the machine specific initialisation */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900336 if (likely(sh_mv.mv_setup))
337 sh_mv.mv_setup(cmdline_p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 paging_init();
340}
341
342struct sh_machine_vector* __init get_mv_byname(const char* name)
343{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 extern long __machvec_start, __machvec_end;
345 struct sh_machine_vector *all_vecs =
346 (struct sh_machine_vector *)&__machvec_start;
347
348 int i, n = ((unsigned long)&__machvec_end
349 - (unsigned long)&__machvec_start)/
350 sizeof(struct sh_machine_vector);
351
352 for (i = 0; i < n; ++i) {
353 struct sh_machine_vector *mv = &all_vecs[i];
354 if (mv == NULL)
355 continue;
356 if (strcasecmp(name, get_system_type()) == 0) {
357 return mv;
358 }
359 }
360 return NULL;
361}
362
363static struct cpu cpu[NR_CPUS];
364
365static int __init topology_init(void)
366{
367 int cpu_id;
368
KAMEZAWA Hiroyukibc83db42006-03-31 02:30:02 -0800369 for_each_possible_cpu(cpu_id)
KAMEZAWA Hiroyuki76b67ed92006-06-27 02:53:41 -0700370 register_cpu(&cpu[cpu_id], cpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 return 0;
373}
374
375subsys_initcall(topology_init);
376
377static const char *cpu_name[] = {
Paul Mundtb552c7e2006-11-20 14:14:29 +0900378 [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619",
Paul Mundte5723e02006-09-27 17:38:11 +0900379 [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300",
380 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706",
381 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708",
382 [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710",
383 [CPU_SH7729] = "SH7729", [CPU_SH7750] = "SH7750",
384 [CPU_SH7750S] = "SH7750S", [CPU_SH7750R] = "SH7750R",
385 [CPU_SH7751] = "SH7751", [CPU_SH7751R] = "SH7751R",
386 [CPU_SH7760] = "SH7760", [CPU_SH73180] = "SH73180",
387 [CPU_ST40RA] = "ST40RA", [CPU_ST40GX1] = "ST40GX1",
388 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501",
389 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780",
390 [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343",
Paul Mundt41504c32006-12-11 20:28:03 +0900391 [CPU_SH7785] = "SH7785", [CPU_SH7722] = "SH7722",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 [CPU_SH_NONE] = "Unknown"
393};
394
Paul Mundt11c19652006-12-25 10:19:56 +0900395const char *get_cpu_subtype(struct sh_cpuinfo *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
Paul Mundt11c19652006-12-25 10:19:56 +0900397 return cpu_name[c->type];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398}
399
400#ifdef CONFIG_PROC_FS
Paul Mundt2220d162006-09-27 18:24:28 +0900401/* Symbolic CPU flags, keep in sync with asm/cpu-features.h */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402static const char *cpu_flags[] = {
Paul Mundt2220d162006-09-27 18:24:28 +0900403 "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr",
Paul Mundt72c35542006-09-27 18:27:43 +0900404 "ptea", "llsc", "l2", NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405};
406
Paul Mundt11c19652006-12-25 10:19:56 +0900407static void show_cpuflags(struct seq_file *m, struct sh_cpuinfo *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 unsigned long i;
410
411 seq_printf(m, "cpu flags\t:");
412
Paul Mundt11c19652006-12-25 10:19:56 +0900413 if (!c->flags) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 seq_printf(m, " %s\n", cpu_flags[0]);
415 return;
416 }
417
Paul Mundtde027972006-02-01 03:06:02 -0800418 for (i = 0; cpu_flags[i]; i++)
Paul Mundt11c19652006-12-25 10:19:56 +0900419 if ((c->flags & (1 << i)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 seq_printf(m, " %s", cpu_flags[i+1]);
421
422 seq_printf(m, "\n");
423}
424
Paul Mundt2c7834a2006-09-27 18:17:31 +0900425static void show_cacheinfo(struct seq_file *m, const char *type,
426 struct cache_info info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427{
428 unsigned int cache_size;
429
430 cache_size = info.ways * info.sets * info.linesz;
431
Paul Mundtde027972006-02-01 03:06:02 -0800432 seq_printf(m, "%s size\t: %2dKiB (%d-way)\n",
433 type, cache_size >> 10, info.ways);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434}
435
436/*
437 * Get CPU information for use by the procfs.
438 */
439static int show_cpuinfo(struct seq_file *m, void *v)
440{
Paul Mundt11c19652006-12-25 10:19:56 +0900441 struct sh_cpuinfo *c = v;
442 unsigned int cpu = c - cpu_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Paul Mundt11c19652006-12-25 10:19:56 +0900444 if (!cpu_online(cpu))
445 return 0;
446
447 if (cpu == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 seq_printf(m, "machine\t\t: %s\n", get_system_type());
449
450 seq_printf(m, "processor\t: %d\n", cpu);
Serge E. Hallyn96b644b2006-10-02 02:18:13 -0700451 seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine);
Paul Mundt11c19652006-12-25 10:19:56 +0900452 seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype(c));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
Paul Mundt11c19652006-12-25 10:19:56 +0900454 show_cpuflags(m, c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 seq_printf(m, "cache type\t: ");
457
458 /*
459 * Check for what type of cache we have, we support both the
460 * unified cache on the SH-2 and SH-3, as well as the harvard
461 * style cache on the SH-4.
462 */
Paul Mundt11c19652006-12-25 10:19:56 +0900463 if (c->icache.flags & SH_CACHE_COMBINED) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 seq_printf(m, "unified\n");
Paul Mundt11c19652006-12-25 10:19:56 +0900465 show_cacheinfo(m, "cache", c->icache);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 } else {
467 seq_printf(m, "split (harvard)\n");
Paul Mundt11c19652006-12-25 10:19:56 +0900468 show_cacheinfo(m, "icache", c->icache);
469 show_cacheinfo(m, "dcache", c->dcache);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 }
471
Paul Mundt72c35542006-09-27 18:27:43 +0900472 /* Optional secondary cache */
Paul Mundt11c19652006-12-25 10:19:56 +0900473 if (c->flags & CPU_HAS_L2_CACHE)
474 show_cacheinfo(m, "scache", c->scache);
Paul Mundt72c35542006-09-27 18:27:43 +0900475
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 seq_printf(m, "bogomips\t: %lu.%02lu\n",
Paul Mundt11c19652006-12-25 10:19:56 +0900477 c->loops_per_jiffy/(500000/HZ),
478 (c->loops_per_jiffy/(5000/HZ)) % 100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Paul Mundtde027972006-02-01 03:06:02 -0800480 return show_clocks(m);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481}
482
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483static void *c_start(struct seq_file *m, loff_t *pos)
484{
485 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
486}
487static void *c_next(struct seq_file *m, void *v, loff_t *pos)
488{
489 ++*pos;
490 return c_start(m, pos);
491}
492static void c_stop(struct seq_file *m, void *v)
493{
494}
495struct seq_operations cpuinfo_op = {
496 .start = c_start,
497 .next = c_next,
498 .stop = c_stop,
499 .show = show_cpuinfo,
500};
501#endif /* CONFIG_PROC_FS */
502
503#ifdef CONFIG_SH_KGDB
504/*
505 * Parse command-line kgdb options. By default KGDB is enabled,
506 * entered on error (or other action) using default serial info.
507 * The command-line option can include a serial port specification
508 * and an action to override default or configured behavior.
509 */
510struct kgdb_sermap kgdb_sci_sermap =
511{ "ttySC", 5, kgdb_sci_setup, NULL };
512
513struct kgdb_sermap *kgdb_serlist = &kgdb_sci_sermap;
514struct kgdb_sermap *kgdb_porttype = &kgdb_sci_sermap;
515
516void kgdb_register_sermap(struct kgdb_sermap *map)
517{
518 struct kgdb_sermap *last;
519
520 for (last = kgdb_serlist; last->next; last = last->next)
521 ;
522 last->next = map;
523 if (!map->namelen) {
524 map->namelen = strlen(map->name);
525 }
526}
527
528static int __init kgdb_parse_options(char *options)
529{
530 char c;
531 int baud;
532
533 /* Check for port spec (or use default) */
534
535 /* Determine port type and instance */
536 if (!memcmp(options, "tty", 3)) {
537 struct kgdb_sermap *map = kgdb_serlist;
538
539 while (map && memcmp(options, map->name, map->namelen))
540 map = map->next;
541
542 if (!map) {
543 KGDB_PRINTK("unknown port spec in %s\n", options);
544 return -1;
545 }
546
547 kgdb_porttype = map;
548 kgdb_serial_setup = map->setup_fn;
549 kgdb_portnum = options[map->namelen] - '0';
550 options += map->namelen + 1;
551
552 options = (*options == ',') ? options+1 : options;
Paul Mundtde027972006-02-01 03:06:02 -0800553
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 /* Read optional parameters (baud/parity/bits) */
555 baud = simple_strtoul(options, &options, 10);
556 if (baud != 0) {
557 kgdb_baud = baud;
558
559 c = toupper(*options);
560 if (c == 'E' || c == 'O' || c == 'N') {
561 kgdb_parity = c;
562 options++;
563 }
564
565 c = *options;
566 if (c == '7' || c == '8') {
567 kgdb_bits = c;
568 options++;
569 }
570 options = (*options == ',') ? options+1 : options;
571 }
572 }
573
574 /* Check for action specification */
575 if (!memcmp(options, "halt", 4)) {
576 kgdb_halt = 1;
577 options += 4;
578 } else if (!memcmp(options, "disabled", 8)) {
579 kgdb_enabled = 0;
580 options += 8;
581 }
582
583 if (*options) {
584 KGDB_PRINTK("ignored unknown options: %s\n", options);
585 return 0;
586 }
587 return 1;
588}
589__setup("kgdb=", kgdb_parse_options);
590#endif /* CONFIG_SH_KGDB */