irq.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * arch/arm/mach-mv78xx0/irq.c
  3. *
  4. * MV78xx0 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/gpio.h>
  11. #include <linux/kernel.h>
  12. #include <linux/irq.h>
  13. #include <linux/io.h>
  14. #include <asm/exception.h>
  15. #include <plat/orion-gpio.h>
  16. #include <plat/irq.h>
  17. #include "bridge-regs.h"
  18. #include "common.h"
  19. static int __initdata gpio0_irqs[4] = {
  20. IRQ_MV78XX0_GPIO_0_7,
  21. IRQ_MV78XX0_GPIO_8_15,
  22. IRQ_MV78XX0_GPIO_16_23,
  23. IRQ_MV78XX0_GPIO_24_31,
  24. };
  25. static void __iomem *mv78xx0_irq_base = IRQ_VIRT_BASE;
  26. static asmlinkage void
  27. __exception_irq_entry mv78xx0_legacy_handle_irq(struct pt_regs *regs)
  28. {
  29. u32 stat;
  30. stat = readl_relaxed(mv78xx0_irq_base + IRQ_CAUSE_LOW_OFF);
  31. stat &= readl_relaxed(mv78xx0_irq_base + IRQ_MASK_LOW_OFF);
  32. if (stat) {
  33. unsigned int hwirq = __fls(stat);
  34. handle_IRQ(hwirq, regs);
  35. return;
  36. }
  37. stat = readl_relaxed(mv78xx0_irq_base + IRQ_CAUSE_HIGH_OFF);
  38. stat &= readl_relaxed(mv78xx0_irq_base + IRQ_MASK_HIGH_OFF);
  39. if (stat) {
  40. unsigned int hwirq = 32 + __fls(stat);
  41. handle_IRQ(hwirq, regs);
  42. return;
  43. }
  44. stat = readl_relaxed(mv78xx0_irq_base + IRQ_CAUSE_ERR_OFF);
  45. stat &= readl_relaxed(mv78xx0_irq_base + IRQ_MASK_ERR_OFF);
  46. if (stat) {
  47. unsigned int hwirq = 64 + __fls(stat);
  48. handle_IRQ(hwirq, regs);
  49. return;
  50. }
  51. }
  52. void __init mv78xx0_init_irq(void)
  53. {
  54. orion_irq_init(0, IRQ_VIRT_BASE + IRQ_MASK_LOW_OFF);
  55. orion_irq_init(32, IRQ_VIRT_BASE + IRQ_MASK_HIGH_OFF);
  56. orion_irq_init(64, IRQ_VIRT_BASE + IRQ_MASK_ERR_OFF);
  57. set_handle_irq(mv78xx0_legacy_handle_irq);
  58. /*
  59. * Initialize gpiolib for GPIOs 0-31. (The GPIO interrupt mask
  60. * registers for core #1 are at an offset of 0x18 from those of
  61. * core #0.)
  62. */
  63. orion_gpio_init(NULL, 0, 32, GPIO_VIRT_BASE,
  64. mv78xx0_core_index() ? 0x18 : 0,
  65. IRQ_MV78XX0_GPIO_START, gpio0_irqs);
  66. }