Path: blob/master/arch/sh/drivers/pci/ops-dreamcast.c
10819 views
/*1* PCI operations for the Sega Dreamcast2*3* Copyright (C) 2001, 2002 M. R. Brown4* Copyright (C) 2002, 2003 Paul Mundt5*6* This file is subject to the terms and conditions of the GNU General Public7* License. See the file "COPYING" in the main directory of this archive8* for more details.9*/1011#include <linux/sched.h>12#include <linux/kernel.h>13#include <linux/param.h>14#include <linux/interrupt.h>15#include <linux/init.h>16#include <linux/irq.h>17#include <linux/pci.h>18#include <linux/module.h>19#include <linux/io.h>20#include <mach/pci.h>2122/*23* The !gapspci_config_access case really shouldn't happen, ever, unless24* someone implicitly messes around with the last devfn value.. otherwise we25* only support a single device anyways, and if we didn't have a BBA, we26* wouldn't make it terribly far through the PCI setup anyways.27*28* Also, we could very easily support both Type 0 and Type 1 configurations29* here, but since it doesn't seem that there is any such implementation in30* existence, we don't bother.31*32* I suppose if someone actually gets around to ripping the chip out of33* the BBA and hanging some more devices off of it, then this might be34* something to take into consideration. However, due to the cost of the BBA,35* and the general lack of activity by DC hardware hackers, this doesn't seem36* likely to happen anytime soon.37*/38static int gapspci_config_access(unsigned char bus, unsigned int devfn)39{40return (bus == 0) && (devfn == 0);41}4243/*44* We can also actually read and write in b/w/l sizes! Thankfully this part45* was at least done right, and we don't have to do the stupid masking and46* shifting that we do on the 7751! Small wonders never cease to amaze.47*/48static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)49{50*val = 0xffffffff;5152if (!gapspci_config_access(bus->number, devfn))53return PCIBIOS_DEVICE_NOT_FOUND;5455switch (size) {56case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break;57case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break;58case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break;59}6061return PCIBIOS_SUCCESSFUL;62}6364static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)65{66if (!gapspci_config_access(bus->number, devfn))67return PCIBIOS_DEVICE_NOT_FOUND;6869switch (size) {70case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;71case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;72case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;73}7475return PCIBIOS_SUCCESSFUL;76}7778struct pci_ops gapspci_pci_ops = {79.read = gapspci_read,80.write = gapspci_write,81};828384