0025-MIPS-ralink-allow-loading-irq-registers-from-the-dev.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From b1cc9a15f6ead8dbd849257e42d69a5799fb7597 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Wed, 6 Aug 2014 18:24:36 +0200
  4. Subject: [PATCH 25/57] MIPS: ralink: allow loading irq registers from the
  5. devicetree
  6. Signed-off-by: John Crispin <blogic@openwrt.org>
  7. ---
  8. arch/mips/ralink/irq.c | 33 +++++++++++++++++++++++----------
  9. 1 file changed, 23 insertions(+), 10 deletions(-)
  10. --- a/arch/mips/ralink/irq.c
  11. +++ b/arch/mips/ralink/irq.c
  12. @@ -20,14 +20,6 @@
  13. #include "common.h"
  14. -/* INTC register offsets */
  15. -#define INTC_REG_STATUS0 0x00
  16. -#define INTC_REG_STATUS1 0x04
  17. -#define INTC_REG_TYPE 0x20
  18. -#define INTC_REG_RAW_STATUS 0x30
  19. -#define INTC_REG_ENABLE 0x34
  20. -#define INTC_REG_DISABLE 0x38
  21. -
  22. #define INTC_INT_GLOBAL BIT(31)
  23. #define RALINK_CPU_IRQ_INTC (MIPS_CPU_IRQ_BASE + 2)
  24. @@ -44,16 +36,34 @@
  25. #define RALINK_INTC_IRQ_PERFC (RALINK_INTC_IRQ_BASE + 9)
  26. +enum rt_intc_regs_enum {
  27. + INTC_REG_STATUS0 = 0,
  28. + INTC_REG_STATUS1,
  29. + INTC_REG_TYPE,
  30. + INTC_REG_RAW_STATUS,
  31. + INTC_REG_ENABLE,
  32. + INTC_REG_DISABLE,
  33. +};
  34. +
  35. +static u32 rt_intc_regs[] = {
  36. + [INTC_REG_STATUS0] = 0x00,
  37. + [INTC_REG_STATUS1] = 0x04,
  38. + [INTC_REG_TYPE] = 0x20,
  39. + [INTC_REG_RAW_STATUS] = 0x30,
  40. + [INTC_REG_ENABLE] = 0x34,
  41. + [INTC_REG_DISABLE] = 0x38,
  42. +};
  43. +
  44. static void __iomem *rt_intc_membase;
  45. static inline void rt_intc_w32(u32 val, unsigned reg)
  46. {
  47. - __raw_writel(val, rt_intc_membase + reg);
  48. + __raw_writel(val, rt_intc_membase + rt_intc_regs[reg]);
  49. }
  50. static inline u32 rt_intc_r32(unsigned reg)
  51. {
  52. - return __raw_readl(rt_intc_membase + reg);
  53. + return __raw_readl(rt_intc_membase + rt_intc_regs[reg]);
  54. }
  55. static void ralink_intc_irq_unmask(struct irq_data *d)
  56. @@ -134,6 +144,9 @@ static int __init intc_of_init(struct de
  57. struct irq_domain *domain;
  58. int irq;
  59. + if (!of_property_read_u32_array(node, "ralink,intc-registers", rt_intc_regs, 6))
  60. + pr_info("intc: using register map from devicetree\n");
  61. +
  62. irq = irq_of_parse_and_map(node, 0);
  63. if (!irq)
  64. panic("Failed to get INTC IRQ");