Path: blob/master/arch/sh/drivers/pci/pci-dreamcast.c
10819 views
/*1* PCI support for the Sega Dreamcast2*3* Copyright (C) 2001, 2002 M. R. Brown4* Copyright (C) 2002, 2003 Paul Mundt5*6* This file originally bore the message (with enclosed-$):7* Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp8* Dreamcast PCI: Supports SEGA Broadband Adaptor only.9*10* This file is subject to the terms and conditions of the GNU General Public11* License. See the file "COPYING" in the main directory of this archive12* for more details.13*/1415#include <linux/sched.h>16#include <linux/kernel.h>17#include <linux/param.h>18#include <linux/interrupt.h>19#include <linux/init.h>20#include <linux/irq.h>21#include <linux/pci.h>22#include <linux/module.h>23#include <asm/io.h>24#include <asm/irq.h>25#include <mach/pci.h>2627static struct resource gapspci_resources[] = {28{29.name = "GAPSPCI IO",30.start = GAPSPCI_BBA_CONFIG,31.end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,32.flags = IORESOURCE_IO,33}, {34.name = "GAPSPCI mem",35.start = GAPSPCI_DMA_BASE,36.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,37.flags = IORESOURCE_MEM,38},39};4041static struct pci_channel dreamcast_pci_controller = {42.pci_ops = &gapspci_pci_ops,43.resources = gapspci_resources,44.nr_resources = ARRAY_SIZE(gapspci_resources),45.io_offset = 0x00000000,46.mem_offset = 0x00000000,47};4849/*50* gapspci init51*/5253static int __init gapspci_init(void)54{55char idbuf[16];56int i;5758/*59* FIXME: All of this wants documenting to some degree,60* even some basic register definitions would be nice.61*62* I haven't seen anything this ugly since.. maple.63*/6465for (i=0; i<16; i++)66idbuf[i] = inb(GAPSPCI_REGS+i);6768if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))69return -ENODEV;7071outl(0x5a14a501, GAPSPCI_REGS+0x18);7273for (i=0; i<1000000; i++)74cpu_relax();7576if (inl(GAPSPCI_REGS+0x18) != 1)77return -EINVAL;7879outl(0x01000000, GAPSPCI_REGS+0x20);80outl(0x01000000, GAPSPCI_REGS+0x24);8182outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);83outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);8485outl(1, GAPSPCI_REGS+0x14);86outl(1, GAPSPCI_REGS+0x34);8788/* Setting Broadband Adapter */89outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);90outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);91outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);92outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);93outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);94outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);95outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);9697return register_pci_controller(&dreamcast_pci_controller);98}99arch_initcall(gapspci_init);100101102