imx8m_csu.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2020-2022 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef IMX_CSU_H
  7. #define IMX_CSU_H
  8. #include <lib/utils_def.h>
  9. #include <platform_def.h>
  10. #define CSU_SEC_LEVEL_0 0xff
  11. #define CSU_SEC_LEVEL_1 0xbb
  12. #define CSU_SEC_LEVEL_2 0x3f
  13. #define CSU_SEC_LEVEL_3 0x3b
  14. #define CSU_SEC_LEVEL_4 0x33
  15. #define CSU_SEC_LEVEL_5 0x22
  16. #define CSU_SEC_LEVEL_6 0x03
  17. #define CSU_SEC_LEVEL_7 0x0
  18. #define SEC_ACCESS 0x0
  19. #define NON_SEC_ACCESS 0x1
  20. #define LOCKED 0x1
  21. #define UNLOCKED 0x0
  22. #define CSLx_REG(x) (IMX_CSU_BASE + ((x) / 2) * 4)
  23. #define CSLx_LOCK(x) ((0x1 << (((x) % 2) * 16 + 8)))
  24. #define CSLx_CFG(x, n) ((x) << (((n) % 2) * 16))
  25. #define CSU_HP_REG(x) (IMX_CSU_BASE + (((x) / 16) * 4) + 0x200)
  26. #define CSU_HP_LOCK(x) ((0x1 << (((x) % 16) * 2 + 1)))
  27. #define CSU_HP_CFG(x, n) ((x) << (((n) % 16) * 2))
  28. #define CSU_SA_REG(x) (IMX_CSU_BASE + (((x) / 16) * 4) + 0x218)
  29. #define CSU_SA_LOCK(x) ((0x1 << (((x) % 16) * 2 + 1)))
  30. #define CSU_SA_CFG(x, n) ((x) << (((n) % 16) * 2))
  31. #define CSU_HPCONTROL_REG(x) (IMX_CSU_BASE + (((x) / 16) * 4) + 0x358)
  32. #define CSU_HPCONTROL_LOCK(x) ((0x1 << (((x) % 16) * 2 + 1)))
  33. #define CSU_HPCONTROL_CFG(x, n) ((x) << (((n) % 16) * 2))
  34. enum csu_cfg_type {
  35. CSU_INVALID,
  36. CSU_CSL,
  37. CSU_HP,
  38. CSU_SA,
  39. CSU_HPCONTROL,
  40. };
  41. struct imx_csu_cfg {
  42. enum csu_cfg_type type;
  43. uint16_t idx;
  44. uint16_t lock : 1;
  45. uint16_t csl_level : 8;
  46. uint16_t hp : 1;
  47. uint16_t sa : 1;
  48. uint16_t hpctrl : 1;
  49. };
  50. #define CSU_CSLx(i, level, lk) \
  51. {CSU_CSL, .idx = (i), .csl_level = (level), .lock = (lk),}
  52. #define CSU_HPx(i, val, lk) \
  53. {CSU_HP, .idx = (i), .hp = (val), .lock = (lk), }
  54. #define CSU_SA(i, val, lk) \
  55. {CSU_SA, .idx = (i), .sa = (val), .lock = (lk), }
  56. #define CSU_HPCTRL(i, val, lk) \
  57. {CSU_HPCONTROL, .idx = (i), .hpctrl = (val), .lock = (lk), }
  58. void imx_csu_init(const struct imx_csu_cfg *csu_cfg);
  59. #endif /* IMX_CSU_H */