pci-ip32.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2000, 2001 Keith M Wesolowski
  7. * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/pci.h>
  13. #include <linux/types.h>
  14. #include <asm/ip32/mace.h>
  15. #include <asm/ip32/ip32_ints.h>
  16. #undef DEBUG_MACE_PCI
  17. /*
  18. * Handle errors from the bridge. This includes master and target aborts,
  19. * various command and address errors, and the interrupt test. This gets
  20. * registered on the bridge error irq. It's conceivable that some of these
  21. * conditions warrant a panic. Anybody care to say which ones?
  22. */
  23. static irqreturn_t macepci_error(int irq, void *dev)
  24. {
  25. char s;
  26. unsigned int flags = mace->pci.error;
  27. unsigned int addr = mace->pci.error_addr;
  28. if (flags & MACEPCI_ERROR_MEMORY_ADDR)
  29. s = 'M';
  30. else if (flags & MACEPCI_ERROR_CONFIG_ADDR)
  31. s = 'C';
  32. else
  33. s = 'X';
  34. if (flags & MACEPCI_ERROR_MASTER_ABORT) {
  35. printk("MACEPCI: Master abort at 0x%08x (%c)\n", addr, s);
  36. flags &= ~MACEPCI_ERROR_MASTER_ABORT;
  37. }
  38. if (flags & MACEPCI_ERROR_TARGET_ABORT) {
  39. printk("MACEPCI: Target abort at 0x%08x (%c)\n", addr, s);
  40. flags &= ~MACEPCI_ERROR_TARGET_ABORT;
  41. }
  42. if (flags & MACEPCI_ERROR_DATA_PARITY_ERR) {
  43. printk("MACEPCI: Data parity error at 0x%08x (%c)\n", addr, s);
  44. flags &= ~MACEPCI_ERROR_DATA_PARITY_ERR;
  45. }
  46. if (flags & MACEPCI_ERROR_RETRY_ERR) {
  47. printk("MACEPCI: Retry error at 0x%08x (%c)\n", addr, s);
  48. flags &= ~MACEPCI_ERROR_RETRY_ERR;
  49. }
  50. if (flags & MACEPCI_ERROR_ILLEGAL_CMD) {
  51. printk("MACEPCI: Illegal command at 0x%08x (%c)\n", addr, s);
  52. flags &= ~MACEPCI_ERROR_ILLEGAL_CMD;
  53. }
  54. if (flags & MACEPCI_ERROR_SYSTEM_ERR) {
  55. printk("MACEPCI: System error at 0x%08x (%c)\n", addr, s);
  56. flags &= ~MACEPCI_ERROR_SYSTEM_ERR;
  57. }
  58. if (flags & MACEPCI_ERROR_PARITY_ERR) {
  59. printk("MACEPCI: Parity error at 0x%08x (%c)\n", addr, s);
  60. flags &= ~MACEPCI_ERROR_PARITY_ERR;
  61. }
  62. if (flags & MACEPCI_ERROR_OVERRUN) {
  63. printk("MACEPCI: Overrun error at 0x%08x (%c)\n", addr, s);
  64. flags &= ~MACEPCI_ERROR_OVERRUN;
  65. }
  66. if (flags & MACEPCI_ERROR_SIG_TABORT) {
  67. printk("MACEPCI: Signaled target abort (clearing)\n");
  68. flags &= ~MACEPCI_ERROR_SIG_TABORT;
  69. }
  70. if (flags & MACEPCI_ERROR_INTERRUPT_TEST) {
  71. printk("MACEPCI: Interrupt test triggered (clearing)\n");
  72. flags &= ~MACEPCI_ERROR_INTERRUPT_TEST;
  73. }
  74. mace->pci.error = flags;
  75. return IRQ_HANDLED;
  76. }
  77. extern struct pci_ops mace_pci_ops;
  78. #ifdef CONFIG_64BIT
  79. static struct resource mace_pci_mem_resource = {
  80. .name = "SGI O2 PCI MEM",
  81. .start = MACEPCI_HI_MEMORY,
  82. .end = 0x2FFFFFFFFUL,
  83. .flags = IORESOURCE_MEM,
  84. };
  85. static struct resource mace_pci_io_resource = {
  86. .name = "SGI O2 PCI IO",
  87. .start = 0x00000000UL,
  88. .end = 0xffffffffUL,
  89. .flags = IORESOURCE_IO,
  90. };
  91. #define MACE_PCI_MEM_OFFSET 0x200000000
  92. #else
  93. static struct resource mace_pci_mem_resource = {
  94. .name = "SGI O2 PCI MEM",
  95. .start = MACEPCI_LOW_MEMORY,
  96. .end = MACEPCI_LOW_MEMORY + 0x2000000 - 1,
  97. .flags = IORESOURCE_MEM,
  98. };
  99. static struct resource mace_pci_io_resource = {
  100. .name = "SGI O2 PCI IO",
  101. .start = 0x00000000,
  102. .end = 0xFFFFFFFF,
  103. .flags = IORESOURCE_IO,
  104. };
  105. #define MACE_PCI_MEM_OFFSET (MACEPCI_LOW_MEMORY - 0x80000000)
  106. #endif
  107. static struct pci_controller mace_pci_controller = {
  108. .pci_ops = &mace_pci_ops,
  109. .mem_resource = &mace_pci_mem_resource,
  110. .io_resource = &mace_pci_io_resource,
  111. .mem_offset = MACE_PCI_MEM_OFFSET,
  112. .io_offset = 0,
  113. .io_map_base = CKSEG1ADDR(MACEPCI_LOW_IO),
  114. };
  115. static int __init mace_init(void)
  116. {
  117. PCIBIOS_MIN_IO = 0x1000;
  118. /* Clear any outstanding errors and enable interrupts */
  119. mace->pci.error_addr = 0;
  120. mace->pci.error = 0;
  121. mace->pci.control = 0xff008500;
  122. printk("MACE PCI rev %d\n", mace->pci.rev);
  123. BUG_ON(request_irq(MACE_PCI_BRIDGE_IRQ, macepci_error, 0,
  124. "MACE PCI error", NULL));
  125. /* extend memory resources */
  126. iomem_resource.end = mace_pci_mem_resource.end;
  127. ioport_resource = mace_pci_io_resource;
  128. register_pci_controller(&mace_pci_controller);
  129. return 0;
  130. }
  131. arch_initcall(mace_init);