psc_defs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * (C) Copyright 2012-2014
  3. * Texas Instruments Incorporated, <www.ti.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _PSC_DEFS_H_
  8. #define _PSC_DEFS_H_
  9. #include <asm/arch/hardware.h>
  10. /*
  11. * FILE PURPOSE: Local Power Sleep Controller definitions
  12. *
  13. * FILE NAME: psc_defs.h
  14. *
  15. * DESCRIPTION: Provides local definitions for the power saver controller
  16. *
  17. */
  18. /* Register offsets */
  19. #define PSC_REG_PTCMD 0x120
  20. #define PSC_REG_PSTAT 0x128
  21. #define PSC_REG_PDSTAT(x) (0x200 + (4 * (x)))
  22. #define PSC_REG_PDCTL(x) (0x300 + (4 * (x)))
  23. #define PSC_REG_MDCFG(x) (0x600 + (4 * (x)))
  24. #define PSC_REG_MDSTAT(x) (0x800 + (4 * (x)))
  25. #define PSC_REG_MDCTL(x) (0xa00 + (4 * (x)))
  26. static inline u32 _boot_bit_mask(u32 x, u32 y)
  27. {
  28. u32 val = (1 << (x - y + 1)) - 1;
  29. return val << y;
  30. }
  31. static inline u32 boot_read_bitfield(u32 z, u32 x, u32 y)
  32. {
  33. u32 val = z & _boot_bit_mask(x, y);
  34. return val >> y;
  35. }
  36. static inline u32 boot_set_bitfield(u32 z, u32 f, u32 x, u32 y)
  37. {
  38. u32 mask = _boot_bit_mask(x, y);
  39. return (z & ~mask) | ((f << y) & mask);
  40. }
  41. /* PDCTL */
  42. #define PSC_REG_PDCTL_SET_NEXT(x, y) boot_set_bitfield((x), (y), 0, 0)
  43. #define PSC_REG_PDCTL_SET_PDMODE(x, y) boot_set_bitfield((x), (y), 15, 12)
  44. /* PDSTAT */
  45. #define PSC_REG_PDSTAT_GET_STATE(x) boot_read_bitfield((x), 4, 0)
  46. /* MDCFG */
  47. #define PSC_REG_MDCFG_GET_PD(x) boot_read_bitfield((x), 20, 16)
  48. #define PSC_REG_MDCFG_GET_RESET_ISO(x) boot_read_bitfield((x), 14, 14)
  49. /* MDCTL */
  50. #define PSC_REG_MDCTL_SET_NEXT(x, y) boot_set_bitfield((x), (y), 4, 0)
  51. #define PSC_REG_MDCTL_SET_LRSTZ(x, y) boot_set_bitfield((x), (y), 8, 8)
  52. #define PSC_REG_MDCTL_GET_LRSTZ(x) boot_read_bitfield((x), 8, 8)
  53. #define PSC_REG_MDCTL_SET_RESET_ISO(x, y) boot_set_bitfield((x), (y), \
  54. 12, 12)
  55. /* MDSTAT */
  56. #define PSC_REG_MDSTAT_GET_STATUS(x) boot_read_bitfield((x), 5, 0)
  57. #define PSC_REG_MDSTAT_GET_LRSTZ(x) boot_read_bitfield((x), 8, 8)
  58. #define PSC_REG_MDSTAT_GET_LRSTDONE(x) boot_read_bitfield((x), 9, 9)
  59. #define PSC_REG_MDSTAT_GET_MRSTZ(x) boot_read_bitfield((x), 10, 10)
  60. #define PSC_REG_MDSTAT_GET_MRSTDONE(x) boot_read_bitfield((x), 11, 11)
  61. /* PDCTL states */
  62. #define PSC_REG_VAL_PDCTL_NEXT_ON 1
  63. #define PSC_REG_VAL_PDCTL_NEXT_OFF 0
  64. #define PSC_REG_VAL_PDCTL_PDMODE_SLEEP 0
  65. /* MDCTL states */
  66. #define PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE 0
  67. #define PSC_REG_VAL_MDCTL_NEXT_OFF 2
  68. #define PSC_REG_VAL_MDCTL_NEXT_ON 3
  69. /* MDSTAT states */
  70. #define PSC_REG_VAL_MDSTAT_STATE_ON 3
  71. #define PSC_REG_VAL_MDSTAT_STATE_ENABLE_IN_PROG 0x24
  72. #define PSC_REG_VAL_MDSTAT_STATE_OFF 2
  73. #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG1 0x20
  74. #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG2 0x21
  75. #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG3 0x22
  76. /*
  77. * Timeout limit on checking PTSTAT. This is the number of times the
  78. * wait function will be called before giving up.
  79. */
  80. #define PSC_PTSTAT_TIMEOUT_LIMIT 100
  81. u32 psc_get_domain_num(u32 mod_num);
  82. int psc_enable_module(u32 mod_num);
  83. int psc_disable_module(u32 mod_num);
  84. int psc_disable_domain(u32 domain_num);
  85. int psc_module_keep_in_reset_enabled(u32 mod_num, bool gate_clocks);
  86. int psc_module_release_from_reset(u32 mod_num);
  87. #endif /* _PSC_DEFS_H_ */