irq-pm.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* linux/arch/arm/plat-s5p/irq-pm.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Based on arch/arm/plat-s3c24xx/irq-pm.c,
  7. * Copyright (c) 2003,2004 Simtec Electronics
  8. * Ben Dooks <ben@simtec.co.uk>
  9. * http://armlinux.simtec.co.uk/
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/module.h>
  17. #include <linux/interrupt.h>
  18. #include <plat/cpu.h>
  19. #include <plat/irqs.h>
  20. #include <plat/pm.h>
  21. #include <mach/map.h>
  22. #include <mach/regs-gpio.h>
  23. #include <mach/regs-irq.h>
  24. /* state for IRQs over sleep */
  25. /* default is to allow for EINT0..EINT31, and IRQ_RTC_TIC, IRQ_RTC_ALARM,
  26. * as wakeup sources
  27. *
  28. * set bit to 1 in allow bitfield to enable the wakeup settings on it
  29. */
  30. unsigned long s3c_irqwake_intallow = 0x00000006L;
  31. unsigned long s3c_irqwake_eintallow = 0xffffffffL;
  32. int s3c_irq_wake(struct irq_data *data, unsigned int state)
  33. {
  34. unsigned long irqbit;
  35. unsigned int irq_rtc_tic, irq_rtc_alarm;
  36. #ifdef CONFIG_ARCH_EXYNOS
  37. if (soc_is_exynos5250()) {
  38. irq_rtc_tic = EXYNOS5_IRQ_RTC_TIC;
  39. irq_rtc_alarm = EXYNOS5_IRQ_RTC_ALARM;
  40. } else {
  41. irq_rtc_tic = EXYNOS4_IRQ_RTC_TIC;
  42. irq_rtc_alarm = EXYNOS4_IRQ_RTC_ALARM;
  43. }
  44. #else
  45. irq_rtc_tic = IRQ_RTC_TIC;
  46. irq_rtc_alarm = IRQ_RTC_ALARM;
  47. #endif
  48. if (data->irq == irq_rtc_tic || data->irq == irq_rtc_alarm) {
  49. irqbit = 1 << (data->irq + 1 - irq_rtc_alarm);
  50. if (!state)
  51. s3c_irqwake_intmask |= irqbit;
  52. else
  53. s3c_irqwake_intmask &= ~irqbit;
  54. } else {
  55. return -ENOENT;
  56. }
  57. return 0;
  58. }
  59. static struct sleep_save eint_save[] = {
  60. SAVE_ITEM(S5P_EINT_CON(0)),
  61. SAVE_ITEM(S5P_EINT_CON(1)),
  62. SAVE_ITEM(S5P_EINT_CON(2)),
  63. SAVE_ITEM(S5P_EINT_CON(3)),
  64. SAVE_ITEM(S5P_EINT_FLTCON(0)),
  65. SAVE_ITEM(S5P_EINT_FLTCON(1)),
  66. SAVE_ITEM(S5P_EINT_FLTCON(2)),
  67. SAVE_ITEM(S5P_EINT_FLTCON(3)),
  68. SAVE_ITEM(S5P_EINT_FLTCON(4)),
  69. SAVE_ITEM(S5P_EINT_FLTCON(5)),
  70. SAVE_ITEM(S5P_EINT_FLTCON(6)),
  71. SAVE_ITEM(S5P_EINT_FLTCON(7)),
  72. SAVE_ITEM(S5P_EINT_MASK(0)),
  73. SAVE_ITEM(S5P_EINT_MASK(1)),
  74. SAVE_ITEM(S5P_EINT_MASK(2)),
  75. SAVE_ITEM(S5P_EINT_MASK(3)),
  76. };
  77. int s3c24xx_irq_suspend(void)
  78. {
  79. s3c_pm_do_save(eint_save, ARRAY_SIZE(eint_save));
  80. return 0;
  81. }
  82. void s3c24xx_irq_resume(void)
  83. {
  84. s3c_pm_do_restore(eint_save, ARRAY_SIZE(eint_save));
  85. }