pci-dreamcast.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * PCI support for the Sega Dreamcast
  3. *
  4. * Copyright (C) 2001, 2002 M. R. Brown
  5. * Copyright (C) 2002, 2003 Paul Mundt
  6. *
  7. * This file originally bore the message (with enclosed-$):
  8. * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
  9. * Dreamcast PCI: Supports SEGA Broadband Adaptor only.
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #include <linux/sched.h>
  16. #include <linux/kernel.h>
  17. #include <linux/param.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/init.h>
  20. #include <linux/irq.h>
  21. #include <linux/pci.h>
  22. #include <linux/module.h>
  23. #include <asm/io.h>
  24. #include <asm/irq.h>
  25. #include <mach/pci.h>
  26. static struct resource gapspci_resources[] = {
  27. {
  28. .name = "GAPSPCI IO",
  29. .start = GAPSPCI_BBA_CONFIG,
  30. .end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,
  31. .flags = IORESOURCE_IO,
  32. }, {
  33. .name = "GAPSPCI mem",
  34. .start = GAPSPCI_DMA_BASE,
  35. .end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,
  36. .flags = IORESOURCE_MEM,
  37. },
  38. };
  39. static struct pci_channel dreamcast_pci_controller = {
  40. .pci_ops = &gapspci_pci_ops,
  41. .resources = gapspci_resources,
  42. .nr_resources = ARRAY_SIZE(gapspci_resources),
  43. .io_offset = 0x00000000,
  44. .mem_offset = 0x00000000,
  45. };
  46. /*
  47. * gapspci init
  48. */
  49. static int __init gapspci_init(void)
  50. {
  51. char idbuf[16];
  52. int i;
  53. /*
  54. * FIXME: All of this wants documenting to some degree,
  55. * even some basic register definitions would be nice.
  56. *
  57. * I haven't seen anything this ugly since.. maple.
  58. */
  59. for (i=0; i<16; i++)
  60. idbuf[i] = inb(GAPSPCI_REGS+i);
  61. if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
  62. return -ENODEV;
  63. outl(0x5a14a501, GAPSPCI_REGS+0x18);
  64. for (i=0; i<1000000; i++)
  65. cpu_relax();
  66. if (inl(GAPSPCI_REGS+0x18) != 1)
  67. return -EINVAL;
  68. outl(0x01000000, GAPSPCI_REGS+0x20);
  69. outl(0x01000000, GAPSPCI_REGS+0x24);
  70. outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
  71. outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
  72. outl(1, GAPSPCI_REGS+0x14);
  73. outl(1, GAPSPCI_REGS+0x34);
  74. /* Setting Broadband Adapter */
  75. outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
  76. outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
  77. outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
  78. outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
  79. outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
  80. outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
  81. outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
  82. return register_pci_controller(&dreamcast_pci_controller);
  83. }
  84. arch_initcall(gapspci_init);