Yang Wu has uploaded this change for review. ( 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 and panel-wyrdeer.c to reduce code duplication.
BUG=b:379810871 TEST=emerge-staryu coreboot chromeos-bootimage and check both starmie and wyrdeer FW screen BRANCH=corsola
Change-Id: Ic0561e57d99ab55e6dcbb7744b2228c4cebb0d88 Signed-off-by: Yang Wu wuyang5@huaqin.corp-partner.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 M src/mainboard/google/corsola/panel_wyrdeer.c 5 files changed, 64 insertions(+), 66 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/45/85745/1
diff --git a/src/mainboard/google/corsola/Makefile.mk b/src/mainboard/google/corsola/Makefile.mk index b0d87e58..43d3dc3 100644 --- a/src/mainboard/google/corsola/Makefile.mk +++ b/src/mainboard/google/corsola/Makefile.mk @@ -22,6 +22,7 @@ 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..e4b4130 100644 --- a/src/mainboard/google/corsola/panel.h +++ b/src/mainboard/google/corsola/panel.h @@ -4,16 +4,22 @@ #define __MAINBOARD_GOOGLE_CORSOLA_DISPLAY_H__
#include <soc/display.h> +#include <soc/gpio.h> #include <soc/i2c.h>
#define BRIDGE_I2C I2C0 #define PMIC_AW37503_SLAVE 0x3E #define PMIC_I2C_BUS I2C6 +struct mipi_panel_config { + gpio_t en_gpio; + gpio_t sync_gpio; +};
void aw37503_init(unsigned int bus); bool is_pmic_aw37503(unsigned int bus); uint32_t panel_id(void); void backlight_control(void); +void tps65132s_power_on(const struct mipi_panel_config *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..c3c4512 100644 --- a/src/mainboard/google/corsola/panel_starmie.c +++ b/src/mainboard/google/corsola/panel_starmie.c @@ -11,40 +11,11 @@
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 }, + struct mipi_panel_config config = { + .en_gpio = GPIO_EN_PP3300_DISP_X, + .sync_gpio = GPIO_EN_PP3300_SDBRDG_X, }; - const struct tps65132s_cfg cfg = { - .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..36f3163 --- /dev/null +++ b/src/mainboard/google/corsola/panel_tps65132s.c @@ -0,0 +1,49 @@ +/* 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(const struct mipi_panel_config *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 }, + }; + const struct tps65132s_cfg cfg = { + .i2c_bus = PMIC_I2C_BUS, + .en = config->en_gpio, + .sync = config->sync_gpio, + .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(config->en_gpio, 1); + mdelay(2); + gpio_output(config->sync_gpio, 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); +} + diff --git a/src/mainboard/google/corsola/panel_wyrdeer.c b/src/mainboard/google/corsola/panel_wyrdeer.c index 2c984ac..316c5e6 100644 --- a/src/mainboard/google/corsola/panel_wyrdeer.c +++ b/src/mainboard/google/corsola/panel_wyrdeer.c @@ -11,40 +11,11 @@
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 }, + struct mipi_panel_config config = { + .en_gpio = GPIO_EN_PP3300_DISP_X, + .sync_gpio = GPIO_TCHPAD_INT_ODL, }; - const struct tps65132s_cfg cfg = { - .i2c_bus = PMIC_I2C_BUS, - .en = GPIO_EN_PP3300_DISP_X, - .sync = GPIO_TCHPAD_INT_ODL, - .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_TCHPAD_INT_ODL, 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 wyrdeer_panels[] = {