generic-chip.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * Library implementing the most common irq chip callback functions
  3. *
  4. * Copyright (C) 2011, Thomas Gleixner
  5. */
  6. #include <linux/io.h>
  7. #include <linux/irq.h>
  8. #include <linux/slab.h>
  9. #include <linux/export.h>
  10. #include <linux/irqdomain.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/kernel_stat.h>
  13. #include <linux/syscore_ops.h>
  14. #include "internals.h"
  15. static LIST_HEAD(gc_list);
  16. static DEFINE_RAW_SPINLOCK(gc_lock);
  17. /**
  18. * irq_gc_noop - NOOP function
  19. * @d: irq_data
  20. */
  21. void irq_gc_noop(struct irq_data *d)
  22. {
  23. }
  24. /**
  25. * irq_gc_mask_disable_reg - Mask chip via disable register
  26. * @d: irq_data
  27. *
  28. * Chip has separate enable/disable registers instead of a single mask
  29. * register.
  30. */
  31. void irq_gc_mask_disable_reg(struct irq_data *d)
  32. {
  33. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  34. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  35. u32 mask = d->mask;
  36. irq_gc_lock(gc);
  37. irq_reg_writel(gc, mask, ct->regs.disable);
  38. *ct->mask_cache &= ~mask;
  39. irq_gc_unlock(gc);
  40. }
  41. /**
  42. * irq_gc_mask_set_bit - Mask chip via setting bit in mask register
  43. * @d: irq_data
  44. *
  45. * Chip has a single mask register. Values of this register are cached
  46. * and protected by gc->lock
  47. */
  48. void irq_gc_mask_set_bit(struct irq_data *d)
  49. {
  50. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  51. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  52. u32 mask = d->mask;
  53. irq_gc_lock(gc);
  54. *ct->mask_cache |= mask;
  55. irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
  56. irq_gc_unlock(gc);
  57. }
  58. EXPORT_SYMBOL_GPL(irq_gc_mask_set_bit);
  59. /**
  60. * irq_gc_mask_clr_bit - Mask chip via clearing bit in mask register
  61. * @d: irq_data
  62. *
  63. * Chip has a single mask register. Values of this register are cached
  64. * and protected by gc->lock
  65. */
  66. void irq_gc_mask_clr_bit(struct irq_data *d)
  67. {
  68. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  69. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  70. u32 mask = d->mask;
  71. irq_gc_lock(gc);
  72. *ct->mask_cache &= ~mask;
  73. irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
  74. irq_gc_unlock(gc);
  75. }
  76. EXPORT_SYMBOL_GPL(irq_gc_mask_clr_bit);
  77. /**
  78. * irq_gc_unmask_enable_reg - Unmask chip via enable register
  79. * @d: irq_data
  80. *
  81. * Chip has separate enable/disable registers instead of a single mask
  82. * register.
  83. */
  84. void irq_gc_unmask_enable_reg(struct irq_data *d)
  85. {
  86. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  87. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  88. u32 mask = d->mask;
  89. irq_gc_lock(gc);
  90. irq_reg_writel(gc, mask, ct->regs.enable);
  91. *ct->mask_cache |= mask;
  92. irq_gc_unlock(gc);
  93. }
  94. /**
  95. * irq_gc_ack_set_bit - Ack pending interrupt via setting bit
  96. * @d: irq_data
  97. */
  98. void irq_gc_ack_set_bit(struct irq_data *d)
  99. {
  100. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  101. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  102. u32 mask = d->mask;
  103. irq_gc_lock(gc);
  104. irq_reg_writel(gc, mask, ct->regs.ack);
  105. irq_gc_unlock(gc);
  106. }
  107. EXPORT_SYMBOL_GPL(irq_gc_ack_set_bit);
  108. /**
  109. * irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit
  110. * @d: irq_data
  111. */
  112. void irq_gc_ack_clr_bit(struct irq_data *d)
  113. {
  114. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  115. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  116. u32 mask = ~d->mask;
  117. irq_gc_lock(gc);
  118. irq_reg_writel(gc, mask, ct->regs.ack);
  119. irq_gc_unlock(gc);
  120. }
  121. /**
  122. * irq_gc_mask_disable_and_ack_set - Mask and ack pending interrupt
  123. * @d: irq_data
  124. *
  125. * This generic implementation of the irq_mask_ack method is for chips
  126. * with separate enable/disable registers instead of a single mask
  127. * register and where a pending interrupt is acknowledged by setting a
  128. * bit.
  129. *
  130. * Note: This is the only permutation currently used. Similar generic
  131. * functions should be added here if other permutations are required.
  132. */
  133. void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
  134. {
  135. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  136. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  137. u32 mask = d->mask;
  138. irq_gc_lock(gc);
  139. irq_reg_writel(gc, mask, ct->regs.disable);
  140. *ct->mask_cache &= ~mask;
  141. irq_reg_writel(gc, mask, ct->regs.ack);
  142. irq_gc_unlock(gc);
  143. }
  144. /**
  145. * irq_gc_eoi - EOI interrupt
  146. * @d: irq_data
  147. */
  148. void irq_gc_eoi(struct irq_data *d)
  149. {
  150. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  151. struct irq_chip_type *ct = irq_data_get_chip_type(d);
  152. u32 mask = d->mask;
  153. irq_gc_lock(gc);
  154. irq_reg_writel(gc, mask, ct->regs.eoi);
  155. irq_gc_unlock(gc);
  156. }
  157. /**
  158. * irq_gc_set_wake - Set/clr wake bit for an interrupt
  159. * @d: irq_data
  160. * @on: Indicates whether the wake bit should be set or cleared
  161. *
  162. * For chips where the wake from suspend functionality is not
  163. * configured in a separate register and the wakeup active state is
  164. * just stored in a bitmask.
  165. */
  166. int irq_gc_set_wake(struct irq_data *d, unsigned int on)
  167. {
  168. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  169. u32 mask = d->mask;
  170. if (!(mask & gc->wake_enabled))
  171. return -EINVAL;
  172. irq_gc_lock(gc);
  173. if (on)
  174. gc->wake_active |= mask;
  175. else
  176. gc->wake_active &= ~mask;
  177. irq_gc_unlock(gc);
  178. return 0;
  179. }
  180. static u32 irq_readl_be(void __iomem *addr)
  181. {
  182. return ioread32be(addr);
  183. }
  184. static void irq_writel_be(u32 val, void __iomem *addr)
  185. {
  186. iowrite32be(val, addr);
  187. }
  188. void irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
  189. int num_ct, unsigned int irq_base,
  190. void __iomem *reg_base, irq_flow_handler_t handler)
  191. {
  192. raw_spin_lock_init(&gc->lock);
  193. gc->num_ct = num_ct;
  194. gc->irq_base = irq_base;
  195. gc->reg_base = reg_base;
  196. gc->chip_types->chip.name = name;
  197. gc->chip_types->handler = handler;
  198. }
  199. /**
  200. * irq_alloc_generic_chip - Allocate a generic chip and initialize it
  201. * @name: Name of the irq chip
  202. * @num_ct: Number of irq_chip_type instances associated with this
  203. * @irq_base: Interrupt base nr for this chip
  204. * @reg_base: Register base address (virtual)
  205. * @handler: Default flow handler associated with this chip
  206. *
  207. * Returns an initialized irq_chip_generic structure. The chip defaults
  208. * to the primary (index 0) irq_chip_type and @handler
  209. */
  210. struct irq_chip_generic *
  211. irq_alloc_generic_chip(const char *name, int num_ct, unsigned int irq_base,
  212. void __iomem *reg_base, irq_flow_handler_t handler)
  213. {
  214. struct irq_chip_generic *gc;
  215. unsigned long sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
  216. gc = kzalloc(sz, GFP_KERNEL);
  217. if (gc) {
  218. irq_init_generic_chip(gc, name, num_ct, irq_base, reg_base,
  219. handler);
  220. }
  221. return gc;
  222. }
  223. EXPORT_SYMBOL_GPL(irq_alloc_generic_chip);
  224. static void
  225. irq_gc_init_mask_cache(struct irq_chip_generic *gc, enum irq_gc_flags flags)
  226. {
  227. struct irq_chip_type *ct = gc->chip_types;
  228. u32 *mskptr = &gc->mask_cache, mskreg = ct->regs.mask;
  229. int i;
  230. for (i = 0; i < gc->num_ct; i++) {
  231. if (flags & IRQ_GC_MASK_CACHE_PER_TYPE) {
  232. mskptr = &ct[i].mask_cache_priv;
  233. mskreg = ct[i].regs.mask;
  234. }
  235. ct[i].mask_cache = mskptr;
  236. if (flags & IRQ_GC_INIT_MASK_CACHE)
  237. *mskptr = irq_reg_readl(gc, mskreg);
  238. }
  239. }
  240. /**
  241. * __irq_alloc_domain_generic_chip - Allocate generic chips for an irq domain
  242. * @d: irq domain for which to allocate chips
  243. * @irqs_per_chip: Number of interrupts each chip handles (max 32)
  244. * @num_ct: Number of irq_chip_type instances associated with this
  245. * @name: Name of the irq chip
  246. * @handler: Default flow handler associated with these chips
  247. * @clr: IRQ_* bits to clear in the mapping function
  248. * @set: IRQ_* bits to set in the mapping function
  249. * @gcflags: Generic chip specific setup flags
  250. */
  251. int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
  252. int num_ct, const char *name,
  253. irq_flow_handler_t handler,
  254. unsigned int clr, unsigned int set,
  255. enum irq_gc_flags gcflags)
  256. {
  257. struct irq_domain_chip_generic *dgc;
  258. struct irq_chip_generic *gc;
  259. int numchips, sz, i;
  260. unsigned long flags;
  261. void *tmp;
  262. if (d->gc)
  263. return -EBUSY;
  264. numchips = DIV_ROUND_UP(d->revmap_size, irqs_per_chip);
  265. if (!numchips)
  266. return -EINVAL;
  267. /* Allocate a pointer, generic chip and chiptypes for each chip */
  268. sz = sizeof(*dgc) + numchips * sizeof(gc);
  269. sz += numchips * (sizeof(*gc) + num_ct * sizeof(struct irq_chip_type));
  270. tmp = dgc = kzalloc(sz, GFP_KERNEL);
  271. if (!dgc)
  272. return -ENOMEM;
  273. dgc->irqs_per_chip = irqs_per_chip;
  274. dgc->num_chips = numchips;
  275. dgc->irq_flags_to_set = set;
  276. dgc->irq_flags_to_clear = clr;
  277. dgc->gc_flags = gcflags;
  278. d->gc = dgc;
  279. /* Calc pointer to the first generic chip */
  280. tmp += sizeof(*dgc) + numchips * sizeof(gc);
  281. for (i = 0; i < numchips; i++) {
  282. /* Store the pointer to the generic chip */
  283. dgc->gc[i] = gc = tmp;
  284. irq_init_generic_chip(gc, name, num_ct, i * irqs_per_chip,
  285. NULL, handler);
  286. gc->domain = d;
  287. if (gcflags & IRQ_GC_BE_IO) {
  288. gc->reg_readl = &irq_readl_be;
  289. gc->reg_writel = &irq_writel_be;
  290. }
  291. raw_spin_lock_irqsave(&gc_lock, flags);
  292. list_add_tail(&gc->list, &gc_list);
  293. raw_spin_unlock_irqrestore(&gc_lock, flags);
  294. /* Calc pointer to the next generic chip */
  295. tmp += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
  296. }
  297. return 0;
  298. }
  299. EXPORT_SYMBOL_GPL(__irq_alloc_domain_generic_chips);
  300. static struct irq_chip_generic *
  301. __irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq)
  302. {
  303. struct irq_domain_chip_generic *dgc = d->gc;
  304. int idx;
  305. if (!dgc)
  306. return ERR_PTR(-ENODEV);
  307. idx = hw_irq / dgc->irqs_per_chip;
  308. if (idx >= dgc->num_chips)
  309. return ERR_PTR(-EINVAL);
  310. return dgc->gc[idx];
  311. }
  312. /**
  313. * irq_get_domain_generic_chip - Get a pointer to the generic chip of a hw_irq
  314. * @d: irq domain pointer
  315. * @hw_irq: Hardware interrupt number
  316. */
  317. struct irq_chip_generic *
  318. irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq)
  319. {
  320. struct irq_chip_generic *gc = __irq_get_domain_generic_chip(d, hw_irq);
  321. return !IS_ERR(gc) ? gc : NULL;
  322. }
  323. EXPORT_SYMBOL_GPL(irq_get_domain_generic_chip);
  324. /*
  325. * Separate lockdep class for interrupt chip which can nest irq_desc
  326. * lock.
  327. */
  328. static struct lock_class_key irq_nested_lock_class;
  329. /*
  330. * irq_map_generic_chip - Map a generic chip for an irq domain
  331. */
  332. int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
  333. irq_hw_number_t hw_irq)
  334. {
  335. struct irq_data *data = irq_domain_get_irq_data(d, virq);
  336. struct irq_domain_chip_generic *dgc = d->gc;
  337. struct irq_chip_generic *gc;
  338. struct irq_chip_type *ct;
  339. struct irq_chip *chip;
  340. unsigned long flags;
  341. int idx;
  342. gc = __irq_get_domain_generic_chip(d, hw_irq);
  343. if (IS_ERR(gc))
  344. return PTR_ERR(gc);
  345. idx = hw_irq % dgc->irqs_per_chip;
  346. if (test_bit(idx, &gc->unused))
  347. return -ENOTSUPP;
  348. if (test_bit(idx, &gc->installed))
  349. return -EBUSY;
  350. ct = gc->chip_types;
  351. chip = &ct->chip;
  352. /* We only init the cache for the first mapping of a generic chip */
  353. if (!gc->installed) {
  354. raw_spin_lock_irqsave(&gc->lock, flags);
  355. irq_gc_init_mask_cache(gc, dgc->gc_flags);
  356. raw_spin_unlock_irqrestore(&gc->lock, flags);
  357. }
  358. /* Mark the interrupt as installed */
  359. set_bit(idx, &gc->installed);
  360. if (dgc->gc_flags & IRQ_GC_INIT_NESTED_LOCK)
  361. irq_set_lockdep_class(virq, &irq_nested_lock_class);
  362. if (chip->irq_calc_mask)
  363. chip->irq_calc_mask(data);
  364. else
  365. data->mask = 1 << idx;
  366. irq_domain_set_info(d, virq, hw_irq, chip, gc, ct->handler, NULL, NULL);
  367. irq_modify_status(virq, dgc->irq_flags_to_clear, dgc->irq_flags_to_set);
  368. return 0;
  369. }
  370. static void irq_unmap_generic_chip(struct irq_domain *d, unsigned int virq)
  371. {
  372. struct irq_data *data = irq_domain_get_irq_data(d, virq);
  373. struct irq_domain_chip_generic *dgc = d->gc;
  374. unsigned int hw_irq = data->hwirq;
  375. struct irq_chip_generic *gc;
  376. int irq_idx;
  377. gc = irq_get_domain_generic_chip(d, hw_irq);
  378. if (!gc)
  379. return;
  380. irq_idx = hw_irq % dgc->irqs_per_chip;
  381. clear_bit(irq_idx, &gc->installed);
  382. irq_domain_set_info(d, virq, hw_irq, &no_irq_chip, NULL, NULL, NULL,
  383. NULL);
  384. }
  385. struct irq_domain_ops irq_generic_chip_ops = {
  386. .map = irq_map_generic_chip,
  387. .unmap = irq_unmap_generic_chip,
  388. .xlate = irq_domain_xlate_onetwocell,
  389. };
  390. EXPORT_SYMBOL_GPL(irq_generic_chip_ops);
  391. /**
  392. * irq_setup_generic_chip - Setup a range of interrupts with a generic chip
  393. * @gc: Generic irq chip holding all data
  394. * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base
  395. * @flags: Flags for initialization
  396. * @clr: IRQ_* bits to clear
  397. * @set: IRQ_* bits to set
  398. *
  399. * Set up max. 32 interrupts starting from gc->irq_base. Note, this
  400. * initializes all interrupts to the primary irq_chip_type and its
  401. * associated handler.
  402. */
  403. void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
  404. enum irq_gc_flags flags, unsigned int clr,
  405. unsigned int set)
  406. {
  407. struct irq_chip_type *ct = gc->chip_types;
  408. struct irq_chip *chip = &ct->chip;
  409. unsigned int i;
  410. raw_spin_lock(&gc_lock);
  411. list_add_tail(&gc->list, &gc_list);
  412. raw_spin_unlock(&gc_lock);
  413. irq_gc_init_mask_cache(gc, flags);
  414. for (i = gc->irq_base; msk; msk >>= 1, i++) {
  415. if (!(msk & 0x01))
  416. continue;
  417. if (flags & IRQ_GC_INIT_NESTED_LOCK)
  418. irq_set_lockdep_class(i, &irq_nested_lock_class);
  419. if (!(flags & IRQ_GC_NO_MASK)) {
  420. struct irq_data *d = irq_get_irq_data(i);
  421. if (chip->irq_calc_mask)
  422. chip->irq_calc_mask(d);
  423. else
  424. d->mask = 1 << (i - gc->irq_base);
  425. }
  426. irq_set_chip_and_handler(i, chip, ct->handler);
  427. irq_set_chip_data(i, gc);
  428. irq_modify_status(i, clr, set);
  429. }
  430. gc->irq_cnt = i - gc->irq_base;
  431. }
  432. EXPORT_SYMBOL_GPL(irq_setup_generic_chip);
  433. /**
  434. * irq_setup_alt_chip - Switch to alternative chip
  435. * @d: irq_data for this interrupt
  436. * @type: Flow type to be initialized
  437. *
  438. * Only to be called from chip->irq_set_type() callbacks.
  439. */
  440. int irq_setup_alt_chip(struct irq_data *d, unsigned int type)
  441. {
  442. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  443. struct irq_chip_type *ct = gc->chip_types;
  444. unsigned int i;
  445. for (i = 0; i < gc->num_ct; i++, ct++) {
  446. if (ct->type & type) {
  447. d->chip = &ct->chip;
  448. irq_data_to_desc(d)->handle_irq = ct->handler;
  449. return 0;
  450. }
  451. }
  452. return -EINVAL;
  453. }
  454. EXPORT_SYMBOL_GPL(irq_setup_alt_chip);
  455. /**
  456. * irq_remove_generic_chip - Remove a chip
  457. * @gc: Generic irq chip holding all data
  458. * @msk: Bitmask holding the irqs to initialize relative to gc->irq_base
  459. * @clr: IRQ_* bits to clear
  460. * @set: IRQ_* bits to set
  461. *
  462. * Remove up to 32 interrupts starting from gc->irq_base.
  463. */
  464. void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
  465. unsigned int clr, unsigned int set)
  466. {
  467. unsigned int i = gc->irq_base;
  468. raw_spin_lock(&gc_lock);
  469. list_del(&gc->list);
  470. raw_spin_unlock(&gc_lock);
  471. for (; msk; msk >>= 1, i++) {
  472. if (!(msk & 0x01))
  473. continue;
  474. /* Remove handler first. That will mask the irq line */
  475. irq_set_handler(i, NULL);
  476. irq_set_chip(i, &no_irq_chip);
  477. irq_set_chip_data(i, NULL);
  478. irq_modify_status(i, clr, set);
  479. }
  480. }
  481. EXPORT_SYMBOL_GPL(irq_remove_generic_chip);
  482. static struct irq_data *irq_gc_get_irq_data(struct irq_chip_generic *gc)
  483. {
  484. unsigned int virq;
  485. if (!gc->domain)
  486. return irq_get_irq_data(gc->irq_base);
  487. /*
  488. * We don't know which of the irqs has been actually
  489. * installed. Use the first one.
  490. */
  491. if (!gc->installed)
  492. return NULL;
  493. virq = irq_find_mapping(gc->domain, gc->irq_base + __ffs(gc->installed));
  494. return virq ? irq_get_irq_data(virq) : NULL;
  495. }
  496. #ifdef CONFIG_PM
  497. static int irq_gc_suspend(void)
  498. {
  499. struct irq_chip_generic *gc;
  500. list_for_each_entry(gc, &gc_list, list) {
  501. struct irq_chip_type *ct = gc->chip_types;
  502. if (ct->chip.irq_suspend) {
  503. struct irq_data *data = irq_gc_get_irq_data(gc);
  504. if (data)
  505. ct->chip.irq_suspend(data);
  506. }
  507. if (gc->suspend)
  508. gc->suspend(gc);
  509. }
  510. return 0;
  511. }
  512. static void irq_gc_resume(void)
  513. {
  514. struct irq_chip_generic *gc;
  515. list_for_each_entry(gc, &gc_list, list) {
  516. struct irq_chip_type *ct = gc->chip_types;
  517. if (gc->resume)
  518. gc->resume(gc);
  519. if (ct->chip.irq_resume) {
  520. struct irq_data *data = irq_gc_get_irq_data(gc);
  521. if (data)
  522. ct->chip.irq_resume(data);
  523. }
  524. }
  525. }
  526. #else
  527. #define irq_gc_suspend NULL
  528. #define irq_gc_resume NULL
  529. #endif
  530. static void irq_gc_shutdown(void)
  531. {
  532. struct irq_chip_generic *gc;
  533. list_for_each_entry(gc, &gc_list, list) {
  534. struct irq_chip_type *ct = gc->chip_types;
  535. if (ct->chip.irq_pm_shutdown) {
  536. struct irq_data *data = irq_gc_get_irq_data(gc);
  537. if (data)
  538. ct->chip.irq_pm_shutdown(data);
  539. }
  540. }
  541. }
  542. static struct syscore_ops irq_gc_syscore_ops = {
  543. .suspend = irq_gc_suspend,
  544. .resume = irq_gc_resume,
  545. .shutdown = irq_gc_shutdown,
  546. };
  547. static int __init irq_gc_init_ops(void)
  548. {
  549. register_syscore_ops(&irq_gc_syscore_ops);
  550. return 0;
  551. }
  552. device_initcall(irq_gc_init_ops);