2 * arch/ppc/platforms/pplus_setup.c
4 * Board setup routines for MCG PowerPlus
6 * Author: Randy Vinson <rvinson@mvista.com>
8 * Derived from original PowerPlus PReP work by
9 * Cort Dougan, Johnnie Peters, Matt Porter, and
12 * Copyright 2001-2002 MontaVista Software Inc.
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/config.h>
25 #include <linux/delay.h>
26 #include <linux/module.h>
27 #include <linux/errno.h>
28 #include <linux/sched.h>
29 #include <linux/kernel.h>
31 #include <linux/stddef.h>
32 #include <linux/unistd.h>
33 #include <linux/ptrace.h>
34 #include <linux/slab.h>
35 #include <linux/user.h>
36 #include <linux/a.out.h>
37 #include <linux/tty.h>
38 #include <linux/major.h>
39 #include <linux/interrupt.h>
40 #include <linux/reboot.h>
41 #include <linux/init.h>
42 #include <linux/blk.h>
43 #include <linux/ioport.h>
44 #include <linux/console.h>
45 #include <linux/timex.h>
46 #include <linux/pci.h>
47 #include <linux/irq.h>
48 #include <linux/ide.h>
49 #include <linux/kdev_t.h>
50 #include <linux/seq_file.h>
51 #include <linux/serial.h>
52 #include <linux/serialP.h>
54 #include <asm/sections.h>
56 #include <asm/processor.h>
57 #include <asm/system.h>
58 #include <asm/residual.h>
60 #include <asm/pgtable.h>
61 #include <asm/cache.h>
63 #include <asm/machdep.h>
64 #include <asm/mk48t59.h>
65 #include <asm/prep_nvram.h>
66 #include <asm/raven.h>
67 #include <asm/keyboard.h>
71 #include <asm/i8259.h>
72 #include <asm/open_pic.h>
73 #include <asm/pplus.h>
75 #include <asm/bootinfo.h>
76 #include <asm/serial.h>
82 extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
83 extern int pckbd_getkeycode(unsigned int scancode);
84 extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
86 extern char pckbd_unexpected_up(unsigned char keycode);
87 extern void pckbd_leds(unsigned char leds);
88 extern void pckbd_init_hw(void);
89 extern unsigned char pckbd_sysrq_xlate[128];
91 extern char saved_command_line[];
93 extern void pplus_setup_hose(void);
94 extern void pplus_set_VIA_IDE_native(void);
96 extern unsigned long loops_per_jiffy;
98 extern void gen550_progress(char *, unsigned short);
99 extern void gen550_init(int, struct serial_struct *);
102 pplus_show_cpuinfo(struct seq_file *m)
104 extern char *Motherboard_map_name;
106 seq_printf(m, "vendor\t\t: Motorola MCG\n");
107 seq_printf(m, "machine\t\t: %s\n", Motherboard_map_name);
113 pplus_setup_arch(void)
117 if ( ppc_md.progress )
118 ppc_md.progress("pplus_setup_arch: enter", 0);
120 /* init to some ~sane value until calibrate_delay() runs */
121 loops_per_jiffy = 50000000;
123 if ( ppc_md.progress )
124 ppc_md.progress("pplus_setup_arch: find_bridges", 0);
126 /* Setup PCI host bridge */
129 /* Set up floppy in PS/2 mode */
130 outb(0x09, SIO_CONFIG_RA);
131 reg = inb(SIO_CONFIG_RD);
132 reg = (reg & 0x3F) | 0x40;
133 outb(reg, SIO_CONFIG_RD);
134 outb(reg, SIO_CONFIG_RD); /* Have to write twice to change! */
136 /* Enable L2. Assume we don't need to flush -- Cort*/
137 *(unsigned char *)(0x8000081c) |= 3;
139 #ifdef CONFIG_BLK_DEV_INITRD
141 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); /* /dev/ram */
144 #ifdef CONFIG_ROOT_NFS
145 ROOT_DEV = to_kdev_t(0x00ff); /* /dev/nfs */
147 ROOT_DEV = to_kdev_t(0x0802); /* /dev/sda2 */
150 printk(KERN_INFO "Motorola PowerPlus Platform\n");
151 printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
153 if ( ppc_md.progress )
154 ppc_md.progress("pplus_setup_arch: raven_init", 0);
158 #ifdef CONFIG_VGA_CONSOLE
159 /* remap the VGA memory */
160 vgacon_remap_base = 0xf0000000;
161 conswitchp = &vga_con;
162 #elif defined(CONFIG_DUMMY_CONSOLE)
163 conswitchp = &dummy_con;
165 #ifdef CONFIG_PPCBUG_NVRAM
166 /* Read in NVRAM data */
169 /* if no bootargs, look in NVRAM */
170 if ( cmd_line[0] == '\0' ) {
172 bootargs = prep_nvram_get_var("bootargs");
173 if (bootargs != NULL) {
174 strcpy(cmd_line, bootargs);
176 strcpy(saved_command_line, cmd_line);
180 if ( ppc_md.progress )
181 ppc_md.progress("pplus_setup_arch: exit", 0);
185 pplus_restart(char *cmd)
187 unsigned long i = 10000;
191 /* set VIA IDE controller into native mode */
192 pplus_set_VIA_IDE_native();
194 /* set exception prefix high - to the prom */
195 _nmask_and_or_msr(0, MSR_IP);
197 /* make sure bit 0 (reset) is a 0 */
198 outb( inb(0x92) & ~1L , 0x92 );
199 /* signal a reset to system control port A - soft reset */
200 outb( inb(0x92) | 1 , 0x92 );
202 while ( i != 0 ) i++;
203 panic("restart failed\n");
211 /* set exception prefix high - to the prom */
213 restore_flags( flags|MSR_IP );
215 /* make sure bit 0 (reset) is a 0 */
216 outb( inb(0x92) & ~1L , 0x92 );
217 /* signal a reset to system control port A - soft reset */
218 outb( inb(0x92) | 1 , 0x92 );
227 pplus_power_off(void)
233 pplus_irq_cannonicalize(u_int irq)
250 if (OpenPIC_Addr != NULL) {
251 openpic_set_sources(0, 16, OpenPIC_Addr+0x10000);
252 openpic_init(NUM_8259_INTERRUPTS);
253 openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
257 for ( i = 0 ; i < NUM_8259_INTERRUPTS ; i++ )
258 irq_desc[i].handler = &i8259_pic;
262 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
267 pplus_ide_default_irq(ide_ioreg_t base)
270 case 0x1f0: return 14;
271 case 0x170: return 15;
277 pplus_ide_default_io_base(int index)
280 case 0: return 0x1f0;
281 case 1: return 0x170;
288 pplus_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
290 ide_ioreg_t reg = data_port;
293 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
294 hw->io_ports[i] = reg;
298 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
300 hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
303 *irq = pplus_ide_default_irq(data_port);
308 /* PowerPlus (MTX) support */
310 smp_pplus_probe(void)
312 extern int mot_multi;
315 openpic_request_IPIs();
324 smp_pplus_kick_cpu(int nr)
326 *(unsigned long *)KERNELBASE = nr;
327 asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
328 printk("CPU1 reset, waiting\n");
332 smp_pplus_setup_cpu(int cpu_nr)
335 do_openpic_setup_cpu();
338 static struct smp_ops_t pplus_smp_ops = {
339 smp_openpic_message_pass,
344 #endif /* CONFIG_SMP */
347 static void print_dbat(int idx, u32 bat) {
351 sprintf(str, "DBAT%c%c = 0x%08x\n",
352 (char)((idx - DBAT0U) / 2) + '0',
353 (idx & 1) ? 'L' : 'U', bat);
354 ppc_md.progress(str, 0);
357 #define DUMP_DBAT(x) \
359 u32 __temp = mfspr(x);\
360 print_dbat(x, __temp); \
363 static void dump_dbats(void) {
365 if (ppc_md.progress) {
378 static unsigned long __init
379 pplus_find_end_of_memory(void)
384 ppc_md.progress("pplus_find_end_of_memory",0);
390 total = pplus_get_mem_size(0xfef80000);
397 io_block_mapping(0x80000000, 0x80000000, 0x10000000, _PAGE_IO);
398 io_block_mapping(0xf0000000, 0xc0000000, 0x08000000, _PAGE_IO);
405 request_region(PREP_NVRAM_AS0, 0x8, "nvram");
407 request_region(0x20,0x20,"pic1");
408 request_region(0xa0,0x20,"pic2");
409 request_region(0x00,0x20,"dma1");
410 request_region(0x40,0x20,"timer");
411 request_region(0x80,0x10,"dma page reg");
412 request_region(0xc0,0x20,"dma2");
416 * Set BAT 2 to access 0x8000000 so progress messages will work and set BAT 3
417 * to 0xf0000000 to access Falcon/Raven or Hawk registers
419 static __inline__ void
422 static int mapping_set = 0;
426 /* wait for all outstanding memory accesses to complete */
430 mtspr(DBAT2U, 0x80001ffe);
431 mtspr(DBAT2L, 0x8000002a);
432 mtspr(DBAT3U, 0xf0001ffe);
433 mtspr(DBAT3L, 0xf000002a);
435 /* wait for updates */
444 #if defined(CONFIG_SERIAL) && \
445 (defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB))
446 extern struct serial_state rs_table[];
449 pplus_early_serial_map(void)
451 struct serial_struct serial_req;
453 /* Setup serial port access */
454 memset(&serial_req, 0, sizeof(serial_req));
457 * rs_table[] already set up by <asm/pc_serial.h> so use that info for
458 * gen550_init(). This also means early_serial_setup() doesn't
461 serial_req.port = rs_table[0].port;
462 serial_req.io_type = rs_table[0].io_type;
463 serial_req.iomem_reg_shift = rs_table[0].iomem_reg_shift;
464 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
465 gen550_init(0, &serial_req);
468 serial_req.port = rs_table[1].port;
469 serial_req.io_type = rs_table[1].io_type;
470 serial_req.iomem_reg_shift = rs_table[1].iomem_reg_shift;
471 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
472 gen550_init(1, &serial_req);
478 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
479 unsigned long r6, unsigned long r7)
481 parse_bootinfo(find_bootinfo());
483 /* Map in board regs, etc. */
486 isa_io_base = PREP_ISA_IO_BASE;
487 isa_mem_base = PREP_ISA_MEM_BASE;
488 pci_dram_offset = PREP_PCI_DRAM_OFFSET;
489 ISA_DMA_THRESHOLD = 0x00ffffff;
490 DMA_MODE_READ = 0x44;
491 DMA_MODE_WRITE = 0x48;
493 ppc_md.setup_arch = pplus_setup_arch;
494 ppc_md.show_percpuinfo = NULL;
495 ppc_md.show_cpuinfo = pplus_show_cpuinfo;
496 ppc_md.irq_cannonicalize = pplus_irq_cannonicalize;
497 ppc_md.init_IRQ = pplus_init_IRQ;
498 /* this gets changed later on if we have an OpenPIC -- Cort */
499 ppc_md.get_irq = i8259_irq;
500 ppc_md.init = pplus_init2;
502 ppc_md.restart = pplus_restart;
503 ppc_md.power_off = pplus_power_off;
504 ppc_md.halt = pplus_halt;
506 TODC_INIT(TODC_TYPE_MK48T59, PREP_NVRAM_AS0, PREP_NVRAM_AS1,
509 ppc_md.time_init = todc_time_init;
510 ppc_md.set_rtc_time = todc_set_rtc_time;
511 ppc_md.get_rtc_time = todc_get_rtc_time;
512 ppc_md.calibrate_decr = todc_calibrate_decr;
513 ppc_md.nvram_read_val = todc_m48txx_read_val;
514 ppc_md.nvram_write_val = todc_m48txx_write_val;
516 ppc_md.find_end_of_memory = pplus_find_end_of_memory;
517 ppc_md.setup_io_mappings = pplus_map_io;
519 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
520 ppc_ide_md.default_irq = pplus_ide_default_irq;
521 ppc_ide_md.default_io_base = pplus_ide_default_io_base;
522 ppc_ide_md.ide_init_hwif = pplus_ide_init_hwif_ports;
526 ppc_md.kbd_setkeycode = pckbd_setkeycode;
527 ppc_md.kbd_getkeycode = pckbd_getkeycode;
528 ppc_md.kbd_translate = pckbd_translate;
529 ppc_md.kbd_unexpected_up = pckbd_unexpected_up;
530 ppc_md.kbd_leds = pckbd_leds;
531 ppc_md.kbd_init_hw = pckbd_init_hw;
532 #ifdef CONFIG_MAGIC_SYSRQ
533 ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate;
538 #if defined(CONFIG_SERIAL) && \
539 (defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB))
540 pplus_early_serial_map();
542 #ifdef CONFIG_SERIAL_TEXT_DEBUG
543 ppc_md.progress = gen550_progress;
544 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
548 ppc_md.smp_ops = &pplus_smp_ops;
549 #endif /* CONFIG_SMP */