2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2006-10-04 04:01:26 +07:00
|
|
|
* arch/sh/drivers/pci/fixups-dreamcast.c
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* PCI fixups for the Sega Dreamcast
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001, 2002 M. R. Brown
|
2006-09-27 14:43:28 +07:00
|
|
|
* Copyright (C) 2002, 2003, 2006 Paul Mundt
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* This file originally bore the message (with enclosed-$):
|
|
|
|
* Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
|
|
|
|
* Dreamcast PCI: Supports SEGA Broadband Adaptor only.
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/param.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/pci.h>
|
2008-01-24 16:40:50 +07:00
|
|
|
#include <linux/dma-mapping.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/irq.h>
|
2008-07-29 06:09:44 +07:00
|
|
|
#include <mach/pci.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-12-22 05:06:37 +07:00
|
|
|
static void gapspci_fixup_resources(struct pci_dev *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-04-20 19:34:36 +07:00
|
|
|
struct pci_channel *p = dev->sysdata;
|
2014-05-21 05:54:23 +07:00
|
|
|
struct resource res;
|
|
|
|
struct pci_bus_region region;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));
|
|
|
|
|
|
|
|
switch (dev->device) {
|
|
|
|
case PCI_DEVICE_ID_SEGA_BBA:
|
|
|
|
/*
|
|
|
|
* We also assume that dev->devfn == 0
|
|
|
|
*/
|
2010-02-01 18:01:50 +07:00
|
|
|
dev->resource[1].start = p->resources[0].start + 0x100;
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->resource[1].end = dev->resource[1].start + 0x200 - 1;
|
2009-04-20 17:31:20 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is not a normal BAR, prevent any attempts to move
|
|
|
|
* the BAR, as this will result in a bus lock.
|
|
|
|
*/
|
|
|
|
dev->resource[1].flags |= IORESOURCE_PCI_FIXED;
|
|
|
|
|
2008-01-24 16:40:50 +07:00
|
|
|
/*
|
|
|
|
* Redirect dma memory allocations to special memory window.
|
2014-05-21 05:54:23 +07:00
|
|
|
*
|
|
|
|
* If this GAPSPCI region were mapped by a BAR, the CPU
|
|
|
|
* phys_addr_t would be pci_resource_start(), and the bus
|
|
|
|
* address would be pci_bus_address(pci_resource_start()).
|
|
|
|
* But apparently there's no BAR mapping it, so we just
|
|
|
|
* "know" its CPU address is GAPSPCI_DMA_BASE.
|
2008-01-24 16:40:50 +07:00
|
|
|
*/
|
2014-05-21 05:54:23 +07:00
|
|
|
res.start = GAPSPCI_DMA_BASE;
|
|
|
|
res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
|
|
|
|
res.flags = IORESOURCE_MEM;
|
|
|
|
pcibios_resource_to_bus(dev->bus, ®ion, &res);
|
2017-08-25 22:13:09 +07:00
|
|
|
BUG_ON(dma_declare_coherent_memory(&dev->dev,
|
2014-05-21 05:54:23 +07:00
|
|
|
res.start,
|
|
|
|
region.start,
|
|
|
|
resource_size(&res),
|
2008-01-24 16:40:50 +07:00
|
|
|
DMA_MEMORY_EXCLUSIVE));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk("PCI: Failed resource fixup\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources);
|
|
|
|
|
2017-07-31 23:37:49 +07:00
|
|
|
int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2006-09-27 14:43:28 +07:00
|
|
|
/*
|
|
|
|
* The interrupt routing semantics here are quite trivial.
|
|
|
|
*
|
|
|
|
* We basically only support one interrupt, so we only bother
|
|
|
|
* updating a device's interrupt line with this single shared
|
|
|
|
* interrupt. Keeps routing quite simple, doesn't it?
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2006-09-27 14:43:28 +07:00
|
|
|
return GAPSPCI_IRQ;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|