pci-dreamcast.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /*
  39. * gapspci init
  40. */
  41. static int __init gapspci_init(struct pci_channel *chan)
  42. {
  43. char idbuf[16];
  44. int i;
  45. /*
  46. * FIXME: All of this wants documenting to some degree,
  47. * even some basic register definitions would be nice.
  48. *
  49. * I haven't seen anything this ugly since.. maple.
  50. */
  51. for (i=0; i<16; i++)
  52. idbuf[i] = inb(GAPSPCI_REGS+i);
  53. if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
  54. return -ENODEV;
  55. outl(0x5a14a501, GAPSPCI_REGS+0x18);
  56. for (i=0; i<1000000; i++)
  57. cpu_relax();
  58. if (inl(GAPSPCI_REGS+0x18) != 1)
  59. return -EINVAL;
  60. outl(0x01000000, GAPSPCI_REGS+0x20);
  61. outl(0x01000000, GAPSPCI_REGS+0x24);
  62. outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
  63. outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
  64. outl(1, GAPSPCI_REGS+0x14);
  65. outl(1, GAPSPCI_REGS+0x34);
  66. /* Setting Broadband Adapter */
  67. outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
  68. outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
  69. outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
  70. outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
  71. outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
  72. outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
  73. outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
  74. return 0;
  75. }
  76. struct pci_channel board_pci_channels[] = {
  77. {
  78. .init = gapspci_init,
  79. .pci_ops = &gapspci_pci_ops,
  80. .io_resource = &gapspci_io_resource,
  81. .mem_resource = &gapspci_mem_resource,
  82. .first_devfn = 0,
  83. .last_devfn = 1,
  84. }, {
  85. .init = NULL,
  86. }
  87. };