pci-dreamcast.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_io_resource = {
  27. .name = "GAPSPCI IO",
  28. .start = GAPSPCI_BBA_CONFIG,
  29. .end = GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,
  30. .flags = IORESOURCE_IO,
  31. };
  32. static struct resource gapspci_mem_resource = {
  33. .name = "GAPSPCI mem",
  34. .start = GAPSPCI_DMA_BASE,
  35. .end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,
  36. .flags = IORESOURCE_MEM,
  37. };
  38. static struct pci_channel dreamcast_pci_controller = {
  39. .pci_ops = &gapspci_pci_ops,
  40. .io_resource = &gapspci_io_resource,
  41. .io_offset = 0x00000000,
  42. .mem_resource = &gapspci_mem_resource,
  43. .mem_offset = 0x00000000,
  44. };
  45. /*
  46. * gapspci init
  47. */
  48. static int __init gapspci_init(void)
  49. {
  50. char idbuf[16];
  51. int i;
  52. /*
  53. * FIXME: All of this wants documenting to some degree,
  54. * even some basic register definitions would be nice.
  55. *
  56. * I haven't seen anything this ugly since.. maple.
  57. */
  58. for (i=0; i<16; i++)
  59. idbuf[i] = inb(GAPSPCI_REGS+i);
  60. if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
  61. return -ENODEV;
  62. outl(0x5a14a501, GAPSPCI_REGS+0x18);
  63. for (i=0; i<1000000; i++)
  64. cpu_relax();
  65. if (inl(GAPSPCI_REGS+0x18) != 1)
  66. return -EINVAL;
  67. outl(0x01000000, GAPSPCI_REGS+0x20);
  68. outl(0x01000000, GAPSPCI_REGS+0x24);
  69. outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
  70. outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
  71. outl(1, GAPSPCI_REGS+0x14);
  72. outl(1, GAPSPCI_REGS+0x34);
  73. /* Setting Broadband Adapter */
  74. outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
  75. outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
  76. outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
  77. outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
  78. outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
  79. outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
  80. outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
  81. register_pci_controller(&dreamcast_pci_controller);
  82. return 0;
  83. }
  84. arch_initcall(gapspci_init);