initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / m32r / kernel / setup.c
blobdb9589c24de5bd0552d6d879493188a5dbfb79e0
1 /*
2 * linux/arch/m32r/kernel/setup.c
4 * Setup routines for Renesas M32R
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto
8 */
10 /* $Id$ */
12 #include <linux/config.h>
13 #include <linux/init.h>
14 #include <linux/stddef.h>
15 #include <linux/fs.h>
16 #include <linux/sched.h>
17 #include <linux/ioport.h>
18 #include <linux/mm.h>
19 #include <linux/bootmem.h>
20 #include <linux/console.h>
21 #include <linux/initrd.h>
22 #include <linux/major.h>
23 #include <linux/root_dev.h>
24 #include <linux/seq_file.h>
25 #include <linux/timex.h>
26 #include <linux/tty.h>
27 #include <asm/processor.h>
28 #include <asm/pgtable.h>
29 #include <asm/io.h>
30 #include <asm/mmu_context.h>
31 #include <asm/m32r.h>
32 #include <asm/setup.h>
33 #include <asm/sections.h>
35 #ifdef CONFIG_MMU
36 extern void init_mmu(void);
37 #endif
39 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) \
40 || defined(CONFIG_BLK_DEV_IDE_MODULE) \
41 || defined(CONFIG_BLK_DEV_HD_MODULE)
42 struct drive_info_struct { char dummy[32]; } drive_info;
43 #endif
45 extern char _end[];
48 * Machine setup..
50 struct cpuinfo_m32r boot_cpu_data;
52 #ifdef CONFIG_BLK_DEV_RAM
53 extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
54 extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
55 extern int rd_image_start; /* starting block # of image */
56 #endif
58 #if defined(CONFIG_VGA_CONSOLE)
59 struct screen_info screen_info = {
60 .orig_video_lines = 25,
61 .orig_video_cols = 80,
62 .orig_video_mode = 0,
63 .orig_video_ega_bx = 0,
64 .orig_video_isVGA = 1,
65 .orig_video_points = 8
67 #endif
69 extern int root_mountflags;
71 static char command_line[COMMAND_LINE_SIZE];
73 static struct resource data_resource = {
74 .name = "Kernel data",
75 .start = 0,
76 .end = 0,
77 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
80 static struct resource code_resource = {
81 .name = "Kernel code",
82 .start = 0,
83 .end = 0,
84 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
87 unsigned long memory_start;
88 unsigned long memory_end;
90 void __init setup_arch(char **);
91 int get_cpuinfo(char *);
93 static __inline__ void parse_mem_cmdline(char ** cmdline_p)
95 char c = ' ';
96 char *to = command_line;
97 char *from = COMMAND_LINE;
98 int len = 0;
99 int usermem = 0;
101 /* Save unparsed command line copy for /proc/cmdline */
102 memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
103 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
105 memory_start = (unsigned long)CONFIG_MEMORY_START+PAGE_OFFSET;
106 memory_end = memory_start+(unsigned long)CONFIG_MEMORY_SIZE;
108 for ( ; ; ) {
109 if (c == ' ' && !memcmp(from, "mem=", 4)) {
110 if (to != command_line)
111 to--;
114 unsigned long mem_size;
116 usermem = 1;
117 mem_size = memparse(from+4, &from);
118 memory_end = memory_start + mem_size;
121 c = *(from++);
122 if (!c)
123 break;
125 if (COMMAND_LINE_SIZE <= ++len)
126 break;
128 *(to++) = c;
130 *to = '\0';
131 *cmdline_p = command_line;
132 if (usermem)
133 printk(KERN_INFO "user-defined physical RAM map:\n");
136 #ifndef CONFIG_DISCONTIGMEM
137 static unsigned long __init setup_memory(void)
139 unsigned long start_pfn, max_low_pfn, bootmap_size;
141 start_pfn = PFN_UP( __pa(_end) );
142 max_low_pfn = PFN_DOWN( __pa(memory_end) );
145 * Initialize the boot-time allocator (with low memory only):
147 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
148 CONFIG_MEMORY_START>>PAGE_SHIFT, max_low_pfn);
151 * Register fully available low RAM pages with the bootmem allocator.
154 unsigned long curr_pfn;
155 unsigned long last_pfn;
156 unsigned long pages;
159 * We are rounding up the start address of usable memory:
161 curr_pfn = PFN_UP(__pa(memory_start));
164 * ... and at the end of the usable range downwards:
166 last_pfn = PFN_DOWN(__pa(memory_end));
168 if (last_pfn > max_low_pfn)
169 last_pfn = max_low_pfn;
171 pages = last_pfn - curr_pfn;
172 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
176 * Reserve the kernel text and
177 * Reserve the bootmem bitmap. We do this in two steps (first step
178 * was init_bootmem()), because this catches the (definitely buggy)
179 * case of us accidentally initializing the bootmem allocator with
180 * an invalid RAM area.
182 reserve_bootmem(CONFIG_MEMORY_START + PAGE_SIZE,
183 (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE - 1)
184 - CONFIG_MEMORY_START);
187 * reserve physical page 0 - it's a special BIOS page on many boxes,
188 * enabling clean reboots, SMP operation, laptop functions.
190 reserve_bootmem(CONFIG_MEMORY_START, PAGE_SIZE);
193 * reserve memory hole
195 #ifdef CONFIG_MEMHOLE
196 reserve_bootmem(CONFIG_MEMHOLE_START, CONFIG_MEMHOLE_SIZE);
197 #endif
199 #ifdef CONFIG_BLK_DEV_INITRD
200 if (LOADER_TYPE && INITRD_START) {
201 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
202 reserve_bootmem(INITRD_START, INITRD_SIZE);
203 initrd_start = INITRD_START ?
204 INITRD_START + PAGE_OFFSET : 0;
206 initrd_end = initrd_start + INITRD_SIZE;
207 printk("initrd:start[%08lx],size[%08lx]\n",
208 initrd_start, INITRD_SIZE);
209 } else {
210 printk("initrd extends beyond end of memory "
211 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
212 INITRD_START + INITRD_SIZE,
213 max_low_pfn << PAGE_SHIFT);
215 initrd_start = 0;
218 #endif
220 return max_low_pfn;
222 #else /* CONFIG_DISCONTIGMEM */
223 extern unsigned long setup_memory(void);
224 #endif /* CONFIG_DISCONTIGMEM */
226 #define M32R_PCC_PCATCR 0x00ef7014 /* will move to m32r.h */
228 void __init setup_arch(char **cmdline_p)
230 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
232 boot_cpu_data.cpu_clock = M32R_CPUCLK;
233 boot_cpu_data.bus_clock = M32R_BUSCLK;
234 boot_cpu_data.timer_divide = M32R_TIMER_DIVIDE;
236 #ifdef CONFIG_BLK_DEV_RAM
237 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
238 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
239 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
240 #endif
242 if (!MOUNT_ROOT_RDONLY)
243 root_mountflags &= ~MS_RDONLY;
245 #ifdef CONFIG_VT
246 #if defined(CONFIG_VGA_CONSOLE)
247 conswitchp = &vga_con;
248 #elif defined(CONFIG_DUMMY_CONSOLE)
249 conswitchp = &dummy_con;
250 #endif
251 #endif
253 #ifdef CONFIG_DISCONTIGMEM
254 numnodes = 2;
255 #endif /* CONFIG_DISCONTIGMEM */
257 init_mm.start_code = (unsigned long) _text;
258 init_mm.end_code = (unsigned long) _etext;
259 init_mm.end_data = (unsigned long) _edata;
260 init_mm.brk = (unsigned long) _end;
262 code_resource.start = virt_to_phys(_text);
263 code_resource.end = virt_to_phys(_etext)-1;
264 data_resource.start = virt_to_phys(_etext);
265 data_resource.end = virt_to_phys(_edata)-1;
267 parse_mem_cmdline(cmdline_p);
269 setup_memory();
271 paging_init();
274 #ifdef CONFIG_PROC_FS
276 * Get CPU information for use by the procfs.
278 static int show_cpuinfo(struct seq_file *m, void *v)
280 struct cpuinfo_m32r *c = v;
281 unsigned long cpu = c - cpu_data;
283 #ifdef CONFIG_SMP
284 if (!cpu_online(cpu))
285 return 0;
286 #endif /* CONFIG_SMP */
288 seq_printf(m, "processor\t: %ld\n", cpu);
290 #ifdef CONFIG_CHIP_VDEC2
291 seq_printf(m, "cpu family\t: VDEC2\n"
292 "cache size\t: Unknown\n");
293 #elif CONFIG_CHIP_M32700
294 seq_printf(m,"cpu family\t: M32700\n"
295 "cache size\t: I-8KB/D-8KB\n");
296 #elif CONFIG_CHIP_M32102
297 seq_printf(m,"cpu family\t: M32102\n"
298 "cache size\t: I-8KB\n");
299 #elif CONFIG_CHIP_OPSP
300 seq_printf(m,"cpu family\t: OPSP\n"
301 "cache size\t: I-8KB/D-8KB\n");
302 #elif CONFIG_CHIP_MP
303 seq_printf(m, "cpu family\t: M32R-MP\n"
304 "cache size\t: I-xxKB/D-xxKB\n");
305 #else
306 seq_printf(m, "cpu family\t: Unknown\n");
307 #endif
308 seq_printf(m, "bogomips\t: %lu.%02lu\n",
309 c->loops_per_jiffy/(500000/HZ),
310 (c->loops_per_jiffy/(5000/HZ)) % 100);
311 #ifdef CONFIG_PLAT_MAPPI
312 seq_printf(m, "Machine\t\t: Mappi Evaluation board\n");
313 #elif CONFIG_PLAT_MAPPI2
314 seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n");
315 #elif CONFIG_PLAT_M32700UT
316 seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n");
317 #elif CONFIG_PLAT_OPSPUT
318 seq_printf(m, "Machine\t\t: OPSPUT Evaluation board\n");
319 #elif CONFIG_PLAT_USRV
320 seq_printf(m, "Machine\t\t: uServer\n");
321 #elif CONFIG_PLAT_OAKS32R
322 seq_printf(m, "Machine\t\t: OAKS32R\n");
323 #else
324 seq_printf(m, "Machine\t\t: Unknown\n");
325 #endif
327 #define PRINT_CLOCK(name, value) \
328 seq_printf(m, name " clock\t: %d.%02dMHz\n", \
329 ((value) / 1000000), ((value) % 1000000)/10000)
331 PRINT_CLOCK("CPU", (int)c->cpu_clock);
332 PRINT_CLOCK("Bus", (int)c->bus_clock);
334 seq_printf(m, "\n");
336 return 0;
339 static void *c_start(struct seq_file *m, loff_t *pos)
341 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
344 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
346 ++*pos;
347 return c_start(m, pos);
350 static void c_stop(struct seq_file *m, void *v)
354 struct seq_operations cpuinfo_op = {
355 start: c_start,
356 next: c_next,
357 stop: c_stop,
358 show: show_cpuinfo,
360 #endif /* CONFIG_PROC_FS */
362 unsigned long cpu_initialized __initdata = 0;
365 * cpu_init() initializes state that is per-CPU. Some data is already
366 * initialized (naturally) in the bootstrap process.
367 * We reload them nevertheless, this function acts as a
368 * 'CPU state barrier', nothing should get across.
370 #if defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \
371 || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \
372 || defined(CONFIG_CHIP_OPSP)
373 void __init cpu_init (void)
375 int cpu_id = smp_processor_id();
377 if (test_and_set_bit(cpu_id, &cpu_initialized)) {
378 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu_id);
379 for ( ; ; )
380 local_irq_enable();
382 printk(KERN_INFO "Initializing CPU#%d\n", cpu_id);
384 /* Set up and load the per-CPU TSS and LDT */
385 atomic_inc(&init_mm.mm_count);
386 current->active_mm = &init_mm;
387 if (current->mm)
388 BUG();
390 /* Force FPU initialization */
391 current_thread_info()->status = 0;
392 current->used_math = 0;
394 #ifdef CONFIG_MMU
395 /* Set up MMU */
396 init_mmu();
397 #endif
399 /* Set up ICUIMASK */
400 outl(0x00070000, M32R_ICU_IMASK_PORTL); /* imask=111 */
402 #endif /* defined(CONFIG_CHIP_VDEC2) ... */