History

spmi: pmic-arb: convert to v2 irq interfaces to support hierarchical IRQ chips

Convert the spmi-pmic-arb IRQ code to use the version 2 IRQ interface in order to support hierarchical IRQ chips. This is necessary so that spmi-gpio can be setup as a hierarchical IRQ chip with pmic-arb as the parent. IRQ chips in device tree should be usable from the start without the consumer having to make an additional call to gpio[d]_to_irq() to get the proper IRQ on the parent. The old qpnpint_irq_domain_map function would hardcode the handler as handle_level_irq, however qpnpint_irq_set_type would later override the handler. Properly set the handler when the IRQ is mapped. This new code doesn't return an error for IRQ_TYPE_NONE and preserves the existing behavior of using handle_level_irq since there are some broken device tree bindings that need to be corrected first. Driver was tested on a LG Nexus 5 (hammerhead) phone.

Brian Masney committed 7 years ago

Commit 12a9eea1 parent cfacef31 file · +47 −20Browse files

Unified · Split

drivers/spmi/spmi-pmic-arb.c+47−20
@@ -666,7 +666,8 @@ static int qpnpint_get_irqchip_state(struct irq_data *d, · 665 unmodified lines
666666 return 0;
667667 }
668668
669−static int qpnpint_irq_request_resources(struct irq_data *d)
669+static int qpnpint_irq_domain_activate(struct irq_domain *domain,
670+ struct irq_data *d, bool reserve)
670671 {
671672 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
672673 u16 periph = hwirq_to_per(d->hwirq);
@@ -692,27 +693,25 @@ static struct irq_chip pmic_arb_irqchip = { · 19 unmodified lines
692693 .irq_set_type = qpnpint_irq_set_type,
693694 .irq_set_wake = qpnpint_irq_set_wake,
694695 .irq_get_irqchip_state = qpnpint_get_irqchip_state,
695− .irq_request_resources = qpnpint_irq_request_resources,
696696 .flags = IRQCHIP_MASK_ON_SUSPEND,
697697 };
698698
699−static int qpnpint_irq_domain_dt_translate(struct irq_domain *d,
700− struct device_node *controller,
701− const u32 *intspec,
702− unsigned int intsize,
703− unsigned long *out_hwirq,
704− unsigned int *out_type)
699+static int qpnpint_irq_domain_translate(struct irq_domain *d,
700+ struct irq_fwspec *fwspec,
701+ unsigned long *out_hwirq,
702+ unsigned int *out_type)
705703 {
706704 struct spmi_pmic_arb *pmic_arb = d->host_data;
705+ u32 *intspec = fwspec->param;
707706 u16 apid, ppid;
708707 int rc;
709708
710709 dev_dbg(&pmic_arb->spmic->dev, "intspec[0] 0x%1x intspec[1] 0x%02x intspec[2] 0x%02x\n",
711710 intspec[0], intspec[1], intspec[2]);
712711
713− if (irq_domain_get_of_node(d) != controller)
712+ if (irq_domain_get_of_node(d) != pmic_arb->spmic->dev.of_node)
714713 return -EINVAL;
715− if (intsize != 4)
714+ if (fwspec->param_count != 4)
716715 return -EINVAL;
717716 if (intspec[0] > 0xF || intspec[1] > 0xFF || intspec[2] > 0x7)
718717 return -EINVAL;
@@ -740,17 +739,43 @@ static int qpnpint_irq_domain_dt_translate(struct irq_domain *d, · 21 unmodified lines
740739 return 0;
741740 }
742741
743−static int qpnpint_irq_domain_map(struct irq_domain *d,
744− unsigned int virq,
745− irq_hw_number_t hwirq)
742+
743+static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb,
744+ struct irq_domain *domain, unsigned int virq,
745+ irq_hw_number_t hwirq, unsigned int type)
746746 {
747− struct spmi_pmic_arb *pmic_arb = d->host_data;
747+ irq_flow_handler_t handler;
748+
749+ dev_dbg(&pmic_arb->spmic->dev, "virq = %u, hwirq = %lu, type = %u\n",
750+ virq, hwirq, type);
751+
752+ if (type & IRQ_TYPE_EDGE_BOTH)
753+ handler = handle_edge_irq;
754+ else
755+ handler = handle_level_irq;
756+
757+ irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb,
758+ handler, NULL, NULL);
759+}
760+
761+static int qpnpint_irq_domain_alloc(struct irq_domain *domain,
762+ unsigned int virq, unsigned int nr_irqs,
763+ void *data)
764+{
765+ struct spmi_pmic_arb *pmic_arb = domain->host_data;
766+ struct irq_fwspec *fwspec = data;
767+ irq_hw_number_t hwirq;
768+ unsigned int type;
769+ int ret, i;
770+
771+ ret = qpnpint_irq_domain_translate(domain, fwspec, &hwirq, &type);
772+ if (ret)
773+ return ret;
748774
749− dev_dbg(&pmic_arb->spmic->dev, "virq = %u, hwirq = %lu\n", virq, hwirq);
775+ for (i = 0; i < nr_irqs; i++)
776+ qpnpint_irq_domain_map(pmic_arb, domain, virq + i, hwirq + i,
777+ type);
750778
751− irq_set_chip_and_handler(virq, &pmic_arb_irqchip, handle_level_irq);
752− irq_set_chip_data(virq, d->host_data);
753− irq_set_noprobe(virq);
754779 return 0;
755780 }
756781
@@ -1126,8 +1151,10 @@ static const struct pmic_arb_ver_ops pmic_arb_v5 = { · 369 unmodified lines
11261151 };
11271152
11281153 static const struct irq_domain_ops pmic_arb_irq_domain_ops = {
1129− .map = qpnpint_irq_domain_map,
1130− .xlate = qpnpint_irq_domain_dt_translate,
1154+ .activate = qpnpint_irq_domain_activate,
1155+ .alloc = qpnpint_irq_domain_alloc,
1156+ .free = irq_domain_free_irqs_common,
1157+ .translate = qpnpint_irq_domain_translate,
11311158 };
11321159
11331160 static int spmi_pmic_arb_probe(struct platform_device *pdev)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t