ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / cobalt / setup.c
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  *
8  * Copyright (C) 1996, 1997 by Ralf Baechle
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>
16
17 #include <asm/bootinfo.h>
18 #include <asm/pci_channel.h>
19 #include <asm/time.h>
20 #include <asm/io.h>
21 #include <asm/irq.h>
22 #include <asm/processor.h>
23 #include <asm/reboot.h>
24 #include <asm/gt64120.h>
25
26 #include <asm/cobalt/cobalt.h>
27
28 extern void cobalt_machine_restart(char *command);
29 extern void cobalt_machine_halt(void);
30 extern void cobalt_machine_power_off(void);
31
32 int cobalt_board_id;
33
34 static char my_cmdline[CL_SIZE] = {
35  "console=ttyS0,115200 "
36 #ifdef CONFIG_IP_PNP
37  "ip=on "
38 #endif
39 #ifdef CONFIG_ROOT_NFS
40  "root=/dev/nfs "
41 #else
42  "root=/dev/hda1 "
43 #endif
44  };
45
46 const char *get_system_type(void)
47 {
48         return "MIPS Cobalt";
49 }
50
51 static void __init cobalt_timer_setup(struct irqaction *irq)
52 {
53         /* Load timer value for 150 Hz */
54         GALILEO_OUTL(500000, GT_TC0_OFS);
55
56         /* Register our timer interrupt */
57         setup_irq(COBALT_TIMER_IRQ, irq);
58
59         /* Enable timer ints */
60         GALILEO_OUTL((GALILEO_ENTC0 | GALILEO_SELTC0), GT_TC_CONTROL_OFS);
61         /* Unmask timer int */
62         GALILEO_OUTL(0x100, GT_INTRMASK_OFS);
63 }
64
65 extern struct pci_ops gt64111_pci_ops;
66
67 static struct resource cobalt_mem_resource = {
68         "GT64111 PCI MEM", GT64111_IO_BASE, 0xffffffffUL, IORESOURCE_MEM
69 };
70
71 static struct resource cobalt_io_resource = {
72         "GT64111 IO MEM", 0x00001000UL, 0x0fffffffUL, IORESOURCE_IO
73 };
74
75 static struct resource cobalt_io_resources[] = {
76         { "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
77         { "timer", 0x40, 0x5f, IORESOURCE_BUSY },
78         { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY },
79         { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
80         { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
81 };
82
83 #define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
84
85 static struct pci_controller cobalt_pci_controller = {
86         .pci_ops        = &gt64111_pci_ops,
87         .mem_resource   = &cobalt_mem_resource,
88         .mem_offset     = 0,
89         .io_resource    = &cobalt_io_resource,
90         .io_offset      = 0x00001000UL - GT64111_IO_BASE
91 };
92
93 static void __init cobalt_setup(void)
94 {
95         unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
96         int i;
97
98         _machine_restart = cobalt_machine_restart;
99         _machine_halt = cobalt_machine_halt;
100         _machine_power_off = cobalt_machine_power_off;
101
102         board_timer_setup = cobalt_timer_setup;
103
104         set_io_port_base(KSEG1ADDR(GT64111_IO_BASE));
105
106         /*
107          * This is a prom style console. We just poke at the
108          *  UART to make it talk.
109          * Only use this console if you really screw up and can't
110          *  get to the stage of setting up a real serial console.
111          */
112         /*ns16550_setup_console();*/
113
114         /* request I/O space for devices used on all i[345]86 PCs */
115         for (i = 0; i < COBALT_IO_RESOURCES; i++)
116                 request_resource(&ioport_resource, cobalt_io_resources + i);
117
118         /* Read the cobalt id register out of the PCI config space */
119         PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
120         cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS);
121         cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
122         cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
123
124 #ifdef CONFIG_PCI
125         register_pci_controller(&cobalt_pci_controller);
126 #endif
127 }
128
129 early_initcall(cobalt_setup);
130
131 /*
132  * Prom init. We read our one and only communication with the firmware.
133  * Grab the amount of installed memory
134  */
135
136 void __init prom_init(void)
137 {
138         int argc = fw_arg0;
139
140         strcpy(arcs_cmdline, my_cmdline);
141
142         mips_machgroup = MACH_GROUP_COBALT;
143
144         add_memory_region(0x0, argc & 0x7fffffff, BOOT_MEM_RAM);
145 }
146
147 unsigned long __init prom_free_prom_memory(void)
148 {
149         /* Nothing to do! */
150         return 0;
151 }