irq.c 1.8 KB

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