diff options
author | Rex-BC Chen <rex-bc.chen@mediatek.com> | 2022-07-14 14:15:43 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-07-21 10:27:27 +0000 |
commit | 823dcea39ceb44e938ace8b40e0cca4244a052c5 (patch) | |
tree | 0cc89a072c1d84cb7fb2927f6d07cca2cbd2a9c3 /src/soc/mediatek/common | |
parent | b9c1ce67a5ceb723b1a06d22f7740675af3160ab (diff) |
soc/mediatek: Create a function to check ulposc
We will use the same drivers for checking ulposc in MT8188, so we add a
new function pmif_ulposc_check() to common.
TEST=build pass
BUG=b:233720142
Signed-off-by: Bo-Chen Chen <rex-bc.chen@mediatek.com>
Change-Id: I40136eaeb2c08a97cd65bfb8a81f2f24739d4d51
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65841
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/mediatek/common')
-rw-r--r-- | src/soc/mediatek/common/include/soc/pmif_clk_common.h | 1 | ||||
-rw-r--r-- | src/soc/mediatek/common/pmif_clk.c | 26 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/soc/mediatek/common/include/soc/pmif_clk_common.h b/src/soc/mediatek/common/include/soc/pmif_clk_common.h index f1bd2c7cf8..c61cd1a96e 100644 --- a/src/soc/mediatek/common/include/soc/pmif_clk_common.h +++ b/src/soc/mediatek/common/include/soc/pmif_clk_common.h @@ -3,6 +3,7 @@ #ifndef __MEDIATEK_SOC_PMIF_CLK_COMMON__ #define __MEDIATEK_SOC_PMIF_CLK_COMMON__ +int pmif_ulposc_check(u32 current_clk, u32 target_clk); int pmif_ulposc_cali(u32 target_val); #endif /*__MEDIATEK_SOC_PMIF_CLK_COMMON__*/ diff --git a/src/soc/mediatek/common/pmif_clk.c b/src/soc/mediatek/common/pmif_clk.c index 5b458a02c7..b7f2228a76 100644 --- a/src/soc/mediatek/common/pmif_clk.c +++ b/src/soc/mediatek/common/pmif_clk.c @@ -5,6 +5,23 @@ #include <soc/pmif_clk_common.h> #include <soc/pmif_sw.h> +int pmif_ulposc_check(u32 current_clk, u32 target_clk) +{ + if (current_clk < (target_clk * (1000 - CAL_TOL_RATE) / 1000) || + current_clk > (target_clk * (1000 + CAL_TOL_RATE) / 1000)) { + printk(BIOS_WARNING, + "[%s] calibration fail: cur=%d, CAL_RATE=%d, target=%dM\n", + __func__, current_clk, CAL_TOL_RATE, target_clk); + return -1; + } + + printk(BIOS_DEBUG, + "[%s] calibration done: cur=%d, CAL_RATE=%d, target=%dM\n", + __func__, current_clk, CAL_TOL_RATE, target_clk); + + return 0; +} + int pmif_ulposc_cali(u32 target_val) { u32 current_val, min = 0, max = CAL_MAX_VAL, middle; @@ -32,12 +49,5 @@ int pmif_ulposc_cali(u32 target_val) current_val = pmif_get_ulposc_freq_mhz(cal_result); /* check if calibrated value is in the range of target value +- 15% */ - if (current_val < (target_val * (1000 - CAL_TOL_RATE) / 1000) || - current_val > (target_val * (1000 + CAL_TOL_RATE) / 1000)) { - printk(BIOS_ERR, "[%s] calibration fail: cur=%d, CAL_RATE=%d, target=%dM\n", - __func__, current_val, CAL_TOL_RATE, target_val); - return 1; - } - - return 0; + return pmif_ulposc_check(current_val, target_val); } |