2 * linux/arch/m32r/kernel/setup.c
4 * Setup routines for Renesas M32R
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata,
10 #include <linux/config.h>
11 #include <linux/init.h>
12 #include <linux/stddef.h>
14 #include <linux/sched.h>
15 #include <linux/ioport.h>
17 #include <linux/bootmem.h>
18 #include <linux/console.h>
19 #include <linux/initrd.h>
20 #include <linux/major.h>
21 #include <linux/root_dev.h>
22 #include <linux/seq_file.h>
23 #include <linux/timex.h>
24 #include <linux/tty.h>
25 #include <linux/cpu.h>
26 #include <linux/nodemask.h>
27 #include <linux/pfn.h>
29 #include <asm/processor.h>
30 #include <asm/pgtable.h>
32 #include <asm/mmu_context.h>
34 #include <asm/setup.h>
35 #include <asm/sections.h>
38 extern void init_mmu(void);
46 struct cpuinfo_m32r boot_cpu_data;
48 #ifdef CONFIG_BLK_DEV_RAM
49 extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
50 extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
51 extern int rd_image_start; /* starting block # of image */
54 #if defined(CONFIG_VGA_CONSOLE)
55 struct screen_info screen_info = {
56 .orig_video_lines = 25,
57 .orig_video_cols = 80,
59 .orig_video_ega_bx = 0,
60 .orig_video_isVGA = 1,
61 .orig_video_points = 8
65 extern int root_mountflags;
67 static char command_line[COMMAND_LINE_SIZE];
69 static struct resource data_resource = {
70 .name = "Kernel data",
73 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
76 static struct resource code_resource = {
77 .name = "Kernel code",
80 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
83 unsigned long memory_start;
84 unsigned long memory_end;
86 void __init setup_arch(char **);
87 int get_cpuinfo(char *);
89 static __inline__ void parse_mem_cmdline(char ** cmdline_p)
92 char *to = command_line;
93 char *from = COMMAND_LINE;
97 /* Save unparsed command line copy for /proc/cmdline */
98 memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
99 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
101 memory_start = (unsigned long)CONFIG_MEMORY_START+PAGE_OFFSET;
102 memory_end = memory_start+(unsigned long)CONFIG_MEMORY_SIZE;
105 if (c == ' ' && !memcmp(from, "mem=", 4)) {
106 if (to != command_line)
110 unsigned long mem_size;
113 mem_size = memparse(from+4, &from);
114 memory_end = memory_start + mem_size;
121 if (COMMAND_LINE_SIZE <= ++len)
127 *cmdline_p = command_line;
129 printk(KERN_INFO "user-defined physical RAM map:\n");
132 #ifndef CONFIG_DISCONTIGMEM
133 static unsigned long __init setup_memory(void)
135 unsigned long start_pfn, max_low_pfn, bootmap_size;
137 start_pfn = PFN_UP( __pa(_end) );
138 max_low_pfn = PFN_DOWN( __pa(memory_end) );
141 * Initialize the boot-time allocator (with low memory only):
143 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
144 CONFIG_MEMORY_START>>PAGE_SHIFT, max_low_pfn);
147 * Register fully available low RAM pages with the bootmem allocator.
150 unsigned long curr_pfn;
151 unsigned long last_pfn;
155 * We are rounding up the start address of usable memory:
157 curr_pfn = PFN_UP(__pa(memory_start));
160 * ... and at the end of the usable range downwards:
162 last_pfn = PFN_DOWN(__pa(memory_end));
164 if (last_pfn > max_low_pfn)
165 last_pfn = max_low_pfn;
167 pages = last_pfn - curr_pfn;
168 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
172 * Reserve the kernel text and
173 * Reserve the bootmem bitmap. We do this in two steps (first step
174 * was init_bootmem()), because this catches the (definitely buggy)
175 * case of us accidentally initializing the bootmem allocator with
176 * an invalid RAM area.
178 reserve_bootmem(CONFIG_MEMORY_START + PAGE_SIZE,
179 (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE - 1)
180 - CONFIG_MEMORY_START);
183 * reserve physical page 0 - it's a special BIOS page on many boxes,
184 * enabling clean reboots, SMP operation, laptop functions.
186 reserve_bootmem(CONFIG_MEMORY_START, PAGE_SIZE);
189 * reserve memory hole
191 #ifdef CONFIG_MEMHOLE
192 reserve_bootmem(CONFIG_MEMHOLE_START, CONFIG_MEMHOLE_SIZE);
195 #ifdef CONFIG_BLK_DEV_INITRD
196 if (LOADER_TYPE && INITRD_START) {
197 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
198 reserve_bootmem(INITRD_START, INITRD_SIZE);
199 initrd_start = INITRD_START ?
200 INITRD_START + PAGE_OFFSET : 0;
202 initrd_end = initrd_start + INITRD_SIZE;
203 printk("initrd:start[%08lx],size[%08lx]\n",
204 initrd_start, INITRD_SIZE);
206 printk("initrd extends beyond end of memory "
207 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
208 INITRD_START + INITRD_SIZE,
209 max_low_pfn << PAGE_SHIFT);
218 #else /* CONFIG_DISCONTIGMEM */
219 extern unsigned long setup_memory(void);
220 #endif /* CONFIG_DISCONTIGMEM */
222 #define M32R_PCC_PCATCR 0x00ef7014 /* will move to m32r.h */
224 void __init setup_arch(char **cmdline_p)
226 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
228 boot_cpu_data.cpu_clock = M32R_CPUCLK;
229 boot_cpu_data.bus_clock = M32R_BUSCLK;
230 boot_cpu_data.timer_divide = M32R_TIMER_DIVIDE;
232 #ifdef CONFIG_BLK_DEV_RAM
233 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
234 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
235 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
238 if (!MOUNT_ROOT_RDONLY)
239 root_mountflags &= ~MS_RDONLY;
242 #if defined(CONFIG_VGA_CONSOLE)
243 conswitchp = &vga_con;
244 #elif defined(CONFIG_DUMMY_CONSOLE)
245 conswitchp = &dummy_con;
249 #ifdef CONFIG_DISCONTIGMEM
250 nodes_clear(node_online_map);
253 #endif /* CONFIG_DISCONTIGMEM */
255 init_mm.start_code = (unsigned long) _text;
256 init_mm.end_code = (unsigned long) _etext;
257 init_mm.end_data = (unsigned long) _edata;
258 init_mm.brk = (unsigned long) _end;
260 code_resource.start = virt_to_phys(_text);
261 code_resource.end = virt_to_phys(_etext)-1;
262 data_resource.start = virt_to_phys(_etext);
263 data_resource.end = virt_to_phys(_edata)-1;
265 parse_mem_cmdline(cmdline_p);
272 static struct cpu cpu[NR_CPUS];
274 static int __init topology_init(void)
278 for (cpu_id = 0; cpu_id < NR_CPUS; cpu_id++)
279 if (cpu_possible(cpu_id))
280 register_cpu(&cpu[cpu_id], cpu_id, NULL);
285 subsys_initcall(topology_init);
287 #ifdef CONFIG_PROC_FS
289 * Get CPU information for use by the procfs.
291 static int show_cpuinfo(struct seq_file *m, void *v)
293 struct cpuinfo_m32r *c = v;
294 unsigned long cpu = c - cpu_data;
297 if (!cpu_online(cpu))
299 #endif /* CONFIG_SMP */
301 seq_printf(m, "processor\t: %ld\n", cpu);
303 #if defined(CONFIG_CHIP_VDEC2)
304 seq_printf(m, "cpu family\t: VDEC2\n"
305 "cache size\t: Unknown\n");
306 #elif defined(CONFIG_CHIP_M32700)
307 seq_printf(m,"cpu family\t: M32700\n"
308 "cache size\t: I-8KB/D-8KB\n");
309 #elif defined(CONFIG_CHIP_M32102)
310 seq_printf(m,"cpu family\t: M32102\n"
311 "cache size\t: I-8KB\n");
312 #elif defined(CONFIG_CHIP_OPSP)
313 seq_printf(m,"cpu family\t: OPSP\n"
314 "cache size\t: I-8KB/D-8KB\n");
315 #elif defined(CONFIG_CHIP_MP)
316 seq_printf(m, "cpu family\t: M32R-MP\n"
317 "cache size\t: I-xxKB/D-xxKB\n");
318 #elif defined(CONFIG_CHIP_M32104)
319 seq_printf(m,"cpu family\t: M32104\n"
320 "cache size\t: I-8KB/D-8KB\n");
322 seq_printf(m, "cpu family\t: Unknown\n");
324 seq_printf(m, "bogomips\t: %lu.%02lu\n",
325 c->loops_per_jiffy/(500000/HZ),
326 (c->loops_per_jiffy/(5000/HZ)) % 100);
327 #if defined(CONFIG_PLAT_MAPPI)
328 seq_printf(m, "Machine\t\t: Mappi Evaluation board\n");
329 #elif defined(CONFIG_PLAT_MAPPI2)
330 seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n");
331 #elif defined(CONFIG_PLAT_MAPPI3)
332 seq_printf(m, "Machine\t\t: Mappi-III Evaluation board\n");
333 #elif defined(CONFIG_PLAT_M32700UT)
334 seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n");
335 #elif defined(CONFIG_PLAT_OPSPUT)
336 seq_printf(m, "Machine\t\t: OPSPUT Evaluation board\n");
337 #elif defined(CONFIG_PLAT_USRV)
338 seq_printf(m, "Machine\t\t: uServer\n");
339 #elif defined(CONFIG_PLAT_OAKS32R)
340 seq_printf(m, "Machine\t\t: OAKS32R\n");
341 #elif defined(CONFIG_PLAT_M32104UT)
342 seq_printf(m, "Machine\t\t: M3T-M32104UT uT Engine board\n");
344 seq_printf(m, "Machine\t\t: Unknown\n");
347 #define PRINT_CLOCK(name, value) \
348 seq_printf(m, name " clock\t: %d.%02dMHz\n", \
349 ((value) / 1000000), ((value) % 1000000)/10000)
351 PRINT_CLOCK("CPU", (int)c->cpu_clock);
352 PRINT_CLOCK("Bus", (int)c->bus_clock);
359 static void *c_start(struct seq_file *m, loff_t *pos)
361 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
364 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
367 return c_start(m, pos);
370 static void c_stop(struct seq_file *m, void *v)
374 struct seq_operations cpuinfo_op = {
380 #endif /* CONFIG_PROC_FS */
382 unsigned long cpu_initialized __initdata = 0;
385 * cpu_init() initializes state that is per-CPU. Some data is already
386 * initialized (naturally) in the bootstrap process.
387 * We reload them nevertheless, this function acts as a
388 * 'CPU state barrier', nothing should get across.
390 #if defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \
391 || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \
392 || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104)
393 void __init cpu_init (void)
395 int cpu_id = smp_processor_id();
397 if (test_and_set_bit(cpu_id, &cpu_initialized)) {
398 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu_id);
402 printk(KERN_INFO "Initializing CPU#%d\n", cpu_id);
404 /* Set up and load the per-CPU TSS and LDT */
405 atomic_inc(&init_mm.mm_count);
406 current->active_mm = &init_mm;
410 /* Force FPU initialization */
411 current_thread_info()->status = 0;
419 /* Set up ICUIMASK */
420 outl(0x00070000, M32R_ICU_IMASK_PORTL); /* imask=111 */
422 #endif /* defined(CONFIG_CHIP_VDEC2) ... */