diff --git a/src/mainboard/google/skywalker/Kconfig b/src/mainboard/google/skywalker/Kconfig index 81b49ba513..dd97f682b4 100644 --- a/src/mainboard/google/skywalker/Kconfig +++ b/src/mainboard/google/skywalker/Kconfig @@ -41,6 +41,7 @@ config BOARD_SPECIFIC_OPTIONS select RTC select COMMONLIB_STORAGE select COMMONLIB_STORAGE_MMC + select MIPI_PANEL_TM_TL121BVMS07_00C if BOARD_GOOGLE_PADME config MAINBOARD_DIR string diff --git a/src/mainboard/google/skywalker/Makefile.mk b/src/mainboard/google/skywalker/Makefile.mk index ff3c1701de..4a21a59187 100644 --- a/src/mainboard/google/skywalker/Makefile.mk +++ b/src/mainboard/google/skywalker/Makefile.mk @@ -13,3 +13,5 @@ ramstage-y += boardid.c ramstage-y += mainboard.c ramstage-y += panel.c ramstage-y += regulator.c + +ramstage-$(CONFIG_BOARD_GOOGLE_PADME) += panel_padme.c diff --git a/src/mainboard/google/skywalker/mainboard.c b/src/mainboard/google/skywalker/mainboard.c index 99c45cf17a..9952bfc1ec 100644 --- a/src/mainboard/google/skywalker/mainboard.c +++ b/src/mainboard/google/skywalker/mainboard.c @@ -17,6 +17,7 @@ #include #include "gpio.h" +#include "panel.h" #include "storage.h" #define AFE_SE_SECURE_CON1 (AUDIO_BASE + 0x5634) @@ -88,6 +89,8 @@ enum mtk_storage_type mainboard_get_storage_type(void) static void mainboard_init(struct device *dev) { + mt6359p_init_pmif_arb(); + if (mainboard_get_storage_type() == STORAGE_EMMC) { mtk_msdc_configure_emmc(true); mtcmos_ufs_power_off(); diff --git a/src/mainboard/google/skywalker/panel.c b/src/mainboard/google/skywalker/panel.c index 35313c23f6..deb392f281 100644 --- a/src/mainboard/google/skywalker/panel.c +++ b/src/mainboard/google/skywalker/panel.c @@ -1,12 +1,34 @@ /* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +#include +#include +#include + #include #include +#include #include "gpio.h" +#include "panel.h" + +static void aw37503_init(unsigned int bus) +{ + i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x00, 0x13, 0x1F, 0); + i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x01, 0x13, 0x1F, 0); + i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x21, 0x4C, 0xFF, 0); + i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x03, 0x43, 0xFF, 0); + i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x21, 0x00, 0xFF, 0); +} + +static bool is_pmic_aw37503(unsigned int bus) +{ + u8 vendor_id; + return (!i2c_read_field(bus, PMIC_AW37503_SLAVE, + 0x04, &vendor_id, 0x0F, 0) && vendor_id == 0x01); +} /* Set up backlight control pins as output pins, and set them to power off by default */ -static void configure_backlight(void) +void panel_configure_backlight(void) { gpio_output(GPIO_EDP_BL_EN_1V8, 0); gpio_output(GPIO_BL_PWM_1V8, 0); @@ -19,8 +41,39 @@ static void power_on_panel(void) gpio_set_pull(GPIO_EDP_HPD_1V8, GPIO_PULL_DISABLE, GPIO_PULL_UP); } +void mipi_panel_power_on(void) +{ + struct aw37503_config config = { + .i2c_bus = PMIC_I2C_BUS, + .en = GPIO_TCHSCR_REPORT_DISABLE, + }; + gpio_output(config.en, 0); + mdelay(1); + + mainboard_set_regulator_voltage(MTK_REGULATOR_VCN18, 1800000); + mtk_i2c_bus_init(config.i2c_bus, I2C_SPEED_FAST); + + mainboard_enable_regulator(MTK_REGULATOR_VCN18, true); + mdelay(5); + + 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(10); + } + gpio_output(GPIO_EN_PP3300_EDP_X, 0); + mdelay(1); + gpio_output(GPIO_EN_PP3300_EDP_X, 1); + mdelay(1); + gpio_output(GPIO_TCHSCR_RST_1V8_L, 0); + mdelay(1); + gpio_output(GPIO_TCHSCR_RST_1V8_L, 1); + mdelay(6); +} + static struct panel_description panel = { - .configure_backlight = configure_backlight, + .configure_backlight = panel_configure_backlight, .power_on = power_on_panel, .disp_path = DISP_PATH_EDP, .orientation = LB_FB_ORIENTATION_NORMAL, @@ -28,5 +81,8 @@ static struct panel_description panel = { struct panel_description *get_active_panel(void) { + if (CONFIG(BOARD_GOOGLE_PADME)) + return get_panel_description(); + return &panel; } diff --git a/src/mainboard/google/skywalker/panel.h b/src/mainboard/google/skywalker/panel.h index 6a969b323e..77c8aed5e5 100644 --- a/src/mainboard/google/skywalker/panel.h +++ b/src/mainboard/google/skywalker/panel.h @@ -3,6 +3,24 @@ #ifndef __MAINBOARD_GOOGLE_SKYWALKER_PANEL_H__ #define __MAINBOARD_GOOGLE_SKYWALKER_PANEL_H__ +#include +#include +#include + +#define PMIC_AW37503_SLAVE 0x3E +#define PMIC_I2C_BUS I2C6 + +struct aw37503_config { + uint32_t i2c_bus; + gpio_t en; +}; + uint8_t panel_id(void); +void panel_configure_backlight(void); +void mipi_panel_power_on(void); + +/* Return the mipi panel description */ +struct panel_description *get_panel_description(void); + #endif diff --git a/src/mainboard/google/skywalker/panel_padme.c b/src/mainboard/google/skywalker/panel_padme.c new file mode 100644 index 0000000000..13fdaa62cf --- /dev/null +++ b/src/mainboard/google/skywalker/panel_padme.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include + +#include "gpio.h" +#include "panel.h" + +static struct panel_description padme_panels[] = { + [0x22] = { + .configure_backlight = panel_configure_backlight, + .power_on = mipi_panel_power_on, + .name = "TM_TL121BVMS07_00C", + .disp_path = DISP_PATH_MIPI, + .orientation = LB_FB_ORIENTATION_LEFT_UP, + }, +}; + +struct panel_description *get_panel_description(void) +{ + uint8_t id = panel_id(); + if (id >= ARRAY_SIZE(padme_panels)) + return NULL; + + return &padme_panels[id]; +}