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