s5p-irq-pm.c 2.3 KB

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