1 // SPDX-License-Identifier: GPL-2.0-only
3 * sl28cpld interrupt controller driver
5 * Copyright 2020 Kontron Europe GmbH
8 #include <linux/interrupt.h>
9 #include <linux/kernel.h>
10 #include <linux/mod_devicetable.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/property.h>
14 #include <linux/regmap.h>
19 static const struct regmap_irq sl28cpld_irqs
[] = {
20 REGMAP_IRQ_REG_LINE(0, 8),
21 REGMAP_IRQ_REG_LINE(1, 8),
22 REGMAP_IRQ_REG_LINE(2, 8),
23 REGMAP_IRQ_REG_LINE(3, 8),
24 REGMAP_IRQ_REG_LINE(4, 8),
25 REGMAP_IRQ_REG_LINE(5, 8),
26 REGMAP_IRQ_REG_LINE(6, 8),
27 REGMAP_IRQ_REG_LINE(7, 8),
30 struct sl28cpld_intc
{
31 struct regmap
*regmap
;
32 struct regmap_irq_chip chip
;
33 struct regmap_irq_chip_data
*irq_data
;
36 static int sl28cpld_intc_probe(struct platform_device
*pdev
)
38 struct device
*dev
= &pdev
->dev
;
39 struct sl28cpld_intc
*irqchip
;
47 irqchip
= devm_kzalloc(dev
, sizeof(*irqchip
), GFP_KERNEL
);
51 irqchip
->regmap
= dev_get_regmap(dev
->parent
, NULL
);
55 irq
= platform_get_irq(pdev
, 0);
59 ret
= device_property_read_u32(&pdev
->dev
, "reg", &base
);
63 irqchip
->chip
.name
= "sl28cpld-intc";
64 irqchip
->chip
.irqs
= sl28cpld_irqs
;
65 irqchip
->chip
.num_irqs
= ARRAY_SIZE(sl28cpld_irqs
);
66 irqchip
->chip
.num_regs
= 1;
67 irqchip
->chip
.status_base
= base
+ INTC_IP
;
68 irqchip
->chip
.mask_base
= base
+ INTC_IE
;
69 irqchip
->chip
.mask_invert
= true;
70 irqchip
->chip
.ack_base
= base
+ INTC_IP
;
72 return devm_regmap_add_irq_chip_fwnode(dev
, dev_fwnode(dev
),
74 IRQF_SHARED
| IRQF_ONESHOT
, 0,
79 static const struct of_device_id sl28cpld_intc_of_match
[] = {
80 { .compatible
= "kontron,sl28cpld-intc" },
83 MODULE_DEVICE_TABLE(of
, sl28cpld_intc_of_match
);
85 static struct platform_driver sl28cpld_intc_driver
= {
86 .probe
= sl28cpld_intc_probe
,
88 .name
= "sl28cpld-intc",
89 .of_match_table
= sl28cpld_intc_of_match
,
92 module_platform_driver(sl28cpld_intc_driver
);
94 MODULE_DESCRIPTION("sl28cpld Interrupt Controller Driver");
95 MODULE_AUTHOR("Michael Walle <michael@walle.cc>");
96 MODULE_LICENSE("GPL");