17 #include <linux/module.h>
26 static u32 ipu_read_reg(
struct ipu *
ipu,
unsigned long reg)
41 #define IPU_IRQ_NR_FN_BANKS 3
42 #define IPU_IRQ_NR_ERR_BANKS 2
43 #define IPU_IRQ_NR_BANKS (IPU_IRQ_NR_FN_BANKS + IPU_IRQ_NR_ERR_BANKS)
91 for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++)
92 if (irq_map[i].
source == src)
98 static void ipu_irq_unmask(
struct irq_data *
d)
110 pr_err(
"IPU: %s(%u) - unmapped!\n", __func__, d->
irq);
121 static void ipu_irq_mask(
struct irq_data *d)
123 struct ipu_irq_map *map = irq_data_get_irq_chip_data(d);
133 pr_err(
"IPU: %s(%u) - unmapped!\n", __func__, d->
irq);
138 reg &= ~(1
UL << (map->
source & 31));
144 static void ipu_irq_ack(
struct irq_data *d)
146 struct ipu_irq_map *map = irq_data_get_irq_chip_data(d);
155 pr_err(
"IPU: %s(%u) - unmapped!\n", __func__, d->
irq);
178 ret = bank && ipu_read_reg(bank->
ipu, bank->
status) &
206 map = src2map(source);
208 pr_err(
"IPU: Source %u already mapped to IRQ %u\n", source, map->
irq);
213 for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) {
219 irq_map[
i].bank = irq_bank + source / 32;
223 pr_debug(
"IPU: mapped source %u to IRQ %u\n",
232 pr_err(
"IPU: couldn't map source %u: %d\n", source, ret);
249 for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) {
250 if (
irq_map[i].source == source) {
253 pr_debug(
"IPU: unmapped source %u from IRQ %u\n",
273 struct ipu *
ipu = irq_get_handler_data(irq);
281 status = ipu_read_reg(ipu, bank->
status);
287 status &= ipu_read_reg(ipu, bank->
control);
289 while ((line =
ffs(status))) {
293 status &= ~(1
UL << line);
296 map = src2map(32 * i + line);
302 pr_err(
"IPU: Interrupt on unmapped source %u bank %d\n",
312 static void ipu_irq_fn(
unsigned int irq,
struct irq_desc *desc)
314 struct ipu *ipu = irq_desc_get_handler_data(desc);
322 status = ipu_read_reg(ipu, bank->
status);
324 status &= ipu_read_reg(ipu, bank->
control);
326 while ((line =
ffs(status))) {
330 status &= ~(1
UL << line);
333 map = src2map(32 * i + line);
339 pr_err(
"IPU: Interrupt on unmapped source %u bank %d\n",
348 static struct irq_chip ipu_irq_chip = {
350 .irq_ack = ipu_irq_ack,
351 .irq_mask = ipu_irq_mask,
352 .irq_unmask = ipu_irq_unmask,
359 int irq_base = irq_alloc_descs(-1, 0, CONFIG_MX3_IPU_IRQS,
366 irq_bank[i].ipu = ipu;
368 for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) {
388 irq_set_chained_handler(ipu->
irq_fn, ipu_irq_fn);
391 irq_set_chained_handler(ipu->
irq_err, ipu_irq_err);
400 unsigned int irq, irq_base;
410 for (irq = irq_base; irq < irq_base + CONFIG_MX3_IPU_IRQS; irq++) {