0007-irqchip-irq-ath79-intc-add-irq-cascade-driver-for-QC.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. From cb376159800b9b44be76949c3aee89eb06d29faa Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Tue, 6 Mar 2018 09:55:13 +0100
  4. Subject: [PATCH 07/27] irqchip/irq-ath79-intc: add irq cascade driver for
  5. QCA9556 SoCs
  6. Signed-off-by: John Crispin <[email protected]>
  7. ---
  8. drivers/irqchip/Makefile | 1 +
  9. drivers/irqchip/irq-ath79-intc.c | 104 +++++++++++++++++++++++++++++++++++++++
  10. 2 files changed, 105 insertions(+)
  11. create mode 100644 drivers/irqchip/irq-ath79-intc.c
  12. --- a/drivers/irqchip/Makefile
  13. +++ b/drivers/irqchip/Makefile
  14. @@ -3,6 +3,7 @@ obj-$(CONFIG_IRQCHIP) += irqchip.o
  15. obj-$(CONFIG_ALPINE_MSI) += irq-alpine-msi.o
  16. obj-$(CONFIG_ATH79) += irq-ath79-cpu.o
  17. +obj-$(CONFIG_ATH79) += irq-ath79-intc.o
  18. obj-$(CONFIG_ATH79) += irq-ath79-misc.o
  19. obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
  20. obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2836.o
  21. --- /dev/null
  22. +++ b/drivers/irqchip/irq-ath79-intc.c
  23. @@ -0,0 +1,104 @@
  24. +/*
  25. + * Atheros AR71xx/AR724x/AR913x specific interrupt handling
  26. + *
  27. + * Copyright (C) 2018 John Crispin <[email protected]>
  28. + *
  29. + * This program is free software; you can redistribute it and/or modify it
  30. + * under the terms of the GNU General Public License version 2 as published
  31. + * by the Free Software Foundation.
  32. + */
  33. +
  34. +#include <linux/interrupt.h>
  35. +#include <linux/irqchip.h>
  36. +#include <linux/of.h>
  37. +#include <linux/of_irq.h>
  38. +#include <linux/irqdomain.h>
  39. +
  40. +#include <asm/irq_cpu.h>
  41. +#include <asm/mach-ath79/ath79.h>
  42. +#include <asm/mach-ath79/ar71xx_regs.h>
  43. +
  44. +#define ATH79_MAX_INTC_CASCADE 3
  45. +
  46. +struct ath79_intc {
  47. + struct irq_chip chip;
  48. + u32 irq;
  49. + u32 pending_mask;
  50. + u32 irq_mask[ATH79_MAX_INTC_CASCADE];
  51. +};
  52. +
  53. +static void ath79_intc_irq_handler(struct irq_desc *desc)
  54. +{
  55. + struct irq_domain *domain = irq_desc_get_handler_data(desc);
  56. + struct ath79_intc *intc = domain->host_data;
  57. + u32 pending;
  58. +
  59. + pending = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
  60. + pending &= intc->pending_mask;
  61. +
  62. + if (pending) {
  63. + int i;
  64. +
  65. + for (i = 0; i < domain->hwirq_max; i++)
  66. + if (pending & intc->irq_mask[i])
  67. + generic_handle_irq(irq_find_mapping(domain, i));
  68. + } else {
  69. + spurious_interrupt();
  70. + }
  71. +}
  72. +
  73. +static void ath79_intc_irq_unmask(struct irq_data *d)
  74. +{
  75. +}
  76. +
  77. +static void ath79_intc_irq_mask(struct irq_data *d)
  78. +{
  79. +}
  80. +
  81. +static int ath79_intc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
  82. +{
  83. + struct ath79_intc *intc = d->host_data;
  84. +
  85. + irq_set_chip_and_handler(irq, &intc->chip, handle_level_irq);
  86. +
  87. + return 0;
  88. +}
  89. +
  90. +static const struct irq_domain_ops ath79_irq_domain_ops = {
  91. + .xlate = irq_domain_xlate_onecell,
  92. + .map = ath79_intc_map,
  93. +};
  94. +
  95. +static int __init qca9556_intc_of_init(
  96. + struct device_node *node, struct device_node *parent)
  97. +{
  98. + struct irq_domain *domain;
  99. + struct ath79_intc *intc;
  100. + int cnt, i;
  101. +
  102. + cnt = of_property_count_u32_elems(node, "qcom,pending-bits");
  103. + if (cnt > ATH79_MAX_INTC_CASCADE)
  104. + panic("Too many INTC pending bits\n");
  105. +
  106. + intc = kzalloc(sizeof(*intc), GFP_KERNEL);
  107. + if (!intc)
  108. + panic("Failed to allocate INTC memory\n");
  109. + intc->chip.name = "INTC";
  110. + intc->chip.irq_unmask = ath79_intc_irq_unmask,
  111. + intc->chip.irq_mask = ath79_intc_irq_mask,
  112. +
  113. + of_property_read_u32_array(node, "qcom,pending-bits", intc->irq_mask, cnt);
  114. + for (i = 0; i < cnt; i++)
  115. + intc->pending_mask |= intc->irq_mask[i];
  116. +
  117. + intc->irq = irq_of_parse_and_map(node, 0);
  118. + if (!intc->irq)
  119. + panic("Failed to get INTC IRQ");
  120. +
  121. + domain = irq_domain_add_linear(node, cnt, &ath79_irq_domain_ops, intc);
  122. + irq_set_chained_handler_and_data(intc->irq, ath79_intc_irq_handler, domain);
  123. +
  124. + return 0;
  125. +}
  126. +IRQCHIP_DECLARE(qca9556_intc, "qcom,qca9556-intc",
  127. + qca9556_intc_of_init);