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