summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHui Liu <hui.liu@mediatek.corp-partner.google.com>2022-07-15 14:02:34 +0800
committerMartin Roth <martin.roth@amd.corp-partner.google.com>2022-07-22 04:02:49 +0000
commitba16e057ad181ee73ffb989606f97260856d433b (patch)
tree20d1451ef7405bee6695695c91de6b8007b55b63
parent15e4c0a23f93835a7f4e3756705eaa11a3a5bc2f (diff)
downloadcoreboot-ba16e057ad181ee73ffb989606f97260856d433b.tar.gz
coreboot-ba16e057ad181ee73ffb989606f97260856d433b.tar.bz2
coreboot-ba16e057ad181ee73ffb989606f97260856d433b.zip
mb/google/geralt: Implement regulator interface
Control regulator more easily with regulator interface. TEST=measure 3.0V in VMCH and VMC. BUG=b:236331724 Signed-off-by: Hui Liu <hui.liu@mediatek.corp-partner.google.com> Change-Id: I9727475774b3b9a8dcd49e5e60e133f9d745b407 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65875 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/mainboard/google/geralt/Makefile.inc1
-rw-r--r--src/mainboard/google/geralt/regulator.c77
-rw-r--r--src/soc/mediatek/common/include/soc/regulator.h2
3 files changed, 80 insertions, 0 deletions
diff --git a/src/mainboard/google/geralt/Makefile.inc b/src/mainboard/google/geralt/Makefile.inc
index 4720dc586f7c..d1d9ff3b0e49 100644
--- a/src/mainboard/google/geralt/Makefile.inc
+++ b/src/mainboard/google/geralt/Makefile.inc
@@ -13,4 +13,5 @@ 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/geralt/regulator.c b/src/mainboard/google/geralt/regulator.c
new file mode 100644
index 000000000000..6089af90d62c
--- /dev/null
+++ b/src/mainboard/google/geralt/regulator.c
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <console/console.h>
+#include <soc/mt6359p.h>
+#include <soc/regulator.h>
+
+#define MTK_REGULATOR_INVALID -1
+
+static int get_mt6359p_regulator_id(enum mtk_regulator regulator)
+{
+ switch (regulator) {
+ case MTK_REGULATOR_VCORE:
+ return MT6359P_GPU11;
+ case MTK_REGULATOR_VPROC11:
+ return MT6359P_CORE;
+ case MTK_REGULATOR_VSRAM_PROC11:
+ return MT6359P_SRAM_PROC1;
+ case MTK_REGULATOR_VMCH:
+ return MT6359P_PA;
+ case MTK_REGULATOR_VMC:
+ return MT6359P_SIM1;
+ default:
+ return MTK_REGULATOR_INVALID;
+ }
+}
+
+void mainboard_set_regulator_voltage(enum mtk_regulator regulator, uint32_t voltage_uv)
+{
+ int id;
+
+ id = get_mt6359p_regulator_id(regulator);
+ if (id < 0) {
+ printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
+ return;
+ }
+
+ if (id == MT6359P_SIM1)
+ mt6359p_set_vsim1_voltage(voltage_uv);
+ else
+ mt6359p_buck_set_voltage(id, voltage_uv);
+}
+
+uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator)
+{
+ int id;
+
+ id = get_mt6359p_regulator_id(regulator);
+ if (id < 0) {
+ printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
+ return 0;
+ }
+
+ if (id == MT6359P_SIM1)
+ return mt6359p_get_vsim1_voltage();
+
+ return mt6359p_buck_get_voltage(id);
+}
+
+int mainboard_enable_regulator(enum mtk_regulator regulator, bool enable)
+{
+ int id;
+
+ id = get_mt6359p_regulator_id(regulator);
+ if (id < 0) {
+ printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
+ return -1;
+ }
+
+ if (id == MT6359P_SIM1)
+ mt6359p_enable_vsim1(enable);
+ else if (id == MT6359P_PA)
+ mt6359p_enable_vpa(enable);
+ else
+ printk(BIOS_INFO, "No need to enable regulator ID: %d\n", regulator);
+
+ return 0;
+}
diff --git a/src/soc/mediatek/common/include/soc/regulator.h b/src/soc/mediatek/common/include/soc/regulator.h
index 2ff122637a4e..7f3bd49e0458 100644
--- a/src/soc/mediatek/common/include/soc/regulator.h
+++ b/src/soc/mediatek/common/include/soc/regulator.h
@@ -16,7 +16,9 @@ enum mtk_regulator {
MTK_REGULATOR_VDRAM1,
MTK_REGULATOR_VMCH,
MTK_REGULATOR_VMC,
+ MTK_REGULATOR_VPROC11,
MTK_REGULATOR_VPROC12,
+ MTK_REGULATOR_VSRAM_PROC11,
MTK_REGULATOR_VSRAM_PROC12,
MTK_REGULATOR_VRF12,
MTK_REGULATOR_VCN33,