2 * arch/ppc/platforms/lopec_setup.c
4 * Setup routines for the Motorola LoPEC.
9 * Copyright 2001-2002 MontaVista Software Inc.
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
17 #include <linux/config.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/errno.h>
21 #include <linux/pci.h>
22 #include <linux/time.h>
23 #include <linux/types.h>
24 #include <linux/major.h>
25 #include <linux/kdev_t.h>
26 #include <linux/ide.h>
27 #include <linux/irq.h>
28 #include <linux/seq_file.h>
29 #include <linux/console.h>
30 #include <linux/serial.h>
31 #include <linux/serialP.h>
33 #include <asm/system.h>
34 #include <asm/pgtable.h>
35 #include <asm/machdep.h>
40 #include <asm/delay.h>
42 #include <asm/open_pic.h>
43 #include <asm/i8259.h>
44 #include <asm/pci-bridge.h>
46 #include <asm/bootinfo.h>
47 #include <asm/mpc10x.h>
48 #include <asm/keyboard.h>
49 #include <asm/prep_nvram.h>
50 #include <asm/serial.h>
52 extern char saved_command_line[];
53 extern void lopec_find_bridges(void);
55 extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
56 extern int pckbd_getkeycode(unsigned int scancode);
57 extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
59 extern char pckbd_unexpected_up(unsigned char keycode);
60 extern void pckbd_leds(unsigned char leds);
61 extern void pckbd_init_hw(void);
62 extern unsigned char pckbd_sysrq_xlate[128];
63 extern void gen550_progress(char *, unsigned short);
64 extern void gen550_init(int, struct serial_struct *);
67 * Define all of the IRQ senses and polarities. Taken from the
68 * LoPEC Programmer's Reference Guide */
69 static u_char lopec_openpic_initsenses[17] __initdata = {
70 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 0 */
71 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 1 */
72 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 2 */
73 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 3 */
74 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 4 */
75 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 5 */
76 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 6 */
77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 7 */
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 8 */
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 9 */
80 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 10 */
81 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 11 */
82 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 12 */
83 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 13 */
84 (IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE), /* IRQ 14 */
85 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE) /* IRQ 15 */
89 lopec_show_cpuinfo(struct seq_file *m)
91 seq_printf(m, "machine\t\t: Motorola LoPEC\n");
96 lopec_irq_cannonicalize(u32 irq)
105 lopec_restart(char *cmd)
107 #define LOPEC_SYSSTAT1 0xffe00000
108 /* force a hard reset, if possible */
109 unsigned char reg = *((unsigned char *) LOPEC_SYSSTAT1);
111 *((unsigned char *) LOPEC_SYSSTAT1) = reg;
115 #undef LOPEC_SYSSTAT1
126 lopec_power_off(void)
131 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
132 int lopec_ide_ports_known = 0;
133 static ide_ioreg_t lopec_ide_regbase[MAX_HWIFS];
134 static ide_ioreg_t lopec_ide_ctl_regbase[MAX_HWIFS];
135 static ide_ioreg_t lopec_idedma_regbase;
138 lopec_ide_probe(void)
140 struct pci_dev *dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
141 PCI_DEVICE_ID_WINBOND_82C105,
143 lopec_ide_ports_known = 1;
146 lopec_ide_regbase[0] = dev->resource[0].start;
147 lopec_ide_regbase[1] = dev->resource[2].start;
148 lopec_ide_ctl_regbase[0] = dev->resource[1].start;
149 lopec_ide_ctl_regbase[1] = dev->resource[3].start;
150 lopec_idedma_regbase = dev->resource[4].start;
155 lopec_ide_default_irq(ide_ioreg_t base)
157 if (lopec_ide_ports_known == 0)
160 if (base == lopec_ide_regbase[0])
162 else if (base == lopec_ide_regbase[1])
169 lopec_ide_default_io_base(int index)
171 if (lopec_ide_ports_known == 0)
173 return lopec_ide_regbase[index];
177 lopec_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data,
178 ide_ioreg_t ctl, int *irq)
180 ide_ioreg_t reg = data;
181 uint alt_status_base;
184 for(i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
185 hw->io_ports[i] = reg++;
187 if (data == lopec_ide_regbase[0]) {
188 alt_status_base = lopec_ide_ctl_regbase[0] + 2;
191 else if (data == lopec_ide_regbase[1]) {
192 alt_status_base = lopec_ide_ctl_regbase[1] + 2;
201 hw->io_ports[IDE_CONTROL_OFFSET] = ctl;
203 hw->io_ports[IDE_CONTROL_OFFSET] = alt_status_base;
209 #endif /* BLK_DEV_IDE */
216 OpenPIC_InitSenses = lopec_openpic_initsenses;
217 OpenPIC_NumInitSenses = sizeof(lopec_openpic_initsenses);
220 * We need to tell openpic_set_sources where things actually are.
221 * mpc10x_common will setup OpenPIC_Addr at ioremap(EUMB phys base +
222 * EPIC offset (0x40000)); The EPIC IRQ Register Address Map -
223 * Interrupt Source Configuration Registers gives these numbers
224 * as offsets starting at 0x50200, we need to adjust occordinly.
226 /* Map serial interrupts 0-15 */
227 openpic_set_sources(0, 16, OpenPIC_Addr + 0x10200);
228 /* Skip reserved space and map i2c and DMA Ch[01] */
229 openpic_set_sources(16, 3, OpenPIC_Addr + 0x11020);
230 /* Skip reserved space and map Message Unit Interrupt (I2O) */
231 openpic_set_sources(19, 1, OpenPIC_Addr + 0x110C0);
233 openpic_init(NUM_8259_INTERRUPTS);
234 /* We have a cascade on OpenPIC IRQ 0, Linux IRQ 16 */
235 openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
238 /* Map i8259 interrupts */
239 for(i = 0; i < NUM_8259_INTERRUPTS; i++)
240 irq_desc[i].handler = &i8259_pic;
251 request_region(0x00, 0x20, "dma1");
252 request_region(0x20, 0x20, "pic1");
253 request_region(0x40, 0x20, "timer");
254 request_region(0x80, 0x10, "dma page reg");
255 request_region(0xa0, 0x20, "pic2");
256 request_region(0xc0, 0x20, "dma2");
262 io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
263 io_block_mapping(0xb0000000, 0xb0000000, 0x10000000, _PAGE_IO);
269 unsigned long batu, batl;
271 __asm__ __volatile__(
279 : "=r" (batu), "=r" (batl));
282 static unsigned long __init
283 lopec_find_end_of_memory(void)
285 return boot_mem_size;
292 lopec_early_serial_map(void)
294 struct serial_struct serial_req;
296 memset(&serial_req, 0, sizeof(serial_req));
298 /* Setup ioremapped serial port access */
300 serial_req.baud_base = BASE_BAUD;
301 serial_req.irq = UART0_INT;
302 serial_req.flags = ASYNC_BOOT_AUTOCONF;
303 serial_req.io_type = SERIAL_IO_MEM;
304 serial_req.iomem_base = ioremap(UART0_PORT, 8);
306 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
307 /* Configure debug serial access */
308 gen550_init(0, &serial_req);
311 if (early_serial_setup(&serial_req) != 0)
312 printk("Early serial init of port 0 failed\n");
314 /* Assume early_serial_setup() doesn't modify serial_req */
317 serial_req.irq = UART1_INT;
318 serial_req.iomem_base = ioremap(UART1_PORT, 8);
320 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
321 /* Configure debug serial access */
322 gen550_init(1, &serial_req);
325 if (early_serial_setup(&serial_req) != 0)
326 printk("Early serial init of port 1 failed\n");
330 serial_req.irq = UART2_INT;
331 serial_req.iomem_base = ioremap(UART2_PORT, 8);
333 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
334 /* Configure debug serial access */
335 gen550_init(2, &serial_req);
338 if (early_serial_setup(&serial_req) != 0)
339 printk("Early serial init of port 2 failed\n");
344 lopec_setup_arch(void)
347 TODC_INIT(TODC_TYPE_MK48T37, 0, 0,
348 ioremap(0xffe80000, 0x8000), 8);
350 loops_per_jiffy = 100000000/HZ;
352 lopec_find_bridges();
354 #ifdef CONFIG_BLK_DEV_INITRD
356 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
358 #elif defined(CONFIG_ROOT_NFS)
359 ROOT_DEV = to_kdev_t(0x00ff);
360 #elif defined(CONFIG_BLK_DEV_IDE)
361 ROOT_DEV = to_kdev_t(0x0301);
363 ROOT_DEV = to_kdev_t(0x0801);
366 #ifdef CONFIG_DUMMY_CONSOLE
367 conswitchp = &dummy_con;
371 lopec_early_serial_map();
374 #ifdef CONFIG_PPCBUG_NVRAM
375 /* Read in NVRAM data */
378 /* if no bootargs, look in NVRAM */
379 if ( cmd_line[0] == '\0' ) {
381 bootargs = prep_nvram_get_var("bootargs");
382 if (bootargs != NULL) {
383 strcpy(cmd_line, bootargs);
385 strcpy(saved_command_line, cmd_line);
392 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
393 unsigned long r6, unsigned long r7)
395 parse_bootinfo(find_bootinfo());
398 isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
399 isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
400 pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
401 ISA_DMA_THRESHOLD = 0x00ffffff;
402 DMA_MODE_READ = 0x44;
403 DMA_MODE_WRITE = 0x48;
405 ppc_md.setup_arch = lopec_setup_arch;
406 ppc_md.show_cpuinfo = lopec_show_cpuinfo;
407 ppc_md.irq_cannonicalize = lopec_irq_cannonicalize;
408 ppc_md.init_IRQ = lopec_init_IRQ;
409 ppc_md.get_irq = openpic_get_irq;
410 ppc_md.init = lopec_init2;
412 ppc_md.restart = lopec_restart;
413 ppc_md.power_off = lopec_power_off;
414 ppc_md.halt = lopec_halt;
416 ppc_md.find_end_of_memory = lopec_find_end_of_memory;
417 ppc_md.setup_io_mappings = lopec_map_io;
420 ppc_md.kbd_setkeycode = pckbd_setkeycode;
421 ppc_md.kbd_getkeycode = pckbd_getkeycode;
422 ppc_md.kbd_translate = pckbd_translate;
423 ppc_md.kbd_unexpected_up = pckbd_unexpected_up;
424 #ifdef CONFIG_MAGIC_SYSRQ
425 ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate;
427 #endif /* CONFIG_MAGIC_SYSRQ */
428 #endif /* CONFIG_VT */
430 ppc_md.time_init = todc_time_init;
431 ppc_md.set_rtc_time = todc_set_rtc_time;
432 ppc_md.get_rtc_time = todc_get_rtc_time;
433 ppc_md.calibrate_decr = todc_calibrate_decr;
435 ppc_md.nvram_read_val = todc_direct_read_val;
436 ppc_md.nvram_write_val = todc_direct_write_val;
438 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_ID_MODULE)
439 ppc_ide_md.default_irq = lopec_ide_default_irq;
440 ppc_ide_md.default_io_base = lopec_ide_default_io_base;
441 ppc_ide_md.ide_init_hwif = lopec_ide_init_hwif_ports;
444 #ifdef CONFIG_SERIAL_TEXT_DEBUG
445 ppc_md.progress = gen550_progress;
447 ppc_md.early_serial_map = lopec_early_serial_map;