From 669184434a41945ba239a446a0563d66e3972cfa Mon Sep 17 00:00:00 2001 From: Jan Samek Date: Thu, 15 Sep 2022 16:31:44 +0200 Subject: drivers/i2c/ptn3460: Add early init option Create Kconfig options and boot state machine callback in ramstage for an early initialization of the PTN3460 DP-to-LVDS bridge. This allows showing the bootsplash screen on mainboards utilizing this chip during the PCI device enumeration. BUG=none TEST=Select PTN3460_EARLY_INIT config switch in mainboard Kconfig and check the log for "Attempting PTN3460 early init" message. If the board (e.g. siemens/mc_apl7 in this case) is also configured for showing the bootsplash logo, it should be now visible. Change-Id: I5424d062b3fb63c78cfced3971376353be11c504 Signed-off-by: Jan Samek Reviewed-on: https://review.coreboot.org/c/coreboot/+/67681 Reviewed-by: Angel Pons Reviewed-by: Uwe Poeche Tested-by: build bot (Jenkins) --- src/drivers/i2c/ptn3460/Kconfig | 14 ++++++++++++++ src/drivers/i2c/ptn3460/ptn3460.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/drivers/i2c/ptn3460/Kconfig b/src/drivers/i2c/ptn3460/Kconfig index 6dcdbc0915c1..6d3ca2d233ba 100644 --- a/src/drivers/i2c/ptn3460/Kconfig +++ b/src/drivers/i2c/ptn3460/Kconfig @@ -3,3 +3,17 @@ config DRIVERS_I2C_PTN3460 default n help Enable support for external display bridge (eDP to LVDS) PTN3460. + +config PTN3460_EARLY_INIT + bool + default n + depends on DRIVERS_I2C_PTN3460 + help + Enable early initialization of the PTN3460 DP-to-LVDS bridge + +config PTN3460_EARLY_ADDR + hex + default 0x60 + depends on PTN3460_EARLY_INIT + help + I2C address for early initialization of the PTN3460 DP-to-LVDS bridge diff --git a/src/drivers/i2c/ptn3460/ptn3460.c b/src/drivers/i2c/ptn3460/ptn3460.c index 98a343228e1a..25ed98a4bef5 100644 --- a/src/drivers/i2c/ptn3460/ptn3460.c +++ b/src/drivers/i2c/ptn3460/ptn3460.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "ptn3460.h" @@ -65,6 +66,14 @@ static void ptn3460_init(struct device *dev) uint8_t edid_data[PTN_EDID_LEN], edid_tab, *ptr = (uint8_t *) &cfg; int i, val; + /* Guard against re-initialization of the device */ + static bool init_done = false; + + if (init_done) { + printk(BIOS_DEBUG, "Skipping PTN3460 init as it's already initialized\n"); + return; + } + /* Mainboard provides EDID data. */ if (mb_get_edid(edid_data) != CB_SUCCESS) { printk(BIOS_ERR, "PTN3460 error: Unable to get EDID data from mainboard.\n"); @@ -109,6 +118,8 @@ static void ptn3460_init(struct device *dev) } } } + + init_done = true; } __weak enum cb_err mb_get_edid(uint8_t edid_data[0x80]) @@ -139,3 +150,30 @@ struct chip_operations drivers_i2c_ptn3460_ops = { CHIP_NAME("PTN3460") .enable_dev = ptn3460_enable }; + +#if CONFIG(PTN3460_EARLY_INIT) + +/** + * \brief This function provides a callback for the boot state machine to initialize the + * PTN3460 DP-to-LVDS bridge before graphics initialization in order for the bootsplash + * logo to be shown. + * @param *unused Unused argument for the callback. + */ + +static void ptn3460_early_init(void *unused) +{ + struct device *ptn_dev; + + printk(BIOS_DEBUG, "Attempting PTN3460 early init.\n"); + ptn_dev = dev_find_slot_on_smbus(0, CONFIG_PTN3460_EARLY_ADDR); + if (!ptn_dev) { + printk(BIOS_ERR, "Failed to find the PTN3460 device!\n"); + return; + } + + ptn3460_init(ptn_dev); +} + +BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, ptn3460_early_init, NULL); + +#endif /* CONFIG(PTN3460_EARLY_INIT) */ -- cgit v1.2.3