Lines Matching +full:ingenic +full:- +full:tcu
1 // SPDX-License-Identifier: GPL-2.0
3 * JZ47xx SoCs TCU IRQ driver
11 #include <linux/mfd/ingenic-tcu.h>
26 struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data); in ingenic_tcu_intc_cascade()
29 struct regmap *map = gc->private; in ingenic_tcu_intc_cascade()
50 struct regmap *map = gc->private; in ingenic_tcu_gc_unmask_enable_reg()
51 u32 mask = d->mask; in ingenic_tcu_gc_unmask_enable_reg()
54 regmap_write(map, ct->regs.ack, mask); in ingenic_tcu_gc_unmask_enable_reg()
55 regmap_write(map, ct->regs.enable, mask); in ingenic_tcu_gc_unmask_enable_reg()
56 *ct->mask_cache |= mask; in ingenic_tcu_gc_unmask_enable_reg()
64 struct regmap *map = gc->private; in ingenic_tcu_gc_mask_disable_reg()
65 u32 mask = d->mask; in ingenic_tcu_gc_mask_disable_reg()
68 regmap_write(map, ct->regs.disable, mask); in ingenic_tcu_gc_mask_disable_reg()
69 *ct->mask_cache &= ~mask; in ingenic_tcu_gc_mask_disable_reg()
77 struct regmap *map = gc->private; in ingenic_tcu_gc_mask_disable_reg_and_ack()
78 u32 mask = d->mask; in ingenic_tcu_gc_mask_disable_reg_and_ack()
81 regmap_write(map, ct->regs.ack, mask); in ingenic_tcu_gc_mask_disable_reg_and_ack()
82 regmap_write(map, ct->regs.disable, mask); in ingenic_tcu_gc_mask_disable_reg_and_ack()
91 struct ingenic_tcu *tcu; in ingenic_tcu_irq_init() local
100 tcu = kzalloc(sizeof(*tcu), GFP_KERNEL); in ingenic_tcu_irq_init()
101 if (!tcu) in ingenic_tcu_irq_init()
102 return -ENOMEM; in ingenic_tcu_irq_init()
104 tcu->map = map; in ingenic_tcu_irq_init()
107 if (irqs < 0 || irqs > ARRAY_SIZE(tcu->parent_irqs)) { in ingenic_tcu_irq_init()
109 ret = -EINVAL; in ingenic_tcu_irq_init()
113 tcu->nb_parent_irqs = irqs; in ingenic_tcu_irq_init()
115 tcu->domain = irq_domain_add_linear(np, 32, &irq_generic_chip_ops, in ingenic_tcu_irq_init()
117 if (!tcu->domain) { in ingenic_tcu_irq_init()
118 ret = -ENOMEM; in ingenic_tcu_irq_init()
122 ret = irq_alloc_domain_generic_chips(tcu->domain, 32, 1, "TCU", in ingenic_tcu_irq_init()
130 gc = irq_get_domain_generic_chip(tcu->domain, 0); in ingenic_tcu_irq_init()
131 ct = gc->chip_types; in ingenic_tcu_irq_init()
133 gc->wake_enabled = IRQ_MSK(32); in ingenic_tcu_irq_init()
134 gc->private = tcu->map; in ingenic_tcu_irq_init()
136 ct->regs.disable = TCU_REG_TMSR; in ingenic_tcu_irq_init()
137 ct->regs.enable = TCU_REG_TMCR; in ingenic_tcu_irq_init()
138 ct->regs.ack = TCU_REG_TFCR; in ingenic_tcu_irq_init()
139 ct->chip.irq_unmask = ingenic_tcu_gc_unmask_enable_reg; in ingenic_tcu_irq_init()
140 ct->chip.irq_mask = ingenic_tcu_gc_mask_disable_reg; in ingenic_tcu_irq_init()
141 ct->chip.irq_mask_ack = ingenic_tcu_gc_mask_disable_reg_and_ack; in ingenic_tcu_irq_init()
142 ct->chip.flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE; in ingenic_tcu_irq_init()
145 regmap_write(tcu->map, TCU_REG_TMSR, IRQ_MSK(32)); in ingenic_tcu_irq_init()
149 * timers 2-7 share one interrupt. in ingenic_tcu_irq_init()
151 * timers 0-4 and 6-7 share one single interrupt. in ingenic_tcu_irq_init()
158 tcu->parent_irqs[i] = irq_of_parse_and_map(np, i); in ingenic_tcu_irq_init()
159 if (!tcu->parent_irqs[i]) { in ingenic_tcu_irq_init()
160 ret = -EINVAL; in ingenic_tcu_irq_init()
164 irq_set_chained_handler_and_data(tcu->parent_irqs[i], in ingenic_tcu_irq_init()
166 tcu->domain); in ingenic_tcu_irq_init()
172 for (; i > 0; i--) in ingenic_tcu_irq_init()
173 irq_dispose_mapping(tcu->parent_irqs[i - 1]); in ingenic_tcu_irq_init()
175 irq_domain_remove(tcu->domain); in ingenic_tcu_irq_init()
177 kfree(tcu); in ingenic_tcu_irq_init()
180 IRQCHIP_DECLARE(jz4740_tcu_irq, "ingenic,jz4740-tcu", ingenic_tcu_irq_init);
181 IRQCHIP_DECLARE(jz4725b_tcu_irq, "ingenic,jz4725b-tcu", ingenic_tcu_irq_init);
182 IRQCHIP_DECLARE(jz4770_tcu_irq, "ingenic,jz4770-tcu", ingenic_tcu_irq_init);
183 IRQCHIP_DECLARE(x1000_tcu_irq, "ingenic,x1000-tcu", ingenic_tcu_irq_init);