sc520_pci.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * (C) Copyright 2002
  3. * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /* stuff specific for the sc520, but independent of implementation */
  24. #include <common.h>
  25. #include <pci.h>
  26. #include <asm/pci.h>
  27. #include <asm/ic/sc520.h>
  28. static struct {
  29. u8 priority;
  30. u16 level_reg;
  31. u8 level_bit;
  32. } sc520_irq[] = {
  33. { SC520_IRQ0, 0, 0x01 },
  34. { SC520_IRQ1, 0, 0x02 },
  35. { SC520_IRQ2, 1, 0x02 },
  36. { SC520_IRQ3, 0, 0x08 },
  37. { SC520_IRQ4, 0, 0x10 },
  38. { SC520_IRQ5, 0, 0x20 },
  39. { SC520_IRQ6, 0, 0x40 },
  40. { SC520_IRQ7, 0, 0x80 },
  41. { SC520_IRQ8, 1, 0x01 },
  42. { SC520_IRQ9, 1, 0x02 },
  43. { SC520_IRQ10, 1, 0x04 },
  44. { SC520_IRQ11, 1, 0x08 },
  45. { SC520_IRQ12, 1, 0x10 },
  46. { SC520_IRQ13, 1, 0x20 },
  47. { SC520_IRQ14, 1, 0x40 },
  48. { SC520_IRQ15, 1, 0x80 }
  49. };
  50. /* The interrupt used for PCI INTA-INTD */
  51. int sc520_pci_ints[15] = {
  52. -1, -1, -1, -1, -1, -1, -1, -1,
  53. -1, -1, -1, -1, -1, -1, -1
  54. };
  55. /* utility function to configure a pci interrupt */
  56. int pci_sc520_set_irq(int pci_pin, int irq)
  57. {
  58. int i;
  59. # if 1
  60. printf("set_irq(): map INT%c to IRQ%d\n", pci_pin + 'A', irq);
  61. #endif
  62. if (irq < 0 || irq > 15) {
  63. return -1; /* illegal irq */
  64. }
  65. if (pci_pin < 0 || pci_pin > 15) {
  66. return -1; /* illegal pci int pin */
  67. }
  68. /* first disable any non-pci interrupt source that use
  69. * this level */
  70. /* PCI interrupt mapping (A through D)*/
  71. for (i=0; i<=3 ;i++) {
  72. if (sc520_mmcr->pci_int_map[i] == sc520_irq[irq].priority)
  73. sc520_mmcr->pci_int_map[i] = SC520_IRQ_DISABLED;
  74. }
  75. /* GP IRQ interrupt mapping */
  76. for (i=0; i<=10 ;i++) {
  77. if (sc520_mmcr->gp_int_map[i] == sc520_irq[irq].priority)
  78. sc520_mmcr->gp_int_map[i] = SC520_IRQ_DISABLED;
  79. }
  80. /* Set the trigger to level */
  81. sc520_mmcr->pic_mode[sc520_irq[irq].level_reg] =
  82. sc520_mmcr->pic_mode[sc520_irq[irq].level_reg] | sc520_irq[irq].level_bit;
  83. if (pci_pin < 4) {
  84. /* PCI INTA-INTD */
  85. /* route the interrupt */
  86. sc520_mmcr->pci_int_map[pci_pin] = sc520_irq[irq].priority;
  87. } else {
  88. /* GPIRQ0-GPIRQ10 used for additional PCI INTS */
  89. sc520_mmcr->gp_int_map[pci_pin - 4] = sc520_irq[irq].priority;
  90. /* also set the polarity in this case */
  91. sc520_mmcr->intpinpol = sc520_mmcr->intpinpol | (1 << (pci_pin-4));
  92. }
  93. /* register the pin */
  94. sc520_pci_ints[pci_pin] = irq;
  95. return 0; /* OK */
  96. }
  97. void pci_sc520_init(struct pci_controller *hose)
  98. {
  99. hose->first_busno = 0;
  100. hose->last_busno = 0xff;
  101. /* System memory space */
  102. pci_set_region(hose->regions + 0,
  103. SC520_PCI_MEMORY_BUS,
  104. SC520_PCI_MEMORY_PHYS,
  105. SC520_PCI_MEMORY_SIZE,
  106. PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
  107. /* PCI memory space */
  108. pci_set_region(hose->regions + 1,
  109. SC520_PCI_MEM_BUS,
  110. SC520_PCI_MEM_PHYS,
  111. SC520_PCI_MEM_SIZE,
  112. PCI_REGION_MEM);
  113. /* ISA/PCI memory space */
  114. pci_set_region(hose->regions + 2,
  115. SC520_ISA_MEM_BUS,
  116. SC520_ISA_MEM_PHYS,
  117. SC520_ISA_MEM_SIZE,
  118. PCI_REGION_MEM);
  119. /* PCI I/O space */
  120. pci_set_region(hose->regions + 3,
  121. SC520_PCI_IO_BUS,
  122. SC520_PCI_IO_PHYS,
  123. SC520_PCI_IO_SIZE,
  124. PCI_REGION_IO);
  125. /* ISA/PCI I/O space */
  126. pci_set_region(hose->regions + 4,
  127. SC520_ISA_IO_BUS,
  128. SC520_ISA_IO_PHYS,
  129. SC520_ISA_IO_SIZE,
  130. PCI_REGION_IO);
  131. hose->region_count = 5;
  132. pci_setup_type1(hose,
  133. SC520_REG_ADDR,
  134. SC520_REG_DATA);
  135. pci_register_hose(hose);
  136. hose->last_busno = pci_hose_scan(hose);
  137. /* enable target memory acceses on host brige */
  138. pci_write_config_word(0, PCI_COMMAND,
  139. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
  140. }