]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/irqchip/irq-renesas-intc-irqpin.c
irqchip/renesas-intc-irqpin: Use a separate lockdep class
[mirror_ubuntu-jammy-kernel.git] / drivers / irqchip / irq-renesas-intc-irqpin.c
CommitLineData
44358048
MD
1/*
2 * Renesas INTC External IRQ Pin Driver
3 *
4 * Copyright (C) 2013 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
705bc96c 20#include <linux/clk.h>
44358048 21#include <linux/init.h>
894db164 22#include <linux/of.h>
44358048
MD
23#include <linux/platform_device.h>
24#include <linux/spinlock.h>
25#include <linux/interrupt.h>
26#include <linux/ioport.h>
27#include <linux/io.h>
28#include <linux/irq.h>
29#include <linux/irqdomain.h>
30#include <linux/err.h>
31#include <linux/slab.h>
32#include <linux/module.h>
e03f9088 33#include <linux/of_device.h>
44358048 34#include <linux/platform_data/irq-renesas-intc-irqpin.h>
705bc96c 35#include <linux/pm_runtime.h>
44358048
MD
36
37#define INTC_IRQPIN_MAX 8 /* maximum 8 interrupts per driver instance */
38
39#define INTC_IRQPIN_REG_SENSE 0 /* ICRn */
40#define INTC_IRQPIN_REG_PRIO 1 /* INTPRInn */
41#define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */
42#define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */
43#define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */
e03f9088
MD
44#define INTC_IRQPIN_REG_NR_MANDATORY 5
45#define INTC_IRQPIN_REG_IRLM 5 /* ICR0 with IRLM bit (optional) */
46#define INTC_IRQPIN_REG_NR 6
44358048
MD
47
48/* INTC external IRQ PIN hardware register access:
49 *
50 * SENSE is read-write 32-bit with 2-bits or 4-bits per IRQ (*)
51 * PRIO is read-write 32-bit with 4-bits per IRQ (**)
52 * SOURCE is read-only 32-bit or 8-bit with 1-bit per IRQ (***)
53 * MASK is write-only 32-bit or 8-bit with 1-bit per IRQ (***)
54 * CLEAR is write-only 32-bit or 8-bit with 1-bit per IRQ (***)
55 *
56 * (*) May be accessed by more than one driver instance - lock needed
57 * (**) Read-modify-write access by one driver instance - lock needed
58 * (***) Accessed by one driver instance only - no locking needed
59 */
60
61struct intc_irqpin_iomem {
62 void __iomem *iomem;
63 unsigned long (*read)(void __iomem *iomem);
64 void (*write)(void __iomem *iomem, unsigned long data);
65 int width;
862d3098 66};
44358048
MD
67
68struct intc_irqpin_irq {
69 int hw_irq;
33f958f2
MD
70 int requested_irq;
71 int domain_irq;
44358048 72 struct intc_irqpin_priv *p;
862d3098 73};
44358048
MD
74
75struct intc_irqpin_priv {
76 struct intc_irqpin_iomem iomem[INTC_IRQPIN_REG_NR];
77 struct intc_irqpin_irq irq[INTC_IRQPIN_MAX];
78 struct renesas_intc_irqpin_config config;
79 unsigned int number_of_irqs;
80 struct platform_device *pdev;
81 struct irq_chip irq_chip;
82 struct irq_domain *irq_domain;
705bc96c 83 struct clk *clk;
427cc720
BH
84 bool shared_irqs;
85 u8 shared_irq_mask;
44358048
MD
86};
87
e03f9088
MD
88struct intc_irqpin_irlm_config {
89 unsigned int irlm_bit;
90};
91
44358048
MD
92static unsigned long intc_irqpin_read32(void __iomem *iomem)
93{
94 return ioread32(iomem);
95}
96
97static unsigned long intc_irqpin_read8(void __iomem *iomem)
98{
99 return ioread8(iomem);
100}
101
102static void intc_irqpin_write32(void __iomem *iomem, unsigned long data)
103{
104 iowrite32(data, iomem);
105}
106
107static void intc_irqpin_write8(void __iomem *iomem, unsigned long data)
108{
109 iowrite8(data, iomem);
110}
111
112static inline unsigned long intc_irqpin_read(struct intc_irqpin_priv *p,
113 int reg)
114{
115 struct intc_irqpin_iomem *i = &p->iomem[reg];
862d3098 116
44358048
MD
117 return i->read(i->iomem);
118}
119
120static inline void intc_irqpin_write(struct intc_irqpin_priv *p,
121 int reg, unsigned long data)
122{
123 struct intc_irqpin_iomem *i = &p->iomem[reg];
862d3098 124
44358048
MD
125 i->write(i->iomem, data);
126}
127
128static inline unsigned long intc_irqpin_hwirq_mask(struct intc_irqpin_priv *p,
129 int reg, int hw_irq)
130{
131 return BIT((p->iomem[reg].width - 1) - hw_irq);
132}
133
134static inline void intc_irqpin_irq_write_hwirq(struct intc_irqpin_priv *p,
135 int reg, int hw_irq)
136{
137 intc_irqpin_write(p, reg, intc_irqpin_hwirq_mask(p, reg, hw_irq));
138}
139
140static DEFINE_RAW_SPINLOCK(intc_irqpin_lock); /* only used by slow path */
141
142static void intc_irqpin_read_modify_write(struct intc_irqpin_priv *p,
143 int reg, int shift,
144 int width, int value)
145{
146 unsigned long flags;
147 unsigned long tmp;
148
149 raw_spin_lock_irqsave(&intc_irqpin_lock, flags);
150
151 tmp = intc_irqpin_read(p, reg);
152 tmp &= ~(((1 << width) - 1) << shift);
153 tmp |= value << shift;
154 intc_irqpin_write(p, reg, tmp);
155
156 raw_spin_unlock_irqrestore(&intc_irqpin_lock, flags);
157}
158
159static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p,
160 int irq, int do_mask)
161{
e55bc558
LP
162 /* The PRIO register is assumed to be 32-bit with fixed 4-bit fields. */
163 int bitfield_width = 4;
164 int shift = 32 - (irq + 1) * bitfield_width;
44358048
MD
165
166 intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_PRIO,
167 shift, bitfield_width,
168 do_mask ? 0 : (1 << bitfield_width) - 1);
169}
170
171static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value)
172{
e55bc558 173 /* The SENSE register is assumed to be 32-bit. */
44358048 174 int bitfield_width = p->config.sense_bitfield_width;
e55bc558 175 int shift = 32 - (irq + 1) * bitfield_width;
44358048
MD
176
177 dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value);
178
179 if (value >= (1 << bitfield_width))
180 return -EINVAL;
181
182 intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_SENSE, shift,
183 bitfield_width, value);
184 return 0;
185}
186
187static void intc_irqpin_dbg(struct intc_irqpin_irq *i, char *str)
188{
189 dev_dbg(&i->p->pdev->dev, "%s (%d:%d:%d)\n",
33f958f2 190 str, i->requested_irq, i->hw_irq, i->domain_irq);
44358048
MD
191}
192
193static void intc_irqpin_irq_enable(struct irq_data *d)
194{
195 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
196 int hw_irq = irqd_to_hwirq(d);
197
198 intc_irqpin_dbg(&p->irq[hw_irq], "enable");
199 intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_CLEAR, hw_irq);
200}
201
202static void intc_irqpin_irq_disable(struct irq_data *d)
203{
204 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
205 int hw_irq = irqd_to_hwirq(d);
206
207 intc_irqpin_dbg(&p->irq[hw_irq], "disable");
208 intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_MASK, hw_irq);
209}
210
427cc720
BH
211static void intc_irqpin_shared_irq_enable(struct irq_data *d)
212{
213 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
214 int hw_irq = irqd_to_hwirq(d);
215
216 intc_irqpin_dbg(&p->irq[hw_irq], "shared enable");
217 intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_CLEAR, hw_irq);
218
219 p->shared_irq_mask &= ~BIT(hw_irq);
220}
221
222static void intc_irqpin_shared_irq_disable(struct irq_data *d)
223{
224 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
225 int hw_irq = irqd_to_hwirq(d);
226
227 intc_irqpin_dbg(&p->irq[hw_irq], "shared disable");
228 intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_MASK, hw_irq);
229
230 p->shared_irq_mask |= BIT(hw_irq);
231}
232
44358048
MD
233static void intc_irqpin_irq_enable_force(struct irq_data *d)
234{
235 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
33f958f2 236 int irq = p->irq[irqd_to_hwirq(d)].requested_irq;
44358048
MD
237
238 intc_irqpin_irq_enable(d);
d1b6aecd
MD
239
240 /* enable interrupt through parent interrupt controller,
241 * assumes non-shared interrupt with 1:1 mapping
242 * needed for busted IRQs on some SoCs like sh73a0
243 */
44358048
MD
244 irq_get_chip(irq)->irq_unmask(irq_get_irq_data(irq));
245}
246
247static void intc_irqpin_irq_disable_force(struct irq_data *d)
248{
249 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
33f958f2 250 int irq = p->irq[irqd_to_hwirq(d)].requested_irq;
44358048 251
d1b6aecd
MD
252 /* disable interrupt through parent interrupt controller,
253 * assumes non-shared interrupt with 1:1 mapping
254 * needed for busted IRQs on some SoCs like sh73a0
255 */
44358048
MD
256 irq_get_chip(irq)->irq_mask(irq_get_irq_data(irq));
257 intc_irqpin_irq_disable(d);
258}
259
260#define INTC_IRQ_SENSE_VALID 0x10
261#define INTC_IRQ_SENSE(x) (x + INTC_IRQ_SENSE_VALID)
262
263static unsigned char intc_irqpin_sense[IRQ_TYPE_SENSE_MASK + 1] = {
264 [IRQ_TYPE_EDGE_FALLING] = INTC_IRQ_SENSE(0x00),
265 [IRQ_TYPE_EDGE_RISING] = INTC_IRQ_SENSE(0x01),
266 [IRQ_TYPE_LEVEL_LOW] = INTC_IRQ_SENSE(0x02),
267 [IRQ_TYPE_LEVEL_HIGH] = INTC_IRQ_SENSE(0x03),
268 [IRQ_TYPE_EDGE_BOTH] = INTC_IRQ_SENSE(0x04),
269};
270
271static int intc_irqpin_irq_set_type(struct irq_data *d, unsigned int type)
272{
273 unsigned char value = intc_irqpin_sense[type & IRQ_TYPE_SENSE_MASK];
274 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
275
276 if (!(value & INTC_IRQ_SENSE_VALID))
277 return -EINVAL;
278
279 return intc_irqpin_set_sense(p, irqd_to_hwirq(d),
280 value ^ INTC_IRQ_SENSE_VALID);
281}
282
705bc96c
GU
283static int intc_irqpin_irq_set_wake(struct irq_data *d, unsigned int on)
284{
285 struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
286
287 if (!p->clk)
288 return 0;
289
290 if (on)
291 clk_enable(p->clk);
292 else
293 clk_disable(p->clk);
294
295 return 0;
296}
297
44358048
MD
298static irqreturn_t intc_irqpin_irq_handler(int irq, void *dev_id)
299{
300 struct intc_irqpin_irq *i = dev_id;
301 struct intc_irqpin_priv *p = i->p;
302 unsigned long bit;
303
304 intc_irqpin_dbg(i, "demux1");
305 bit = intc_irqpin_hwirq_mask(p, INTC_IRQPIN_REG_SOURCE, i->hw_irq);
306
307 if (intc_irqpin_read(p, INTC_IRQPIN_REG_SOURCE) & bit) {
308 intc_irqpin_write(p, INTC_IRQPIN_REG_SOURCE, ~bit);
309 intc_irqpin_dbg(i, "demux2");
33f958f2 310 generic_handle_irq(i->domain_irq);
44358048
MD
311 return IRQ_HANDLED;
312 }
313 return IRQ_NONE;
314}
315
427cc720
BH
316static irqreturn_t intc_irqpin_shared_irq_handler(int irq, void *dev_id)
317{
318 struct intc_irqpin_priv *p = dev_id;
319 unsigned int reg_source = intc_irqpin_read(p, INTC_IRQPIN_REG_SOURCE);
320 irqreturn_t status = IRQ_NONE;
321 int k;
322
323 for (k = 0; k < 8; k++) {
324 if (reg_source & BIT(7 - k)) {
325 if (BIT(k) & p->shared_irq_mask)
326 continue;
327
328 status |= intc_irqpin_irq_handler(irq, &p->irq[k]);
329 }
330 }
331
332 return status;
333}
334
769b5cf7
GU
335/*
336 * This lock class tells lockdep that INTC External IRQ Pin irqs are in a
337 * different category than their parents, so it won't report false recursion.
338 */
339static struct lock_class_key intc_irqpin_irq_lock_class;
340
44358048
MD
341static int intc_irqpin_irq_domain_map(struct irq_domain *h, unsigned int virq,
342 irq_hw_number_t hw)
343{
344 struct intc_irqpin_priv *p = h->host_data;
345
33f958f2
MD
346 p->irq[hw].domain_irq = virq;
347 p->irq[hw].hw_irq = hw;
348
44358048
MD
349 intc_irqpin_dbg(&p->irq[hw], "map");
350 irq_set_chip_data(virq, h->host_data);
769b5cf7 351 irq_set_lockdep_class(virq, &intc_irqpin_irq_lock_class);
44358048
MD
352 irq_set_chip_and_handler(virq, &p->irq_chip, handle_level_irq);
353 set_irq_flags(virq, IRQF_VALID); /* kill me now */
354 return 0;
355}
356
96009736 357static const struct irq_domain_ops intc_irqpin_irq_domain_ops = {
44358048 358 .map = intc_irqpin_irq_domain_map,
9d833bbe 359 .xlate = irq_domain_xlate_twocell,
44358048
MD
360};
361
e03f9088
MD
362static const struct intc_irqpin_irlm_config intc_irqpin_irlm_r8a7779 = {
363 .irlm_bit = 23, /* ICR0.IRLM0 */
364};
365
366static const struct of_device_id intc_irqpin_dt_ids[] = {
367 { .compatible = "renesas,intc-irqpin", },
368 { .compatible = "renesas,intc-irqpin-r8a7779",
369 .data = &intc_irqpin_irlm_r8a7779 },
370 {},
371};
372MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
373
44358048
MD
374static int intc_irqpin_probe(struct platform_device *pdev)
375{
36845f1b
GU
376 struct device *dev = &pdev->dev;
377 struct renesas_intc_irqpin_config *pdata = dev->platform_data;
e03f9088 378 const struct of_device_id *of_id;
44358048
MD
379 struct intc_irqpin_priv *p;
380 struct intc_irqpin_iomem *i;
381 struct resource *io[INTC_IRQPIN_REG_NR];
382 struct resource *irq;
383 struct irq_chip *irq_chip;
384 void (*enable_fn)(struct irq_data *d);
385 void (*disable_fn)(struct irq_data *d);
36845f1b 386 const char *name = dev_name(dev);
427cc720 387 int ref_irq;
44358048
MD
388 int ret;
389 int k;
390
36845f1b 391 p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL);
44358048 392 if (!p) {
36845f1b 393 dev_err(dev, "failed to allocate driver data\n");
705bc96c 394 return -ENOMEM;
44358048
MD
395 }
396
397 /* deal with driver instance configuration */
c4fa4946 398 if (pdata) {
44358048 399 memcpy(&p->config, pdata, sizeof(*pdata));
c4fa4946 400 } else {
36845f1b 401 of_property_read_u32(dev->of_node, "sense-bitfield-width",
894db164 402 &p->config.sense_bitfield_width);
36845f1b 403 p->config.control_parent = of_property_read_bool(dev->of_node,
c4fa4946
GL
404 "control-parent");
405 }
44358048
MD
406 if (!p->config.sense_bitfield_width)
407 p->config.sense_bitfield_width = 4; /* default to 4 bits */
408
409 p->pdev = pdev;
410 platform_set_drvdata(pdev, p);
411
705bc96c
GU
412 p->clk = devm_clk_get(dev, NULL);
413 if (IS_ERR(p->clk)) {
414 dev_warn(dev, "unable to get clock\n");
415 p->clk = NULL;
416 }
417
418 pm_runtime_enable(dev);
419 pm_runtime_get_sync(dev);
420
e03f9088
MD
421 /* get hold of register banks */
422 memset(io, 0, sizeof(io));
44358048
MD
423 for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
424 io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
e03f9088 425 if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
36845f1b 426 dev_err(dev, "not enough IOMEM resources\n");
44358048 427 ret = -EINVAL;
08eba5ba 428 goto err0;
44358048
MD
429 }
430 }
431
432 /* allow any number of IRQs between 1 and INTC_IRQPIN_MAX */
433 for (k = 0; k < INTC_IRQPIN_MAX; k++) {
434 irq = platform_get_resource(pdev, IORESOURCE_IRQ, k);
435 if (!irq)
436 break;
437
44358048 438 p->irq[k].p = p;
33f958f2 439 p->irq[k].requested_irq = irq->start;
44358048
MD
440 }
441
442 p->number_of_irqs = k;
443 if (p->number_of_irqs < 1) {
36845f1b 444 dev_err(dev, "not enough IRQ resources\n");
44358048 445 ret = -EINVAL;
08eba5ba 446 goto err0;
44358048
MD
447 }
448
449 /* ioremap IOMEM and setup read/write callbacks */
450 for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
451 i = &p->iomem[k];
452
e03f9088
MD
453 /* handle optional registers */
454 if (!io[k])
455 continue;
456
44358048
MD
457 switch (resource_size(io[k])) {
458 case 1:
459 i->width = 8;
460 i->read = intc_irqpin_read8;
461 i->write = intc_irqpin_write8;
462 break;
463 case 4:
464 i->width = 32;
465 i->read = intc_irqpin_read32;
466 i->write = intc_irqpin_write32;
467 break;
468 default:
36845f1b 469 dev_err(dev, "IOMEM size mismatch\n");
44358048 470 ret = -EINVAL;
08eba5ba 471 goto err0;
44358048
MD
472 }
473
36845f1b 474 i->iomem = devm_ioremap_nocache(dev, io[k]->start,
08eba5ba 475 resource_size(io[k]));
44358048 476 if (!i->iomem) {
36845f1b 477 dev_err(dev, "failed to remap IOMEM\n");
44358048 478 ret = -ENXIO;
08eba5ba 479 goto err0;
44358048
MD
480 }
481 }
482
e03f9088
MD
483 /* configure "individual IRQ mode" where needed */
484 of_id = of_match_device(intc_irqpin_dt_ids, dev);
485 if (of_id && of_id->data) {
486 const struct intc_irqpin_irlm_config *irlm_config = of_id->data;
487
488 if (io[INTC_IRQPIN_REG_IRLM])
489 intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_IRLM,
490 irlm_config->irlm_bit,
491 1, 1);
492 else
493 dev_warn(dev, "unable to select IRLM mode\n");
494 }
495
44358048
MD
496 /* mask all interrupts using priority */
497 for (k = 0; k < p->number_of_irqs; k++)
498 intc_irqpin_mask_unmask_prio(p, k, 1);
499
427cc720
BH
500 /* clear all pending interrupts */
501 intc_irqpin_write(p, INTC_IRQPIN_REG_SOURCE, 0x0);
502
503 /* scan for shared interrupt lines */
504 ref_irq = p->irq[0].requested_irq;
505 p->shared_irqs = true;
506 for (k = 1; k < p->number_of_irqs; k++) {
507 if (ref_irq != p->irq[k].requested_irq) {
508 p->shared_irqs = false;
509 break;
510 }
511 }
512
44358048
MD
513 /* use more severe masking method if requested */
514 if (p->config.control_parent) {
515 enable_fn = intc_irqpin_irq_enable_force;
516 disable_fn = intc_irqpin_irq_disable_force;
427cc720 517 } else if (!p->shared_irqs) {
44358048
MD
518 enable_fn = intc_irqpin_irq_enable;
519 disable_fn = intc_irqpin_irq_disable;
427cc720
BH
520 } else {
521 enable_fn = intc_irqpin_shared_irq_enable;
522 disable_fn = intc_irqpin_shared_irq_disable;
44358048
MD
523 }
524
525 irq_chip = &p->irq_chip;
526 irq_chip->name = name;
527 irq_chip->irq_mask = disable_fn;
528 irq_chip->irq_unmask = enable_fn;
44358048 529 irq_chip->irq_set_type = intc_irqpin_irq_set_type;
705bc96c
GU
530 irq_chip->irq_set_wake = intc_irqpin_irq_set_wake;
531 irq_chip->flags = IRQCHIP_MASK_ON_SUSPEND;
44358048 532
36845f1b 533 p->irq_domain = irq_domain_add_simple(dev->of_node,
44358048
MD
534 p->number_of_irqs,
535 p->config.irq_base,
536 &intc_irqpin_irq_domain_ops, p);
537 if (!p->irq_domain) {
538 ret = -ENXIO;
36845f1b 539 dev_err(dev, "cannot initialize irq domain\n");
08eba5ba 540 goto err0;
44358048
MD
541 }
542
427cc720
BH
543 if (p->shared_irqs) {
544 /* request one shared interrupt */
36845f1b 545 if (devm_request_irq(dev, p->irq[0].requested_irq,
427cc720
BH
546 intc_irqpin_shared_irq_handler,
547 IRQF_SHARED, name, p)) {
36845f1b 548 dev_err(dev, "failed to request low IRQ\n");
44358048 549 ret = -ENOENT;
08eba5ba 550 goto err1;
44358048 551 }
427cc720
BH
552 } else {
553 /* request interrupts one by one */
554 for (k = 0; k < p->number_of_irqs; k++) {
36845f1b
GU
555 if (devm_request_irq(dev, p->irq[k].requested_irq,
556 intc_irqpin_irq_handler, 0, name,
557 &p->irq[k])) {
558 dev_err(dev, "failed to request low IRQ\n");
427cc720
BH
559 ret = -ENOENT;
560 goto err1;
561 }
562 }
44358048
MD
563 }
564
427cc720
BH
565 /* unmask all interrupts on prio level */
566 for (k = 0; k < p->number_of_irqs; k++)
567 intc_irqpin_mask_unmask_prio(p, k, 0);
568
36845f1b 569 dev_info(dev, "driving %d irqs\n", p->number_of_irqs);
44358048
MD
570
571 /* warn in case of mismatch if irq base is specified */
572 if (p->config.irq_base) {
33f958f2 573 if (p->config.irq_base != p->irq[0].domain_irq)
36845f1b 574 dev_warn(dev, "irq base mismatch (%d/%d)\n",
33f958f2 575 p->config.irq_base, p->irq[0].domain_irq);
44358048 576 }
862d3098 577
44358048
MD
578 return 0;
579
44358048 580err1:
08eba5ba 581 irq_domain_remove(p->irq_domain);
44358048 582err0:
705bc96c
GU
583 pm_runtime_put(dev);
584 pm_runtime_disable(dev);
44358048
MD
585 return ret;
586}
587
588static int intc_irqpin_remove(struct platform_device *pdev)
589{
590 struct intc_irqpin_priv *p = platform_get_drvdata(pdev);
44358048
MD
591
592 irq_domain_remove(p->irq_domain);
705bc96c
GU
593 pm_runtime_put(&pdev->dev);
594 pm_runtime_disable(&pdev->dev);
44358048
MD
595 return 0;
596}
597
598static struct platform_driver intc_irqpin_device_driver = {
599 .probe = intc_irqpin_probe,
600 .remove = intc_irqpin_remove,
601 .driver = {
602 .name = "renesas_intc_irqpin",
9d833bbe 603 .of_match_table = intc_irqpin_dt_ids,
44358048
MD
604 }
605};
606
607static int __init intc_irqpin_init(void)
608{
609 return platform_driver_register(&intc_irqpin_device_driver);
610}
611postcore_initcall(intc_irqpin_init);
612
613static void __exit intc_irqpin_exit(void)
614{
615 platform_driver_unregister(&intc_irqpin_device_driver);
616}
617module_exit(intc_irqpin_exit);
618
619MODULE_AUTHOR("Magnus Damm");
620MODULE_DESCRIPTION("Renesas INTC External IRQ Pin Driver");
621MODULE_LICENSE("GPL v2");