irq-lh7a404.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* arch/arm/mach-lh7a40x/irq-lh7a404.c
  2. *
  3. * Copyright (C) 2004 Logic Product Development
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * version 2 as published by the Free Software Foundation.
  8. *
  9. */
  10. #include <linux/init.h>
  11. #include <linux/module.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/ptrace.h>
  14. #include <asm/hardware.h>
  15. #include <asm/irq.h>
  16. #include <asm/mach/irq.h>
  17. #include <asm/arch/irq.h>
  18. #include <asm/arch/irqs.h>
  19. #define USE_PRIORITIES
  20. /* See Documentation/arm/Sharp-LH/VectoredInterruptController for more
  21. * information on using the vectored interrupt controller's
  22. * prioritizing feature. */
  23. static unsigned char irq_pri_vic1[] = {
  24. #if defined (USE_PRIORITIES)
  25. IRQ_GPIO3INTR,
  26. #endif
  27. };
  28. static unsigned char irq_pri_vic2[] = {
  29. #if defined (USE_PRIORITIES)
  30. IRQ_T3UI, IRQ_GPIO7INTR,
  31. IRQ_UART1INTR, IRQ_UART2INTR, IRQ_UART3INTR,
  32. #endif
  33. };
  34. /* CPU IRQ handling */
  35. static void lh7a404_vic1_mask_irq (u32 irq)
  36. {
  37. VIC1_INTENCLR = (1 << irq);
  38. }
  39. static void lh7a404_vic1_unmask_irq (u32 irq)
  40. {
  41. VIC1_INTEN = (1 << irq);
  42. }
  43. static void lh7a404_vic2_mask_irq (u32 irq)
  44. {
  45. VIC2_INTENCLR = (1 << (irq - 32));
  46. }
  47. static void lh7a404_vic2_unmask_irq (u32 irq)
  48. {
  49. VIC2_INTEN = (1 << (irq - 32));
  50. }
  51. static void lh7a404_vic1_ack_gpio_irq (u32 irq)
  52. {
  53. GPIO_GPIOFEOI = (1 << IRQ_TO_GPIO (irq));
  54. VIC1_INTENCLR = (1 << irq);
  55. }
  56. static void lh7a404_vic2_ack_gpio_irq (u32 irq)
  57. {
  58. GPIO_GPIOFEOI = (1 << IRQ_TO_GPIO (irq));
  59. VIC2_INTENCLR = (1 << irq);
  60. }
  61. static struct irqchip lh7a404_vic1_chip = {
  62. .ack = lh7a404_vic1_mask_irq, /* Because level-triggered */
  63. .mask = lh7a404_vic1_mask_irq,
  64. .unmask = lh7a404_vic1_unmask_irq,
  65. };
  66. static struct irqchip lh7a404_vic2_chip = {
  67. .ack = lh7a404_vic2_mask_irq, /* Because level-triggered */
  68. .mask = lh7a404_vic2_mask_irq,
  69. .unmask = lh7a404_vic2_unmask_irq,
  70. };
  71. static struct irqchip lh7a404_gpio_vic1_chip = {
  72. .ack = lh7a404_vic1_ack_gpio_irq,
  73. .mask = lh7a404_vic1_mask_irq,
  74. .unmask = lh7a404_vic1_unmask_irq,
  75. };
  76. static struct irqchip lh7a404_gpio_vic2_chip = {
  77. .ack = lh7a404_vic2_ack_gpio_irq,
  78. .mask = lh7a404_vic2_mask_irq,
  79. .unmask = lh7a404_vic2_unmask_irq,
  80. };
  81. /* IRQ initialization */
  82. void __init lh7a404_init_irq (void)
  83. {
  84. int irq;
  85. VIC1_INTENCLR = 0xffffffff;
  86. VIC2_INTENCLR = 0xffffffff;
  87. VIC1_INTSEL = 0; /* All IRQs */
  88. VIC2_INTSEL = 0; /* All IRQs */
  89. VIC1_NVADDR = VA_VIC1DEFAULT;
  90. VIC2_NVADDR = VA_VIC2DEFAULT;
  91. VIC1_VECTADDR = 0;
  92. VIC2_VECTADDR = 0;
  93. GPIO_GPIOFINTEN = 0x00; /* Disable all GPIOF interrupts */
  94. barrier ();
  95. /* Install prioritized interrupts, if there are any. */
  96. /* The | 0x20*/
  97. for (irq = 0; irq < 16; ++irq) {
  98. (&VIC1_VAD0)[irq]
  99. = (irq < ARRAY_SIZE (irq_pri_vic1))
  100. ? (irq_pri_vic1[irq] | VA_VECTORED) : 0;
  101. (&VIC1_VECTCNTL0)[irq]
  102. = (irq < ARRAY_SIZE (irq_pri_vic1))
  103. ? (irq_pri_vic1[irq] | VIC_CNTL_ENABLE) : 0;
  104. (&VIC2_VAD0)[irq]
  105. = (irq < ARRAY_SIZE (irq_pri_vic2))
  106. ? (irq_pri_vic2[irq] | VA_VECTORED) : 0;
  107. (&VIC2_VECTCNTL0)[irq]
  108. = (irq < ARRAY_SIZE (irq_pri_vic2))
  109. ? (irq_pri_vic2[irq] | VIC_CNTL_ENABLE) : 0;
  110. }
  111. for (irq = 0; irq < NR_IRQS; ++irq) {
  112. switch (irq) {
  113. case IRQ_GPIO0INTR:
  114. case IRQ_GPIO1INTR:
  115. case IRQ_GPIO2INTR:
  116. case IRQ_GPIO3INTR:
  117. case IRQ_GPIO4INTR:
  118. case IRQ_GPIO5INTR:
  119. case IRQ_GPIO6INTR:
  120. case IRQ_GPIO7INTR:
  121. set_irq_chip (irq, irq < 32
  122. ? &lh7a404_gpio_vic1_chip
  123. : &lh7a404_gpio_vic2_chip);
  124. set_irq_handler (irq, do_level_IRQ); /* OK default */
  125. break;
  126. default:
  127. set_irq_chip (irq, irq < 32
  128. ? &lh7a404_vic1_chip
  129. : &lh7a404_vic2_chip);
  130. set_irq_handler (irq, do_level_IRQ);
  131. }
  132. set_irq_flags (irq, IRQF_VALID);
  133. }
  134. lh7a40x_init_board_irq ();
  135. }