summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/mediatek/common/include/soc/pmif_clk_common.h1
-rw-r--r--src/soc/mediatek/common/pmif_clk.c26
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);
}