fixups-dreamcast.c 2.4 KB

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