OSDN Git Service

Merge branch 'h8300' into h8300_clk
[uclinux-h8/linux.git] / arch / h8300 / kernel / setup.c
1 /*
2  *  linux/arch/h8300/kernel/setup.c
3  *
4  *  Copyleft  ()) 2000       James D. Schettine {james@telos-systems.com}
5  *  Copyright (C) 1999,2000  Greg Ungerer (gerg@snapgear.com)
6  *  Copyright (C) 1998,1999  D. Jeff Dionne <jeff@lineo.ca>
7  *  Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
8  *  Copyright (C) 1995       Hamish Macdonald
9  *  Copyright (C) 2000       Lineo Inc. (www.lineo.com) 
10  *  Copyright (C) 2001       Lineo, Inc. <www.lineo.com>
11  *
12  *  H8/300 porting Yoshinori Sato <ysato@users.sourceforge.jp>
13  */
14
15 /*
16  * This file handles the architecture-dependent parts of system setup
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/sched.h>
21 #include <linux/delay.h>
22 #include <linux/interrupt.h>
23 #include <linux/mm.h>
24 #include <linux/fs.h>
25 #include <linux/fb.h>
26 #include <linux/console.h>
27 #include <linux/genhd.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
30 #include <linux/major.h>
31 #include <linux/bootmem.h>
32 #include <linux/seq_file.h>
33 #include <linux/init.h>
34
35 #include <asm/setup.h>
36 #include <asm/irq.h>
37 #include <asm/pgtable.h>
38
39 #if defined(__H8300H__)
40 #define CPU "H8/300H"
41 #include <asm/regs306x.h>
42 #endif
43
44 #if defined(__H8300S__)
45 #define CPU "H8S"
46 #include <asm/regs267x.h>
47 #endif
48
49 #define STUBSIZE 0xc000
50
51 unsigned long rom_length;
52 unsigned long memory_start;
53 unsigned long memory_end;
54
55 char __initdata command_line[COMMAND_LINE_SIZE];
56
57 extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
58 extern unsigned long _ramstart, _ramend;
59 extern char _target_name[];
60 void h8300_early_devices_register(void);
61
62 void __init setup_arch(char **cmdline_p)
63 {
64         int bootmap_size;
65
66         memory_start = (unsigned long) &_ramstart;
67
68         /* allow for ROMFS on the end of the kernel */
69         if (memcmp((void *)memory_start, "-rom1fs-", 8) == 0) {
70 #if defined(CONFIG_BLK_DEV_INITRD)
71                 initrd_start = memory_start;
72                 initrd_end = memory_start += be32_to_cpu(((unsigned long *) (memory_start))[2]);
73 #else
74                 memory_start += be32_to_cpu(((unsigned long *) memory_start)[2]);
75 #endif
76         }
77         memory_start = PAGE_ALIGN(memory_start);
78 #if !defined(CONFIG_BLKDEV_RESERVE)
79         memory_end = (unsigned long) &_ramend; /* by now the stack is part of the init task */
80 #if defined(CONFIG_GDB_DEBUG)
81         memory_end -= STUBSIZE;
82 #endif
83 #else
84         if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) && 
85             (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
86             /* overlap userarea */
87             memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS; 
88 #endif
89
90         init_mm.start_code = (unsigned long) &_stext;
91         init_mm.end_code = (unsigned long) &_etext;
92         init_mm.end_data = (unsigned long) &_edata;
93         init_mm.brk = (unsigned long) 0; 
94
95         printk(KERN_INFO "\r\n\nuClinux " CPU "\n");
96         printk(KERN_INFO "Target Hardware: %s\n",_target_name);
97         printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
98         printk(KERN_INFO "H8/300 series support by Yoshinori Sato <ysato@users.sourceforge.jp>\n");
99
100 #ifdef DEBUG
101         printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
102                 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
103                 (int) &_sdata, (int) &_edata,
104                 (int) &_sbss, (int) &_ebss);
105         printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
106                 "STACK=0x%06x-0x%06x\n",
107                (int) &_ebss, (int) memory_start,
108                 (int) memory_start, (int) memory_end,
109                 (int) memory_end, (int) &_ramend);
110 #endif
111
112 #ifdef CONFIG_DEFAULT_CMDLINE
113         /* set from default command line */
114         if (*command_start == '\0')
115                 memcpy(command_line, CONFIG_KERNEL_COMMAND, sizeof(command_line));
116 #endif
117         if (*command_line == '\0')
118                 memcpy(command_line, command_start, sizeof(command_line));
119         *cmdline_p = command_line;
120         memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
121         boot_command_line[COMMAND_LINE_SIZE-1] = 0;
122
123 #ifdef DEBUG
124         if (strlen(*cmdline_p)) 
125                 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
126 #endif
127
128         /*
129          * give all the memory to the bootmap allocator,  tell it to put the
130          * boot mem_map at the start of memory
131          */
132         bootmap_size = init_bootmem_node(
133                         NODE_DATA(0),
134                         memory_start >> PAGE_SHIFT, /* map goes here */
135                         PAGE_OFFSET >> PAGE_SHIFT,      /* 0 on coldfire */
136                         memory_end >> PAGE_SHIFT);
137         /*
138          * free the usable memory,  we have to make sure we do not free
139          * the bootmem bitmap so we then reserve it after freeing it :-)
140          */
141         free_bootmem(memory_start, memory_end - memory_start);
142         reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
143         /*
144          * get kmalloc into gear
145          */
146         paging_init();
147         h8300_early_devices_register();
148 #ifdef DEBUG
149         printk(KERN_DEBUG "Done setup_arch\n");
150 #endif
151 }
152
153 /*
154  *      Get CPU information for use by the procfs.
155  */
156
157 static int show_cpuinfo(struct seq_file *m, void *v)
158 {
159     char *cpu;
160     int mode;
161     u_long clockfreq;
162
163     cpu = CPU;
164     mode = *(volatile unsigned char *)MDCR & 0x07;
165
166     clockfreq = CONFIG_CPU_CLOCK;
167
168     seq_printf(m,  "CPU:\t\t%s (mode:%d)\n"
169                    "Clock:\t\t%lu.%1luMHz\n"
170                    "BogoMips:\t%lu.%02lu\n"
171                    "Calibration:\t%lu loops\n",
172                    cpu,mode,
173                    clockfreq/1000,clockfreq%1000,
174                    (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
175                    (loops_per_jiffy*HZ));
176
177     return 0;
178 }
179
180 static void *c_start(struct seq_file *m, loff_t *pos)
181 {
182         return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
183 }
184
185 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
186 {
187         ++*pos;
188         return c_start(m, pos);
189 }
190
191 static void c_stop(struct seq_file *m, void *v)
192 {
193 }
194
195 const struct seq_operations cpuinfo_op = {
196         .start  = c_start,
197         .next   = c_next,
198         .stop   = c_stop,
199         .show   = show_cpuinfo,
200 };