psc_defs.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #define BOOTBITMASK(x, y) ((((((u32)1 << (((u32)x) - ((u32)y) + (u32)1)) - \
  27. (u32)1)) << ((u32)y)))
  28. #define BOOT_READ_BITFIELD(z, x, y) ((((u32)z) & BOOTBITMASK(x, y)) >> (y))
  29. #define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~BOOTBITMASK(x, y)) | \
  30. ((((u32)f) << (y)) & BOOTBITMASK(x, y)))
  31. /* PDCTL */
  32. #define PSC_REG_PDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 0, 0)
  33. #define PSC_REG_PDCTL_SET_PDMODE(x, y) BOOT_SET_BITFIELD((x), (y), 15, 12)
  34. /* PDSTAT */
  35. #define PSC_REG_PDSTAT_GET_STATE(x) BOOT_READ_BITFIELD((x), 4, 0)
  36. /* MDCFG */
  37. #define PSC_REG_MDCFG_GET_PD(x) BOOT_READ_BITFIELD((x), 20, 16)
  38. #define PSC_REG_MDCFG_GET_RESET_ISO(x) BOOT_READ_BITFIELD((x), 14, 14)
  39. /* MDCTL */
  40. #define PSC_REG_MDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 4, 0)
  41. #define PSC_REG_MDCTL_SET_LRSTZ(x, y) BOOT_SET_BITFIELD((x), (y), 8, 8)
  42. #define PSC_REG_MDCTL_GET_LRSTZ(x) BOOT_READ_BITFIELD((x), 8, 8)
  43. #define PSC_REG_MDCTL_SET_RESET_ISO(x, y) BOOT_SET_BITFIELD((x), (y), \
  44. 12, 12)
  45. /* MDSTAT */
  46. #define PSC_REG_MDSTAT_GET_STATUS(x) BOOT_READ_BITFIELD((x), 5, 0)
  47. #define PSC_REG_MDSTAT_GET_LRSTZ(x) BOOT_READ_BITFIELD((x), 8, 8)
  48. #define PSC_REG_MDSTAT_GET_LRSTDONE(x) BOOT_READ_BITFIELD((x), 9, 9)
  49. #define PSC_REG_MDSTAT_GET_MRSTZ(x) BOOT_READ_BITFIELD((x), 10, 10)
  50. #define PSC_REG_MDSTAT_GET_MRSTDONE(x) BOOT_READ_BITFIELD((x), 11, 11)
  51. /* PDCTL states */
  52. #define PSC_REG_VAL_PDCTL_NEXT_ON 1
  53. #define PSC_REG_VAL_PDCTL_NEXT_OFF 0
  54. #define PSC_REG_VAL_PDCTL_PDMODE_SLEEP 0
  55. /* MDCTL states */
  56. #define PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE 0
  57. #define PSC_REG_VAL_MDCTL_NEXT_OFF 2
  58. #define PSC_REG_VAL_MDCTL_NEXT_ON 3
  59. /* MDSTAT states */
  60. #define PSC_REG_VAL_MDSTAT_STATE_ON 3
  61. #define PSC_REG_VAL_MDSTAT_STATE_ENABLE_IN_PROG 0x24
  62. #define PSC_REG_VAL_MDSTAT_STATE_OFF 2
  63. #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG1 0x20
  64. #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG2 0x21
  65. #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG3 0x22
  66. /*
  67. * Timeout limit on checking PTSTAT. This is the number of times the
  68. * wait function will be called before giving up.
  69. */
  70. #define PSC_PTSTAT_TIMEOUT_LIMIT 100
  71. u32 psc_get_domain_num(u32 mod_num);
  72. int psc_enable_module(u32 mod_num);
  73. int psc_disable_module(u32 mod_num);
  74. int psc_disable_domain(u32 domain_num);
  75. int psc_module_keep_in_reset_enabled(u32 mod_num, bool gate_clocks);
  76. int psc_module_release_from_reset(u32 mod_num);
  77. #endif /* _PSC_DEFS_H_ */