mtk_dcm.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2021, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <mtk_dcm.h>
  8. #include <mtk_dcm_utils.h>
  9. static void dcm_armcore(bool mode)
  10. {
  11. dcm_mp_cpusys_top_bus_pll_div_dcm(mode);
  12. dcm_mp_cpusys_top_cpu_pll_div_0_dcm(mode);
  13. dcm_mp_cpusys_top_cpu_pll_div_1_dcm(mode);
  14. }
  15. static void dcm_mcusys(bool on)
  16. {
  17. dcm_mp_cpusys_top_adb_dcm(on);
  18. dcm_mp_cpusys_top_apb_dcm(on);
  19. dcm_mp_cpusys_top_cpubiu_dcm(on);
  20. dcm_mp_cpusys_top_cpubiu_dbg_cg(on);
  21. dcm_mp_cpusys_top_misc_dcm(on);
  22. dcm_mp_cpusys_top_mp0_qdcm(on);
  23. dcm_cpccfg_reg_emi_wfifo(on);
  24. dcm_mp_cpusys_top_last_cor_idle_dcm(on);
  25. }
  26. static void dcm_stall(bool on)
  27. {
  28. dcm_mp_cpusys_top_core_stall_dcm(on);
  29. dcm_mp_cpusys_top_fcm_stall_dcm(on);
  30. }
  31. static bool check_dcm_state(void)
  32. {
  33. bool ret = true;
  34. ret &= dcm_mp_cpusys_top_bus_pll_div_dcm_is_on();
  35. ret &= dcm_mp_cpusys_top_cpu_pll_div_0_dcm_is_on();
  36. ret &= dcm_mp_cpusys_top_cpu_pll_div_1_dcm_is_on();
  37. ret &= dcm_mp_cpusys_top_adb_dcm_is_on();
  38. ret &= dcm_mp_cpusys_top_apb_dcm_is_on();
  39. ret &= dcm_mp_cpusys_top_cpubiu_dcm_is_on();
  40. ret &= dcm_mp_cpusys_top_cpubiu_dbg_cg_is_on();
  41. ret &= dcm_mp_cpusys_top_misc_dcm_is_on();
  42. ret &= dcm_mp_cpusys_top_mp0_qdcm_is_on();
  43. ret &= dcm_cpccfg_reg_emi_wfifo_is_on();
  44. ret &= dcm_mp_cpusys_top_last_cor_idle_dcm_is_on();
  45. ret &= dcm_mp_cpusys_top_core_stall_dcm_is_on();
  46. ret &= dcm_mp_cpusys_top_fcm_stall_dcm_is_on();
  47. return ret;
  48. }
  49. void dcm_set_default(void)
  50. {
  51. dcm_armcore(true);
  52. dcm_mcusys(true);
  53. dcm_stall(true);
  54. INFO("%s: %d", __func__, check_dcm_state());
  55. }