blob: 1d1c5a227e509e50e865011b7e9912c8db109196 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * arch/sh/drivers/pci/fixups-dreamcast.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * PCI fixups for the Sega Dreamcast
5 *
6 * Copyright (C) 2001, 2002 M. R. Brown
Paul Mundt959f85f2006-09-27 16:43:28 +09007 * Copyright (C) 2002, 2003, 2006 Paul Mundt
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * This file originally bore the message (with enclosed-$):
10 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
11 * Dreamcast PCI: Supports SEGA Broadband Adaptor only.
12 *
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
16 */
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/sched.h>
19#include <linux/kernel.h>
20#include <linux/param.h>
21#include <linux/interrupt.h>
22#include <linux/init.h>
23#include <linux/irq.h>
24#include <linux/pci.h>
Magnus Damma7246052008-01-24 18:40:50 +090025#include <linux/dma-mapping.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27#include <asm/io.h>
28#include <asm/irq.h>
Paul Mundtf15cbe62008-07-29 08:09:44 +090029#include <mach/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Greg Kroah-Hartmanb881bc42012-12-21 14:06:37 -080031static void gapspci_fixup_resources(struct pci_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
Paul Mundt951a6812009-04-20 21:34:36 +090033 struct pci_channel *p = dev->sysdata;
Bjorn Helgaasace4b3f2014-05-20 16:54:23 -060034 struct resource res;
35 struct pci_bus_region region;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37 printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));
38
39 switch (dev->device) {
40 case PCI_DEVICE_ID_SEGA_BBA:
41 /*
42 * We also assume that dev->devfn == 0
43 */
Paul Mundtb6c58b12010-02-01 20:01:50 +090044 dev->resource[1].start = p->resources[0].start + 0x100;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 dev->resource[1].end = dev->resource[1].start + 0x200 - 1;
Paul Mundtd556fcc2009-04-20 19:31:20 +090046
47 /*
48 * This is not a normal BAR, prevent any attempts to move
49 * the BAR, as this will result in a bus lock.
50 */
51 dev->resource[1].flags |= IORESOURCE_PCI_FIXED;
52
Magnus Damma7246052008-01-24 18:40:50 +090053 /*
54 * Redirect dma memory allocations to special memory window.
Bjorn Helgaasace4b3f2014-05-20 16:54:23 -060055 *
56 * If this GAPSPCI region were mapped by a BAR, the CPU
57 * phys_addr_t would be pci_resource_start(), and the bus
58 * address would be pci_bus_address(pci_resource_start()).
59 * But apparently there's no BAR mapping it, so we just
60 * "know" its CPU address is GAPSPCI_DMA_BASE.
Magnus Damma7246052008-01-24 18:40:50 +090061 */
Bjorn Helgaasace4b3f2014-05-20 16:54:23 -060062 res.start = GAPSPCI_DMA_BASE;
63 res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
64 res.flags = IORESOURCE_MEM;
65 pcibios_resource_to_bus(dev->bus, &region, &res);
Magnus Damma7246052008-01-24 18:40:50 +090066 BUG_ON(!dma_declare_coherent_memory(&dev->dev,
Bjorn Helgaasace4b3f2014-05-20 16:54:23 -060067 res.start,
68 region.start,
69 resource_size(&res),
Magnus Damma7246052008-01-24 18:40:50 +090070 DMA_MEMORY_MAP |
71 DMA_MEMORY_EXCLUSIVE));
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 break;
73 default:
74 printk("PCI: Failed resource fixup\n");
75 }
76}
Linus Torvalds1da177e2005-04-16 15:20:36 -070077DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources);
78
Ralf Baechled5341942011-06-10 15:30:21 +010079int __init pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
Paul Mundt959f85f2006-09-27 16:43:28 +090081 /*
82 * The interrupt routing semantics here are quite trivial.
83 *
84 * We basically only support one interrupt, so we only bother
85 * updating a device's interrupt line with this single shared
86 * interrupt. Keeps routing quite simple, doesn't it?
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 */
Paul Mundt959f85f2006-09-27 16:43:28 +090088 return GAPSPCI_IRQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}