b2e86d0255e691e7464bb786e6c16091de0bd84b
[deliverable/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/fs.h>
24 #include <linux/fb.h>
25 #include <linux/console.h>
26 #include <linux/genhd.h>
27 #include <linux/errno.h>
28 #include <linux/string.h>
29 #include <linux/major.h>
30 #include <linux/bootmem.h>
31 #include <linux/seq_file.h>
32 #include <linux/init.h>
33
34 #include <asm/setup.h>
35 #include <asm/irq.h>
36 #include <asm/pgtable.h>
37
38 #if defined(__H8300H__)
39 #define CPU "H8/300H"
40 #include <asm/regs306x.h>
41 #endif
42
43 #if defined(__H8300S__)
44 #define CPU "H8S"
45 #include <asm/regs267x.h>
46 #endif
47
48 #define STUBSIZE 0xc000;
49
50 unsigned long rom_length;
51 unsigned long memory_start;
52 unsigned long memory_end;
53
54 char __initdata command_line[COMMAND_LINE_SIZE];
55
56 extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
57 extern int _ramstart, _ramend;
58 extern char _target_name[];
59 extern void h8300_gpio_init(void);
60
61 #if (defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)) \
62 && defined(CONFIG_GDB_MAGICPRINT)
63 /* printk with gdb service */
64 static void gdb_console_output(struct console *c, const char *msg, unsigned len)
65 {
66 for (; len > 0; len--) {
67 asm("mov.w %0,r2\n\t"
68 "jsr @0xc4"::"r"(*msg++):"er2");
69 }
70 }
71
72 /*
73 * Setup initial baud/bits/parity. We do two things here:
74 * - construct a cflag setting for the first rs_open()
75 * - initialize the serial port
76 * Return non-zero if we didn't find a serial port.
77 */
78 static int __init gdb_console_setup(struct console *co, char *options)
79 {
80 return 0;
81 }
82
83 static const struct console gdb_console = {
84 .name = "gdb_con",
85 .write = gdb_console_output,
86 .device = NULL,
87 .setup = gdb_console_setup,
88 .flags = CON_PRINTBUFFER,
89 .index = -1,
90 };
91 #endif
92
93 void __init setup_arch(char **cmdline_p)
94 {
95 int bootmap_size;
96
97 memory_start = (unsigned long) &_ramstart;
98
99 /* allow for ROMFS on the end of the kernel */
100 if (memcmp((void *)memory_start, "-rom1fs-", 8) == 0) {
101 #if defined(CONFIG_BLK_DEV_INITRD)
102 initrd_start = memory_start;
103 initrd_end = memory_start += be32_to_cpu(((unsigned long *) (memory_start))[2]);
104 #else
105 memory_start += be32_to_cpu(((unsigned long *) memory_start)[2]);
106 #endif
107 }
108 memory_start = PAGE_ALIGN(memory_start);
109 #if !defined(CONFIG_BLKDEV_RESERVE)
110 memory_end = (unsigned long) &_ramend; /* by now the stack is part of the init task */
111 #if defined(CONFIG_GDB_DEBUG)
112 memory_end -= STUBSIZE;
113 #endif
114 #else
115 if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) &&
116 (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
117 /* overlap userarea */
118 memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS;
119 #endif
120
121 init_mm.start_code = (unsigned long) &_stext;
122 init_mm.end_code = (unsigned long) &_etext;
123 init_mm.end_data = (unsigned long) &_edata;
124 init_mm.brk = (unsigned long) 0;
125
126 #if (defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)) && defined(CONFIG_GDB_MAGICPRINT)
127 register_console((struct console *)&gdb_console);
128 #endif
129
130 printk(KERN_INFO "\r\n\nuClinux " CPU "\n");
131 printk(KERN_INFO "Target Hardware: %s\n",_target_name);
132 printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
133 printk(KERN_INFO "H8/300 series support by Yoshinori Sato <ysato@users.sourceforge.jp>\n");
134
135 #ifdef DEBUG
136 printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
137 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
138 (int) &_sdata, (int) &_edata,
139 (int) &_sbss, (int) &_ebss);
140 printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
141 "STACK=0x%06x-0x%06x\n",
142 (int) &_ebss, (int) memory_start,
143 (int) memory_start, (int) memory_end,
144 (int) memory_end, (int) &_ramend);
145 #endif
146
147 #ifdef CONFIG_DEFAULT_CMDLINE
148 /* set from default command line */
149 if (*command_line == '\0')
150 strcpy(command_line,CONFIG_KERNEL_COMMAND);
151 #endif
152 /* Keep a copy of command line */
153 *cmdline_p = &command_line[0];
154 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
155 boot_command_line[COMMAND_LINE_SIZE-1] = 0;
156
157 #ifdef DEBUG
158 if (strlen(*cmdline_p))
159 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
160 #endif
161
162 /*
163 * give all the memory to the bootmap allocator, tell it to put the
164 * boot mem_map at the start of memory
165 */
166 bootmap_size = init_bootmem_node(
167 NODE_DATA(0),
168 memory_start >> PAGE_SHIFT, /* map goes here */
169 PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
170 memory_end >> PAGE_SHIFT);
171 /*
172 * free the usable memory, we have to make sure we do not free
173 * the bootmem bitmap so we then reserve it after freeing it :-)
174 */
175 free_bootmem(memory_start, memory_end - memory_start);
176 reserve_bootmem(memory_start, bootmap_size);
177 /*
178 * get kmalloc into gear
179 */
180 paging_init();
181 h8300_gpio_init();
182 #if defined(CONFIG_H8300_AKI3068NET) && defined(CONFIG_IDE)
183 {
184 #define AREABIT(addr) (1 << (((addr) >> 21) & 7))
185 /* setup BSC */
186 volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
187 volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
188 *abwcr &= ~(AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT));
189 *cscr |= (AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT)) | 0x0f;
190 }
191 #endif
192 #ifdef DEBUG
193 printk(KERN_DEBUG "Done setup_arch\n");
194 #endif
195 }
196
197 /*
198 * Get CPU information for use by the procfs.
199 */
200
201 static int show_cpuinfo(struct seq_file *m, void *v)
202 {
203 char *cpu;
204 int mode;
205 u_long clockfreq;
206
207 cpu = CPU;
208 mode = *(volatile unsigned char *)MDCR & 0x07;
209
210 clockfreq = CONFIG_CPU_CLOCK;
211
212 seq_printf(m, "CPU:\t\t%s (mode:%d)\n"
213 "Clock:\t\t%lu.%1luMHz\n"
214 "BogoMips:\t%lu.%02lu\n"
215 "Calibration:\t%lu loops\n",
216 cpu,mode,
217 clockfreq/1000,clockfreq%1000,
218 (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
219 (loops_per_jiffy*HZ));
220
221 return 0;
222 }
223
224 static void *c_start(struct seq_file *m, loff_t *pos)
225 {
226 return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
227 }
228
229 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
230 {
231 ++*pos;
232 return c_start(m, pos);
233 }
234
235 static void c_stop(struct seq_file *m, void *v)
236 {
237 }
238
239 struct seq_operations cpuinfo_op = {
240 .start = c_start,
241 .next = c_next,
242 .stop = c_stop,
243 .show = show_cpuinfo,
244 };
This page took 0.045455 seconds and 4 git commands to generate.