imx8m_csu.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2020-2022 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <lib/mmio.h>
  7. #include <imx8m_csu.h>
  8. void imx_csu_init(const struct imx_csu_cfg *csu_cfg)
  9. {
  10. const struct imx_csu_cfg *csu = csu_cfg;
  11. uint32_t val;
  12. while (csu->type != CSU_INVALID) {
  13. switch (csu->type) {
  14. case CSU_CSL:
  15. val = mmio_read_32(CSLx_REG(csu->idx));
  16. if (val & CSLx_LOCK(csu->idx)) {
  17. break;
  18. }
  19. mmio_clrsetbits_32(CSLx_REG(csu->idx), CSLx_CFG(0xff, csu->idx),
  20. CSLx_CFG(csu->csl_level | (csu->lock << 8), csu->idx));
  21. break;
  22. case CSU_HP:
  23. val = mmio_read_32(CSU_HP_REG(csu->idx));
  24. if (val & CSU_HP_LOCK(csu->idx)) {
  25. break;
  26. }
  27. mmio_clrsetbits_32(CSU_HP_REG(csu->idx), CSU_HP_CFG(0x1, csu->idx),
  28. CSU_HP_CFG(csu->hp | (csu->lock << 0x1), csu->idx));
  29. break;
  30. case CSU_SA:
  31. val = mmio_read_32(CSU_SA_REG(csu->idx));
  32. if (val & CSU_SA_LOCK(csu->idx)) {
  33. break;
  34. }
  35. mmio_clrsetbits_32(CSU_SA_REG(csu->idx), CSU_SA_CFG(0x1, csu->idx),
  36. CSU_SA_CFG(csu->sa | (csu->lock << 0x1), csu->idx));
  37. break;
  38. case CSU_HPCONTROL:
  39. val = mmio_read_32(CSU_HPCONTROL_REG(csu->idx));
  40. if (val & CSU_HPCONTROL_LOCK(csu->idx)) {
  41. break;
  42. }
  43. mmio_clrsetbits_32(CSU_HPCONTROL_REG(csu->idx), CSU_HPCONTROL_CFG(0x1, csu->idx),
  44. CSU_HPCONTROL_CFG(csu->hpctrl | (csu->lock << 0x1), csu->idx));
  45. break;
  46. default:
  47. break;
  48. }
  49. csu++;
  50. }
  51. }