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>
This commit is contained in:
Rex-BC Chen 2021-07-13 19:41:02 +08:00 committed by Felix Held
parent fdde4cd153
commit cc80a9ac8e
3 changed files with 55 additions and 12 deletions

View File

@ -126,7 +126,10 @@ static void configure_sdcard(void)
MSDC1_GPIO_MODE1_3, MSDC1_GPIO_MODE1_VALUE); MSDC1_GPIO_MODE1_3, MSDC1_GPIO_MODE1_VALUE);
mtk_i2c_bus_init(7); mtk_i2c_bus_init(7);
if (CONFIG(BOARD_GOOGLE_CHERRY))
mt6360_init(7); mt6360_init(7);
mainboard_enable_regulator(MTK_REGULATOR_VCCQ, 1); mainboard_enable_regulator(MTK_REGULATOR_VCCQ, 1);
mainboard_enable_regulator(MTK_REGULATOR_VCC, 1); mainboard_enable_regulator(MTK_REGULATOR_VCC, 1);
} }

View File

@ -61,7 +61,16 @@ void mainboard_set_regulator_vol(enum mtk_regulator regulator,
id = get_mt6360_regulator_id(regulator); id = get_mt6360_regulator_id(regulator);
if (id >= 0) { if (id >= 0) {
if (CONFIG(BOARD_GOOGLE_CHERRY)) {
mt6360_set_voltage(id, voltage_uv); 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; return;
} }
@ -88,8 +97,19 @@ uint32_t mainboard_get_regulator_vol(enum mtk_regulator regulator)
int id; int id;
id = get_mt6360_regulator_id(regulator); id = get_mt6360_regulator_id(regulator);
if (id >= 0) if (id >= 0) {
if (CONFIG(BOARD_GOOGLE_CHERRY)) {
return mt6360_get_voltage(id); 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); id = get_mt6359p_regulator_id(regulator);
if (id >= 0) if (id >= 0)
@ -117,8 +137,17 @@ int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable)
id = get_mt6360_regulator_id(regulator); id = get_mt6360_regulator_id(regulator);
if (id >= 0) { if (id >= 0) {
if (CONFIG(BOARD_GOOGLE_CHERRY)) {
mt6360_enable(id, enable); mt6360_enable(id, enable);
return 0; 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); 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; int id;
id = get_mt6360_regulator_id(regulator); id = get_mt6360_regulator_id(regulator);
if (id >= 0) if (id >= 0) {
if (CONFIG(BOARD_GOOGLE_CHERRY)) {
return mt6360_is_enabled(id); 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; return 0;
} }

View File

@ -19,6 +19,7 @@ void platform_romstage_main(void)
mt6359p_init(); mt6359p_init();
mt6315_init(); mt6315_init();
mtk_i2c_bus_init(I2C_BUS); mtk_i2c_bus_init(I2C_BUS);
if (CONFIG(BOARD_GOOGLE_CHERRY))
mt6360_init(I2C_BUS); mt6360_init(I2C_BUS);
clk_buf_init(); clk_buf_init();
rtc_boot(); rtc_boot();