fixups-dreamcast.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * arch/sh/drivers/pci/fixups-dreamcast.c
  3. *
  4. * PCI fixups for the Sega Dreamcast
  5. *
  6. * Copyright (C) 2001, 2002 M. R. Brown
  7. * Copyright (C) 2002, 2003, 2006 Paul Mundt
  8. *
  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. #include <linux/sched.h>
  18. #include <linux/kernel.h>
  19. #include <linux/param.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/init.h>
  22. #include <linux/irq.h>
  23. #include <linux/pci.h>
  24. #include <linux/dma-mapping.h>
  25. #include <asm/io.h>
  26. #include <asm/irq.h>
  27. #include <mach/pci.h>
  28. static void gapspci_fixup_resources(struct pci_dev *dev)
  29. {
  30. struct pci_channel *p = dev->sysdata;
  31. struct resource res;
  32. struct pci_bus_region region;
  33. printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));
  34. switch (dev->device) {
  35. case PCI_DEVICE_ID_SEGA_BBA:
  36. /*
  37. * We also assume that dev->devfn == 0
  38. */
  39. dev->resource[1].start = p->resources[0].start + 0x100;
  40. dev->resource[1].end = dev->resource[1].start + 0x200 - 1;
  41. /*
  42. * This is not a normal BAR, prevent any attempts to move
  43. * the BAR, as this will result in a bus lock.
  44. */
  45. dev->resource[1].flags |= IORESOURCE_PCI_FIXED;
  46. /*
  47. * Redirect dma memory allocations to special memory window.
  48. *
  49. * If this GAPSPCI region were mapped by a BAR, the CPU
  50. * phys_addr_t would be pci_resource_start(), and the bus
  51. * address would be pci_bus_address(pci_resource_start()).
  52. * But apparently there's no BAR mapping it, so we just
  53. * "know" its CPU address is GAPSPCI_DMA_BASE.
  54. */
  55. res.start = GAPSPCI_DMA_BASE;
  56. res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
  57. res.flags = IORESOURCE_MEM;
  58. pcibios_resource_to_bus(dev->bus, &region, &res);
  59. BUG_ON(!dma_declare_coherent_memory(&dev->dev,
  60. res.start,
  61. region.start,
  62. resource_size(&res),
  63. DMA_MEMORY_MAP |
  64. DMA_MEMORY_EXCLUSIVE));
  65. break;
  66. default:
  67. printk("PCI: Failed resource fixup\n");
  68. }
  69. }
  70. DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources);
  71. int __init pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  72. {
  73. /*
  74. * The interrupt routing semantics here are quite trivial.
  75. *
  76. * We basically only support one interrupt, so we only bother
  77. * updating a device's interrupt line with this single shared
  78. * interrupt. Keeps routing quite simple, doesn't it?
  79. */
  80. return GAPSPCI_IRQ;
  81. }