110-pci_isolated_interrupts.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. --- a/arch/arm/mach-cns3xxx/laguna.c
  2. +++ b/arch/arm/mach-cns3xxx/laguna.c
  3. @@ -21,6 +21,7 @@
  4. #include <linux/kernel.h>
  5. #include <linux/compiler.h>
  6. #include <linux/io.h>
  7. +#include <linux/irq.h>
  8. #include <linux/gpio.h>
  9. #include <linux/dma-mapping.h>
  10. #include <linux/serial_core.h>
  11. @@ -872,6 +873,47 @@ static int laguna_register_gpio(struct g
  12. return ret;
  13. }
  14. +/* allow disabling of external isolated PCIe IRQs */
  15. +static int cns3xxx_pciextirq = 1;
  16. +static int __init cns3xxx_pciextirq_disable(char *s)
  17. +{
  18. + cns3xxx_pciextirq = 0;
  19. + return 1;
  20. +}
  21. +__setup("noextirq", cns3xxx_pciextirq_disable);
  22. +
  23. +static int __init laguna_pcie_init_irq(void)
  24. +{
  25. + u32 __iomem *mem = (void __iomem *)(CNS3XXX_GPIOB_BASE_VIRT + 0x0004);
  26. + u32 reg = (__raw_readl(mem) >> 26) & 0xf;
  27. + int irqs[] = {
  28. + IRQ_CNS3XXX_EXTERNAL_PIN0,
  29. + IRQ_CNS3XXX_EXTERNAL_PIN1,
  30. + IRQ_CNS3XXX_EXTERNAL_PIN2,
  31. + 154,
  32. + };
  33. +
  34. + if (!machine_is_gw2388())
  35. + return 0;
  36. +
  37. + /* Verify GPIOB[26:29] == 0001b indicating support for ext irqs */
  38. + if (cns3xxx_pciextirq && reg != 1)
  39. + cns3xxx_pciextirq = 0;
  40. +
  41. + if (cns3xxx_pciextirq) {
  42. + printk("laguna: using isolated PCI interrupts:"
  43. + " irq%d/irq%d/irq%d/irq%d\n",
  44. + irqs[0], irqs[1], irqs[2], irqs[3]);
  45. + cns3xxx_pcie_set_irqs(0, irqs);
  46. + } else {
  47. + printk("laguna: using shared PCI interrupts: irq%d\n",
  48. + IRQ_CNS3XXX_PCIE0_DEVICE);
  49. + }
  50. +
  51. + return 0;
  52. +}
  53. +subsys_initcall(laguna_pcie_init_irq);
  54. +
  55. static int __init laguna_model_setup(void)
  56. {
  57. u32 __iomem *mem;
  58. @@ -883,8 +925,33 @@ static int __init laguna_model_setup(voi
  59. printk("Running on Gateworks Laguna %s\n", laguna_info.model);
  60. cns3xxx_gpio_init( 0, 32, CNS3XXX_GPIOA_BASE_VIRT, IRQ_CNS3XXX_GPIOA,
  61. NR_IRQS_CNS3XXX);
  62. - cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT, IRQ_CNS3XXX_GPIOB,
  63. - NR_IRQS_CNS3XXX + 32);
  64. +
  65. + /*
  66. + * If pcie external interrupts are supported and desired
  67. + * configure IRQ types and configure pin function.
  68. + * Note that cns3xxx_pciextirq is enabled by default, but can be
  69. + * unset via the 'noextirq' kernel param or by laguna_pcie_init() if
  70. + * the baseboard model does not support this hardware feature.
  71. + */
  72. + if (cns3xxx_pciextirq) {
  73. + mem = (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0018);
  74. + reg = __raw_readl(mem);
  75. + /* GPIO26 is gpio, EXT_INT[0:2] not gpio func */
  76. + reg &= ~0x3c000000;
  77. + reg |= 0x38000000;
  78. + __raw_writel(reg, mem);
  79. +
  80. + cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT,
  81. + IRQ_CNS3XXX_GPIOB, NR_IRQS_CNS3XXX + 32);
  82. +
  83. + irq_set_irq_type(154, IRQ_TYPE_LEVEL_LOW);
  84. + irq_set_irq_type(93, IRQ_TYPE_LEVEL_HIGH);
  85. + irq_set_irq_type(94, IRQ_TYPE_LEVEL_HIGH);
  86. + irq_set_irq_type(95, IRQ_TYPE_LEVEL_HIGH);
  87. + } else {
  88. + cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT,
  89. + IRQ_CNS3XXX_GPIOB, NR_IRQS_CNS3XXX + 32);
  90. + }
  91. if (strncmp(laguna_info.model, "GW", 2) == 0) {
  92. if (laguna_info.config_bitmap & ETH0_LOAD)
  93. --- a/arch/arm/mach-cns3xxx/pcie.c
  94. +++ b/arch/arm/mach-cns3xxx/pcie.c
  95. @@ -18,6 +18,7 @@
  96. #include <linux/io.h>
  97. #include <linux/ioport.h>
  98. #include <linux/interrupt.h>
  99. +#include <linux/irq.h>
  100. #include <linux/ptrace.h>
  101. #include <asm/mach/map.h>
  102. #include "cns3xxx.h"
  103. @@ -27,7 +28,7 @@ struct cns3xxx_pcie {
  104. void __iomem *host_regs; /* PCI config registers for host bridge */
  105. void __iomem *cfg0_regs; /* PCI Type 0 config registers */
  106. void __iomem *cfg1_regs; /* PCI Type 1 config registers */
  107. - unsigned int irqs[2];
  108. + unsigned int irqs[5];
  109. struct resource res_io;
  110. struct resource res_mem;
  111. struct hw_pci hw_pci;
  112. @@ -97,7 +98,7 @@ static inline int check_master_abort(str
  113. void __iomem *host_base;
  114. u32 sreg, ereg;
  115. - host_base = (void __iomem *) cnspci->cfg_bases[CNS3XXX_HOST_TYPE].virtual;
  116. + host_base = (void __iomem *) cnspci->host_regs;
  117. sreg = __raw_readw(host_base + 0x6) & 0xF900;
  118. ereg = __raw_readl(host_base + 0x104); // Uncorrectable Error Status Reg
  119. @@ -251,7 +252,7 @@ static struct pci_ops cns3xxx_pcie_ops =
  120. static int cns3xxx_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  121. {
  122. struct cns3xxx_pcie *cnspci = pdev_to_cnspci(dev);
  123. - int irq = cnspci->irqs[!!dev->bus->number];
  124. + int irq = cnspci->irqs[!!dev->bus->number + pin - 1];
  125. pr_info("PCIe map irq: %04d:%02x:%02x.%02x slot %d, pin %d, irq: %d\n",
  126. pci_domain_nr(dev->bus), dev->bus->number, PCI_SLOT(dev->devfn),
  127. @@ -277,7 +278,12 @@ static struct cns3xxx_pcie cns3xxx_pcie[
  128. .end = CNS3XXX_PCIE0_HOST_BASE - 1, /* 176 MiB */
  129. .flags = IORESOURCE_MEM,
  130. },
  131. - .irqs = { IRQ_CNS3XXX_PCIE0_RC, IRQ_CNS3XXX_PCIE0_DEVICE, },
  132. + .irqs = { IRQ_CNS3XXX_PCIE0_RC,
  133. + IRQ_CNS3XXX_PCIE0_DEVICE,
  134. + IRQ_CNS3XXX_PCIE0_DEVICE,
  135. + IRQ_CNS3XXX_PCIE0_DEVICE,
  136. + IRQ_CNS3XXX_PCIE0_DEVICE,
  137. + },
  138. .hw_pci = {
  139. .domain = 0,
  140. .nr_controllers = 1,
  141. @@ -302,7 +308,13 @@ static struct cns3xxx_pcie cns3xxx_pcie[
  142. .end = CNS3XXX_PCIE1_HOST_BASE - 1, /* 176 MiB */
  143. .flags = IORESOURCE_MEM,
  144. },
  145. - .irqs = { IRQ_CNS3XXX_PCIE1_RC, IRQ_CNS3XXX_PCIE1_DEVICE, },
  146. + .irqs = {
  147. + IRQ_CNS3XXX_PCIE1_RC,
  148. + IRQ_CNS3XXX_PCIE1_DEVICE,
  149. + IRQ_CNS3XXX_PCIE1_DEVICE,
  150. + IRQ_CNS3XXX_PCIE1_DEVICE,
  151. + IRQ_CNS3XXX_PCIE1_DEVICE,
  152. + },
  153. .hw_pci = {
  154. .domain = 1,
  155. .nr_controllers = 1,
  156. @@ -412,6 +424,14 @@ static int cns3xxx_pcie_abort_handler(un
  157. return 0;
  158. }
  159. +void __init cns3xxx_pcie_set_irqs(int bus, int *irqs)
  160. +{
  161. + int i;
  162. +
  163. + for (i = 0; i < 4; i++)
  164. + cns3xxx_pcie[bus].irqs[i + 1] = irqs[i];
  165. +}
  166. +
  167. void __init cns3xxx_pcie_init_late(void)
  168. {
  169. int i;
  170. --- a/arch/arm/mach-cns3xxx/core.h
  171. +++ b/arch/arm/mach-cns3xxx/core.h
  172. @@ -18,8 +18,10 @@ extern void cns3xxx_timer_init(void);
  173. #ifdef CONFIG_PCI
  174. extern void __init cns3xxx_pcie_init_late(void);
  175. +extern void __init cns3xxx_pcie_set_irqs(int bus, int *irqs);
  176. #else
  177. static inline void __init cns3xxx_pcie_init_late(void) {}
  178. +static inline void cns3xxx_pcie_set_irqs(int bus, int *irqs) {}
  179. #endif
  180. void __init cns3xxx_map_io(void);