pci-ip32.c 4.0 KB

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