diff options
author | Fred Reitberger <reitbergerfred@gmail.com> | 2022-04-22 17:37:47 -0400 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-04-27 20:14:25 +0000 |
commit | 248916ad5713da5a2a0e7a9a06792be389d5223a (patch) | |
tree | 8c14b83e8ff7c7a6544565df787bfbc6b0941fe5 /src/mainboard | |
parent | 263f143c4429a256734c3ac5b2caa1a0725c5002 (diff) |
mb/amd/chausie: Auto-detect DDI type
Read the EEPROM to detect the DDI type.
BUG=b:225139014
TEST=Boot chausie and correctly detect display card type
Change-Id: I3ddd8789e75d5da2ea1e6ce9a81e5ebb2cf3c007
Signed-off-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63795
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Diffstat (limited to 'src/mainboard')
-rw-r--r-- | src/mainboard/amd/chausie/devicetree.cb | 5 | ||||
-rw-r--r-- | src/mainboard/amd/chausie/port_descriptors.c | 46 |
2 files changed, 49 insertions, 2 deletions
diff --git a/src/mainboard/amd/chausie/devicetree.cb b/src/mainboard/amd/chausie/devicetree.cb index 4a0c5b056e..09b850058d 100644 --- a/src/mainboard/amd/chausie/devicetree.cb +++ b/src/mainboard/amd/chausie/devicetree.cb @@ -24,6 +24,11 @@ chip soc/amd/sabrina register "i2c_scl_reset" = "GPIO_I2C0_SCL | GPIO_I2C1_SCL | GPIO_I2C2_SCL | GPIO_I2C3_SCL" + register "i2c[0].early_init" = "1" + register "i2c[1].early_init" = "1" + register "i2c[2].early_init" = "1" + register "i2c[3].early_init" = "1" + # I2C Pad Control RX Select Configuration register "i2c_pad[0].rx_level" = "I2C_PAD_RX_1_8V" register "i2c_pad[1].rx_level" = "I2C_PAD_RX_1_8V" diff --git a/src/mainboard/amd/chausie/port_descriptors.c b/src/mainboard/amd/chausie/port_descriptors.c index 4a8a0fda8a..17091e780e 100644 --- a/src/mainboard/amd/chausie/port_descriptors.c +++ b/src/mainboard/amd/chausie/port_descriptors.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include <console/console.h> +#include <device/i2c_simple.h> #include <soc/gpio.h> #include <soc/platform_descriptors.h> #include <types.h> @@ -47,13 +49,13 @@ static const fsp_dxio_descriptor chausie_dxio_descriptors[] = { }, }; -static const fsp_ddi_descriptor chausie_ddi_descriptors[] = { +static fsp_ddi_descriptor chausie_ddi_descriptors[] = { { /* DDI0 - eDP */ .connector_type = DDI_EDP, .aux_index = DDI_AUX1, .hdp_index = DDI_HDP1 }, - { /* DDI1 - HDMI - TODO: add runtime HDMI/DP connector card detection */ + { /* DDI1 - HDMI/DP */ .connector_type = DDI_HDMI, .aux_index = DDI_AUX2, .hdp_index = DDI_HDP2 @@ -75,10 +77,50 @@ static const fsp_ddi_descriptor chausie_ddi_descriptors[] = { } }; +static uint8_t get_ddi1_type(void) +{ + const uint8_t eeprom_i2c_bus = 2; + const uint8_t eeprom_i2c_address = 0x55; + const uint16_t eeprom_connector_type_offset = 2; + uint8_t eeprom_connector_type_data[2]; + uint16_t connector_type; + + if (i2c_2ba_read_bytes(eeprom_i2c_bus, eeprom_i2c_address, + eeprom_connector_type_offset, eeprom_connector_type_data, + sizeof(eeprom_connector_type_data))) { + printk(BIOS_NOTICE, + "Display connector type couldn't be determined. Disabling DDI1.\n"); + return DDI_UNUSED_TYPE; + } + + connector_type = eeprom_connector_type_data[1] | eeprom_connector_type_data[0] << 8; + + switch (connector_type) { + case 0xc: + printk(BIOS_DEBUG, "Configuring DDI1 as HDMI.\n"); + return DDI_HDMI; + break; + case 0x13: + printk(BIOS_DEBUG, "Configuring DDI1 as DP.\n"); + return DDI_DP; + break; + case 0x14: + printk(BIOS_DEBUG, "Configuring DDI1 as eDP.\n"); + return DDI_EDP; + break; + default: + printk(BIOS_WARNING, "Unexpected display connector type %x. Disabling DDI1.\n", + connector_type); + return DDI_UNUSED_TYPE; + } +} + void mainboard_get_dxio_ddi_descriptors( const fsp_dxio_descriptor **dxio_descs, size_t *dxio_num, const fsp_ddi_descriptor **ddi_descs, size_t *ddi_num) { + chausie_ddi_descriptors[1].connector_type = get_ddi1_type(); + *dxio_descs = chausie_dxio_descriptors; *dxio_num = ARRAY_SIZE(chausie_dxio_descriptors); *ddi_descs = chausie_ddi_descriptors; |