aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/pci/pci-dreamcast.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/drivers/pci/pci-dreamcast.c')
-rw-r--r--arch/sh/drivers/pci/pci-dreamcast.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/arch/sh/drivers/pci/pci-dreamcast.c b/arch/sh/drivers/pci/pci-dreamcast.c
new file mode 100644
index 000000000000..0897be5053d4
--- /dev/null
+++ b/arch/sh/drivers/pci/pci-dreamcast.c
@@ -0,0 +1,105 @@
1/*
2 * PCI support for the Sega Dreamcast
3 *
4 * Copyright (C) 2001, 2002 M. R. Brown
5 * Copyright (C) 2002, 2003 Paul Mundt
6 *
7 * This file originally bore the message (with enclosed-$):
8 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
9 * Dreamcast PCI: Supports SEGA Broadband Adaptor only.
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15
16#include <linux/sched.h>
17#include <linux/kernel.h>
18#include <linux/param.h>
19#include <linux/interrupt.h>
20#include <linux/init.h>
21#include <linux/irq.h>
22#include <linux/pci.h>
23#include <linux/module.h>
24
25#include <asm/io.h>
26#include <asm/irq.h>
27#include <mach/pci.h>
28
29static struct resource gapspci_io_resource = {
30 .name = "GAPSPCI IO",
31 .start = GAPSPCI_BBA_CONFIG,
32 .end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,
33 .flags = IORESOURCE_IO,
34};
35
36static struct resource gapspci_mem_resource = {
37 .name = "GAPSPCI mem",
38 .start = GAPSPCI_DMA_BASE,
39 .end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,
40 .flags = IORESOURCE_MEM,
41};
42
43/*
44 * gapspci init
45 */
46
47static int __init gapspci_init(struct pci_channel *chan)
48{
49 char idbuf[16];
50 int i;
51
52 /*
53 * FIXME: All of this wants documenting to some degree,
54 * even some basic register definitions would be nice.
55 *
56 * I haven't seen anything this ugly since.. maple.
57 */
58
59 for (i=0; i<16; i++)
60 idbuf[i] = inb(GAPSPCI_REGS+i);
61
62 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
63 return -ENODEV;
64
65 outl(0x5a14a501, GAPSPCI_REGS+0x18);
66
67 for (i=0; i<1000000; i++)
68 cpu_relax();
69
70 if (inl(GAPSPCI_REGS+0x18) != 1)
71 return -EINVAL;
72
73 outl(0x01000000, GAPSPCI_REGS+0x20);
74 outl(0x01000000, GAPSPCI_REGS+0x24);
75
76 outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
77 outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
78
79 outl(1, GAPSPCI_REGS+0x14);
80 outl(1, GAPSPCI_REGS+0x34);
81
82 /* Setting Broadband Adapter */
83 outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
84 outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
85 outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
86 outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
87 outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
88 outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
89 outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
90
91 return 0;
92}
93
94struct pci_channel board_pci_channels[] = {
95 {
96 .init = gapspci_init,
97 .pci_ops = &gapspci_pci_ops,
98 .io_resource = &gapspci_io_resource,
99 .mem_resource = &gapspci_mem_resource,
100 .first_devfn = 0,
101 .last_devfn = 1,
102 }, {
103 .init = NULL,
104 }
105};