summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2018-10-02 04:54:16 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2018-10-02 06:59:59 -0400
commit4f4c867c91e644fc9d461c8c5cf2f09d6d5bcac2 (patch)
tree0b1d29bd22884c6e3419f4a4f4a1b3f5c090d4d7
parent00885a77c8ffbeee58a9662c92d6a60a9b49f120 (diff)
irqchip/irq-mvebu-icu: Support ICU subnodes
The ICU can handle several type of interrupt, each of them being handled differently on AP side. On CP side, the ICU should be able to make the distinction between each interrupt group by pointing to the right parent. This is done through the introduction of new bindings, presenting the ICU node as the parent of multiple ICU sub-nodes, each of them being an interrupt type with a different interrupt parent. ICU interrupt 'clients' now directly point to the right sub-node, avoiding the need for the extra ICU_GRP_* parameter. ICU subnodes are probed automatically with devm_platform_populate(). If the node as no child, the probe function for NSRs will still be called 'manually' in order to preserve backward compatibility with DT using the old binding. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--drivers/irqchip/irq-mvebu-icu.c73
1 files changed, 57 insertions, 16 deletions
diff --git a/drivers/irqchip/irq-mvebu-icu.c b/drivers/irqchip/irq-mvebu-icu.c
index d09f220a2701..d0b1994e2a6f 100644
--- a/drivers/irqchip/irq-mvebu-icu.c
+++ b/drivers/irqchip/irq-mvebu-icu.c
@@ -13,6 +13,7 @@
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/irqchip.h> 14#include <linux/irqchip.h>
15#include <linux/irqdomain.h> 15#include <linux/irqdomain.h>
16#include <linux/jump_label.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/msi.h> 18#include <linux/msi.h>
18#include <linux/of_irq.h> 19#include <linux/of_irq.h>
@@ -49,6 +50,8 @@ struct mvebu_icu_irq_data {
49 unsigned int type; 50 unsigned int type;
50}; 51};
51 52
53DEFINE_STATIC_KEY_FALSE(legacy_bindings);
54
52static void mvebu_icu_init(struct mvebu_icu *icu, struct msi_msg *msg) 55static void mvebu_icu_init(struct mvebu_icu *icu, struct msi_msg *msg)
53{ 56{
54 if (atomic_cmpxchg(&icu->initialized, false, true)) 57 if (atomic_cmpxchg(&icu->initialized, false, true))
@@ -105,32 +108,33 @@ mvebu_icu_irq_domain_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
105 unsigned long *hwirq, unsigned int *type) 108 unsigned long *hwirq, unsigned int *type)
106{ 109{
107 struct mvebu_icu *icu = platform_msi_get_host_data(d); 110 struct mvebu_icu *icu = platform_msi_get_host_data(d);
108 unsigned int icu_group; 111 unsigned int param_count = static_branch_unlikely(&legacy_bindings) ? 3 : 2;
109 112
110 /* Check the count of the parameters in dt */ 113 /* Check the count of the parameters in dt */
111 if (WARN_ON(fwspec->param_count < 3)) { 114 if (WARN_ON(fwspec->param_count != param_count)) {
112 dev_err(icu->dev, "wrong ICU parameter count %d\n", 115 dev_err(icu->dev, "wrong ICU parameter count %d\n",
113 fwspec->param_count); 116 fwspec->param_count);
114 return -EINVAL; 117 return -EINVAL;
115 } 118 }
116 119
117 /* Only ICU group type is handled */ 120 if (static_branch_unlikely(&legacy_bindings)) {
118 icu_group = fwspec->param[0]; 121 *hwirq = fwspec->param[1];
119 if (icu_group != ICU_GRP_NSR && icu_group != ICU_GRP_SR && 122 *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK;
120 icu_group != ICU_GRP_SEI && icu_group != ICU_GRP_REI) { 123 if (fwspec->param[0] != ICU_GRP_NSR) {
121 dev_err(icu->dev, "wrong ICU group type %x\n", icu_group); 124 dev_err(icu->dev, "wrong ICU group type %x\n",
122 return -EINVAL; 125 fwspec->param[0]);
126 return -EINVAL;
127 }
128 } else {
129 *hwirq = fwspec->param[0];
130 *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
123 } 131 }
124 132
125 *hwirq = fwspec->param[1];
126 if (*hwirq >= ICU_MAX_IRQS) { 133 if (*hwirq >= ICU_MAX_IRQS) {
127 dev_err(icu->dev, "invalid interrupt number %ld\n", *hwirq); 134 dev_err(icu->dev, "invalid interrupt number %ld\n", *hwirq);
128 return -EINVAL; 135 return -EINVAL;
129 } 136 }
130 137
131 /* Mask the type to prevent wrong DT configuration */
132 *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK;
133
134 return 0; 138 return 0;
135} 139}
136 140
@@ -155,7 +159,10 @@ mvebu_icu_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
155 goto free_irqd; 159 goto free_irqd;
156 } 160 }
157 161
158 icu_irqd->icu_group = fwspec->param[0]; 162 if (static_branch_unlikely(&legacy_bindings))
163 icu_irqd->icu_group = fwspec->param[0];
164 else
165 icu_irqd->icu_group = ICU_GRP_NSR;
159 icu_irqd->icu = icu; 166 icu_irqd->icu = icu;
160 167
161 err = platform_msi_domain_alloc(domain, virq, nr_irqs); 168 err = platform_msi_domain_alloc(domain, virq, nr_irqs);
@@ -203,6 +210,13 @@ static const struct irq_domain_ops mvebu_icu_domain_ops = {
203 .free = mvebu_icu_irq_domain_free, 210 .free = mvebu_icu_irq_domain_free,
204}; 211};
205 212
213static const struct of_device_id mvebu_icu_subset_of_match[] = {
214 {
215 .compatible = "marvell,cp110-icu-nsr",
216 },
217 {},
218};
219
206static int mvebu_icu_subset_probe(struct platform_device *pdev) 220static int mvebu_icu_subset_probe(struct platform_device *pdev)
207{ 221{
208 struct device_node *msi_parent_dn; 222 struct device_node *msi_parent_dn;
@@ -210,7 +224,10 @@ static int mvebu_icu_subset_probe(struct platform_device *pdev)
210 struct irq_domain *irq_domain; 224 struct irq_domain *irq_domain;
211 struct mvebu_icu *icu; 225 struct mvebu_icu *icu;
212 226
213 icu = dev_get_drvdata(dev); 227 if (static_branch_unlikely(&legacy_bindings))
228 icu = dev_get_drvdata(dev);
229 else
230 icu = dev_get_drvdata(dev->parent);
214 231
215 dev->msi_domain = of_msi_get_domain(dev, dev->of_node, 232 dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
216 DOMAIN_BUS_PLATFORM_MSI); 233 DOMAIN_BUS_PLATFORM_MSI);
@@ -233,6 +250,15 @@ static int mvebu_icu_subset_probe(struct platform_device *pdev)
233 return 0; 250 return 0;
234} 251}
235 252
253static struct platform_driver mvebu_icu_subset_driver = {
254 .probe = mvebu_icu_subset_probe,
255 .driver = {
256 .name = "mvebu-icu-subset",
257 .of_match_table = mvebu_icu_subset_of_match,
258 },
259};
260builtin_platform_driver(mvebu_icu_subset_driver);
261
236static int mvebu_icu_probe(struct platform_device *pdev) 262static int mvebu_icu_probe(struct platform_device *pdev)
237{ 263{
238 struct mvebu_icu *icu; 264 struct mvebu_icu *icu;
@@ -259,6 +285,16 @@ static int mvebu_icu_probe(struct platform_device *pdev)
259 if (!icu->irq_chip.name) 285 if (!icu->irq_chip.name)
260 return -ENOMEM; 286 return -ENOMEM;
261 287
288 /*
289 * Legacy bindings: ICU is one node with one MSI parent: force manually
290 * the probe of the NSR interrupts side.
291 * New bindings: ICU node has children, one per interrupt controller
292 * having its own MSI parent: call platform_populate().
293 * All ICU instances should use the same bindings.
294 */
295 if (!of_get_child_count(pdev->dev.of_node))
296 static_branch_enable(&legacy_bindings);
297
262 icu->irq_chip.irq_mask = irq_chip_mask_parent; 298 icu->irq_chip.irq_mask = irq_chip_mask_parent;
263 icu->irq_chip.irq_unmask = irq_chip_unmask_parent; 299 icu->irq_chip.irq_unmask = irq_chip_unmask_parent;
264 icu->irq_chip.irq_eoi = irq_chip_eoi_parent; 300 icu->irq_chip.irq_eoi = irq_chip_eoi_parent;
@@ -277,13 +313,18 @@ static int mvebu_icu_probe(struct platform_device *pdev)
277 icu_int = readl_relaxed(icu->base + ICU_INT_CFG(i)); 313 icu_int = readl_relaxed(icu->base + ICU_INT_CFG(i));
278 icu_grp = icu_int >> ICU_GROUP_SHIFT; 314 icu_grp = icu_int >> ICU_GROUP_SHIFT;
279 315
280 if (icu_grp == ICU_GRP_NSR) 316 if (icu_grp == ICU_GRP_NSR ||
317 (icu_grp == ICU_GRP_SEI &&
318 !static_branch_unlikely(&legacy_bindings)))
281 writel_relaxed(0x0, icu->base + ICU_INT_CFG(i)); 319 writel_relaxed(0x0, icu->base + ICU_INT_CFG(i));
282 } 320 }
283 321
284 platform_set_drvdata(pdev, icu); 322 platform_set_drvdata(pdev, icu);
285 323
286 return mvebu_icu_subset_probe(pdev); 324 if (static_branch_unlikely(&legacy_bindings))
325 return mvebu_icu_subset_probe(pdev);
326 else
327 return devm_of_platform_populate(&pdev->dev);
287} 328}
288 329
289static const struct of_device_id mvebu_icu_of_match[] = { 330static const struct of_device_id mvebu_icu_of_match[] = {