irq.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Atheros AR71xx/AR724x/AR913x specific interrupt handling
  3. *
  4. * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
  5. * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7. *
  8. * Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/irqchip.h>
  18. #include <linux/of_irq.h>
  19. #include <asm/irq_cpu.h>
  20. #include <asm/mipsregs.h>
  21. #include <asm/mach-ath79/ath79.h>
  22. #include <asm/mach-ath79/ar71xx_regs.h>
  23. #include "common.h"
  24. #include "machtypes.h"
  25. static void ar934x_ip2_irq_dispatch(struct irq_desc *desc)
  26. {
  27. u32 status;
  28. status = ath79_reset_rr(AR934X_RESET_REG_PCIE_WMAC_INT_STATUS);
  29. if (status & AR934X_PCIE_WMAC_INT_PCIE_ALL) {
  30. ath79_ddr_wb_flush(3);
  31. generic_handle_irq(ATH79_IP2_IRQ(0));
  32. } else if (status & AR934X_PCIE_WMAC_INT_WMAC_ALL) {
  33. ath79_ddr_wb_flush(4);
  34. generic_handle_irq(ATH79_IP2_IRQ(1));
  35. } else {
  36. spurious_interrupt();
  37. }
  38. }
  39. static void ar934x_ip2_irq_init(void)
  40. {
  41. int i;
  42. for (i = ATH79_IP2_IRQ_BASE;
  43. i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  44. irq_set_chip_and_handler(i, &dummy_irq_chip,
  45. handle_level_irq);
  46. irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
  47. }
  48. static void qca955x_ip2_irq_dispatch(struct irq_desc *desc)
  49. {
  50. u32 status;
  51. status = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
  52. status &= QCA955X_EXT_INT_PCIE_RC1_ALL | QCA955X_EXT_INT_WMAC_ALL;
  53. if (status == 0) {
  54. spurious_interrupt();
  55. return;
  56. }
  57. if (status & QCA955X_EXT_INT_PCIE_RC1_ALL) {
  58. /* TODO: flush DDR? */
  59. generic_handle_irq(ATH79_IP2_IRQ(0));
  60. }
  61. if (status & QCA955X_EXT_INT_WMAC_ALL) {
  62. /* TODO: flush DDR? */
  63. generic_handle_irq(ATH79_IP2_IRQ(1));
  64. }
  65. }
  66. static void qca955x_ip3_irq_dispatch(struct irq_desc *desc)
  67. {
  68. u32 status;
  69. status = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
  70. status &= QCA955X_EXT_INT_PCIE_RC2_ALL |
  71. QCA955X_EXT_INT_USB1 |
  72. QCA955X_EXT_INT_USB2;
  73. if (status == 0) {
  74. spurious_interrupt();
  75. return;
  76. }
  77. if (status & QCA955X_EXT_INT_USB1) {
  78. /* TODO: flush DDR? */
  79. generic_handle_irq(ATH79_IP3_IRQ(0));
  80. }
  81. if (status & QCA955X_EXT_INT_USB2) {
  82. /* TODO: flush DDR? */
  83. generic_handle_irq(ATH79_IP3_IRQ(1));
  84. }
  85. if (status & QCA955X_EXT_INT_PCIE_RC2_ALL) {
  86. /* TODO: flush DDR? */
  87. generic_handle_irq(ATH79_IP3_IRQ(2));
  88. }
  89. }
  90. static void qca955x_irq_init(void)
  91. {
  92. int i;
  93. for (i = ATH79_IP2_IRQ_BASE;
  94. i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  95. irq_set_chip_and_handler(i, &dummy_irq_chip,
  96. handle_level_irq);
  97. irq_set_chained_handler(ATH79_CPU_IRQ(2), qca955x_ip2_irq_dispatch);
  98. for (i = ATH79_IP3_IRQ_BASE;
  99. i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
  100. irq_set_chip_and_handler(i, &dummy_irq_chip,
  101. handle_level_irq);
  102. irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
  103. }
  104. void __init arch_init_irq(void)
  105. {
  106. unsigned irq_wb_chan2 = -1;
  107. unsigned irq_wb_chan3 = -1;
  108. bool misc_is_ar71xx;
  109. if (mips_machtype == ATH79_MACH_GENERIC_OF) {
  110. irqchip_init();
  111. return;
  112. }
  113. if (soc_is_ar71xx() || soc_is_ar724x() ||
  114. soc_is_ar913x() || soc_is_ar933x()) {
  115. irq_wb_chan2 = 3;
  116. irq_wb_chan3 = 2;
  117. } else if (soc_is_ar934x()) {
  118. irq_wb_chan3 = 2;
  119. }
  120. ath79_cpu_irq_init(irq_wb_chan2, irq_wb_chan3);
  121. if (soc_is_ar71xx() || soc_is_ar913x())
  122. misc_is_ar71xx = true;
  123. else if (soc_is_ar724x() ||
  124. soc_is_ar933x() ||
  125. soc_is_ar934x() ||
  126. soc_is_qca955x())
  127. misc_is_ar71xx = false;
  128. else
  129. BUG();
  130. ath79_misc_irq_init(
  131. ath79_reset_base + AR71XX_RESET_REG_MISC_INT_STATUS,
  132. ATH79_CPU_IRQ(6), ATH79_MISC_IRQ_BASE, misc_is_ar71xx);
  133. if (soc_is_ar934x())
  134. ar934x_ip2_irq_init();
  135. else if (soc_is_qca955x())
  136. qca955x_irq_init();
  137. }