irq-renesas-intc-irqpin.c 17 KB

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