]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/mn10300/kernel/setup.c
MN10300: And Panasonic AM34 subarch and implement SMP
[mirror_ubuntu-artful-kernel.git] / arch / mn10300 / kernel / setup.c
CommitLineData
b920de1b
DH
1/* MN10300 Arch-specific initialisation
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11#include <linux/errno.h>
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/mm.h>
15#include <linux/stddef.h>
16#include <linux/unistd.h>
17#include <linux/ptrace.h>
b920de1b 18#include <linux/user.h>
b920de1b
DH
19#include <linux/tty.h>
20#include <linux/ioport.h>
21#include <linux/delay.h>
22#include <linux/init.h>
23#include <linux/bootmem.h>
24#include <linux/seq_file.h>
368dd5ac 25#include <linux/cpu.h>
b920de1b
DH
26#include <asm/processor.h>
27#include <linux/console.h>
28#include <asm/uaccess.h>
29#include <asm/system.h>
30#include <asm/setup.h>
31#include <asm/io.h>
32#include <asm/smp.h>
2f2a2132 33#include <proc/proc.h>
b920de1b
DH
34#include <asm/fpu.h>
35#include <asm/sections.h>
36
37struct mn10300_cpuinfo boot_cpu_data;
38
39/* For PCI or other memory-mapped resources */
40unsigned long pci_mem_start = 0x18000000;
41
42char redboot_command_line[COMMAND_LINE_SIZE] =
43 "console=ttyS0,115200 root=/dev/mtdblock3 rw";
44
45char __initdata redboot_platform_name[COMMAND_LINE_SIZE];
46
47static struct resource code_resource = {
48 .start = 0x100000,
49 .end = 0,
50 .name = "Kernel code",
51};
52
53static struct resource data_resource = {
54 .start = 0,
55 .end = 0,
56 .name = "Kernel data",
57};
58
59static unsigned long __initdata phys_memory_base;
60static unsigned long __initdata phys_memory_end;
61static unsigned long __initdata memory_end;
62unsigned long memory_size;
63
64struct thread_info *__current_ti = &init_thread_union.thread_info;
65struct task_struct *__current = &init_task;
66
368dd5ac 67#define mn10300_known_cpus 5
b920de1b 68static const char *const mn10300_cputypes[] = {
368dd5ac
AT
69 "am33-1",
70 "am33-2",
71 "am34-1",
72 "am33-3",
73 "am34-2",
b920de1b
DH
74 "unknown"
75};
76
77/*
78 *
79 */
80static void __init parse_mem_cmdline(char **cmdline_p)
81{
82 char *from, *to, c;
83
84 /* save unparsed command line copy for /proc/cmdline */
85 strcpy(boot_command_line, redboot_command_line);
86
87 /* see if there's an explicit memory size option */
88 from = redboot_command_line;
89 to = redboot_command_line;
90 c = ' ';
91
92 for (;;) {
93 if (c == ' ' && !memcmp(from, "mem=", 4)) {
94 if (to != redboot_command_line)
95 to--;
96 memory_size = memparse(from + 4, &from);
97 }
98
99 c = *(from++);
100 if (!c)
101 break;
102
103 *(to++) = c;
104 }
105
106 *to = '\0';
107 *cmdline_p = redboot_command_line;
108
109 if (memory_size == 0)
110 panic("Memory size not known\n");
111
112 memory_end = (unsigned long) CONFIG_KERNEL_RAM_BASE_ADDRESS +
113 memory_size;
114 if (memory_end > phys_memory_end)
115 memory_end = phys_memory_end;
116}
117
118/*
119 * architecture specific setup
120 */
121void __init setup_arch(char **cmdline_p)
122{
123 unsigned long bootmap_size;
124 unsigned long kstart_pfn, start_pfn, free_pfn, end_pfn;
125
126 cpu_init();
127 unit_setup();
368dd5ac 128 smp_init_cpus();
b920de1b
DH
129 parse_mem_cmdline(cmdline_p);
130
131 init_mm.start_code = (unsigned long)&_text;
132 init_mm.end_code = (unsigned long) &_etext;
133 init_mm.end_data = (unsigned long) &_edata;
134 init_mm.brk = (unsigned long) &_end;
135
136 code_resource.start = virt_to_bus(&_text);
137 code_resource.end = virt_to_bus(&_etext)-1;
138 data_resource.start = virt_to_bus(&_etext);
139 data_resource.end = virt_to_bus(&_edata)-1;
140
b920de1b
DH
141 start_pfn = (CONFIG_KERNEL_RAM_BASE_ADDRESS >> PAGE_SHIFT);
142 kstart_pfn = PFN_UP(__pa(&_text));
143 free_pfn = PFN_UP(__pa(&_end));
144 end_pfn = PFN_DOWN(__pa(memory_end));
145
146 bootmap_size = init_bootmem_node(&contig_page_data,
147 free_pfn,
148 start_pfn,
149 end_pfn);
150
151 if (kstart_pfn > start_pfn)
152 free_bootmem(PFN_PHYS(start_pfn),
153 PFN_PHYS(kstart_pfn - start_pfn));
154
155 free_bootmem(PFN_PHYS(free_pfn),
156 PFN_PHYS(end_pfn - free_pfn));
157
158 /* If interrupt vector table is in main ram, then we need to
159 reserve the page it is occupying. */
160 if (CONFIG_INTERRUPT_VECTOR_BASE >= CONFIG_KERNEL_RAM_BASE_ADDRESS &&
161 CONFIG_INTERRUPT_VECTOR_BASE < memory_end)
c7f8d6f6 162 reserve_bootmem(CONFIG_INTERRUPT_VECTOR_BASE, PAGE_SIZE,
b920de1b
DH
163 BOOTMEM_DEFAULT);
164
165 reserve_bootmem(PAGE_ALIGN(PFN_PHYS(free_pfn)), bootmap_size,
166 BOOTMEM_DEFAULT);
167
168#ifdef CONFIG_VT
169#if defined(CONFIG_VGA_CONSOLE)
170 conswitchp = &vga_con;
171#elif defined(CONFIG_DUMMY_CONSOLE)
172 conswitchp = &dummy_con;
173#endif
174#endif
175
176 paging_init();
177}
178
179/*
180 * perform CPU initialisation
181 */
182void __init cpu_init(void)
183{
184 unsigned long cpurev = CPUREV, type;
b920de1b
DH
185
186 type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S;
187 if (type > mn10300_known_cpus)
188 type = mn10300_known_cpus;
189
190 printk(KERN_INFO "Matsushita %s, rev %ld\n",
191 mn10300_cputypes[type],
192 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S);
193
368dd5ac
AT
194 get_mem_info(&phys_memory_base, &memory_size);
195 phys_memory_end = phys_memory_base + memory_size;
b920de1b 196
368dd5ac
AT
197 fpu_init_state();
198}
b920de1b 199
368dd5ac 200static struct cpu cpu_devices[NR_CPUS];
b920de1b 201
368dd5ac
AT
202static int __init topology_init(void)
203{
204 int i;
b920de1b 205
368dd5ac
AT
206 for_each_present_cpu(i)
207 register_cpu(&cpu_devices[i], i);
b920de1b 208
368dd5ac 209 return 0;
b920de1b
DH
210}
211
368dd5ac
AT
212subsys_initcall(topology_init);
213
b920de1b
DH
214/*
215 * Get CPU information for use by the procfs.
216 */
217static int show_cpuinfo(struct seq_file *m, void *v)
218{
368dd5ac
AT
219#ifdef CONFIG_SMP
220 struct mn10300_cpuinfo *c = v;
221 unsigned long cpu_id = c - cpu_data;
222 unsigned long cpurev = c->type, type, icachesz, dcachesz;
223#else /* CONFIG_SMP */
224 unsigned long cpu_id = 0;
b920de1b 225 unsigned long cpurev = CPUREV, type, icachesz, dcachesz;
368dd5ac 226#endif /* CONFIG_SMP */
b920de1b 227
368dd5ac
AT
228#ifdef CONFIG_SMP
229 if (!cpu_online(cpu_id))
230 return 0;
231#endif
232
233 type = (cpurev & CPUREV_TYPE) >> CPUREV_TYPE_S;
b920de1b
DH
234 if (type > mn10300_known_cpus)
235 type = mn10300_known_cpus;
236
237 icachesz =
238 ((cpurev & CPUREV_ICWAY ) >> CPUREV_ICWAY_S) *
239 ((cpurev & CPUREV_ICSIZE) >> CPUREV_ICSIZE_S) *
240 1024;
241
242 dcachesz =
243 ((cpurev & CPUREV_DCWAY ) >> CPUREV_DCWAY_S) *
244 ((cpurev & CPUREV_DCSIZE) >> CPUREV_DCSIZE_S) *
245 1024;
246
247 seq_printf(m,
368dd5ac 248 "processor : %ld\n"
b920de1b
DH
249 "vendor_id : Matsushita\n"
250 "cpu core : %s\n"
251 "cpu rev : %lu\n"
252 "model name : " PROCESSOR_MODEL_NAME "\n"
253 "icache size: %lu\n"
254 "dcache size: %lu\n",
368dd5ac 255 cpu_id,
b920de1b
DH
256 mn10300_cputypes[type],
257 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S,
258 icachesz,
259 dcachesz
260 );
261
262 seq_printf(m,
263 "ioclk speed: %lu.%02luMHz\n"
264 "bogomips : %lu.%02lu\n\n",
265 MN10300_IOCLK / 1000000,
266 (MN10300_IOCLK / 10000) % 100,
368dd5ac
AT
267#ifdef CONFIG_SMP
268 c->loops_per_jiffy / (500000 / HZ),
269 (c->loops_per_jiffy / (5000 / HZ)) % 100
270#else /* CONFIG_SMP */
b920de1b
DH
271 loops_per_jiffy / (500000 / HZ),
272 (loops_per_jiffy / (5000 / HZ)) % 100
368dd5ac 273#endif /* CONFIG_SMP */
b920de1b
DH
274 );
275
276 return 0;
277}
278
279static void *c_start(struct seq_file *m, loff_t *pos)
280{
281 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
282}
283
284static void *c_next(struct seq_file *m, void *v, loff_t *pos)
285{
286 ++*pos;
287 return c_start(m, pos);
288}
289
290static void c_stop(struct seq_file *m, void *v)
291{
292}
293
88e9d34c 294const struct seq_operations cpuinfo_op = {
b920de1b
DH
295 .start = c_start,
296 .next = c_next,
297 .stop = c_stop,
298 .show = show_cpuinfo,
299};