Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Setup pointers to hardware dependent routines. |
| 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file "COPYING" in the main directory of this archive |
| 6 | * for more details. |
| 7 | * |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 8 | * Copyright (C) 1996, 1997, 2004, 05 by Ralf Baechle (ralf@linux-mips.org) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv) |
| 10 | * |
| 11 | */ |
| 12 | #include <linux/config.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/pci.h> |
| 15 | #include <linux/init.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 16 | #include <linux/pm.h> |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 17 | #include <linux/serial.h> |
| 18 | #include <linux/serial_core.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #include <asm/bootinfo.h> |
| 21 | #include <asm/time.h> |
| 22 | #include <asm/io.h> |
| 23 | #include <asm/irq.h> |
| 24 | #include <asm/processor.h> |
| 25 | #include <asm/reboot.h> |
| 26 | #include <asm/gt64120.h> |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 27 | #include <asm/serial.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Ralf Baechle | 11ed6d5 | 2006-01-18 23:26:43 +0000 | [diff] [blame] | 29 | #include <asm/mach-cobalt/cobalt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | extern void cobalt_machine_restart(char *command); |
| 32 | extern void cobalt_machine_halt(void); |
| 33 | extern void cobalt_machine_power_off(void); |
Peter Horton | e87ddde | 2006-02-12 17:10:25 +0000 | [diff] [blame] | 34 | extern void cobalt_early_console(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
| 36 | int cobalt_board_id; |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | const char *get_system_type(void) |
| 39 | { |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 40 | switch (cobalt_board_id) { |
| 41 | case COBALT_BRD_ID_QUBE1: |
| 42 | return "Cobalt Qube"; |
| 43 | case COBALT_BRD_ID_RAQ1: |
| 44 | return "Cobalt RaQ"; |
| 45 | case COBALT_BRD_ID_QUBE2: |
| 46 | return "Cobalt Qube2"; |
| 47 | case COBALT_BRD_ID_RAQ2: |
| 48 | return "Cobalt RaQ2"; |
| 49 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | return "MIPS Cobalt"; |
| 51 | } |
| 52 | |
| 53 | static void __init cobalt_timer_setup(struct irqaction *irq) |
| 54 | { |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 55 | /* Load timer value for 1KHz (TCLK is 50MHz) */ |
| 56 | GALILEO_OUTL(50*1000*1000 / 1000, GT_TC0_OFS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 58 | /* Enable timer */ |
| 59 | GALILEO_OUTL(GALILEO_ENTC0 | GALILEO_SELTC0, GT_TC_CONTROL_OFS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 61 | /* Register interrupt */ |
| 62 | setup_irq(COBALT_GALILEO_IRQ, irq); |
| 63 | |
| 64 | /* Enable interrupt */ |
| 65 | GALILEO_OUTL(GALILEO_INTR_T0EXP | GALILEO_INL(GT_INTRMASK_OFS), GT_INTRMASK_OFS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | extern struct pci_ops gt64111_pci_ops; |
| 69 | |
| 70 | static struct resource cobalt_mem_resource = { |
Ralf Baechle | 5e46c3a | 2006-06-04 15:14:05 -0700 | [diff] [blame] | 71 | .start = GT64111_MEM_BASE, |
| 72 | .end = GT64111_MEM_END, |
| 73 | .name = "PCI memory", |
| 74 | .flags = IORESOURCE_MEM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static struct resource cobalt_io_resource = { |
Ralf Baechle | 5e46c3a | 2006-06-04 15:14:05 -0700 | [diff] [blame] | 78 | .start = 0x1000, |
| 79 | .end = 0xffff, |
| 80 | .name = "PCI I/O", |
| 81 | .flags = IORESOURCE_IO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | static struct resource cobalt_io_resources[] = { |
Ralf Baechle | 5e46c3a | 2006-06-04 15:14:05 -0700 | [diff] [blame] | 85 | { |
| 86 | .start = 0x00, |
| 87 | .end = 0x1f, |
| 88 | .name = "dma1", |
| 89 | .flags = IORESOURCE_BUSY |
| 90 | }, { |
| 91 | .start = 0x40, |
| 92 | .end = 0x5f, |
| 93 | .name = "timer", |
| 94 | .flags = IORESOURCE_BUSY |
| 95 | }, { |
| 96 | .start = 0x60, |
| 97 | .end = 0x6f, |
| 98 | .name = "keyboard", |
| 99 | .flags = IORESOURCE_BUSY |
| 100 | }, { |
| 101 | .start = 0x80, |
| 102 | .end = 0x8f, |
| 103 | .name = "dma page reg", |
| 104 | .flags = IORESOURCE_BUSY |
| 105 | }, { |
| 106 | .start = 0xc0, |
| 107 | .end = 0xdf, |
| 108 | .name = "dma2", |
| 109 | .flags = IORESOURCE_BUSY |
| 110 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | #define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource)) |
| 114 | |
| 115 | static struct pci_controller cobalt_pci_controller = { |
| 116 | .pci_ops = >64111_pci_ops, |
| 117 | .mem_resource = &cobalt_mem_resource, |
| 118 | .mem_offset = 0, |
| 119 | .io_resource = &cobalt_io_resource, |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 120 | .io_offset = 0 - GT64111_IO_BASE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | }; |
| 122 | |
Ralf Baechle | 2925aba | 2006-06-18 01:32:22 +0100 | [diff] [blame^] | 123 | void __init plat_mem_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | { |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 125 | static struct uart_port uart; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0); |
| 127 | int i; |
| 128 | |
| 129 | _machine_restart = cobalt_machine_restart; |
| 130 | _machine_halt = cobalt_machine_halt; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 131 | pm_power_off = cobalt_machine_power_off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | board_timer_setup = cobalt_timer_setup; |
| 134 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 135 | set_io_port_base(CKSEG1ADDR(GT64111_IO_BASE)); |
| 136 | |
| 137 | /* I/O port resource must include UART and LCD/buttons */ |
| 138 | ioport_resource.end = 0x0fffffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | /* request I/O space for devices used on all i[345]86 PCs */ |
| 141 | for (i = 0; i < COBALT_IO_RESOURCES; i++) |
| 142 | request_resource(&ioport_resource, cobalt_io_resources + i); |
| 143 | |
| 144 | /* Read the cobalt id register out of the PCI config space */ |
| 145 | PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3)); |
| 146 | cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS); |
| 147 | cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8); |
| 148 | cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id); |
| 149 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 150 | printk("Cobalt board ID: %d\n", cobalt_board_id); |
| 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | #ifdef CONFIG_PCI |
| 153 | register_pci_controller(&cobalt_pci_controller); |
| 154 | #endif |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 155 | |
| 156 | #ifdef CONFIG_SERIAL_8250 |
| 157 | if (cobalt_board_id > COBALT_BRD_ID_RAQ1) { |
| 158 | |
Peter Horton | e87ddde | 2006-02-12 17:10:25 +0000 | [diff] [blame] | 159 | #ifdef CONFIG_EARLY_PRINTK |
| 160 | cobalt_early_console(); |
| 161 | #endif |
| 162 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 163 | uart.line = 0; |
| 164 | uart.type = PORT_UNKNOWN; |
| 165 | uart.uartclk = 18432000; |
| 166 | uart.irq = COBALT_SERIAL_IRQ; |
Russell King | 59a675b | 2006-02-05 10:52:29 +0000 | [diff] [blame] | 167 | uart.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST; |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 168 | uart.iobase = 0xc800000; |
| 169 | uart.iotype = UPIO_PORT; |
| 170 | |
| 171 | early_serial_setup(&uart); |
| 172 | } |
| 173 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | /* |
| 177 | * Prom init. We read our one and only communication with the firmware. |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 178 | * Grab the amount of installed memory. |
| 179 | * Better boot loaders (CoLo) pass a command line too :-) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | */ |
| 181 | |
| 182 | void __init prom_init(void) |
| 183 | { |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 184 | int narg, indx, posn, nchr; |
| 185 | unsigned long memsz; |
| 186 | char **argv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
| 188 | mips_machgroup = MACH_GROUP_COBALT; |
| 189 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 190 | memsz = fw_arg0 & 0x7fff0000; |
| 191 | narg = fw_arg0 & 0x0000ffff; |
| 192 | |
| 193 | if (narg) { |
| 194 | arcs_cmdline[0] = '\0'; |
| 195 | argv = (char **) fw_arg1; |
| 196 | posn = 0; |
| 197 | for (indx = 1; indx < narg; ++indx) { |
| 198 | nchr = strlen(argv[indx]); |
| 199 | if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline)) |
| 200 | break; |
| 201 | if (posn) |
| 202 | arcs_cmdline[posn++] = ' '; |
| 203 | strcpy(arcs_cmdline + posn, argv[indx]); |
| 204 | posn += nchr; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | add_memory_region(0x0, memsz, BOOT_MEM_RAM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | unsigned long __init prom_free_prom_memory(void) |
| 212 | { |
| 213 | /* Nothing to do! */ |
| 214 | return 0; |
| 215 | } |