Yidi Lin has submitted this change. ( https://review.coreboot.org/c/coreboot/+/85745?usp=email )
Change subject: mb/google/corsola: Refactor mipi_panel_power_on function ......................................................................
mb/google/corsola: Refactor mipi_panel_power_on function
Refactor mipi_panel_power_on function in panel-starmie.c to reduce code duplication.
BUG=b:379810871 TEST=emerge-staryu coreboot chromeos-bootimage and check FW screen BRANCH=corsola
Change-Id: Ic0561e57d99ab55e6dcbb7744b2228c4cebb0d88 Signed-off-by: Yang Wu wuyang5@huaqin.corp-partner.google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/85745 Reviewed-by: Yu-Ping Wu yupingso@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Yidi Lin yidilin@google.com --- M src/mainboard/google/corsola/Makefile.mk M src/mainboard/google/corsola/panel.h M src/mainboard/google/corsola/panel_starmie.c A src/mainboard/google/corsola/panel_tps65132s.c 4 files changed, 49 insertions(+), 33 deletions(-)
Approvals: build bot (Jenkins): Verified Yidi Lin: Looks good to me, approved Yu-Ping Wu: Looks good to me, approved
diff --git a/src/mainboard/google/corsola/Makefile.mk b/src/mainboard/google/corsola/Makefile.mk index 09e9b91..6ff22c6 100644 --- a/src/mainboard/google/corsola/Makefile.mk +++ b/src/mainboard/google/corsola/Makefile.mk @@ -22,6 +22,8 @@ ramstage-y += panel.c ramstage-y += panel_anx7625.c ramstage-y += panel_ps8640.c +ramstage-y += panel_tps65132s.c + ramstage-y += regulator.c ramstage-y += reset.c
diff --git a/src/mainboard/google/corsola/panel.h b/src/mainboard/google/corsola/panel.h index a4198f3..01606f4 100644 --- a/src/mainboard/google/corsola/panel.h +++ b/src/mainboard/google/corsola/panel.h @@ -5,6 +5,7 @@
#include <soc/display.h> #include <soc/i2c.h> +#include <soc/tps65132s.h>
#define BRIDGE_I2C I2C0 #define PMIC_AW37503_SLAVE 0x3E @@ -14,6 +15,7 @@ bool is_pmic_aw37503(unsigned int bus); uint32_t panel_id(void); void backlight_control(void); +void tps65132s_power_on(struct tps65132s_cfg *config);
/* Return the mipi panel description from given panel id */ struct panel_description *get_panel_description(void); diff --git a/src/mainboard/google/corsola/panel_starmie.c b/src/mainboard/google/corsola/panel_starmie.c index 1de2c61..5a1228c 100644 --- a/src/mainboard/google/corsola/panel_starmie.c +++ b/src/mainboard/google/corsola/panel_starmie.c @@ -1,9 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h> -#include <delay.h> -#include <gpio.h> -#include <soc/regulator.h> #include <soc/tps65132s.h>
#include "gpio.h" @@ -11,40 +8,12 @@
static void mipi_panel_power_on(void) { - const struct tps65132s_reg_setting reg_settings[] = { - { PMIC_TPS65132_VPOS, 0x14, 0x1F }, - { PMIC_TPS65132_VNEG, 0x14, 0x1F }, - { PMIC_TPS65132_DLYX, 0x95, 0xFF }, - { PMIC_TPS65132_ASSDD, 0x5b, 0xFF }, - }; - const struct tps65132s_cfg cfg = { + struct tps65132s_cfg config = { .i2c_bus = PMIC_I2C_BUS, .en = GPIO_EN_PP3300_DISP_X, .sync = GPIO_EN_PP3300_SDBRDG_X, - .settings = reg_settings, - .setting_counts = ARRAY_SIZE(reg_settings), }; - - mainboard_set_regulator_voltage(MTK_REGULATOR_VIO18, 1800000); - mtk_i2c_bus_init(PMIC_I2C_BUS, I2C_SPEED_FAST); - - if (is_pmic_aw37503(PMIC_I2C_BUS)) { - printk(BIOS_DEBUG, "Initialize and power on PMIC AW37503\n"); - aw37503_init(PMIC_I2C_BUS); - gpio_output(GPIO_EN_PP3300_DISP_X, 1); - mdelay(2); - gpio_output(GPIO_EN_PP3300_SDBRDG_X, 1); - mdelay(3); - } else if (tps65132s_setup(&cfg) != CB_SUCCESS) { - printk(BIOS_ERR, "Failed to setup tps65132s\n"); - } - - /* DISP_RST_1V8_L */ - gpio_output(GPIO_EDPBRDG_RST_L, 1); - mdelay(1); - gpio_output(GPIO_EDPBRDG_RST_L, 0); - udelay(20); - gpio_output(GPIO_EDPBRDG_RST_L, 1); + tps65132s_power_on(&config); }
static struct panel_description starmie_panels[] = { diff --git a/src/mainboard/google/corsola/panel_tps65132s.c b/src/mainboard/google/corsola/panel_tps65132s.c new file mode 100644 index 0000000..36933c0 --- /dev/null +++ b/src/mainboard/google/corsola/panel_tps65132s.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <delay.h> +#include <gpio.h> +#include <soc/regulator.h> +#include <soc/tps65132s.h> + +#include "gpio.h" +#include "panel.h" + +void tps65132s_power_on(struct tps65132s_cfg *config) +{ + const struct tps65132s_reg_setting reg_settings[] = { + { PMIC_TPS65132_VPOS, 0x14, 0x1F }, + { PMIC_TPS65132_VNEG, 0x14, 0x1F }, + { PMIC_TPS65132_DLYX, 0x95, 0xFF }, + { PMIC_TPS65132_ASSDD, 0x5b, 0xFF }, + }; + config->settings = reg_settings; + config->setting_counts = ARRAY_SIZE(reg_settings); + + mainboard_set_regulator_voltage(MTK_REGULATOR_VIO18, 1800000); + mtk_i2c_bus_init(config->i2c_bus, I2C_SPEED_FAST); + + if (is_pmic_aw37503(config->i2c_bus)) { + printk(BIOS_DEBUG, "Initialize and power on PMIC AW37503\n"); + aw37503_init(config->i2c_bus); + gpio_output(config->en, 1); + mdelay(2); + gpio_output(config->sync, 1); + mdelay(3); + } else if (tps65132s_setup(config) != CB_SUCCESS) { + printk(BIOS_ERR, "Failed to setup tps65132s\n"); + } + + /* DISP_RST_1V8_L */ + gpio_output(GPIO_EDPBRDG_RST_L, 1); + mdelay(1); + gpio_output(GPIO_EDPBRDG_RST_L, 0); + udelay(20); + gpio_output(GPIO_EDPBRDG_RST_L, 1); +}