gpio.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. * arch/arm/plat-orion/gpio.c
  3. *
  4. * Marvell Orion SoC GPIO handling.
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #define DEBUG
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <linux/irqdomain.h>
  15. #include <linux/module.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/bitops.h>
  18. #include <linux/io.h>
  19. #include <linux/gpio.h>
  20. #include <linux/leds.h>
  21. #include <linux/of.h>
  22. #include <linux/of_irq.h>
  23. #include <linux/of_address.h>
  24. #include <plat/orion-gpio.h>
  25. /*
  26. * GPIO unit register offsets.
  27. */
  28. #define GPIO_OUT_OFF 0x0000
  29. #define GPIO_IO_CONF_OFF 0x0004
  30. #define GPIO_BLINK_EN_OFF 0x0008
  31. #define GPIO_IN_POL_OFF 0x000c
  32. #define GPIO_DATA_IN_OFF 0x0010
  33. #define GPIO_EDGE_CAUSE_OFF 0x0014
  34. #define GPIO_EDGE_MASK_OFF 0x0018
  35. #define GPIO_LEVEL_MASK_OFF 0x001c
  36. struct orion_gpio_chip {
  37. struct gpio_chip chip;
  38. spinlock_t lock;
  39. void __iomem *base;
  40. unsigned long valid_input;
  41. unsigned long valid_output;
  42. int mask_offset;
  43. int secondary_irq_base;
  44. struct irq_domain *domain;
  45. };
  46. static void __iomem *GPIO_OUT(struct orion_gpio_chip *ochip)
  47. {
  48. return ochip->base + GPIO_OUT_OFF;
  49. }
  50. static void __iomem *GPIO_IO_CONF(struct orion_gpio_chip *ochip)
  51. {
  52. return ochip->base + GPIO_IO_CONF_OFF;
  53. }
  54. static void __iomem *GPIO_BLINK_EN(struct orion_gpio_chip *ochip)
  55. {
  56. return ochip->base + GPIO_BLINK_EN_OFF;
  57. }
  58. static void __iomem *GPIO_IN_POL(struct orion_gpio_chip *ochip)
  59. {
  60. return ochip->base + GPIO_IN_POL_OFF;
  61. }
  62. static void __iomem *GPIO_DATA_IN(struct orion_gpio_chip *ochip)
  63. {
  64. return ochip->base + GPIO_DATA_IN_OFF;
  65. }
  66. static void __iomem *GPIO_EDGE_CAUSE(struct orion_gpio_chip *ochip)
  67. {
  68. return ochip->base + GPIO_EDGE_CAUSE_OFF;
  69. }
  70. static void __iomem *GPIO_EDGE_MASK(struct orion_gpio_chip *ochip)
  71. {
  72. return ochip->base + ochip->mask_offset + GPIO_EDGE_MASK_OFF;
  73. }
  74. static void __iomem *GPIO_LEVEL_MASK(struct orion_gpio_chip *ochip)
  75. {
  76. return ochip->base + ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
  77. }
  78. static struct orion_gpio_chip orion_gpio_chips[2];
  79. static int orion_gpio_chip_count;
  80. static inline void
  81. __set_direction(struct orion_gpio_chip *ochip, unsigned pin, int input)
  82. {
  83. u32 u;
  84. u = readl(GPIO_IO_CONF(ochip));
  85. if (input)
  86. u |= 1 << pin;
  87. else
  88. u &= ~(1 << pin);
  89. writel(u, GPIO_IO_CONF(ochip));
  90. }
  91. static void __set_level(struct orion_gpio_chip *ochip, unsigned pin, int high)
  92. {
  93. u32 u;
  94. u = readl(GPIO_OUT(ochip));
  95. if (high)
  96. u |= 1 << pin;
  97. else
  98. u &= ~(1 << pin);
  99. writel(u, GPIO_OUT(ochip));
  100. }
  101. static inline void
  102. __set_blinking(struct orion_gpio_chip *ochip, unsigned pin, int blink)
  103. {
  104. u32 u;
  105. u = readl(GPIO_BLINK_EN(ochip));
  106. if (blink)
  107. u |= 1 << pin;
  108. else
  109. u &= ~(1 << pin);
  110. writel(u, GPIO_BLINK_EN(ochip));
  111. }
  112. static inline int
  113. orion_gpio_is_valid(struct orion_gpio_chip *ochip, unsigned pin, int mode)
  114. {
  115. if (pin >= ochip->chip.ngpio)
  116. goto err_out;
  117. if ((mode & GPIO_INPUT_OK) && !test_bit(pin, &ochip->valid_input))
  118. goto err_out;
  119. if ((mode & GPIO_OUTPUT_OK) && !test_bit(pin, &ochip->valid_output))
  120. goto err_out;
  121. return 1;
  122. err_out:
  123. pr_debug("%s: invalid GPIO %d\n", __func__, pin);
  124. return false;
  125. }
  126. /*
  127. * GPIO primitives.
  128. */
  129. static int orion_gpio_request(struct gpio_chip *chip, unsigned pin)
  130. {
  131. struct orion_gpio_chip *ochip =
  132. container_of(chip, struct orion_gpio_chip, chip);
  133. if (orion_gpio_is_valid(ochip, pin, GPIO_INPUT_OK) ||
  134. orion_gpio_is_valid(ochip, pin, GPIO_OUTPUT_OK))
  135. return 0;
  136. return -EINVAL;
  137. }
  138. static int orion_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
  139. {
  140. struct orion_gpio_chip *ochip =
  141. container_of(chip, struct orion_gpio_chip, chip);
  142. unsigned long flags;
  143. if (!orion_gpio_is_valid(ochip, pin, GPIO_INPUT_OK))
  144. return -EINVAL;
  145. spin_lock_irqsave(&ochip->lock, flags);
  146. __set_direction(ochip, pin, 1);
  147. spin_unlock_irqrestore(&ochip->lock, flags);
  148. return 0;
  149. }
  150. static int orion_gpio_get(struct gpio_chip *chip, unsigned pin)
  151. {
  152. struct orion_gpio_chip *ochip =
  153. container_of(chip, struct orion_gpio_chip, chip);
  154. int val;
  155. if (readl(GPIO_IO_CONF(ochip)) & (1 << pin)) {
  156. val = readl(GPIO_DATA_IN(ochip)) ^ readl(GPIO_IN_POL(ochip));
  157. } else {
  158. val = readl(GPIO_OUT(ochip));
  159. }
  160. return (val >> pin) & 1;
  161. }
  162. static int
  163. orion_gpio_direction_output(struct gpio_chip *chip, unsigned pin, int value)
  164. {
  165. struct orion_gpio_chip *ochip =
  166. container_of(chip, struct orion_gpio_chip, chip);
  167. unsigned long flags;
  168. if (!orion_gpio_is_valid(ochip, pin, GPIO_OUTPUT_OK))
  169. return -EINVAL;
  170. spin_lock_irqsave(&ochip->lock, flags);
  171. __set_blinking(ochip, pin, 0);
  172. __set_level(ochip, pin, value);
  173. __set_direction(ochip, pin, 0);
  174. spin_unlock_irqrestore(&ochip->lock, flags);
  175. return 0;
  176. }
  177. static void orion_gpio_set(struct gpio_chip *chip, unsigned pin, int value)
  178. {
  179. struct orion_gpio_chip *ochip =
  180. container_of(chip, struct orion_gpio_chip, chip);
  181. unsigned long flags;
  182. spin_lock_irqsave(&ochip->lock, flags);
  183. __set_level(ochip, pin, value);
  184. spin_unlock_irqrestore(&ochip->lock, flags);
  185. }
  186. static int orion_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
  187. {
  188. struct orion_gpio_chip *ochip =
  189. container_of(chip, struct orion_gpio_chip, chip);
  190. return irq_create_mapping(ochip->domain,
  191. ochip->secondary_irq_base + pin);
  192. }
  193. /*
  194. * Orion-specific GPIO API extensions.
  195. */
  196. static struct orion_gpio_chip *orion_gpio_chip_find(int pin)
  197. {
  198. int i;
  199. for (i = 0; i < orion_gpio_chip_count; i++) {
  200. struct orion_gpio_chip *ochip = orion_gpio_chips + i;
  201. struct gpio_chip *chip = &ochip->chip;
  202. if (pin >= chip->base && pin < chip->base + chip->ngpio)
  203. return ochip;
  204. }
  205. return NULL;
  206. }
  207. void __init orion_gpio_set_unused(unsigned pin)
  208. {
  209. struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin);
  210. if (ochip == NULL)
  211. return;
  212. pin -= ochip->chip.base;
  213. /* Configure as output, drive low. */
  214. __set_level(ochip, pin, 0);
  215. __set_direction(ochip, pin, 0);
  216. }
  217. void __init orion_gpio_set_valid(unsigned pin, int mode)
  218. {
  219. struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin);
  220. if (ochip == NULL)
  221. return;
  222. pin -= ochip->chip.base;
  223. if (mode == 1)
  224. mode = GPIO_INPUT_OK | GPIO_OUTPUT_OK;
  225. if (mode & GPIO_INPUT_OK)
  226. __set_bit(pin, &ochip->valid_input);
  227. else
  228. __clear_bit(pin, &ochip->valid_input);
  229. if (mode & GPIO_OUTPUT_OK)
  230. __set_bit(pin, &ochip->valid_output);
  231. else
  232. __clear_bit(pin, &ochip->valid_output);
  233. }
  234. void orion_gpio_set_blink(unsigned pin, int blink)
  235. {
  236. struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin);
  237. unsigned long flags;
  238. if (ochip == NULL)
  239. return;
  240. spin_lock_irqsave(&ochip->lock, flags);
  241. __set_level(ochip, pin & 31, 0);
  242. __set_blinking(ochip, pin & 31, blink);
  243. spin_unlock_irqrestore(&ochip->lock, flags);
  244. }
  245. EXPORT_SYMBOL(orion_gpio_set_blink);
  246. #define ORION_BLINK_HALF_PERIOD 100 /* ms */
  247. int orion_gpio_led_blink_set(struct gpio_desc *desc, int state,
  248. unsigned long *delay_on, unsigned long *delay_off)
  249. {
  250. unsigned gpio = desc_to_gpio(desc);
  251. if (delay_on && delay_off && !*delay_on && !*delay_off)
  252. *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD;
  253. switch (state) {
  254. case GPIO_LED_NO_BLINK_LOW:
  255. case GPIO_LED_NO_BLINK_HIGH:
  256. orion_gpio_set_blink(gpio, 0);
  257. gpio_set_value(gpio, state);
  258. break;
  259. case GPIO_LED_BLINK:
  260. orion_gpio_set_blink(gpio, 1);
  261. }
  262. return 0;
  263. }
  264. EXPORT_SYMBOL_GPL(orion_gpio_led_blink_set);
  265. /*****************************************************************************
  266. * Orion GPIO IRQ
  267. *
  268. * GPIO_IN_POL register controls whether GPIO_DATA_IN will hold the same
  269. * value of the line or the opposite value.
  270. *
  271. * Level IRQ handlers: DATA_IN is used directly as cause register.
  272. * Interrupt are masked by LEVEL_MASK registers.
  273. * Edge IRQ handlers: Change in DATA_IN are latched in EDGE_CAUSE.
  274. * Interrupt are masked by EDGE_MASK registers.
  275. * Both-edge handlers: Similar to regular Edge handlers, but also swaps
  276. * the polarity to catch the next line transaction.
  277. * This is a race condition that might not perfectly
  278. * work on some use cases.
  279. *
  280. * Every eight GPIO lines are grouped (OR'ed) before going up to main
  281. * cause register.
  282. *
  283. * EDGE cause mask
  284. * data-in /--------| |-----| |----\
  285. * -----| |----- ---- to main cause reg
  286. * X \----------------| |----/
  287. * polarity LEVEL mask
  288. *
  289. ****************************************************************************/
  290. static int gpio_irq_set_type(struct irq_data *d, u32 type)
  291. {
  292. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  293. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  294. struct orion_gpio_chip *ochip = gc->private;
  295. int pin;
  296. u32 u;
  297. pin = d->hwirq - ochip->secondary_irq_base;
  298. u = readl(GPIO_IO_CONF(ochip)) & (1 << pin);
  299. if (!u) {
  300. return -EINVAL;
  301. }
  302. type &= IRQ_TYPE_SENSE_MASK;
  303. if (type == IRQ_TYPE_NONE)
  304. return -EINVAL;
  305. /* Check if we need to change chip and handler */
  306. if (!(ct->type & type))
  307. if (irq_setup_alt_chip(d, type))
  308. return -EINVAL;
  309. /*
  310. * Configure interrupt polarity.
  311. */
  312. if (type == IRQ_TYPE_EDGE_RISING || type == IRQ_TYPE_LEVEL_HIGH) {
  313. u = readl(GPIO_IN_POL(ochip));
  314. u &= ~(1 << pin);
  315. writel(u, GPIO_IN_POL(ochip));
  316. } else if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) {
  317. u = readl(GPIO_IN_POL(ochip));
  318. u |= 1 << pin;
  319. writel(u, GPIO_IN_POL(ochip));
  320. } else if (type == IRQ_TYPE_EDGE_BOTH) {
  321. u32 v;
  322. v = readl(GPIO_IN_POL(ochip)) ^ readl(GPIO_DATA_IN(ochip));
  323. /*
  324. * set initial polarity based on current input level
  325. */
  326. u = readl(GPIO_IN_POL(ochip));
  327. if (v & (1 << pin))
  328. u |= 1 << pin; /* falling */
  329. else
  330. u &= ~(1 << pin); /* rising */
  331. writel(u, GPIO_IN_POL(ochip));
  332. }
  333. return 0;
  334. }
  335. static void gpio_irq_handler(struct irq_desc *desc)
  336. {
  337. struct orion_gpio_chip *ochip = irq_desc_get_handler_data(desc);
  338. u32 cause, type;
  339. int i;
  340. if (ochip == NULL)
  341. return;
  342. cause = readl(GPIO_DATA_IN(ochip)) & readl(GPIO_LEVEL_MASK(ochip));
  343. cause |= readl(GPIO_EDGE_CAUSE(ochip)) & readl(GPIO_EDGE_MASK(ochip));
  344. for (i = 0; i < ochip->chip.ngpio; i++) {
  345. int irq;
  346. irq = ochip->secondary_irq_base + i;
  347. if (!(cause & (1 << i)))
  348. continue;
  349. type = irq_get_trigger_type(irq);
  350. if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
  351. /* Swap polarity (race with GPIO line) */
  352. u32 polarity;
  353. polarity = readl(GPIO_IN_POL(ochip));
  354. polarity ^= 1 << i;
  355. writel(polarity, GPIO_IN_POL(ochip));
  356. }
  357. generic_handle_irq(irq);
  358. }
  359. }
  360. #ifdef CONFIG_DEBUG_FS
  361. #include <linux/seq_file.h>
  362. static void orion_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
  363. {
  364. struct orion_gpio_chip *ochip =
  365. container_of(chip, struct orion_gpio_chip, chip);
  366. u32 out, io_conf, blink, in_pol, data_in, cause, edg_msk, lvl_msk;
  367. int i;
  368. out = readl_relaxed(GPIO_OUT(ochip));
  369. io_conf = readl_relaxed(GPIO_IO_CONF(ochip));
  370. blink = readl_relaxed(GPIO_BLINK_EN(ochip));
  371. in_pol = readl_relaxed(GPIO_IN_POL(ochip));
  372. data_in = readl_relaxed(GPIO_DATA_IN(ochip));
  373. cause = readl_relaxed(GPIO_EDGE_CAUSE(ochip));
  374. edg_msk = readl_relaxed(GPIO_EDGE_MASK(ochip));
  375. lvl_msk = readl_relaxed(GPIO_LEVEL_MASK(ochip));
  376. for (i = 0; i < chip->ngpio; i++) {
  377. const char *label;
  378. u32 msk;
  379. bool is_out;
  380. label = gpiochip_is_requested(chip, i);
  381. if (!label)
  382. continue;
  383. msk = 1 << i;
  384. is_out = !(io_conf & msk);
  385. seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label);
  386. if (is_out) {
  387. seq_printf(s, " out %s %s\n",
  388. out & msk ? "hi" : "lo",
  389. blink & msk ? "(blink )" : "");
  390. continue;
  391. }
  392. seq_printf(s, " in %s (act %s) - IRQ",
  393. (data_in ^ in_pol) & msk ? "hi" : "lo",
  394. in_pol & msk ? "lo" : "hi");
  395. if (!((edg_msk | lvl_msk) & msk)) {
  396. seq_printf(s, " disabled\n");
  397. continue;
  398. }
  399. if (edg_msk & msk)
  400. seq_printf(s, " edge ");
  401. if (lvl_msk & msk)
  402. seq_printf(s, " level");
  403. seq_printf(s, " (%s)\n", cause & msk ? "pending" : "clear ");
  404. }
  405. }
  406. #else
  407. #define orion_gpio_dbg_show NULL
  408. #endif
  409. static void orion_gpio_unmask_irq(struct irq_data *d)
  410. {
  411. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  412. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  413. u32 reg_val;
  414. u32 mask = d->mask;
  415. irq_gc_lock(gc);
  416. reg_val = irq_reg_readl(gc, ct->regs.mask);
  417. reg_val |= mask;
  418. irq_reg_writel(gc, reg_val, ct->regs.mask);
  419. irq_gc_unlock(gc);
  420. }
  421. static void orion_gpio_mask_irq(struct irq_data *d)
  422. {
  423. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  424. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  425. u32 mask = d->mask;
  426. u32 reg_val;
  427. irq_gc_lock(gc);
  428. reg_val = irq_reg_readl(gc, ct->regs.mask);
  429. reg_val &= ~mask;
  430. irq_reg_writel(gc, reg_val, ct->regs.mask);
  431. irq_gc_unlock(gc);
  432. }
  433. void __init orion_gpio_init(struct device_node *np,
  434. int gpio_base, int ngpio,
  435. void __iomem *base, int mask_offset,
  436. int secondary_irq_base,
  437. int irqs[4])
  438. {
  439. struct orion_gpio_chip *ochip;
  440. struct irq_chip_generic *gc;
  441. struct irq_chip_type *ct;
  442. char gc_label[16];
  443. int i;
  444. if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips))
  445. return;
  446. snprintf(gc_label, sizeof(gc_label), "orion_gpio%d",
  447. orion_gpio_chip_count);
  448. ochip = orion_gpio_chips + orion_gpio_chip_count;
  449. ochip->chip.label = kstrdup(gc_label, GFP_KERNEL);
  450. ochip->chip.request = orion_gpio_request;
  451. ochip->chip.direction_input = orion_gpio_direction_input;
  452. ochip->chip.get = orion_gpio_get;
  453. ochip->chip.direction_output = orion_gpio_direction_output;
  454. ochip->chip.set = orion_gpio_set;
  455. ochip->chip.to_irq = orion_gpio_to_irq;
  456. ochip->chip.base = gpio_base;
  457. ochip->chip.ngpio = ngpio;
  458. ochip->chip.can_sleep = 0;
  459. #ifdef CONFIG_OF
  460. ochip->chip.of_node = np;
  461. #endif
  462. ochip->chip.dbg_show = orion_gpio_dbg_show;
  463. spin_lock_init(&ochip->lock);
  464. ochip->base = (void __iomem *)base;
  465. ochip->valid_input = 0;
  466. ochip->valid_output = 0;
  467. ochip->mask_offset = mask_offset;
  468. ochip->secondary_irq_base = secondary_irq_base;
  469. gpiochip_add(&ochip->chip);
  470. /*
  471. * Mask and clear GPIO interrupts.
  472. */
  473. writel(0, GPIO_EDGE_CAUSE(ochip));
  474. writel(0, GPIO_EDGE_MASK(ochip));
  475. writel(0, GPIO_LEVEL_MASK(ochip));
  476. /* Setup the interrupt handlers. Each chip can have up to 4
  477. * interrupt handlers, with each handler dealing with 8 GPIO
  478. * pins. */
  479. for (i = 0; i < 4; i++) {
  480. if (irqs[i]) {
  481. irq_set_chained_handler_and_data(irqs[i],
  482. gpio_irq_handler,
  483. ochip);
  484. }
  485. }
  486. gc = irq_alloc_generic_chip("orion_gpio_irq", 2,
  487. secondary_irq_base,
  488. ochip->base, handle_level_irq);
  489. gc->private = ochip;
  490. ct = gc->chip_types;
  491. ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
  492. ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
  493. ct->chip.irq_mask = orion_gpio_mask_irq;
  494. ct->chip.irq_unmask = orion_gpio_unmask_irq;
  495. ct->chip.irq_set_type = gpio_irq_set_type;
  496. ct->chip.name = ochip->chip.label;
  497. ct++;
  498. ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF;
  499. ct->regs.ack = GPIO_EDGE_CAUSE_OFF;
  500. ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
  501. ct->chip.irq_ack = irq_gc_ack_clr_bit;
  502. ct->chip.irq_mask = orion_gpio_mask_irq;
  503. ct->chip.irq_unmask = orion_gpio_unmask_irq;
  504. ct->chip.irq_set_type = gpio_irq_set_type;
  505. ct->handler = handle_edge_irq;
  506. ct->chip.name = ochip->chip.label;
  507. irq_setup_generic_chip(gc, IRQ_MSK(ngpio), IRQ_GC_INIT_MASK_CACHE,
  508. IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
  509. /* Setup irq domain on top of the generic chip. */
  510. ochip->domain = irq_domain_add_legacy(np,
  511. ochip->chip.ngpio,
  512. ochip->secondary_irq_base,
  513. ochip->secondary_irq_base,
  514. &irq_domain_simple_ops,
  515. ochip);
  516. if (!ochip->domain)
  517. panic("%s: couldn't allocate irq domain (DT).\n",
  518. ochip->chip.label);
  519. orion_gpio_chip_count++;
  520. }