aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo-Chen Chen <rex-bc.chen@mediatek.com>2022-08-18 18:28:27 +0800
committerFelix Held <felix-coreboot@felixheld.de>2022-08-31 16:47:22 +0000
commitdcdbda5c93bedbce202e2f55903a7f52dd4f84f6 (patch)
treea758281a6969a115bba5b366dba09f75622b20b9
parentc0797f50e12b2c01701663d603d4b0112988877d (diff)
soc/mediatek/mt8188: Use MHz as unit for current_clk
The unit of current_clk in pmif_ulposc_check() should be MHz. We use pmif_get_ulposc_freq_mhz() to get the default hardware value in MHz. Without this modification, the judgement in pmif_ulposc_check() is alway wrong due to the wrong unit. TEST=build pass. BUG=b:233720142 Signed-off-by: Bo-Chen Chen <rex-bc.chen@mediatek.com> Change-Id: I3bf80a23bb35ff657023eb4b7e009fa233f61244 Reviewed-on: https://review.coreboot.org/c/coreboot/+/66971 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
-rw-r--r--src/soc/mediatek/common/pmif_clk.c4
-rw-r--r--src/soc/mediatek/mt8188/include/soc/pmif.h1
-rw-r--r--src/soc/mediatek/mt8188/pmif_clk.c7
3 files changed, 9 insertions, 3 deletions
diff --git a/src/soc/mediatek/common/pmif_clk.c b/src/soc/mediatek/common/pmif_clk.c
index b7f2228a76..cfd1dbce6b 100644
--- a/src/soc/mediatek/common/pmif_clk.c
+++ b/src/soc/mediatek/common/pmif_clk.c
@@ -10,13 +10,13 @@ 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",
+ "[%s] calibration fail: cur=%dM, 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",
+ "[%s] calibration done: cur=%dM, CAL_RATE=%d, target=%dM\n",
__func__, current_clk, CAL_TOL_RATE, target_clk);
return 0;
diff --git a/src/soc/mediatek/mt8188/include/soc/pmif.h b/src/soc/mediatek/mt8188/include/soc/pmif.h
index bc4f136c79..3cb8f3505f 100644
--- a/src/soc/mediatek/mt8188/include/soc/pmif.h
+++ b/src/soc/mediatek/mt8188/include/soc/pmif.h
@@ -138,5 +138,6 @@ enum {
};
#define FREQ_METER_ABIST_AD_OSC_CK 42
+#define CALI_DEFAULT_CAP_VALUE 0x3d
#endif /*__MT8188_SOC_PMIF_H__*/
diff --git a/src/soc/mediatek/mt8188/pmif_clk.c b/src/soc/mediatek/mt8188/pmif_clk.c
index e292ba186a..aac9b7b696 100644
--- a/src/soc/mediatek/mt8188/pmif_clk.c
+++ b/src/soc/mediatek/mt8188/pmif_clk.c
@@ -123,8 +123,13 @@ int pmif_clk_init(void)
{
u32 ulposc1;
- ulposc1 = mt_fmeter_get_freq_khz(FMETER_ABIST, FREQ_METER_ABIST_AD_OSC_CK);
+ /* check hardware default value first */
+ ulposc1 = pmif_get_ulposc_freq_mhz(CALI_DEFAULT_CAP_VALUE);
if (pmif_ulposc_check(ulposc1, FREQ_260MHZ)) {
+ /*
+ * If the hardware value is not what we want, we need to adjust
+ * it by the software setting.
+ */
pmif_clockmonitor_config(false);
if (pmif_init_ulposc())
return E_NODEV;