mb/google/asurada: Implement enable_regulator and regulator_is_enabled
SD Card driver needs to access two regulators - MT6360_LDO5 and MT6360_LDO3. These two regulators are disabled by default. Two APIs are implemented: - mainboard_enable_regulator: Configure the regulator as enabled/disabled. - mainboard_regulator_is_enabled: Query if the regulator is enabled. BUG=b:168863056,b:147789962 BRANCH=none TEST=emerge-asurada coreboot Change-Id: I391f908fcb33ffdcccc53063644482eabc863ac4 Signed-off-by: Yidi Lin <yidi.lin@mediatek.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/46687 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
99e6dd9f74
commit
dfd5ccee75
|
@ -20,3 +20,4 @@ ramstage-y += boardid.c
|
|||
ramstage-y += chromeos.c
|
||||
ramstage-y += mainboard.c
|
||||
ramstage-y += reset.c
|
||||
ramstage-y += regulator.c
|
||||
|
|
|
@ -15,6 +15,10 @@ static int get_mt6360_regulator_id(enum mtk_regulator regulator)
|
|||
return MT6360_LDO7;
|
||||
case MTK_REGULATOR_VMDDR:
|
||||
return MT6360_LDO6;
|
||||
case MTK_REGULATOR_VCC:
|
||||
return MT6360_LDO5;
|
||||
case MTK_REGULATOR_VCCQ:
|
||||
return MT6360_LDO3;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -90,3 +94,42 @@ uint32_t mainboard_get_regulator_vol(enum mtk_regulator regulator)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable)
|
||||
{
|
||||
/* Return 0 if the regulator is already enabled or disabled. */
|
||||
if (mainboard_regulator_is_enabled(regulator) == enable)
|
||||
return 0;
|
||||
|
||||
int id;
|
||||
|
||||
id = get_mt6360_regulator_id(regulator);
|
||||
if (id < 0) {
|
||||
printk(BIOS_WARNING, "Invalid regulator ID: %d\n", regulator);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return google_chromeec_regulator_enable(id, enable);
|
||||
}
|
||||
|
||||
uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator)
|
||||
{
|
||||
int id;
|
||||
|
||||
id = get_mt6360_regulator_id(regulator);
|
||||
if (id < 0) {
|
||||
printk(BIOS_WARNING, "Invalid regulator ID: %d\n; assuming disabled",
|
||||
regulator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t enabled;
|
||||
if (google_chromeec_regulator_is_enabled(id, &enabled) < 0) {
|
||||
printk(BIOS_WARNING,
|
||||
"Failed to query regulator ID: %d\n; assuming disabled",
|
||||
regulator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,15 @@ enum mtk_regulator {
|
|||
MTK_REGULATOR_VDDQ,
|
||||
MTK_REGULATOR_VMDDR,
|
||||
MTK_REGULATOR_VCORE,
|
||||
MTK_REGULATOR_VCC,
|
||||
MTK_REGULATOR_VCCQ,
|
||||
};
|
||||
|
||||
void mainboard_set_regulator_vol(enum mtk_regulator regulator,
|
||||
uint32_t voltage_uv);
|
||||
uint32_t mainboard_get_regulator_vol(enum mtk_regulator regulator);
|
||||
|
||||
int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable);
|
||||
uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator);
|
||||
|
||||
#endif /* SOC_MEDIATEK_COMMON_REGULATOR_H */
|
||||
|
|
Loading…
Reference in New Issue