2 * arch/ppc/platforms/spruce_setup.c
4 * Board setup routines for IBM Spruce
6 * Authors: Johnnie Peters <jpeters@mvista.com>
7 * Matt Porter <mporter@mvista.com>
9 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
15 #include <linux/config.h>
16 #include <linux/stddef.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/errno.h>
20 #include <linux/reboot.h>
21 #include <linux/pci.h>
22 #include <linux/kdev_t.h>
23 #include <linux/types.h>
24 #include <linux/major.h>
25 #include <linux/blk.h>
26 #include <linux/console.h>
27 #include <linux/delay.h>
28 #include <linux/seq_file.h>
29 #include <linux/ide.h>
30 #include <linux/serial.h>
32 #include <asm/keyboard.h>
33 #include <asm/system.h>
34 #include <asm/pgtable.h>
38 #include <asm/machdep.h>
40 #include <platforms/spruce.h>
42 #include <asm/bootinfo.h>
46 extern void spruce_init_IRQ(void);
47 extern int spruce_get_irq(struct pt_regs *);
48 extern void spruce_setup_hose(void);
50 extern int pckbd_setkeycode(unsigned int, unsigned int);
51 extern int pckbd_getkeycode(unsigned int);
52 extern int pckbd_translate(unsigned char, unsigned char *, char);
53 extern char pckbd_unexpected_up(unsigned char);
54 extern void pckbd_leds(unsigned char);
55 extern void pckbd_init_hw(void);
56 extern unsigned char pckbd_sysrq_xlate[128];
57 extern char cmd_line[];
59 extern void gen550_progress(char *, unsigned short);
60 extern void gen550_init(int, struct serial_struct *);
63 * CPC700 PIC interrupt programming table
65 * First entry is the sensitivity (level/edge), second is the polarity.
67 unsigned int cpc700_irq_assigns[32][2] = {
68 { 1, 1 }, /* IRQ 0: ECC Correctable Error - rising edge */
69 { 1, 1 }, /* IRQ 1: PCI Write Mem Range - rising edge */
70 { 0, 1 }, /* IRQ 2: PCI Write Command Reg - active high */
71 { 0, 1 }, /* IRQ 3: UART 0 - active high */
72 { 0, 1 }, /* IRQ 4: UART 1 - active high */
73 { 0, 1 }, /* IRQ 5: ICC 0 - active high */
74 { 0, 1 }, /* IRQ 6: ICC 1 - active high */
75 { 0, 1 }, /* IRQ 7: GPT Compare 0 - active high */
76 { 0, 1 }, /* IRQ 8: GPT Compare 1 - active high */
77 { 0, 1 }, /* IRQ 9: GPT Compare 2 - active high */
78 { 0, 1 }, /* IRQ 10: GPT Compare 3 - active high */
79 { 0, 1 }, /* IRQ 11: GPT Compare 4 - active high */
80 { 0, 1 }, /* IRQ 12: GPT Capture 0 - active high */
81 { 0, 1 }, /* IRQ 13: GPT Capture 1 - active high */
82 { 0, 1 }, /* IRQ 14: GPT Capture 2 - active high */
83 { 0, 1 }, /* IRQ 15: GPT Capture 3 - active high */
84 { 0, 1 }, /* IRQ 16: GPT Capture 4 - active high */
85 { 0, 0 }, /* IRQ 17: Reserved */
86 { 0, 0 }, /* IRQ 18: Reserved */
87 { 0, 0 }, /* IRQ 19: Reserved */
88 { 0, 1 }, /* IRQ 20: FPGA EXT_IRQ0 - active high */
89 { 1, 1 }, /* IRQ 21: Mouse - rising edge */
90 { 1, 1 }, /* IRQ 22: Keyboard - rising edge */
91 { 0, 0 }, /* IRQ 23: PCI Slot 3 - active low */
92 { 0, 0 }, /* IRQ 24: PCI Slot 2 - active low */
93 { 0, 0 }, /* IRQ 25: PCI Slot 1 - active low */
94 { 0, 0 }, /* IRQ 26: PCI Slot 0 - active low */
98 spruce_calibrate_decr(void)
100 int freq, divisor = 4;
102 /* determine processor bus speed */
103 freq = SPRUCE_BUS_SPEED;
104 tb_ticks_per_jiffy = freq / HZ / divisor;
105 tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
109 spruce_show_cpuinfo(struct seq_file *m)
111 seq_printf(m, "vendor\t\t: IBM\n");
112 seq_printf(m, "machine\t\t: Spruce\n");
119 spruce_early_serial_map(void)
122 struct serial_struct serial_req;
124 if (SPRUCE_UARTCLK_IS_33M(readb(SPRUCE_FPGA_REG_A)))
125 baud_base = SPRUCE_BAUD_33M;
127 baud_base = SPRUCE_BAUD_30M;
129 /* Setup serial port access */
130 memset(&serial_req, 0, sizeof(serial_req));
131 serial_req.baud_base = baud_base;
135 serial_req.flags = ASYNC_BOOT_AUTOCONF;
136 serial_req.io_type = SERIAL_IO_MEM;
137 serial_req.iomem_base = (u_char *)UART0_IO_BASE;
138 serial_req.iomem_reg_shift = 0;
140 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
141 gen550_init(0, &serial_req);
144 if (early_serial_setup(&serial_req) != 0)
145 printk("Early serial init of port 0 failed\n");
147 /* Assume early_serial_setup() doesn't modify serial_req */
151 serial_req.iomem_base = (u_char *)UART1_IO_BASE;
153 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
154 gen550_init(1, &serial_req);
157 if (early_serial_setup(&serial_req) != 0)
158 printk("Early serial init of port 1 failed\n");
165 spruce_setup_arch(void)
167 /* Setup TODC access */
168 TODC_INIT(TODC_TYPE_DS1643, 0, 0, SPRUCE_RTC_BASE_ADDR, 8);
170 /* init to some ~sane value until calibrate_delay() runs */
171 loops_per_jiffy = 50000000 / HZ;
173 /* Setup PCI host bridge */
176 #ifdef CONFIG_BLK_DEV_INITRD
178 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); /* /dev/ram */
181 #ifdef CONFIG_ROOT_NFS
182 ROOT_DEV = to_kdev_t(0x00FF); /* /dev/nfs pseudo device */
184 ROOT_DEV = to_kdev_t(0x0801); /* /dev/sda1 */
187 #ifdef CONFIG_DUMMY_CONSOLE
188 conswitchp = &dummy_con;
192 spruce_early_serial_map();
195 /* Identify the system */
196 printk("System Identification: IBM Spruce\n");
197 printk("IBM Spruce port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
201 spruce_restart(char *cmd)
205 /* SRR0 has system reset vector, SRR1 has default MSR value */
206 /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
207 asm volatile(" lis 3,0xfff0 \n\
217 spruce_power_off(void)
225 spruce_restart(NULL);
228 static unsigned long __init
229 spruce_find_end_of_memory(void)
231 return boot_mem_size;
237 io_block_mapping(SPRUCE_PCI_IO_BASE, SPRUCE_PCI_PHY_IO_BASE,
238 0x08000000, _PAGE_IO);
241 unsigned char spruce_read_keyb_status(void)
243 unsigned long kbd_status;
245 __raw_writel(0x00000088, 0xff500008);
248 __raw_writel(0x03000000, 0xff50000c);
251 asm volatile(" lis 7,0xff88 \n\
255 : "=r" (kbd_status) :: "6", "7");
257 __raw_writel(0x00000000, 0xff50000c);
260 return (unsigned char)(kbd_status >> 24);
263 unsigned char spruce_read_keyb_data(void)
265 unsigned long kbd_data;
267 __raw_writel(0x00000088, 0xff500008);
270 __raw_writel(0x03000000, 0xff50000c);
273 asm volatile(" lis 7,0xff88 \n\
276 : "=r" (kbd_data) :: "6", "7");
278 __raw_writel(0x00000000, 0xff50000c);
281 return (unsigned char)(kbd_data >> 24);
284 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
286 * Set BAT 3 to map 0xf8000000 to end of physical memory space 1-to-1.
288 static __inline__ void
291 unsigned long bat3u, bat3l;
293 asm volatile(" lis %0,0xf800 \n\
300 : "=r" (bat3u), "=r" (bat3l));
305 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
306 unsigned long r6, unsigned long r7)
308 parse_bootinfo(find_bootinfo());
310 isa_io_base = SPRUCE_ISA_IO_BASE;
311 pci_dram_offset = SPRUCE_PCI_SYS_MEM_BASE;
313 ppc_md.setup_arch = spruce_setup_arch;
314 ppc_md.show_cpuinfo = spruce_show_cpuinfo;
315 ppc_md.init_IRQ = cpc700_init_IRQ;
316 ppc_md.get_irq = cpc700_get_irq;
318 ppc_md.find_end_of_memory = spruce_find_end_of_memory;
319 ppc_md.setup_io_mappings = spruce_map_io;
321 ppc_md.restart = spruce_restart;
322 ppc_md.power_off = spruce_power_off;
323 ppc_md.halt = spruce_halt;
325 ppc_md.time_init = todc_time_init;
326 ppc_md.set_rtc_time = todc_set_rtc_time;
327 ppc_md.get_rtc_time = todc_get_rtc_time;
328 ppc_md.calibrate_decr = spruce_calibrate_decr;
330 ppc_md.nvram_read_val = todc_direct_read_val;
331 ppc_md.nvram_write_val = todc_direct_write_val;
333 #if defined(CONFIG_SERIAL) && (defined(CONFIG_SERIAL_TEXT_DEBUG) \
334 || defined(CONFIG_KGDB))
336 spruce_early_serial_map();
338 #ifdef CONFIG_SERIAL_TEXT_DEBUG
339 ppc_md.progress = gen550_progress;
340 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
341 ppc_md.early_serial_map = spruce_early_serial_map;
345 /* Spruce has a PS2 style keyboard */
346 ppc_md.kbd_setkeycode = pckbd_setkeycode;
347 ppc_md.kbd_getkeycode = pckbd_getkeycode;
348 ppc_md.kbd_translate = pckbd_translate;
349 ppc_md.kbd_unexpected_up = pckbd_unexpected_up;
350 ppc_md.kbd_leds = pckbd_leds;
351 ppc_md.kbd_init_hw = pckbd_init_hw;
352 #ifdef CONFIG_MAGIC_SYSRQ
353 ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate;