diff options
Diffstat (limited to 'src/mainboard/google/cherry')
-rw-r--r-- | src/mainboard/google/cherry/mainboard.c | 5 | ||||
-rw-r--r-- | src/mainboard/google/cherry/regulator.c | 59 | ||||
-rw-r--r-- | src/mainboard/google/cherry/romstage.c | 3 |
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(); |