1 // SPDX-License-Identifier: GPL-2.0
3 * PCI support for the Sega Dreamcast
5 * Copyright (C) 2001, 2002 M. R. Brown
6 * Copyright (C) 2002, 2003 Paul Mundt
8 * This file originally bore the message (with enclosed-$):
9 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
10 * Dreamcast PCI: Supports SEGA Broadband Adaptor only.
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
15 #include <linux/param.h>
16 #include <linux/interrupt.h>
17 #include <linux/init.h>
18 #include <linux/irq.h>
19 #include <linux/pci.h>
20 #include <linux/module.h>
25 static struct resource gapspci_resources
[] = {
28 .start
= GAPSPCI_BBA_CONFIG
,
29 .end
= GAPSPCI_BBA_CONFIG
+ GAPSPCI_BBA_CONFIG_SIZE
- 1,
30 .flags
= IORESOURCE_IO
,
32 .name
= "GAPSPCI mem",
33 .start
= GAPSPCI_DMA_BASE
,
34 .end
= GAPSPCI_DMA_BASE
+ GAPSPCI_DMA_SIZE
- 1,
35 .flags
= IORESOURCE_MEM
,
39 static struct pci_channel dreamcast_pci_controller
= {
40 .pci_ops
= &gapspci_pci_ops
,
41 .resources
= gapspci_resources
,
42 .nr_resources
= ARRAY_SIZE(gapspci_resources
),
43 .io_offset
= 0x00000000,
44 .mem_offset
= 0x00000000,
51 static int __init
gapspci_init(void)
57 * FIXME: All of this wants documenting to some degree,
58 * even some basic register definitions would be nice.
60 * I haven't seen anything this ugly since.. maple.
64 idbuf
[i
] = inb(GAPSPCI_REGS
+i
);
66 if (strncmp(idbuf
, "GAPSPCI_BRIDGE_2", 16))
69 outl(0x5a14a501, GAPSPCI_REGS
+0x18);
71 for (i
=0; i
<1000000; i
++)
74 if (inl(GAPSPCI_REGS
+0x18) != 1)
77 outl(0x01000000, GAPSPCI_REGS
+0x20);
78 outl(0x01000000, GAPSPCI_REGS
+0x24);
80 outl(GAPSPCI_DMA_BASE
, GAPSPCI_REGS
+0x28);
81 outl(GAPSPCI_DMA_BASE
+GAPSPCI_DMA_SIZE
, GAPSPCI_REGS
+0x2c);
83 outl(1, GAPSPCI_REGS
+0x14);
84 outl(1, GAPSPCI_REGS
+0x34);
86 /* Setting Broadband Adapter */
87 outw(0xf900, GAPSPCI_BBA_CONFIG
+0x06);
88 outl(0x00000000, GAPSPCI_BBA_CONFIG
+0x30);
89 outb(0x00, GAPSPCI_BBA_CONFIG
+0x3c);
90 outb(0xf0, GAPSPCI_BBA_CONFIG
+0x0d);
91 outw(0x0006, GAPSPCI_BBA_CONFIG
+0x04);
92 outl(0x00002001, GAPSPCI_BBA_CONFIG
+0x10);
93 outl(0x01000000, GAPSPCI_BBA_CONFIG
+0x14);
95 return register_pci_controller(&dreamcast_pci_controller
);
97 arch_initcall(gapspci_init
);