blob: 050685b87a3ca1cc3d7eb2973c5c0f97c727b7a6 [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);
34
35int cobalt_board_id;
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037const char *get_system_type(void)
38{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000039 switch (cobalt_board_id) {
40 case COBALT_BRD_ID_QUBE1:
41 return "Cobalt Qube";
42 case COBALT_BRD_ID_RAQ1:
43 return "Cobalt RaQ";
44 case COBALT_BRD_ID_QUBE2:
45 return "Cobalt Qube2";
46 case COBALT_BRD_ID_RAQ2:
47 return "Cobalt RaQ2";
48 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 return "MIPS Cobalt";
50}
51
52static void __init cobalt_timer_setup(struct irqaction *irq)
53{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000054 /* Load timer value for 1KHz (TCLK is 50MHz) */
55 GALILEO_OUTL(50*1000*1000 / 1000, GT_TC0_OFS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000057 /* Enable timer */
58 GALILEO_OUTL(GALILEO_ENTC0 | GALILEO_SELTC0, GT_TC_CONTROL_OFS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000060 /* Register interrupt */
61 setup_irq(COBALT_GALILEO_IRQ, irq);
62
63 /* Enable interrupt */
64 GALILEO_OUTL(GALILEO_INTR_T0EXP | GALILEO_INL(GT_INTRMASK_OFS), GT_INTRMASK_OFS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
67extern struct pci_ops gt64111_pci_ops;
68
69static struct resource cobalt_mem_resource = {
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000070 "PCI memory", GT64111_MEM_BASE, GT64111_MEM_END, IORESOURCE_MEM
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
73static struct resource cobalt_io_resource = {
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000074 "PCI I/O", 0x1000, 0xffff, IORESOURCE_IO
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
77static struct resource cobalt_io_resources[] = {
78 { "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
79 { "timer", 0x40, 0x5f, IORESOURCE_BUSY },
80 { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY },
81 { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
82 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
83};
84
85#define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
86
87static struct pci_controller cobalt_pci_controller = {
88 .pci_ops = &gt64111_pci_ops,
89 .mem_resource = &cobalt_mem_resource,
90 .mem_offset = 0,
91 .io_resource = &cobalt_io_resource,
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000092 .io_offset = 0 - GT64111_IO_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -070093};
94
Ralf Baechlec83cfc92005-06-21 13:56:30 +000095void __init plat_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000097 static struct uart_port uart;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
99 int i;
100
101 _machine_restart = cobalt_machine_restart;
102 _machine_halt = cobalt_machine_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +0000103 pm_power_off = cobalt_machine_power_off;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 board_timer_setup = cobalt_timer_setup;
106
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000107 set_io_port_base(CKSEG1ADDR(GT64111_IO_BASE));
108
109 /* I/O port resource must include UART and LCD/buttons */
110 ioport_resource.end = 0x0fffffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112 /*
113 * This is a prom style console. We just poke at the
114 * UART to make it talk.
115 * Only use this console if you really screw up and can't
116 * get to the stage of setting up a real serial console.
117 */
118 /*ns16550_setup_console();*/
119
120 /* request I/O space for devices used on all i[345]86 PCs */
121 for (i = 0; i < COBALT_IO_RESOURCES; i++)
122 request_resource(&ioport_resource, cobalt_io_resources + i);
123
124 /* Read the cobalt id register out of the PCI config space */
125 PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
126 cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS);
127 cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
128 cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
129
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000130 printk("Cobalt board ID: %d\n", cobalt_board_id);
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132#ifdef CONFIG_PCI
133 register_pci_controller(&cobalt_pci_controller);
134#endif
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000135
136#ifdef CONFIG_SERIAL_8250
137 if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
138
139 uart.line = 0;
140 uart.type = PORT_UNKNOWN;
141 uart.uartclk = 18432000;
142 uart.irq = COBALT_SERIAL_IRQ;
143 uart.flags = STD_COM_FLAGS;
144 uart.iobase = 0xc800000;
145 uart.iotype = UPIO_PORT;
146
147 early_serial_setup(&uart);
148 }
149#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150}
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152/*
153 * Prom init. We read our one and only communication with the firmware.
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000154 * Grab the amount of installed memory.
155 * Better boot loaders (CoLo) pass a command line too :-)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 */
157
158void __init prom_init(void)
159{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000160 int narg, indx, posn, nchr;
161 unsigned long memsz;
162 char **argv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164 mips_machgroup = MACH_GROUP_COBALT;
165
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000166 memsz = fw_arg0 & 0x7fff0000;
167 narg = fw_arg0 & 0x0000ffff;
168
169 if (narg) {
170 arcs_cmdline[0] = '\0';
171 argv = (char **) fw_arg1;
172 posn = 0;
173 for (indx = 1; indx < narg; ++indx) {
174 nchr = strlen(argv[indx]);
175 if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
176 break;
177 if (posn)
178 arcs_cmdline[posn++] = ' ';
179 strcpy(arcs_cmdline + posn, argv[indx]);
180 posn += nchr;
181 }
182 }
183
184 add_memory_region(0x0, memsz, BOOT_MEM_RAM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185}
186
187unsigned long __init prom_free_prom_memory(void)
188{
189 /* Nothing to do! */
190 return 0;
191}