irq-pm-s3c24xx.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2003-2004 Simtec Electronics
  4. // Ben Dooks <[email protected]>
  5. // http://armlinux.simtec.co.uk/
  6. //
  7. // S3C24XX - IRQ PM code
  8. #include <linux/init.h>
  9. #include <linux/module.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/irq.h>
  12. #include <linux/syscore_ops.h>
  13. #include <linux/io.h>
  14. #include "cpu.h"
  15. #include "pm.h"
  16. #include "map-base.h"
  17. #include "map-s3c.h"
  18. #include "regs-irq.h"
  19. #include "regs-gpio.h"
  20. #include "pm-core.h"
  21. #include <asm/irq.h>
  22. int s3c_irq_wake(struct irq_data *data, unsigned int state)
  23. {
  24. unsigned long irqbit = 1 << data->hwirq;
  25. if (!(s3c_irqwake_intallow & irqbit))
  26. return -ENOENT;
  27. pr_info("wake %s for hwirq %lu\n",
  28. state ? "enabled" : "disabled", data->hwirq);
  29. if (!state)
  30. s3c_irqwake_intmask |= irqbit;
  31. else
  32. s3c_irqwake_intmask &= ~irqbit;
  33. return 0;
  34. }
  35. static struct sleep_save irq_save[] = {
  36. SAVE_ITEM(S3C2410_INTMSK),
  37. SAVE_ITEM(S3C2410_INTSUBMSK),
  38. };
  39. /* the extint values move between the s3c2410/s3c2440 and the s3c2412
  40. * so we use an array to hold them, and to calculate the address of
  41. * the register at run-time
  42. */
  43. static unsigned long save_extint[3];
  44. static unsigned long save_eintflt[4];
  45. static unsigned long save_eintmask;
  46. static int s3c24xx_irq_suspend(void)
  47. {
  48. unsigned int i;
  49. for (i = 0; i < ARRAY_SIZE(save_extint); i++)
  50. save_extint[i] = __raw_readl(S3C24XX_EXTINT0 + (i*4));
  51. for (i = 0; i < ARRAY_SIZE(save_eintflt); i++)
  52. save_eintflt[i] = __raw_readl(S3C24XX_EINFLT0 + (i*4));
  53. s3c_pm_do_save(irq_save, ARRAY_SIZE(irq_save));
  54. save_eintmask = __raw_readl(S3C24XX_EINTMASK);
  55. return 0;
  56. }
  57. static void s3c24xx_irq_resume(void)
  58. {
  59. unsigned int i;
  60. for (i = 0; i < ARRAY_SIZE(save_extint); i++)
  61. __raw_writel(save_extint[i], S3C24XX_EXTINT0 + (i*4));
  62. for (i = 0; i < ARRAY_SIZE(save_eintflt); i++)
  63. __raw_writel(save_eintflt[i], S3C24XX_EINFLT0 + (i*4));
  64. s3c_pm_do_restore(irq_save, ARRAY_SIZE(irq_save));
  65. __raw_writel(save_eintmask, S3C24XX_EINTMASK);
  66. }
  67. struct syscore_ops s3c24xx_irq_syscore_ops = {
  68. .suspend = s3c24xx_irq_suspend,
  69. .resume = s3c24xx_irq_resume,
  70. };
  71. #ifdef CONFIG_CPU_S3C2416
  72. static struct sleep_save s3c2416_irq_save[] = {
  73. SAVE_ITEM(S3C2416_INTMSK2),
  74. };
  75. static int s3c2416_irq_suspend(void)
  76. {
  77. s3c_pm_do_save(s3c2416_irq_save, ARRAY_SIZE(s3c2416_irq_save));
  78. return 0;
  79. }
  80. static void s3c2416_irq_resume(void)
  81. {
  82. s3c_pm_do_restore(s3c2416_irq_save, ARRAY_SIZE(s3c2416_irq_save));
  83. }
  84. struct syscore_ops s3c2416_irq_syscore_ops = {
  85. .suspend = s3c2416_irq_suspend,
  86. .resume = s3c2416_irq_resume,
  87. };
  88. #endif