Path: blob/master/arch/sh/drivers/pci/fixups-dreamcast.c
26481 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/drivers/pci/fixups-dreamcast.c3*4* PCI fixups for the Sega Dreamcast5*6* Copyright (C) 2001, 2002 M. R. Brown7* Copyright (C) 2002, 2003, 2006 Paul Mundt8*9* This file originally bore the message (with enclosed-$):10* Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp11* Dreamcast PCI: Supports SEGA Broadband Adaptor only.12*/1314#include <linux/sched.h>15#include <linux/kernel.h>16#include <linux/param.h>17#include <linux/interrupt.h>18#include <linux/init.h>19#include <linux/irq.h>20#include <linux/pci.h>21#include <linux/dma-map-ops.h>2223#include <asm/io.h>24#include <asm/irq.h>25#include <mach/pci.h>2627static void gapspci_fixup_resources(struct pci_dev *dev)28{29struct pci_channel *p = dev->sysdata;30struct resource res;31struct pci_bus_region region;3233printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));3435switch (dev->device) {36case PCI_DEVICE_ID_SEGA_BBA:37/*38* We also assume that dev->devfn == 039*/40dev->resource[1].start = p->resources[0].start + 0x100;41dev->resource[1].end = dev->resource[1].start + 0x200 - 1;4243/*44* This is not a normal BAR, prevent any attempts to move45* the BAR, as this will result in a bus lock.46*/47dev->resource[1].flags |= IORESOURCE_PCI_FIXED;4849/*50* Redirect dma memory allocations to special memory window.51*52* If this GAPSPCI region were mapped by a BAR, the CPU53* phys_addr_t would be pci_resource_start(), and the bus54* address would be pci_bus_address(pci_resource_start()).55* But apparently there's no BAR mapping it, so we just56* "know" its CPU address is GAPSPCI_DMA_BASE.57*/58res.start = GAPSPCI_DMA_BASE;59res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;60res.flags = IORESOURCE_MEM;61pcibios_resource_to_bus(dev->bus, ®ion, &res);62BUG_ON(dma_declare_coherent_memory(&dev->dev,63res.start,64region.start,65resource_size(&res)));66break;67default:68printk("PCI: Failed resource fixup\n");69}70}71DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources);7273int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)74{75/*76* The interrupt routing semantics here are quite trivial.77*78* We basically only support one interrupt, so we only bother79* updating a device's interrupt line with this single shared80* interrupt. Keeps routing quite simple, doesn't it?81*/82return GAPSPCI_IRQ;83}848586