pm-common.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  4. * Tomasz Figa <t.figa@samsung.com>
  5. * Copyright (c) 2004 Simtec Electronics
  6. * http://armlinux.simtec.co.uk/
  7. * Written by Ben Dooks, <ben@simtec.co.uk>
  8. */
  9. #ifndef __PLAT_SAMSUNG_PM_COMMON_H
  10. #define __PLAT_SAMSUNG_PM_COMMON_H __FILE__
  11. #include <linux/irq.h>
  12. /* sleep save info */
  13. /**
  14. * struct sleep_save - save information for shared peripherals.
  15. * @reg: Pointer to the register to save.
  16. * @val: Holder for the value saved from reg.
  17. *
  18. * This describes a list of registers which is used by the pm core and
  19. * other subsystem to save and restore register values over suspend.
  20. */
  21. struct sleep_save {
  22. void __iomem *reg;
  23. unsigned long val;
  24. };
  25. #define SAVE_ITEM(x) \
  26. { .reg = (x) }
  27. /* helper functions to save/restore lists of registers. */
  28. extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
  29. extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count);
  30. extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count);
  31. /* PM debug functions */
  32. /**
  33. * struct pm_uart_save - save block for core UART
  34. * @ulcon: Save value for S3C2410_ULCON
  35. * @ucon: Save value for S3C2410_UCON
  36. * @ufcon: Save value for S3C2410_UFCON
  37. * @umcon: Save value for S3C2410_UMCON
  38. * @ubrdiv: Save value for S3C2410_UBRDIV
  39. *
  40. * Save block for UART registers to be held over sleep and restored if they
  41. * are needed (say by debug).
  42. */
  43. struct pm_uart_save {
  44. u32 ulcon;
  45. u32 ucon;
  46. u32 ufcon;
  47. u32 umcon;
  48. u32 ubrdiv;
  49. u32 udivslot;
  50. };
  51. #ifdef CONFIG_SAMSUNG_PM_DEBUG
  52. /**
  53. * s3c_pm_dbg() - low level debug function for use in suspend/resume.
  54. * @msg: The message to print.
  55. *
  56. * This function is used mainly to debug the resume process before the system
  57. * can rely on printk/console output. It uses the low-level debugging output
  58. * routine printascii() to do its work.
  59. */
  60. extern void s3c_pm_dbg(const char *msg, ...);
  61. /**
  62. * s3c_pm_debug_init() - suspend/resume low level debug initialization.
  63. * @base: Virtual base of UART to use for suspend/resume debugging.
  64. *
  65. * This function needs to be called before S3C_PMDBG() can be used, to set up
  66. * UART port base address and configuration.
  67. */
  68. extern void s3c_pm_debug_init(void);
  69. #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
  70. extern void s3c_pm_save_uarts(void);
  71. extern void s3c_pm_restore_uarts(void);
  72. #else
  73. #define S3C_PMDBG(fmt...) pr_debug(fmt)
  74. #define s3c_pm_debug_init() do { } while (0)
  75. static inline void s3c_pm_save_uarts(void) { }
  76. static inline void s3c_pm_restore_uarts(void) { }
  77. #endif
  78. /* suspend memory checking */
  79. #ifdef CONFIG_SAMSUNG_PM_CHECK
  80. extern void s3c_pm_check_prepare(void);
  81. extern void s3c_pm_check_restore(void);
  82. extern void s3c_pm_check_cleanup(void);
  83. extern void s3c_pm_check_store(void);
  84. #else
  85. #define s3c_pm_check_prepare() do { } while (0)
  86. #define s3c_pm_check_restore() do { } while (0)
  87. #define s3c_pm_check_cleanup() do { } while (0)
  88. #define s3c_pm_check_store() do { } while (0)
  89. #endif
  90. #endif