irq-pm.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* linux/arch/arm/mach-s5p64x0/irq-pm.c
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * S5P64X0 - Interrupt handling Power Management
  7. *
  8. * Based on arch/arm/mach-s3c64xx/irq-pm.c by Ben Dooks
  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/syscore_ops.h>
  15. #include <linux/serial_core.h>
  16. #include <linux/io.h>
  17. #include <plat/regs-serial.h>
  18. #include <plat/pm.h>
  19. #include <mach/regs-gpio.h>
  20. static struct sleep_save irq_save[] = {
  21. SAVE_ITEM(S5P64X0_EINT0CON0),
  22. SAVE_ITEM(S5P64X0_EINT0FLTCON0),
  23. SAVE_ITEM(S5P64X0_EINT0FLTCON1),
  24. SAVE_ITEM(S5P64X0_EINT0MASK),
  25. };
  26. static struct irq_grp_save {
  27. u32 con;
  28. u32 fltcon;
  29. u32 mask;
  30. } eint_grp_save[4];
  31. static u32 irq_uart_mask[CONFIG_SERIAL_SAMSUNG_UARTS];
  32. static int s5p64x0_irq_pm_suspend(void)
  33. {
  34. struct irq_grp_save *grp = eint_grp_save;
  35. int i;
  36. S3C_PMDBG("%s: suspending IRQs\n", __func__);
  37. s3c_pm_do_save(irq_save, ARRAY_SIZE(irq_save));
  38. for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++)
  39. irq_uart_mask[i] = __raw_readl(S3C_VA_UARTx(i) + S3C64XX_UINTM);
  40. for (i = 0; i < ARRAY_SIZE(eint_grp_save); i++, grp++) {
  41. grp->con = __raw_readl(S5P64X0_EINT12CON + (i * 4));
  42. grp->mask = __raw_readl(S5P64X0_EINT12MASK + (i * 4));
  43. grp->fltcon = __raw_readl(S5P64X0_EINT12FLTCON + (i * 4));
  44. }
  45. return 0;
  46. }
  47. static void s5p64x0_irq_pm_resume(void)
  48. {
  49. struct irq_grp_save *grp = eint_grp_save;
  50. int i;
  51. S3C_PMDBG("%s: resuming IRQs\n", __func__);
  52. s3c_pm_do_restore(irq_save, ARRAY_SIZE(irq_save));
  53. for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++)
  54. __raw_writel(irq_uart_mask[i], S3C_VA_UARTx(i) + S3C64XX_UINTM);
  55. for (i = 0; i < ARRAY_SIZE(eint_grp_save); i++, grp++) {
  56. __raw_writel(grp->con, S5P64X0_EINT12CON + (i * 4));
  57. __raw_writel(grp->mask, S5P64X0_EINT12MASK + (i * 4));
  58. __raw_writel(grp->fltcon, S5P64X0_EINT12FLTCON + (i * 4));
  59. }
  60. S3C_PMDBG("%s: IRQ configuration restored\n", __func__);
  61. }
  62. static struct syscore_ops s5p64x0_irq_syscore_ops = {
  63. .suspend = s5p64x0_irq_pm_suspend,
  64. .resume = s5p64x0_irq_pm_resume,
  65. };
  66. static int __init s5p64x0_syscore_init(void)
  67. {
  68. register_syscore_ops(&s5p64x0_irq_syscore_ops);
  69. return 0;
  70. }
  71. core_initcall(s5p64x0_syscore_init);