Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / sh / drivers / pci / ops-dreamcast.c
blob4c673d75e3222bb9f9044f0367d5425ff3628aa1
1 /*
2 * arch/sh/drivers/pci/ops-dreamcast.c
4 * PCI operations for the Sega Dreamcast
6 * Copyright (C) 2001, 2002 M. R. Brown
7 * Copyright (C) 2002, 2003 Paul Mundt
9 * This file originally bore the message (with enclosed-$):
10 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
11 * Dreamcast PCI: Supports SEGA Broadband Adaptor only.
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/param.h>
21 #include <linux/interrupt.h>
22 #include <linux/init.h>
23 #include <linux/irq.h>
24 #include <linux/pci.h>
26 #include <asm/io.h>
27 #include <asm/irq.h>
28 #include <asm/mach/pci.h>
30 static struct resource gapspci_io_resource = {
31 .name = "GAPSPCI IO",
32 .start = GAPSPCI_BBA_CONFIG,
33 .end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,
34 .flags = IORESOURCE_IO,
37 static struct resource gapspci_mem_resource = {
38 .name = "GAPSPCI mem",
39 .start = GAPSPCI_DMA_BASE,
40 .end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,
41 .flags = IORESOURCE_MEM,
44 static struct pci_ops gapspci_pci_ops;
46 struct pci_channel board_pci_channels[] = {
47 { &gapspci_pci_ops, &gapspci_io_resource,
48 &gapspci_mem_resource, 0, 1 },
49 { 0, }
53 * The !gapspci_config_access case really shouldn't happen, ever, unless
54 * someone implicitly messes around with the last devfn value.. otherwise we
55 * only support a single device anyways, and if we didn't have a BBA, we
56 * wouldn't make it terribly far through the PCI setup anyways.
58 * Also, we could very easily support both Type 0 and Type 1 configurations
59 * here, but since it doesn't seem that there is any such implementation in
60 * existence, we don't bother.
62 * I suppose if someone actually gets around to ripping the chip out of
63 * the BBA and hanging some more devices off of it, then this might be
64 * something to take into consideration. However, due to the cost of the BBA,
65 * and the general lack of activity by DC hardware hackers, this doesn't seem
66 * likely to happen anytime soon.
68 static int gapspci_config_access(unsigned char bus, unsigned int devfn)
70 return (bus == 0) && (devfn == 0);
74 * We can also actually read and write in b/w/l sizes! Thankfully this part
75 * was at least done right, and we don't have to do the stupid masking and
76 * shifting that we do on the 7751! Small wonders never cease to amaze.
78 static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
80 *val = 0xffffffff;
82 if (!gapspci_config_access(bus->number, devfn))
83 return PCIBIOS_DEVICE_NOT_FOUND;
85 switch (size) {
86 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
87 case 1: *val = ctrl_inb(GAPSPCI_BBA_CONFIG+where); break;
88 case 2: *val = ctrl_inw(GAPSPCI_BBA_CONFIG+where); break;
89 case 4: *val = ctrl_inl(GAPSPCI_BBA_CONFIG+where); break;
90 =======
91 case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break;
92 case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break;
93 case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break;
94 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
97 return PCIBIOS_SUCCESSFUL;
100 static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
102 if (!gapspci_config_access(bus->number, devfn))
103 return PCIBIOS_DEVICE_NOT_FOUND;
105 switch (size) {
106 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
107 case 1: ctrl_outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
108 case 2: ctrl_outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
109 case 4: ctrl_outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
110 =======
111 case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
112 case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
113 case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
114 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
117 return PCIBIOS_SUCCESSFUL;
120 static struct pci_ops gapspci_pci_ops = {
121 .read = gapspci_read,
122 .write = gapspci_write,
126 * gapspci init
129 int __init gapspci_init(void)
131 char idbuf[16];
132 int i;
135 * FIXME: All of this wants documenting to some degree,
136 * even some basic register definitions would be nice.
138 * I haven't seen anything this ugly since.. maple.
141 for (i=0; i<16; i++)
142 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
143 idbuf[i] = ctrl_inb(GAPSPCI_REGS+i);
144 =======
145 idbuf[i] = inb(GAPSPCI_REGS+i);
146 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
148 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
149 return -ENODEV;
151 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
152 ctrl_outl(0x5a14a501, GAPSPCI_REGS+0x18);
153 =======
154 outl(0x5a14a501, GAPSPCI_REGS+0x18);
155 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
157 for (i=0; i<1000000; i++)
160 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
161 if (ctrl_inl(GAPSPCI_REGS+0x18) != 1)
162 =======
163 if (inl(GAPSPCI_REGS+0x18) != 1)
164 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
165 return -EINVAL;
167 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
168 ctrl_outl(0x01000000, GAPSPCI_REGS+0x20);
169 ctrl_outl(0x01000000, GAPSPCI_REGS+0x24);
170 =======
171 outl(0x01000000, GAPSPCI_REGS+0x20);
172 outl(0x01000000, GAPSPCI_REGS+0x24);
173 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
175 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
176 ctrl_outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
177 ctrl_outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
178 =======
179 outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
180 outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
181 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
183 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
184 ctrl_outl(1, GAPSPCI_REGS+0x14);
185 ctrl_outl(1, GAPSPCI_REGS+0x34);
186 =======
187 outl(1, GAPSPCI_REGS+0x14);
188 outl(1, GAPSPCI_REGS+0x34);
189 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
191 /* Setting Broadband Adapter */
192 <<<<<<< HEAD:arch/sh/drivers/pci/ops-dreamcast.c
193 ctrl_outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
194 ctrl_outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
195 ctrl_outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
196 ctrl_outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
197 ctrl_outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
198 ctrl_outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
199 ctrl_outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
200 =======
201 outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
202 outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
203 outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
204 outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
205 outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
206 outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
207 outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
208 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sh/drivers/pci/ops-dreamcast.c
210 return 0;
213 /* Haven't done anything here as yet */
214 char * __devinit pcibios_setup(char *str)
216 return str;