summaryrefslogtreecommitdiff
path: root/src/mainboard/google/cherry
diff options
context:
space:
mode:
authorRex-BC Chen <rex-bc.chen@mediatek.com>2021-07-13 19:41:02 +0800
committerFelix Held <felix-coreboot@felixheld.de>2021-07-21 15:55:53 +0000
commitcc80a9ac8e635a21f73fd15117c75929fe933654 (patch)
treecef49a5b1e1b60a725b9f15fb794875e450c9cec /src/mainboard/google/cherry
parentfdde4cd15304c99d40f14fad3bdc7d215e92068d (diff)
mb/google/cherry: add mt6360 support for MT8195
For new MT8195 devices we will control mt6360 via EC, so we have to add ec function of controlling MT6360 and add CONFIG to separate them. Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com> Change-Id: Ic2228f5b45173f0905ea66a3a1f00ec820e0f855 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56446 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/mainboard/google/cherry')
-rw-r--r--src/mainboard/google/cherry/mainboard.c5
-rw-r--r--src/mainboard/google/cherry/regulator.c59
-rw-r--r--src/mainboard/google/cherry/romstage.c3
3 files changed, 55 insertions, 12 deletions
diff --git a/src/mainboard/google/cherry/mainboard.c b/src/mainboard/google/cherry/mainboard.c
index 9cd0324d49..5758883edb 100644
--- a/src/mainboard/google/cherry/mainboard.c
+++ b/src/mainboard/google/cherry/mainboard.c
@@ -126,7 +126,10 @@ static void configure_sdcard(void)
MSDC1_GPIO_MODE1_3, MSDC1_GPIO_MODE1_VALUE);
mtk_i2c_bus_init(7);
- mt6360_init(7);
+
+ if (CONFIG(BOARD_GOOGLE_CHERRY))
+ mt6360_init(7);
+
mainboard_enable_regulator(MTK_REGULATOR_VCCQ, 1);
mainboard_enable_regulator(MTK_REGULATOR_VCC, 1);
}
diff --git a/src/mainboard/google/cherry/regulator.c b/src/mainboard/google/cherry/regulator.c
index abda0d7682..f157ae61dc 100644
--- a/src/mainboard/google/cherry/regulator.c
+++ b/src/mainboard/google/cherry/regulator.c
@@ -61,7 +61,16 @@ void mainboard_set_regulator_vol(enum mtk_regulator regulator,
id = get_mt6360_regulator_id(regulator);
if (id >= 0) {
- mt6360_set_voltage(id, voltage_uv);
+ if (CONFIG(BOARD_GOOGLE_CHERRY)) {
+ mt6360_set_voltage(id, voltage_uv);
+ } else {
+ uint32_t voltage_mv = voltage_uv / 1000;
+ if (google_chromeec_regulator_set_voltage(id, voltage_mv,
+ voltage_mv) < 0) {
+ printk(BIOS_WARNING,
+ "Failed to set voltage by ec: %d\n", regulator);
+ }
+ }
return;
}
@@ -88,8 +97,19 @@ uint32_t mainboard_get_regulator_vol(enum mtk_regulator regulator)
int id;
id = get_mt6360_regulator_id(regulator);
- if (id >= 0)
- return mt6360_get_voltage(id);
+ if (id >= 0) {
+ if (CONFIG(BOARD_GOOGLE_CHERRY)) {
+ return mt6360_get_voltage(id);
+ } else {
+ uint32_t voltage_mv = 0;
+ if (google_chromeec_regulator_get_voltage(id, &voltage_mv) < 0) {
+ printk(BIOS_WARNING,
+ "Failed to get voltage by ec: %d\n", regulator);
+ return 0;
+ }
+ return voltage_mv * 1000;
+ }
+ }
id = get_mt6359p_regulator_id(regulator);
if (id >= 0)
@@ -117,8 +137,17 @@ int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable)
id = get_mt6360_regulator_id(regulator);
if (id >= 0) {
- mt6360_enable(id, enable);
- return 0;
+ if (CONFIG(BOARD_GOOGLE_CHERRY)) {
+ mt6360_enable(id, enable);
+ return 0;
+ } else {
+ if (google_chromeec_regulator_enable(id, enable) < 0) {
+ printk(BIOS_WARNING,
+ "Failed to enable regulator by ec: %d\n", regulator);
+ return -1;
+ }
+ return 0;
+ }
}
printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
@@ -134,12 +163,22 @@ uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator)
int id;
id = get_mt6360_regulator_id(regulator);
- if (id >= 0)
- return mt6360_is_enabled(id);
+ if (id >= 0) {
+ if (CONFIG(BOARD_GOOGLE_CHERRY)) {
+ return mt6360_is_enabled(id);
+ } else {
+ uint8_t enabled;
+ if (google_chromeec_regulator_is_enabled(id, &enabled) < 0) {
+ printk(BIOS_WARNING,
+ "Failed to retrieve is_enabled by ec; assuming disabled\n");
+ return 0;
+ }
+ return enabled;
+ }
+
+ }
- printk(BIOS_ERR,
- "Failed to query regulator ID: %d\n; assuming disabled",
- regulator);
+ printk(BIOS_ERR, "Invalid regulator ID: %d\n; assuming disabled", regulator);
return 0;
}
diff --git a/src/mainboard/google/cherry/romstage.c b/src/mainboard/google/cherry/romstage.c
index aabb7f5378..193d8e16ac 100644
--- a/src/mainboard/google/cherry/romstage.c
+++ b/src/mainboard/google/cherry/romstage.c
@@ -19,7 +19,8 @@ void platform_romstage_main(void)
mt6359p_init();
mt6315_init();
mtk_i2c_bus_init(I2C_BUS);
- mt6360_init(I2C_BUS);
+ if (CONFIG(BOARD_GOOGLE_CHERRY))
+ mt6360_init(I2C_BUS);
clk_buf_init();
rtc_boot();
mtk_dram_init();