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>
This commit is contained in:
parent
c0797f50e1
commit
dcdbda5c93
|
@ -10,13 +10,13 @@ int pmif_ulposc_check(u32 current_clk, u32 target_clk)
|
||||||
if (current_clk < (target_clk * (1000 - CAL_TOL_RATE) / 1000) ||
|
if (current_clk < (target_clk * (1000 - CAL_TOL_RATE) / 1000) ||
|
||||||
current_clk > (target_clk * (1000 + CAL_TOL_RATE) / 1000)) {
|
current_clk > (target_clk * (1000 + CAL_TOL_RATE) / 1000)) {
|
||||||
printk(BIOS_WARNING,
|
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);
|
__func__, current_clk, CAL_TOL_RATE, target_clk);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printk(BIOS_DEBUG,
|
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);
|
__func__, current_clk, CAL_TOL_RATE, target_clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -138,5 +138,6 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FREQ_METER_ABIST_AD_OSC_CK 42
|
#define FREQ_METER_ABIST_AD_OSC_CK 42
|
||||||
|
#define CALI_DEFAULT_CAP_VALUE 0x3d
|
||||||
|
|
||||||
#endif /*__MT8188_SOC_PMIF_H__*/
|
#endif /*__MT8188_SOC_PMIF_H__*/
|
||||||
|
|
|
@ -123,8 +123,13 @@ int pmif_clk_init(void)
|
||||||
{
|
{
|
||||||
u32 ulposc1;
|
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 (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);
|
pmif_clockmonitor_config(false);
|
||||||
if (pmif_init_ulposc())
|
if (pmif_init_ulposc())
|
||||||
return E_NODEV;
|
return E_NODEV;
|
||||||
|
|
Loading…
Reference in New Issue