irq.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * arch/arm/mach-dove/irq.c
  3. *
  4. * Dove IRQ handling.
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/irq.h>
  13. #include <linux/gpio.h>
  14. #include <linux/io.h>
  15. #include <asm/mach/arch.h>
  16. #include <plat/irq.h>
  17. #include <asm/mach/irq.h>
  18. #include <mach/pm.h>
  19. #include <mach/bridge-regs.h>
  20. #include "common.h"
  21. static void pmu_irq_mask(struct irq_data *d)
  22. {
  23. int pin = irq_to_pmu(d->irq);
  24. u32 u;
  25. u = readl(PMU_INTERRUPT_MASK);
  26. u &= ~(1 << (pin & 31));
  27. writel(u, PMU_INTERRUPT_MASK);
  28. }
  29. static void pmu_irq_unmask(struct irq_data *d)
  30. {
  31. int pin = irq_to_pmu(d->irq);
  32. u32 u;
  33. u = readl(PMU_INTERRUPT_MASK);
  34. u |= 1 << (pin & 31);
  35. writel(u, PMU_INTERRUPT_MASK);
  36. }
  37. static void pmu_irq_ack(struct irq_data *d)
  38. {
  39. int pin = irq_to_pmu(d->irq);
  40. u32 u;
  41. u = ~(1 << (pin & 31));
  42. writel(u, PMU_INTERRUPT_CAUSE);
  43. }
  44. static struct irq_chip pmu_irq_chip = {
  45. .name = "pmu_irq",
  46. .irq_mask = pmu_irq_mask,
  47. .irq_unmask = pmu_irq_unmask,
  48. .irq_ack = pmu_irq_ack,
  49. };
  50. static void pmu_irq_handler(unsigned int irq, struct irq_desc *desc)
  51. {
  52. unsigned long cause = readl(PMU_INTERRUPT_CAUSE);
  53. cause &= readl(PMU_INTERRUPT_MASK);
  54. if (cause == 0) {
  55. do_bad_IRQ(irq, desc);
  56. return;
  57. }
  58. for (irq = 0; irq < NR_PMU_IRQS; irq++) {
  59. if (!(cause & (1 << irq)))
  60. continue;
  61. irq = pmu_to_irq(irq);
  62. generic_handle_irq(irq);
  63. }
  64. }
  65. static int __initdata gpio0_irqs[4] = {
  66. IRQ_DOVE_GPIO_0_7,
  67. IRQ_DOVE_GPIO_8_15,
  68. IRQ_DOVE_GPIO_16_23,
  69. IRQ_DOVE_GPIO_24_31,
  70. };
  71. static int __initdata gpio1_irqs[4] = {
  72. IRQ_DOVE_HIGH_GPIO,
  73. 0,
  74. 0,
  75. 0,
  76. };
  77. static int __initdata gpio2_irqs[4] = {
  78. 0,
  79. 0,
  80. 0,
  81. 0,
  82. };
  83. void __init dove_init_irq(void)
  84. {
  85. int i;
  86. orion_irq_init(0, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_LOW_OFF));
  87. orion_irq_init(32, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_HIGH_OFF));
  88. /*
  89. * Initialize gpiolib for GPIOs 0-71.
  90. */
  91. orion_gpio_init(NULL, 0, 32, (void __iomem *)DOVE_GPIO_LO_VIRT_BASE, 0,
  92. IRQ_DOVE_GPIO_START, gpio0_irqs);
  93. orion_gpio_init(NULL, 32, 32, (void __iomem *)DOVE_GPIO_HI_VIRT_BASE, 0,
  94. IRQ_DOVE_GPIO_START + 32, gpio1_irqs);
  95. orion_gpio_init(NULL, 64, 8, (void __iomem *)DOVE_GPIO2_VIRT_BASE, 0,
  96. IRQ_DOVE_GPIO_START + 64, gpio2_irqs);
  97. /*
  98. * Mask and clear PMU interrupts
  99. */
  100. writel(0, PMU_INTERRUPT_MASK);
  101. writel(0, PMU_INTERRUPT_CAUSE);
  102. for (i = IRQ_DOVE_PMU_START; i < NR_IRQS; i++) {
  103. irq_set_chip_and_handler(i, &pmu_irq_chip, handle_level_irq);
  104. irq_set_status_flags(i, IRQ_LEVEL);
  105. set_irq_flags(i, IRQF_VALID);
  106. }
  107. irq_set_chained_handler(IRQ_DOVE_PMU, pmu_irq_handler);
  108. }