blob: ca719d6398bd81b06689288b233f13873d210e04 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Baechlefcdb27a2006-01-18 17:37:07 +00008 * Copyright (C) 1996, 1997, 2004, 05 by Ralf Baechle (ralf@linux-mips.org)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Baechlefcdb27a2006-01-18 17:37:07 +000016#include <linux/pm.h>
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000017#include <linux/serial.h>
18#include <linux/serial_core.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
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 Baechlec4ed38a2005-02-21 16:18:36 +000027#include <asm/serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Ralf Baechle11ed6d52006-01-18 23:26:43 +000029#include <asm/mach-cobalt/cobalt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31extern void cobalt_machine_restart(char *command);
32extern void cobalt_machine_halt(void);
33extern void cobalt_machine_power_off(void);
Peter Hortone87ddde2006-02-12 17:10:25 +000034extern void cobalt_early_console(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36int cobalt_board_id;
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038const char *get_system_type(void)
39{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000040 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 Torvalds1da177e2005-04-16 15:20:36 -070050 return "MIPS Cobalt";
51}
52
53static void __init cobalt_timer_setup(struct irqaction *irq)
54{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000055 /* Load timer value for 1KHz (TCLK is 50MHz) */
56 GALILEO_OUTL(50*1000*1000 / 1000, GT_TC0_OFS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000058 /* Enable timer */
59 GALILEO_OUTL(GALILEO_ENTC0 | GALILEO_SELTC0, GT_TC_CONTROL_OFS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000061 /* 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 Torvalds1da177e2005-04-16 15:20:36 -070066}
67
68extern struct pci_ops gt64111_pci_ops;
69
70static struct resource cobalt_mem_resource = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -070071 .start = GT64111_MEM_BASE,
72 .end = GT64111_MEM_END,
73 .name = "PCI memory",
74 .flags = IORESOURCE_MEM
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
77static struct resource cobalt_io_resource = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -070078 .start = 0x1000,
79 .end = 0xffff,
80 .name = "PCI I/O",
81 .flags = IORESOURCE_IO
Linus Torvalds1da177e2005-04-16 15:20:36 -070082};
83
84static struct resource cobalt_io_resources[] = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -070085 {
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 Torvalds1da177e2005-04-16 15:20:36 -0700111};
112
113#define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
114
115static struct pci_controller cobalt_pci_controller = {
116 .pci_ops = &gt64111_pci_ops,
117 .mem_resource = &cobalt_mem_resource,
118 .mem_offset = 0,
119 .io_resource = &cobalt_io_resource,
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000120 .io_offset = 0 - GT64111_IO_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121};
122
Ralf Baechle2925aba2006-06-18 01:32:22 +0100123void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000125 static struct uart_port uart;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 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 Baechlefcdb27a2006-01-18 17:37:07 +0000131 pm_power_off = cobalt_machine_power_off;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 board_timer_setup = cobalt_timer_setup;
134
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000135 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 Torvalds1da177e2005-04-16 15:20:36 -0700139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 /* 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 Baechlec4ed38a2005-02-21 16:18:36 +0000150 printk("Cobalt board ID: %d\n", cobalt_board_id);
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#ifdef CONFIG_PCI
153 register_pci_controller(&cobalt_pci_controller);
154#endif
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000155
156#ifdef CONFIG_SERIAL_8250
157 if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
158
Peter Hortone87ddde2006-02-12 17:10:25 +0000159#ifdef CONFIG_EARLY_PRINTK
160 cobalt_early_console();
161#endif
162
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000163 uart.line = 0;
164 uart.type = PORT_UNKNOWN;
165 uart.uartclk = 18432000;
166 uart.irq = COBALT_SERIAL_IRQ;
Russell King59a675b2006-02-05 10:52:29 +0000167 uart.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000168 uart.iobase = 0xc800000;
169 uart.iotype = UPIO_PORT;
170
171 early_serial_setup(&uart);
172 }
173#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174}
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176/*
177 * Prom init. We read our one and only communication with the firmware.
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000178 * Grab the amount of installed memory.
179 * Better boot loaders (CoLo) pass a command line too :-)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 */
181
182void __init prom_init(void)
183{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000184 int narg, indx, posn, nchr;
185 unsigned long memsz;
186 char **argv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
188 mips_machgroup = MACH_GROUP_COBALT;
189
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000190 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 Torvalds1da177e2005-04-16 15:20:36 -0700209}
210
211unsigned long __init prom_free_prom_memory(void)
212{
213 /* Nothing to do! */
214 return 0;
215}