1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * PCI support for the Sega Dreamcast 4 * 5 * Copyright (C) 2001, 2002 M. R. Brown 6 * Copyright (C) 2002, 2003 Paul Mundt 7 * 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. 11 */ 12 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> 21 #include <asm/io.h> 22 #include <asm/irq.h> 23 #include <mach/pci.h> 24 25 static struct resource gapspci_resources[] = { 26 { 27 .name = "GAPSPCI IO", 28 .start = GAPSPCI_BBA_CONFIG, 29 .end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1, 30 .flags = IORESOURCE_IO, 31 }, { 32 .name = "GAPSPCI mem", 33 .start = GAPSPCI_DMA_BASE, 34 .end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1, 35 .flags = IORESOURCE_MEM, 36 }, 37 }; 38 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, 45 }; 46 47 /* 48 * gapspci init 49 */ 50 51 static int __init gapspci_init(void) 52 { 53 char idbuf[16]; 54 int i; 55 56 /* 57 * FIXME: All of this wants documenting to some degree, 58 * even some basic register definitions would be nice. 59 * 60 * I haven't seen anything this ugly since.. maple. 61 */ 62 63 for (i=0; i<16; i++) 64 idbuf[i] = inb(GAPSPCI_REGS+i); 65 66 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16)) 67 return -ENODEV; 68 69 outl(0x5a14a501, GAPSPCI_REGS+0x18); 70 71 for (i=0; i<1000000; i++) 72 cpu_relax(); 73 74 if (inl(GAPSPCI_REGS+0x18) != 1) 75 return -EINVAL; 76 77 outl(0x01000000, GAPSPCI_REGS+0x20); 78 outl(0x01000000, GAPSPCI_REGS+0x24); 79 80 outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28); 81 outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c); 82 83 outl(1, GAPSPCI_REGS+0x14); 84 outl(1, GAPSPCI_REGS+0x34); 85 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); 94 95 return register_pci_controller(&dreamcast_pci_controller); 96 } 97 arch_initcall(gapspci_init); 98
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.