From f9d72e3745a742d154d2d56ecaf58d7ff217b0d2 Mon Sep 17 00:00:00 2001 From: Cong Yang Date: Thu, 13 Apr 2023 14:50:48 +0800 Subject: soc/mediatek: Add assert for regulator VRF12 Add assert for MT6366_VRF12, define a constant macro for 1200000. BUG=none TEST=build board starmie with mt8186. Change-Id: I6d6a969ae993afcda0596a19928e8f98f343d589 Signed-off-by: Cong Yang Reviewed-on: https://review.coreboot.org/c/coreboot/+/74394 Reviewed-by: Yidi Lin Reviewed-by: Ruihai Zhou Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/soc/mediatek/mt8186/mt6366.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/soc/mediatek') diff --git a/src/soc/mediatek/mt8186/mt6366.c b/src/soc/mediatek/mt8186/mt6366.c index 7874c08d68..9dbf483f51 100644 --- a/src/soc/mediatek/mt8186/mt6366.c +++ b/src/soc/mediatek/mt8186/mt6366.c @@ -725,14 +725,17 @@ static void pmic_set_vmc_vol(u32 vmc_uv) pwrap_write_field(PMIC_LDO_VMC_CON0, 1, 0xFF, 0); } +#define VRF12_VOLTAGE_UV 1200000 + static u32 pmic_get_vrf12_vol(void) { return (pwrap_read_field(PMIC_LDO_VRF12_CON0, 0x3, 0) & - pwrap_read_field(PMIC_LDO_VRF12_OP_EN, 0x3, 0)) ? 1200000 : 0; + pwrap_read_field(PMIC_LDO_VRF12_OP_EN, 0x3, 0)) ? VRF12_VOLTAGE_UV : 0; } -static void pmic_enable_vrf12(void) +static void pmic_set_vrf12_vol(u32 vrf12_uv) { + assert(vrf12_uv == VRF12_VOLTAGE_UV); pwrap_write_field(PMIC_LDO_VRF12_CON0, 1, 0x3, 0); pwrap_write_field(PMIC_LDO_VRF12_OP_EN, 1, 0x3, 0); } @@ -921,8 +924,7 @@ void mt6366_set_voltage(enum mt6366_regulator_id id, u32 voltage_uv) pmic_set_vsram_proc12_vol(voltage_uv); break; case MT6366_VRF12: - /* VRF12 only provides 1.2V, so we just need to enable it */ - pmic_enable_vrf12(); + pmic_set_vrf12_vol(voltage_uv); break; case MT6366_VCN33: pmic_set_vcn33_vol(voltage_uv); -- cgit v1.2.3