Attention is currently required from: Hung-Te Lin. Rex-BC Chen has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59250 )
Change subject: mb/google/corsola: Implement regulator interface ......................................................................
mb/google/corsola: Implement regulator interface
Use regulator interface to use regulator more easily.
TEST=build pass BUG=b:202871018
Signed-off-by: Rex-BC Chen rex-bc.chen@mediatek.com Change-Id: Ied43cba51036c62a120df2afffeb63b5d73f012b --- M src/mainboard/google/corsola/Makefile.inc A src/mainboard/google/corsola/regulator.c M src/soc/mediatek/common/include/soc/regulator.h 3 files changed, 48 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/50/59250/1
diff --git a/src/mainboard/google/corsola/Makefile.inc b/src/mainboard/google/corsola/Makefile.inc index 4720dc5..7995f8a 100644 --- a/src/mainboard/google/corsola/Makefile.inc +++ b/src/mainboard/google/corsola/Makefile.inc @@ -8,9 +8,11 @@
romstage-y += memlayout.ld romstage-y += chromeos.c +romstage-y += regulator.c romstage-y += romstage.c
ramstage-y += memlayout.ld ramstage-y += chromeos.c ramstage-y += mainboard.c +ramstage-y += regulator.c ramstage-y += reset.c diff --git a/src/mainboard/google/corsola/regulator.c b/src/mainboard/google/corsola/regulator.c new file mode 100644 index 0000000..1ddc52c --- /dev/null +++ b/src/mainboard/google/corsola/regulator.c @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <assert.h> +#include <console/console.h> +#include <soc/mt6366.h> +#include <soc/regulator.h> + +#define REGULATOR_NOT_SUPPORT -1 + +static const int regulator_id[] = { + [MTK_REGULATOR_VDD1] = REGULATOR_NOT_SUPPORT, + [MTK_REGULATOR_VDD2] = REGULATOR_NOT_SUPPORT, + [MTK_REGULATOR_VDDQ] = MT6366_VDDQ, + [MTK_REGULATOR_VMDDR] = REGULATOR_NOT_SUPPORT, + [MTK_REGULATOR_VCORE] = MT6366_VCORE, + [MTK_REGULATOR_VCC] = REGULATOR_NOT_SUPPORT, + [MTK_REGULATOR_VCCQ] = REGULATOR_NOT_SUPPORT, + [MTK_REGULATOR_VDRAM1] = MT6366_VDRAM1, +}; + +_Static_assert(ARRAY_SIZE(regulator_id) == MTK_REGULATOR_NUM, "regulator_id size error"); + +void mainboard_set_regulator_vol(enum mtk_regulator regulator, + uint32_t voltage_uv) +{ + assert(regulator < MTK_REGULATOR_NUM); + + if (regulator_id[regulator] < 0) { + printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator); + return; + } + mt6366_set_voltage(regulator_id[regulator], voltage_uv); +} + +uint32_t mainboard_get_regulator_vol(enum mtk_regulator regulator) +{ + assert(regulator < MTK_REGULATOR_NUM); + + if (regulator_id[regulator] < 0) { + printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator); + return 0; + } + return mt6366_get_voltage(regulator_id[regulator]); +} diff --git a/src/soc/mediatek/common/include/soc/regulator.h b/src/soc/mediatek/common/include/soc/regulator.h index 0cd0f1e..08ce47f 100644 --- a/src/soc/mediatek/common/include/soc/regulator.h +++ b/src/soc/mediatek/common/include/soc/regulator.h @@ -13,12 +13,13 @@ MTK_REGULATOR_VCORE, MTK_REGULATOR_VCC, MTK_REGULATOR_VCCQ, + MTK_REGULATOR_VDRAM1, + MTK_REGULATOR_NUM, };
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);