Commit 8bc7464b authored by Paul Cercueil's avatar Paul Cercueil Committed by Marc Zyngier

irqchip: ingenic: Alloc generic chips from IRQ domain

By creating the generic chips from the IRQ domain, we don't rely on the
JZ4740_IRQ_BASE macro. It also makes the code a bit cleaner.
Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/1570015525-27018-5-git-send-email-zhouyanjie@zoho.com
parent 208caadc
...@@ -36,12 +36,14 @@ static irqreturn_t intc_cascade(int irq, void *data) ...@@ -36,12 +36,14 @@ static irqreturn_t intc_cascade(int irq, void *data)
{ {
struct ingenic_intc_data *intc = irq_get_handler_data(irq); struct ingenic_intc_data *intc = irq_get_handler_data(irq);
struct irq_domain *domain = intc->domain; struct irq_domain *domain = intc->domain;
struct irq_chip_generic *gc;
uint32_t irq_reg; uint32_t irq_reg;
unsigned i; unsigned i;
for (i = 0; i < intc->num_chips; i++) { for (i = 0; i < intc->num_chips; i++) {
irq_reg = readl(intc->base + (i * CHIP_SIZE) + gc = irq_get_domain_generic_chip(domain, i * 32);
JZ_REG_INTC_PENDING);
irq_reg = irq_reg_readl(gc, JZ_REG_INTC_PENDING);
if (!irq_reg) if (!irq_reg)
continue; continue;
...@@ -92,7 +94,7 @@ static int __init ingenic_intc_of_init(struct device_node *node, ...@@ -92,7 +94,7 @@ static int __init ingenic_intc_of_init(struct device_node *node,
domain = irq_domain_add_legacy(node, num_chips * 32, domain = irq_domain_add_legacy(node, num_chips * 32,
JZ4740_IRQ_BASE, 0, JZ4740_IRQ_BASE, 0,
&irq_domain_simple_ops, NULL); &irq_generic_chip_ops, NULL);
if (!domain) { if (!domain) {
err = -ENOMEM; err = -ENOMEM;
goto out_unmap_base; goto out_unmap_base;
...@@ -100,17 +102,17 @@ static int __init ingenic_intc_of_init(struct device_node *node, ...@@ -100,17 +102,17 @@ static int __init ingenic_intc_of_init(struct device_node *node,
intc->domain = domain; intc->domain = domain;
for (i = 0; i < num_chips; i++) { err = irq_alloc_domain_generic_chips(domain, 32, 1, "INTC",
/* Mask all irqs */ handle_level_irq, 0,
writel(0xffffffff, intc->base + (i * CHIP_SIZE) + IRQ_NOPROBE | IRQ_LEVEL, 0);
JZ_REG_INTC_SET_MASK); if (err)
goto out_domain_remove;
gc = irq_alloc_generic_chip("INTC", 1, for (i = 0; i < num_chips; i++) {
JZ4740_IRQ_BASE + (i * 32), gc = irq_get_domain_generic_chip(domain, i * 32);
intc->base + (i * CHIP_SIZE),
handle_level_irq);
gc->wake_enabled = IRQ_MSK(32); gc->wake_enabled = IRQ_MSK(32);
gc->reg_base = intc->base + (i * CHIP_SIZE);
ct = gc->chip_types; ct = gc->chip_types;
ct->regs.enable = JZ_REG_INTC_CLEAR_MASK; ct->regs.enable = JZ_REG_INTC_CLEAR_MASK;
...@@ -121,13 +123,15 @@ static int __init ingenic_intc_of_init(struct device_node *node, ...@@ -121,13 +123,15 @@ static int __init ingenic_intc_of_init(struct device_node *node,
ct->chip.irq_set_wake = irq_gc_set_wake; ct->chip.irq_set_wake = irq_gc_set_wake;
ct->chip.flags = IRQCHIP_MASK_ON_SUSPEND; ct->chip.flags = IRQCHIP_MASK_ON_SUSPEND;
irq_setup_generic_chip(gc, IRQ_MSK(32), 0, 0, /* Mask all irqs */
IRQ_NOPROBE | IRQ_LEVEL); irq_reg_writel(gc, IRQ_MSK(32), JZ_REG_INTC_SET_MASK);
} }
setup_irq(parent_irq, &intc_cascade_action); setup_irq(parent_irq, &intc_cascade_action);
return 0; return 0;
out_domain_remove:
irq_domain_remove(domain);
out_unmap_base: out_unmap_base:
iounmap(intc->base); iounmap(intc->base);
out_unmap_irq: out_unmap_irq:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment