blob: 4f9ea121002389cdbd5ce874017efbc0e40d12af [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 Baechlec4ed38a2005-02-21 16:18:36 +000071 "PCI memory", GT64111_MEM_BASE, GT64111_MEM_END, IORESOURCE_MEM
Linus Torvalds1da177e2005-04-16 15:20:36 -070072};
73
74static struct resource cobalt_io_resource = {
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000075 "PCI I/O", 0x1000, 0xffff, IORESOURCE_IO
Linus Torvalds1da177e2005-04-16 15:20:36 -070076};
77
78static struct resource cobalt_io_resources[] = {
79 { "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
80 { "timer", 0x40, 0x5f, IORESOURCE_BUSY },
81 { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY },
82 { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
83 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
84};
85
86#define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
87
88static struct pci_controller cobalt_pci_controller = {
89 .pci_ops = &gt64111_pci_ops,
90 .mem_resource = &cobalt_mem_resource,
91 .mem_offset = 0,
92 .io_resource = &cobalt_io_resource,
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000093 .io_offset = 0 - GT64111_IO_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -070094};
95
Ralf Baechlec83cfc92005-06-21 13:56:30 +000096void __init plat_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +000098 static struct uart_port uart;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
100 int i;
101
102 _machine_restart = cobalt_machine_restart;
103 _machine_halt = cobalt_machine_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +0000104 pm_power_off = cobalt_machine_power_off;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106 board_timer_setup = cobalt_timer_setup;
107
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000108 set_io_port_base(CKSEG1ADDR(GT64111_IO_BASE));
109
110 /* I/O port resource must include UART and LCD/buttons */
111 ioport_resource.end = 0x0fffffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 /* request I/O space for devices used on all i[345]86 PCs */
114 for (i = 0; i < COBALT_IO_RESOURCES; i++)
115 request_resource(&ioport_resource, cobalt_io_resources + i);
116
117 /* Read the cobalt id register out of the PCI config space */
118 PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
119 cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS);
120 cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
121 cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
122
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000123 printk("Cobalt board ID: %d\n", cobalt_board_id);
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#ifdef CONFIG_PCI
126 register_pci_controller(&cobalt_pci_controller);
127#endif
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000128
129#ifdef CONFIG_SERIAL_8250
130 if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
131
Peter Hortone87ddde2006-02-12 17:10:25 +0000132#ifdef CONFIG_EARLY_PRINTK
133 cobalt_early_console();
134#endif
135
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000136 uart.line = 0;
137 uart.type = PORT_UNKNOWN;
138 uart.uartclk = 18432000;
139 uart.irq = COBALT_SERIAL_IRQ;
Russell King59a675b2006-02-05 10:52:29 +0000140 uart.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000141 uart.iobase = 0xc800000;
142 uart.iotype = UPIO_PORT;
143
144 early_serial_setup(&uart);
145 }
146#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147}
148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149/*
150 * Prom init. We read our one and only communication with the firmware.
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000151 * Grab the amount of installed memory.
152 * Better boot loaders (CoLo) pass a command line too :-)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 */
154
155void __init prom_init(void)
156{
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000157 int narg, indx, posn, nchr;
158 unsigned long memsz;
159 char **argv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161 mips_machgroup = MACH_GROUP_COBALT;
162
Ralf Baechlec4ed38a2005-02-21 16:18:36 +0000163 memsz = fw_arg0 & 0x7fff0000;
164 narg = fw_arg0 & 0x0000ffff;
165
166 if (narg) {
167 arcs_cmdline[0] = '\0';
168 argv = (char **) fw_arg1;
169 posn = 0;
170 for (indx = 1; indx < narg; ++indx) {
171 nchr = strlen(argv[indx]);
172 if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
173 break;
174 if (posn)
175 arcs_cmdline[posn++] = ' ';
176 strcpy(arcs_cmdline + posn, argv[indx]);
177 posn += nchr;
178 }
179 }
180
181 add_memory_region(0x0, memsz, BOOT_MEM_RAM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182}
183
184unsigned long __init prom_free_prom_memory(void)
185{
186 /* Nothing to do! */
187 return 0;
188}