1
2
3
4
5
6
7
8
9
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>
18#include <linux/slab.h>
19#include <linux/user.h>
20#include <linux/tty.h>
21#include <linux/ioport.h>
22#include <linux/delay.h>
23#include <linux/init.h>
24#include <linux/bootmem.h>
25#include <linux/seq_file.h>
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>
33#include <proc/proc.h>
34#include <asm/busctl-regs.h>
35#include <asm/fpu.h>
36#include <asm/sections.h>
37
38struct mn10300_cpuinfo boot_cpu_data;
39
40
41unsigned long pci_mem_start = 0x18000000;
42
43char redboot_command_line[COMMAND_LINE_SIZE] =
44 "console=ttyS0,115200 root=/dev/mtdblock3 rw";
45
46char __initdata redboot_platform_name[COMMAND_LINE_SIZE];
47
48static struct resource code_resource = {
49 .start = 0x100000,
50 .end = 0,
51 .name = "Kernel code",
52};
53
54static struct resource data_resource = {
55 .start = 0,
56 .end = 0,
57 .name = "Kernel data",
58};
59
60static unsigned long __initdata phys_memory_base;
61static unsigned long __initdata phys_memory_end;
62static unsigned long __initdata memory_end;
63unsigned long memory_size;
64
65struct thread_info *__current_ti = &init_thread_union.thread_info;
66struct task_struct *__current = &init_task;
67
68#define mn10300_known_cpus 3
69static const char *const mn10300_cputypes[] = {
70 "am33v1",
71 "am33v2",
72 "am34v1",
73 "unknown"
74};
75
76
77
78
79static void __init parse_mem_cmdline(char **cmdline_p)
80{
81 char *from, *to, c;
82
83
84 strcpy(boot_command_line, redboot_command_line);
85
86
87 from = redboot_command_line;
88 to = redboot_command_line;
89 c = ' ';
90
91 for (;;) {
92 if (c == ' ' && !memcmp(from, "mem=", 4)) {
93 if (to != redboot_command_line)
94 to--;
95 memory_size = memparse(from + 4, &from);
96 }
97
98 c = *(from++);
99 if (!c)
100 break;
101
102 *(to++) = c;
103 }
104
105 *to = '\0';
106 *cmdline_p = redboot_command_line;
107
108 if (memory_size == 0)
109 panic("Memory size not known\n");
110
111 memory_end = (unsigned long) CONFIG_KERNEL_RAM_BASE_ADDRESS +
112 memory_size;
113 if (memory_end > phys_memory_end)
114 memory_end = phys_memory_end;
115}
116
117
118
119
120void __init setup_arch(char **cmdline_p)
121{
122 unsigned long bootmap_size;
123 unsigned long kstart_pfn, start_pfn, free_pfn, end_pfn;
124
125 cpu_init();
126 unit_setup();
127 parse_mem_cmdline(cmdline_p);
128
129 init_mm.start_code = (unsigned long)&_text;
130 init_mm.end_code = (unsigned long) &_etext;
131 init_mm.end_data = (unsigned long) &_edata;
132 init_mm.brk = (unsigned long) &_end;
133
134 code_resource.start = virt_to_bus(&_text);
135 code_resource.end = virt_to_bus(&_etext)-1;
136 data_resource.start = virt_to_bus(&_etext);
137 data_resource.end = virt_to_bus(&_edata)-1;
138
139 start_pfn = (CONFIG_KERNEL_RAM_BASE_ADDRESS >> PAGE_SHIFT);
140 kstart_pfn = PFN_UP(__pa(&_text));
141 free_pfn = PFN_UP(__pa(&_end));
142 end_pfn = PFN_DOWN(__pa(memory_end));
143
144 bootmap_size = init_bootmem_node(&contig_page_data,
145 free_pfn,
146 start_pfn,
147 end_pfn);
148
149 if (kstart_pfn > start_pfn)
150 free_bootmem(PFN_PHYS(start_pfn),
151 PFN_PHYS(kstart_pfn - start_pfn));
152
153 free_bootmem(PFN_PHYS(free_pfn),
154 PFN_PHYS(end_pfn - free_pfn));
155
156
157
158 if (CONFIG_INTERRUPT_VECTOR_BASE >= CONFIG_KERNEL_RAM_BASE_ADDRESS &&
159 CONFIG_INTERRUPT_VECTOR_BASE < memory_end)
160 reserve_bootmem(CONFIG_INTERRUPT_VECTOR_BASE, PAGE_SIZE,
161 BOOTMEM_DEFAULT);
162
163 reserve_bootmem(PAGE_ALIGN(PFN_PHYS(free_pfn)), bootmap_size,
164 BOOTMEM_DEFAULT);
165
166#ifdef CONFIG_VT
167#if defined(CONFIG_VGA_CONSOLE)
168 conswitchp = &vga_con;
169#elif defined(CONFIG_DUMMY_CONSOLE)
170 conswitchp = &dummy_con;
171#endif
172#endif
173
174 paging_init();
175}
176
177
178
179
180void __init cpu_init(void)
181{
182 unsigned long cpurev = CPUREV, type;
183 unsigned long base, size;
184
185 type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S;
186 if (type > mn10300_known_cpus)
187 type = mn10300_known_cpus;
188
189 printk(KERN_INFO "Matsushita %s, rev %ld\n",
190 mn10300_cputypes[type],
191 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S);
192
193
194 memory_size = 0;
195
196 base = SDBASE(0);
197 if (base & SDBASE_CE) {
198 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
199 size = ~size + 1;
200 base &= SDBASE_CBA;
201
202 printk(KERN_INFO "SDRAM[0]: %luMb @%08lx\n", size >> 20, base);
203 memory_size += size;
204 phys_memory_base = base;
205 }
206
207 base = SDBASE(1);
208 if (base & SDBASE_CE) {
209 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
210 size = ~size + 1;
211 base &= SDBASE_CBA;
212
213 printk(KERN_INFO "SDRAM[1]: %luMb @%08lx\n", size >> 20, base);
214 memory_size += size;
215 if (phys_memory_base == 0)
216 phys_memory_base = base;
217 }
218
219 phys_memory_end = phys_memory_base + memory_size;
220
221#ifdef CONFIG_FPU
222 fpu_init_state();
223#endif
224}
225
226
227
228
229static int show_cpuinfo(struct seq_file *m, void *v)
230{
231 unsigned long cpurev = CPUREV, type, icachesz, dcachesz;
232
233 type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S;
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,
248 "processor : 0\n"
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",
255 mn10300_cputypes[type],
256 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S,
257 icachesz,
258 dcachesz
259 );
260
261 seq_printf(m,
262 "ioclk speed: %lu.%02luMHz\n"
263 "bogomips : %lu.%02lu\n\n",
264 MN10300_IOCLK / 1000000,
265 (MN10300_IOCLK / 10000) % 100,
266 loops_per_jiffy / (500000 / HZ),
267 (loops_per_jiffy / (5000 / HZ)) % 100
268 );
269
270 return 0;
271}
272
273static void *c_start(struct seq_file *m, loff_t *pos)
274{
275 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
276}
277
278static void *c_next(struct seq_file *m, void *v, loff_t *pos)
279{
280 ++*pos;
281 return c_start(m, pos);
282}
283
284static void c_stop(struct seq_file *m, void *v)
285{
286}
287
288const struct seq_operations cpuinfo_op = {
289 .start = c_start,
290 .next = c_next,
291 .stop = c_stop,
292 .show = show_cpuinfo,
293};
294