irq-meson-gpio.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015 Endless Mobile, Inc.
  4. * Author: Carlo Caione <[email protected]>
  5. * Copyright (c) 2016 BayLibre, SAS.
  6. * Author: Jerome Brunet <[email protected]>
  7. */
  8. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  9. #include <linux/io.h>
  10. #include <linux/module.h>
  11. #include <linux/irq.h>
  12. #include <linux/irqdomain.h>
  13. #include <linux/irqchip.h>
  14. #include <linux/of.h>
  15. #include <linux/of_address.h>
  16. #define MAX_NUM_CHANNEL 64
  17. #define MAX_INPUT_MUX 256
  18. #define REG_EDGE_POL 0x00
  19. #define REG_PIN_03_SEL 0x04
  20. #define REG_PIN_47_SEL 0x08
  21. #define REG_FILTER_SEL 0x0c
  22. /* use for A1 like chips */
  23. #define REG_PIN_A1_SEL 0x04
  24. /* Used for s4 chips */
  25. #define REG_EDGE_POL_S4 0x1c
  26. /*
  27. * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by
  28. * bits 24 to 31. Tests on the actual HW show that these bits are
  29. * stuck at 0. Bits 8 to 15 are responsive and have the expected
  30. * effect.
  31. */
  32. #define REG_EDGE_POL_EDGE(params, x) BIT((params)->edge_single_offset + (x))
  33. #define REG_EDGE_POL_LOW(params, x) BIT((params)->pol_low_offset + (x))
  34. #define REG_BOTH_EDGE(params, x) BIT((params)->edge_both_offset + (x))
  35. #define REG_EDGE_POL_MASK(params, x) ( \
  36. REG_EDGE_POL_EDGE(params, x) | \
  37. REG_EDGE_POL_LOW(params, x) | \
  38. REG_BOTH_EDGE(params, x))
  39. #define REG_PIN_SEL_SHIFT(x) (((x) % 4) * 8)
  40. #define REG_FILTER_SEL_SHIFT(x) ((x) * 4)
  41. struct meson_gpio_irq_controller;
  42. static void meson8_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,
  43. unsigned int channel, unsigned long hwirq);
  44. static void meson_gpio_irq_init_dummy(struct meson_gpio_irq_controller *ctl);
  45. static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,
  46. unsigned int channel,
  47. unsigned long hwirq);
  48. static void meson_a1_gpio_irq_init(struct meson_gpio_irq_controller *ctl);
  49. static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,
  50. unsigned int type, u32 *channel_hwirq);
  51. static int meson_s4_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,
  52. unsigned int type, u32 *channel_hwirq);
  53. struct irq_ctl_ops {
  54. void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl,
  55. unsigned int channel, unsigned long hwirq);
  56. void (*gpio_irq_init)(struct meson_gpio_irq_controller *ctl);
  57. int (*gpio_irq_set_type)(struct meson_gpio_irq_controller *ctl,
  58. unsigned int type, u32 *channel_hwirq);
  59. };
  60. struct meson_gpio_irq_params {
  61. unsigned int nr_hwirq;
  62. unsigned int nr_channels;
  63. bool support_edge_both;
  64. unsigned int edge_both_offset;
  65. unsigned int edge_single_offset;
  66. unsigned int pol_low_offset;
  67. unsigned int pin_sel_mask;
  68. struct irq_ctl_ops ops;
  69. };
  70. #define INIT_MESON_COMMON(irqs, init, sel, type) \
  71. .nr_hwirq = irqs, \
  72. .ops = { \
  73. .gpio_irq_init = init, \
  74. .gpio_irq_sel_pin = sel, \
  75. .gpio_irq_set_type = type, \
  76. },
  77. #define INIT_MESON8_COMMON_DATA(irqs) \
  78. INIT_MESON_COMMON(irqs, meson_gpio_irq_init_dummy, \
  79. meson8_gpio_irq_sel_pin, \
  80. meson8_gpio_irq_set_type) \
  81. .edge_single_offset = 0, \
  82. .pol_low_offset = 16, \
  83. .pin_sel_mask = 0xff, \
  84. .nr_channels = 8, \
  85. #define INIT_MESON_A1_COMMON_DATA(irqs) \
  86. INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
  87. meson_a1_gpio_irq_sel_pin, \
  88. meson8_gpio_irq_set_type) \
  89. .support_edge_both = true, \
  90. .edge_both_offset = 16, \
  91. .edge_single_offset = 8, \
  92. .pol_low_offset = 0, \
  93. .pin_sel_mask = 0x7f, \
  94. .nr_channels = 8, \
  95. #define INIT_MESON_S4_COMMON_DATA(irqs) \
  96. INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
  97. meson_a1_gpio_irq_sel_pin, \
  98. meson_s4_gpio_irq_set_type) \
  99. .support_edge_both = true, \
  100. .edge_both_offset = 0, \
  101. .edge_single_offset = 12, \
  102. .pol_low_offset = 0, \
  103. .pin_sel_mask = 0xff, \
  104. .nr_channels = 12, \
  105. static const struct meson_gpio_irq_params meson8_params = {
  106. INIT_MESON8_COMMON_DATA(134)
  107. };
  108. static const struct meson_gpio_irq_params meson8b_params = {
  109. INIT_MESON8_COMMON_DATA(119)
  110. };
  111. static const struct meson_gpio_irq_params gxbb_params = {
  112. INIT_MESON8_COMMON_DATA(133)
  113. };
  114. static const struct meson_gpio_irq_params gxl_params = {
  115. INIT_MESON8_COMMON_DATA(110)
  116. };
  117. static const struct meson_gpio_irq_params axg_params = {
  118. INIT_MESON8_COMMON_DATA(100)
  119. };
  120. static const struct meson_gpio_irq_params sm1_params = {
  121. INIT_MESON8_COMMON_DATA(100)
  122. .support_edge_both = true,
  123. .edge_both_offset = 8,
  124. };
  125. static const struct meson_gpio_irq_params a1_params = {
  126. INIT_MESON_A1_COMMON_DATA(62)
  127. };
  128. static const struct meson_gpio_irq_params s4_params = {
  129. INIT_MESON_S4_COMMON_DATA(82)
  130. };
  131. static const struct of_device_id meson_irq_gpio_matches[] __maybe_unused = {
  132. { .compatible = "amlogic,meson8-gpio-intc", .data = &meson8_params },
  133. { .compatible = "amlogic,meson8b-gpio-intc", .data = &meson8b_params },
  134. { .compatible = "amlogic,meson-gxbb-gpio-intc", .data = &gxbb_params },
  135. { .compatible = "amlogic,meson-gxl-gpio-intc", .data = &gxl_params },
  136. { .compatible = "amlogic,meson-axg-gpio-intc", .data = &axg_params },
  137. { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params },
  138. { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params },
  139. { .compatible = "amlogic,meson-a1-gpio-intc", .data = &a1_params },
  140. { .compatible = "amlogic,meson-s4-gpio-intc", .data = &s4_params },
  141. { }
  142. };
  143. struct meson_gpio_irq_controller {
  144. const struct meson_gpio_irq_params *params;
  145. void __iomem *base;
  146. u32 channel_irqs[MAX_NUM_CHANNEL];
  147. DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL);
  148. spinlock_t lock;
  149. };
  150. static void meson_gpio_irq_update_bits(struct meson_gpio_irq_controller *ctl,
  151. unsigned int reg, u32 mask, u32 val)
  152. {
  153. unsigned long flags;
  154. u32 tmp;
  155. spin_lock_irqsave(&ctl->lock, flags);
  156. tmp = readl_relaxed(ctl->base + reg);
  157. tmp &= ~mask;
  158. tmp |= val;
  159. writel_relaxed(tmp, ctl->base + reg);
  160. spin_unlock_irqrestore(&ctl->lock, flags);
  161. }
  162. static void meson_gpio_irq_init_dummy(struct meson_gpio_irq_controller *ctl)
  163. {
  164. }
  165. static void meson8_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,
  166. unsigned int channel, unsigned long hwirq)
  167. {
  168. unsigned int reg_offset;
  169. unsigned int bit_offset;
  170. reg_offset = (channel < 4) ? REG_PIN_03_SEL : REG_PIN_47_SEL;
  171. bit_offset = REG_PIN_SEL_SHIFT(channel);
  172. meson_gpio_irq_update_bits(ctl, reg_offset,
  173. ctl->params->pin_sel_mask << bit_offset,
  174. hwirq << bit_offset);
  175. }
  176. static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,
  177. unsigned int channel,
  178. unsigned long hwirq)
  179. {
  180. unsigned int reg_offset;
  181. unsigned int bit_offset;
  182. bit_offset = ((channel % 2) == 0) ? 0 : 16;
  183. reg_offset = REG_PIN_A1_SEL + ((channel / 2) << 2);
  184. meson_gpio_irq_update_bits(ctl, reg_offset,
  185. ctl->params->pin_sel_mask << bit_offset,
  186. hwirq << bit_offset);
  187. }
  188. /* For a1 or later chips like a1 there is a switch to enable/disable irq */
  189. static void meson_a1_gpio_irq_init(struct meson_gpio_irq_controller *ctl)
  190. {
  191. meson_gpio_irq_update_bits(ctl, REG_EDGE_POL, BIT(31), BIT(31));
  192. }
  193. static int
  194. meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,
  195. unsigned long hwirq,
  196. u32 **channel_hwirq)
  197. {
  198. unsigned long flags;
  199. unsigned int idx;
  200. spin_lock_irqsave(&ctl->lock, flags);
  201. /* Find a free channel */
  202. idx = find_first_zero_bit(ctl->channel_map, ctl->params->nr_channels);
  203. if (idx >= ctl->params->nr_channels) {
  204. spin_unlock_irqrestore(&ctl->lock, flags);
  205. pr_err("No channel available\n");
  206. return -ENOSPC;
  207. }
  208. /* Mark the channel as used */
  209. set_bit(idx, ctl->channel_map);
  210. spin_unlock_irqrestore(&ctl->lock, flags);
  211. /*
  212. * Setup the mux of the channel to route the signal of the pad
  213. * to the appropriate input of the GIC
  214. */
  215. ctl->params->ops.gpio_irq_sel_pin(ctl, idx, hwirq);
  216. /*
  217. * Get the hwirq number assigned to this channel through
  218. * a pointer the channel_irq table. The added benefit of this
  219. * method is that we can also retrieve the channel index with
  220. * it, using the table base.
  221. */
  222. *channel_hwirq = &(ctl->channel_irqs[idx]);
  223. pr_debug("hwirq %lu assigned to channel %d - irq %u\n",
  224. hwirq, idx, **channel_hwirq);
  225. return 0;
  226. }
  227. static unsigned int
  228. meson_gpio_irq_get_channel_idx(struct meson_gpio_irq_controller *ctl,
  229. u32 *channel_hwirq)
  230. {
  231. return channel_hwirq - ctl->channel_irqs;
  232. }
  233. static void
  234. meson_gpio_irq_release_channel(struct meson_gpio_irq_controller *ctl,
  235. u32 *channel_hwirq)
  236. {
  237. unsigned int idx;
  238. idx = meson_gpio_irq_get_channel_idx(ctl, channel_hwirq);
  239. clear_bit(idx, ctl->channel_map);
  240. }
  241. static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,
  242. unsigned int type, u32 *channel_hwirq)
  243. {
  244. u32 val = 0;
  245. unsigned int idx;
  246. const struct meson_gpio_irq_params *params;
  247. params = ctl->params;
  248. idx = meson_gpio_irq_get_channel_idx(ctl, channel_hwirq);
  249. /*
  250. * The controller has a filter block to operate in either LEVEL or
  251. * EDGE mode, then signal is sent to the GIC. To enable LEVEL_LOW and
  252. * EDGE_FALLING support (which the GIC does not support), the filter
  253. * block is also able to invert the input signal it gets before
  254. * providing it to the GIC.
  255. */
  256. type &= IRQ_TYPE_SENSE_MASK;
  257. /*
  258. * New controller support EDGE_BOTH trigger. This setting takes
  259. * precedence over the other edge/polarity settings
  260. */
  261. if (type == IRQ_TYPE_EDGE_BOTH) {
  262. if (!params->support_edge_both)
  263. return -EINVAL;
  264. val |= REG_BOTH_EDGE(params, idx);
  265. } else {
  266. if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
  267. val |= REG_EDGE_POL_EDGE(params, idx);
  268. if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING))
  269. val |= REG_EDGE_POL_LOW(params, idx);
  270. }
  271. meson_gpio_irq_update_bits(ctl, REG_EDGE_POL,
  272. REG_EDGE_POL_MASK(params, idx), val);
  273. return 0;
  274. }
  275. /*
  276. * gpio irq relative registers for s4
  277. * -PADCTRL_GPIO_IRQ_CTRL0
  278. * bit[31]: enable/disable all the irq lines
  279. * bit[12-23]: single edge trigger
  280. * bit[0-11]: polarity trigger
  281. *
  282. * -PADCTRL_GPIO_IRQ_CTRL[X]
  283. * bit[0-16]: 7 bits to choose gpio source for irq line 2*[X] - 2
  284. * bit[16-22]:7 bits to choose gpio source for irq line 2*[X] - 1
  285. * where X = 1-6
  286. *
  287. * -PADCTRL_GPIO_IRQ_CTRL[7]
  288. * bit[0-11]: both edge trigger
  289. */
  290. static int meson_s4_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,
  291. unsigned int type, u32 *channel_hwirq)
  292. {
  293. u32 val = 0;
  294. unsigned int idx;
  295. idx = meson_gpio_irq_get_channel_idx(ctl, channel_hwirq);
  296. type &= IRQ_TYPE_SENSE_MASK;
  297. meson_gpio_irq_update_bits(ctl, REG_EDGE_POL_S4, BIT(idx), 0);
  298. if (type == IRQ_TYPE_EDGE_BOTH) {
  299. val |= BIT(ctl->params->edge_both_offset + idx);
  300. meson_gpio_irq_update_bits(ctl, REG_EDGE_POL_S4,
  301. BIT(ctl->params->edge_both_offset + idx), val);
  302. return 0;
  303. }
  304. if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING))
  305. val |= BIT(ctl->params->pol_low_offset + idx);
  306. if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
  307. val |= BIT(ctl->params->edge_single_offset + idx);
  308. meson_gpio_irq_update_bits(ctl, REG_EDGE_POL,
  309. BIT(idx) | BIT(12 + idx), val);
  310. return 0;
  311. };
  312. static unsigned int meson_gpio_irq_type_output(unsigned int type)
  313. {
  314. unsigned int sense = type & IRQ_TYPE_SENSE_MASK;
  315. type &= ~IRQ_TYPE_SENSE_MASK;
  316. /*
  317. * The polarity of the signal provided to the GIC should always
  318. * be high.
  319. */
  320. if (sense & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
  321. type |= IRQ_TYPE_LEVEL_HIGH;
  322. else
  323. type |= IRQ_TYPE_EDGE_RISING;
  324. return type;
  325. }
  326. static int meson_gpio_irq_set_type(struct irq_data *data, unsigned int type)
  327. {
  328. struct meson_gpio_irq_controller *ctl = data->domain->host_data;
  329. u32 *channel_hwirq = irq_data_get_irq_chip_data(data);
  330. int ret;
  331. ret = ctl->params->ops.gpio_irq_set_type(ctl, type, channel_hwirq);
  332. if (ret)
  333. return ret;
  334. return irq_chip_set_type_parent(data,
  335. meson_gpio_irq_type_output(type));
  336. }
  337. static struct irq_chip meson_gpio_irq_chip = {
  338. .name = "meson-gpio-irqchip",
  339. .irq_mask = irq_chip_mask_parent,
  340. .irq_unmask = irq_chip_unmask_parent,
  341. .irq_eoi = irq_chip_eoi_parent,
  342. .irq_set_type = meson_gpio_irq_set_type,
  343. .irq_retrigger = irq_chip_retrigger_hierarchy,
  344. #ifdef CONFIG_SMP
  345. .irq_set_affinity = irq_chip_set_affinity_parent,
  346. #endif
  347. .flags = IRQCHIP_SET_TYPE_MASKED,
  348. };
  349. static int meson_gpio_irq_domain_translate(struct irq_domain *domain,
  350. struct irq_fwspec *fwspec,
  351. unsigned long *hwirq,
  352. unsigned int *type)
  353. {
  354. if (is_of_node(fwspec->fwnode) && fwspec->param_count == 2) {
  355. *hwirq = fwspec->param[0];
  356. *type = fwspec->param[1];
  357. return 0;
  358. }
  359. return -EINVAL;
  360. }
  361. static int meson_gpio_irq_allocate_gic_irq(struct irq_domain *domain,
  362. unsigned int virq,
  363. u32 hwirq,
  364. unsigned int type)
  365. {
  366. struct irq_fwspec fwspec;
  367. fwspec.fwnode = domain->parent->fwnode;
  368. fwspec.param_count = 3;
  369. fwspec.param[0] = 0; /* SPI */
  370. fwspec.param[1] = hwirq;
  371. fwspec.param[2] = meson_gpio_irq_type_output(type);
  372. return irq_domain_alloc_irqs_parent(domain, virq, 1, &fwspec);
  373. }
  374. static int meson_gpio_irq_domain_alloc(struct irq_domain *domain,
  375. unsigned int virq,
  376. unsigned int nr_irqs,
  377. void *data)
  378. {
  379. struct irq_fwspec *fwspec = data;
  380. struct meson_gpio_irq_controller *ctl = domain->host_data;
  381. unsigned long hwirq;
  382. u32 *channel_hwirq;
  383. unsigned int type;
  384. int ret;
  385. if (WARN_ON(nr_irqs != 1))
  386. return -EINVAL;
  387. ret = meson_gpio_irq_domain_translate(domain, fwspec, &hwirq, &type);
  388. if (ret)
  389. return ret;
  390. ret = meson_gpio_irq_request_channel(ctl, hwirq, &channel_hwirq);
  391. if (ret)
  392. return ret;
  393. ret = meson_gpio_irq_allocate_gic_irq(domain, virq,
  394. *channel_hwirq, type);
  395. if (ret < 0) {
  396. pr_err("failed to allocate gic irq %u\n", *channel_hwirq);
  397. meson_gpio_irq_release_channel(ctl, channel_hwirq);
  398. return ret;
  399. }
  400. irq_domain_set_hwirq_and_chip(domain, virq, hwirq,
  401. &meson_gpio_irq_chip, channel_hwirq);
  402. return 0;
  403. }
  404. static void meson_gpio_irq_domain_free(struct irq_domain *domain,
  405. unsigned int virq,
  406. unsigned int nr_irqs)
  407. {
  408. struct meson_gpio_irq_controller *ctl = domain->host_data;
  409. struct irq_data *irq_data;
  410. u32 *channel_hwirq;
  411. if (WARN_ON(nr_irqs != 1))
  412. return;
  413. irq_domain_free_irqs_parent(domain, virq, 1);
  414. irq_data = irq_domain_get_irq_data(domain, virq);
  415. channel_hwirq = irq_data_get_irq_chip_data(irq_data);
  416. meson_gpio_irq_release_channel(ctl, channel_hwirq);
  417. }
  418. static const struct irq_domain_ops meson_gpio_irq_domain_ops = {
  419. .alloc = meson_gpio_irq_domain_alloc,
  420. .free = meson_gpio_irq_domain_free,
  421. .translate = meson_gpio_irq_domain_translate,
  422. };
  423. static int meson_gpio_irq_parse_dt(struct device_node *node, struct meson_gpio_irq_controller *ctl)
  424. {
  425. const struct of_device_id *match;
  426. int ret;
  427. match = of_match_node(meson_irq_gpio_matches, node);
  428. if (!match)
  429. return -ENODEV;
  430. ctl->params = match->data;
  431. ret = of_property_read_variable_u32_array(node,
  432. "amlogic,channel-interrupts",
  433. ctl->channel_irqs,
  434. ctl->params->nr_channels,
  435. ctl->params->nr_channels);
  436. if (ret < 0) {
  437. pr_err("can't get %d channel interrupts\n", ctl->params->nr_channels);
  438. return ret;
  439. }
  440. ctl->params->ops.gpio_irq_init(ctl);
  441. return 0;
  442. }
  443. static int meson_gpio_irq_of_init(struct device_node *node, struct device_node *parent)
  444. {
  445. struct irq_domain *domain, *parent_domain;
  446. struct meson_gpio_irq_controller *ctl;
  447. int ret;
  448. if (!parent) {
  449. pr_err("missing parent interrupt node\n");
  450. return -ENODEV;
  451. }
  452. parent_domain = irq_find_host(parent);
  453. if (!parent_domain) {
  454. pr_err("unable to obtain parent domain\n");
  455. return -ENXIO;
  456. }
  457. ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
  458. if (!ctl)
  459. return -ENOMEM;
  460. spin_lock_init(&ctl->lock);
  461. ctl->base = of_iomap(node, 0);
  462. if (!ctl->base) {
  463. ret = -ENOMEM;
  464. goto free_ctl;
  465. }
  466. ret = meson_gpio_irq_parse_dt(node, ctl);
  467. if (ret)
  468. goto free_channel_irqs;
  469. domain = irq_domain_create_hierarchy(parent_domain, 0,
  470. ctl->params->nr_hwirq,
  471. of_node_to_fwnode(node),
  472. &meson_gpio_irq_domain_ops,
  473. ctl);
  474. if (!domain) {
  475. pr_err("failed to add domain\n");
  476. ret = -ENODEV;
  477. goto free_channel_irqs;
  478. }
  479. pr_info("%d to %d gpio interrupt mux initialized\n",
  480. ctl->params->nr_hwirq, ctl->params->nr_channels);
  481. return 0;
  482. free_channel_irqs:
  483. iounmap(ctl->base);
  484. free_ctl:
  485. kfree(ctl);
  486. return ret;
  487. }
  488. IRQCHIP_PLATFORM_DRIVER_BEGIN(meson_gpio_intc)
  489. IRQCHIP_MATCH("amlogic,meson-gpio-intc", meson_gpio_irq_of_init)
  490. IRQCHIP_PLATFORM_DRIVER_END(meson_gpio_intc)
  491. MODULE_AUTHOR("Jerome Brunet <[email protected]>");
  492. MODULE_LICENSE("GPL v2");
  493. MODULE_ALIAS("platform:meson-gpio-intc");