2 * Conexant Digicolor SoCs IRQ chip driver
4 * Author: Baruch Siach <baruch@tkos.co.il>
6 * Copyright (C) 2014 Paradox Innovation Ltd.
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
14 #include <linux/irq.h>
16 #include <linux/of_address.h>
17 #include <linux/of_irq.h>
18 #include <linux/mfd/syscon.h>
19 #include <linux/regmap.h>
21 #include <asm/exception.h>
25 #define UC_IRQ_CONTROL 0x04
27 #define IC_FLAG_CLEAR_LO 0x00
28 #define IC_FLAG_CLEAR_XLO 0x04
29 #define IC_INT0ENABLE_LO 0x10
30 #define IC_INT0ENABLE_XLO 0x14
31 #define IC_INT0STATUS_LO 0x18
32 #define IC_INT0STATUS_XLO 0x1c
34 static struct irq_domain
*digicolor_irq_domain
;
36 static void __exception_irq_entry
digicolor_handle_irq(struct pt_regs
*regs
)
38 struct irq_domain_chip_generic
*dgc
= digicolor_irq_domain
->gc
;
39 struct irq_chip_generic
*gc
= dgc
->gc
[0];
43 status
= irq_reg_readl(gc
, IC_INT0STATUS_LO
);
45 hwirq
= ffs(status
) - 1;
47 status
= irq_reg_readl(gc
, IC_INT0STATUS_XLO
);
49 hwirq
= ffs(status
) - 1 + 32;
54 handle_domain_irq(digicolor_irq_domain
, hwirq
, regs
);
58 static void digicolor_set_gc(void __iomem
*reg_base
, unsigned irq_base
,
59 unsigned en_reg
, unsigned ack_reg
)
61 struct irq_chip_generic
*gc
;
63 gc
= irq_get_domain_generic_chip(digicolor_irq_domain
, irq_base
);
64 gc
->reg_base
= reg_base
;
65 gc
->chip_types
[0].regs
.ack
= ack_reg
;
66 gc
->chip_types
[0].regs
.mask
= en_reg
;
67 gc
->chip_types
[0].chip
.irq_ack
= irq_gc_ack_set_bit
;
68 gc
->chip_types
[0].chip
.irq_mask
= irq_gc_mask_clr_bit
;
69 gc
->chip_types
[0].chip
.irq_unmask
= irq_gc_mask_set_bit
;
72 static int __init
digicolor_of_init(struct device_node
*node
,
73 struct device_node
*parent
)
75 static void __iomem
*reg_base
;
76 unsigned int clr
= IRQ_NOREQUEST
| IRQ_NOPROBE
| IRQ_NOAUTOEN
;
77 struct regmap
*ucregs
;
80 reg_base
= of_iomap(node
, 0);
82 pr_err("%s: unable to map IC registers\n", node
->full_name
);
86 /* disable all interrupts */
87 writel(0, reg_base
+ IC_INT0ENABLE_LO
);
88 writel(0, reg_base
+ IC_INT0ENABLE_XLO
);
90 ucregs
= syscon_regmap_lookup_by_phandle(node
, "syscon");
92 pr_err("%s: unable to map UC registers\n", node
->full_name
);
93 return PTR_ERR(ucregs
);
95 /* channel 1, regular IRQs */
96 regmap_write(ucregs
, UC_IRQ_CONTROL
, 1);
98 digicolor_irq_domain
=
99 irq_domain_add_linear(node
, 64, &irq_generic_chip_ops
, NULL
);
100 if (!digicolor_irq_domain
) {
101 pr_err("%s: unable to create IRQ domain\n", node
->full_name
);
105 ret
= irq_alloc_domain_generic_chips(digicolor_irq_domain
, 32, 1,
106 "digicolor_irq", handle_level_irq
,
109 pr_err("%s: unable to allocate IRQ gc\n", node
->full_name
);
113 digicolor_set_gc(reg_base
, 0, IC_INT0ENABLE_LO
, IC_FLAG_CLEAR_LO
);
114 digicolor_set_gc(reg_base
, 32, IC_INT0ENABLE_XLO
, IC_FLAG_CLEAR_XLO
);
116 set_handle_irq(digicolor_handle_irq
);
120 IRQCHIP_DECLARE(conexant_digicolor_ic
, "cnxt,cx92755-ic", digicolor_of_init
);