aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh')
-rw-r--r--arch/sh/drivers/pci/Makefile3
-rw-r--r--arch/sh/drivers/pci/ops-dreamcast.c98
-rw-r--r--arch/sh/drivers/pci/pci-dreamcast.c105
-rw-r--r--arch/sh/include/mach-dreamcast/mach/pci.h2
4 files changed, 119 insertions, 89 deletions
diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 4cac866d55d4..2160a06b6c11 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -12,7 +12,8 @@ obj-$(CONFIG_CPU_SUBTYPE_SH7780) += pci-sh7780.o ops-sh4.o
12obj-$(CONFIG_CPU_SUBTYPE_SH7785) += pci-sh7780.o ops-sh4.o 12obj-$(CONFIG_CPU_SUBTYPE_SH7785) += pci-sh7780.o ops-sh4.o
13obj-$(CONFIG_CPU_SH5) += pci-sh5.o ops-sh5.o 13obj-$(CONFIG_CPU_SH5) += pci-sh5.o ops-sh5.o
14 14
15obj-$(CONFIG_SH_DREAMCAST) += ops-dreamcast.o fixups-dreamcast.o 15obj-$(CONFIG_SH_DREAMCAST) += ops-dreamcast.o fixups-dreamcast.o \
16 pci-dreamcast.o
16obj-$(CONFIG_SH_SECUREEDGE5410) += ops-snapgear.o 17obj-$(CONFIG_SH_SECUREEDGE5410) += ops-snapgear.o
17obj-$(CONFIG_SH_RTS7751R2D) += ops-rts7751r2d.o fixups-rts7751r2d.o 18obj-$(CONFIG_SH_RTS7751R2D) += ops-rts7751r2d.o fixups-rts7751r2d.o
18obj-$(CONFIG_SH_SH03) += ops-sh03.o fixups-sh03.o 19obj-$(CONFIG_SH_SH03) += ops-sh03.o fixups-sh03.o
diff --git a/arch/sh/drivers/pci/ops-dreamcast.c b/arch/sh/drivers/pci/ops-dreamcast.c
index 529aa4f27a89..e83d0d3aabe2 100644
--- a/arch/sh/drivers/pci/ops-dreamcast.c
+++ b/arch/sh/drivers/pci/ops-dreamcast.c
@@ -1,15 +1,9 @@
1/* 1/*
2 * arch/sh/drivers/pci/ops-dreamcast.c
3 *
4 * PCI operations for the Sega Dreamcast 2 * PCI operations for the Sega Dreamcast
5 * 3 *
6 * Copyright (C) 2001, 2002 M. R. Brown 4 * Copyright (C) 2001, 2002 M. R. Brown
7 * Copyright (C) 2002, 2003 Paul Mundt 5 * Copyright (C) 2002, 2003 Paul Mundt
8 * 6 *
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.
12 *
13 * This file is subject to the terms and conditions of the GNU General Public 7 * 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 8 * License. See the file "COPYING" in the main directory of this archive
15 * for more details. 9 * for more details.
@@ -23,25 +17,10 @@
23#include <linux/irq.h> 17#include <linux/irq.h>
24#include <linux/pci.h> 18#include <linux/pci.h>
25#include <linux/module.h> 19#include <linux/module.h>
26 20#include <linux/io.h>
27#include <asm/io.h> 21#include <linux/irq.h>
28#include <asm/irq.h>
29#include <mach/pci.h> 22#include <mach/pci.h>
30 23
31static struct resource gapspci_io_resource = {
32 .name = "GAPSPCI IO",
33 .start = GAPSPCI_BBA_CONFIG,
34 .end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,
35 .flags = IORESOURCE_IO,
36};
37
38static struct resource gapspci_mem_resource = {
39 .name = "GAPSPCI mem",
40 .start = GAPSPCI_DMA_BASE,
41 .end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,
42 .flags = IORESOURCE_MEM,
43};
44
45/* 24/*
46 * The !gapspci_config_access case really shouldn't happen, ever, unless 25 * The !gapspci_config_access case really shouldn't happen, ever, unless
47 * someone implicitly messes around with the last devfn value.. otherwise we 26 * someone implicitly messes around with the last devfn value.. otherwise we
@@ -76,10 +55,10 @@ static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int
76 return PCIBIOS_DEVICE_NOT_FOUND; 55 return PCIBIOS_DEVICE_NOT_FOUND;
77 56
78 switch (size) { 57 switch (size) {
79 case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break; 58 case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break;
80 case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break; 59 case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break;
81 case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break; 60 case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break;
82 } 61 }
83 62
84 return PCIBIOS_SUCCESSFUL; 63 return PCIBIOS_SUCCESSFUL;
85} 64}
@@ -90,72 +69,15 @@ static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int
90 return PCIBIOS_DEVICE_NOT_FOUND; 69 return PCIBIOS_DEVICE_NOT_FOUND;
91 70
92 switch (size) { 71 switch (size) {
93 case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break; 72 case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
94 case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break; 73 case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
95 case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break; 74 case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
96 } 75 }
97 76
98 return PCIBIOS_SUCCESSFUL; 77 return PCIBIOS_SUCCESSFUL;
99} 78}
100 79
101static struct pci_ops gapspci_pci_ops = { 80struct pci_ops gapspci_pci_ops = {
102 .read = gapspci_read, 81 .read = gapspci_read,
103 .write = gapspci_write, 82 .write = gapspci_write,
104}; 83};
105
106/*
107 * gapspci init
108 */
109
110static int __init gapspci_init(struct pci_channel *chan)
111{
112 char idbuf[16];
113 int i;
114
115 /*
116 * FIXME: All of this wants documenting to some degree,
117 * even some basic register definitions would be nice.
118 *
119 * I haven't seen anything this ugly since.. maple.
120 */
121
122 for (i=0; i<16; i++)
123 idbuf[i] = inb(GAPSPCI_REGS+i);
124
125 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
126 return -ENODEV;
127
128 outl(0x5a14a501, GAPSPCI_REGS+0x18);
129
130 for (i=0; i<1000000; i++)
131 ;
132
133 if (inl(GAPSPCI_REGS+0x18) != 1)
134 return -EINVAL;
135
136 outl(0x01000000, GAPSPCI_REGS+0x20);
137 outl(0x01000000, GAPSPCI_REGS+0x24);
138
139 outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
140 outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
141
142 outl(1, GAPSPCI_REGS+0x14);
143 outl(1, GAPSPCI_REGS+0x34);
144
145 /* Setting Broadband Adapter */
146 outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
147 outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
148 outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
149 outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
150 outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
151 outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
152 outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
153
154 return 0;
155}
156
157struct pci_channel board_pci_channels[] = {
158 { gapspci_init, &gapspci_pci_ops, &gapspci_io_resource,
159 &gapspci_mem_resource, 0, 1 },
160 { 0, }
161};
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};
diff --git a/arch/sh/include/mach-dreamcast/mach/pci.h b/arch/sh/include/mach-dreamcast/mach/pci.h
index 75fc9009e092..0314d975e626 100644
--- a/arch/sh/include/mach-dreamcast/mach/pci.h
+++ b/arch/sh/include/mach-dreamcast/mach/pci.h
@@ -21,5 +21,7 @@
21 21
22#define GAPSPCI_IRQ HW_EVENT_EXTERNAL 22#define GAPSPCI_IRQ HW_EVENT_EXTERNAL
23 23
24extern struct pci_ops gapspci_pci_ops;
25
24#endif /* __ASM_SH_DREAMCAST_PCI_H */ 26#endif /* __ASM_SH_DREAMCAST_PCI_H */
25 27