diff options
author | Ben Chen <ben.chen2@quanta.corp-partner.google.com> | 2021-04-20 16:51:15 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-26 08:28:24 +0000 |
commit | 2b3f0b837a06a1f77e4231299ddc7668dc4b9a24 (patch) | |
tree | 79dca3c27baac80ac9bf94631fb8cd1732b489ff /board/magolor | |
parent | a4a68a2a7fbc67fa9bf5b3d6add4c3c852d9b141 (diff) | |
download | chrome-ec-2b3f0b837a06a1f77e4231299ddc7668dc4b9a24.tar.gz |
magister: config C1 port HDMI/PD function by fw_config
switch GPIO F5/91/92 type by fw_config for 1A_HDMI/PD function
BUG=b:185872184
BRANCH=dedede
TEST=EE check with function workable for HDMI by fw_config
1A_HDMI bits map.
Change-Id: Id9405b2acf1a163c233239339886c984d00dc544
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2839967
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'board/magolor')
-rw-r--r-- | board/magolor/board.c | 107 | ||||
-rw-r--r-- | board/magolor/board.h | 11 | ||||
-rw-r--r-- | board/magolor/gpio.inc | 6 |
3 files changed, 103 insertions, 21 deletions
diff --git a/board/magolor/board.c b/board/magolor/board.c index a64b7781be..d8002c49ab 100644 --- a/board/magolor/board.c +++ b/board/magolor/board.c @@ -193,7 +193,7 @@ static void check_c1_line(void) * If line is still being held low, see if there's more to process from * one of the chips. */ - if (!gpio_get_level(GPIO_SUB_USB_C1_INT_ODL)) { + if (!gpio_get_level(GPIO_SUB_C1_INT_EN_RAILS_ODL)) { notify_c1_chips(); hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); } @@ -211,6 +211,13 @@ static void sub_usb_c1_interrupt(enum gpio_signal s) hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); } +static void sub_hdmi_hpd_interrupt(enum gpio_signal s) +{ + int hdmi_hpd_odl = gpio_get_level(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL); + + gpio_set_level(GPIO_EC_AP_USB_C1_HDMI_HPD, !hdmi_hpd_odl); +} + #include "gpio_list.h" /* ADC channels */ @@ -307,13 +314,29 @@ static void board_update_no_keypad_by_fwconfig(void) } #endif +/* Enable HDMI any time the SoC is on */ +static void hdmi_enable(void) +{ + if (get_cbi_fw_config_db() == DB_1A_HDMI) + gpio_set_level(GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, 0); +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, hdmi_enable, HOOK_PRIO_DEFAULT); + +static void hdmi_disable(void) +{ + if (get_cbi_fw_config_db() == DB_1A_HDMI) + gpio_set_level(GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, 1); +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, hdmi_disable, HOOK_PRIO_DEFAULT); + void board_hibernate(void) { /* * Both charger ICs need to be put into their "low power mode" before * entering the Z-state. */ - raa489000_hibernate(1, true); + if (board_get_charger_chip_count() > 1) + raa489000_hibernate(1, true); raa489000_hibernate(0, true); } @@ -383,16 +406,38 @@ __override void board_power_5v_enable(int enable) * polarity on the sub board charger IC. */ set_5v_gpio(!!enable); - if (isl923x_set_comparator_inversion(1, !!enable)) - CPRINTS("Failed to %sable sub rails!", enable ? "en" : "dis"); - if (!enable) - return; - /* - * Port C1 the PP3300_USB_C1 assert, delay 15ms - * colud be accessed PS8762 by I2C. - */ - hook_call_deferred(&ps8762_chaddr_deferred_data, 15 * MSEC); + if (get_cbi_fw_config_db() == DB_1A_HDMI) { + gpio_set_level(GPIO_SUB_C1_INT_EN_RAILS_ODL, !enable); + } else { + if (isl923x_set_comparator_inversion(1, !!enable)) + CPRINTS("Failed to %sable sub rails!", enable ? + "en" : "dis"); + + if (!enable) + return; + /* + * Port C1 the PP3300_USB_C1 assert, delay 15ms + * colud be accessed PS8762 by I2C. + */ + hook_call_deferred(&ps8762_chaddr_deferred_data, 15 * MSEC); + } +} + +__override uint8_t board_get_usb_pd_port_count(void) +{ + if (get_cbi_fw_config_db() == DB_1A_HDMI) + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; + else + return CONFIG_USB_PD_PORT_MAX_COUNT; +} + +__override uint8_t board_get_charger_chip_count(void) +{ + if (get_cbi_fw_config_db() == DB_1A_HDMI) + return CHARGER_NUM - 1; + else + return CHARGER_NUM; } int board_is_sourcing_vbus(int port) @@ -407,7 +452,7 @@ int board_is_sourcing_vbus(int port) int board_set_active_charge_port(int port) { int is_real_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_MAX_COUNT); + port < board_get_usb_pd_port_count()); int i; int old_port; @@ -420,7 +465,7 @@ int board_set_active_charge_port(int port) /* Disable all ports. */ if (port == CHARGE_PORT_NONE) { - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + for (i = 0; i < board_get_usb_pd_port_count(); i++) { tcpc_write(i, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); raa489000_enable_asgate(i, false); @@ -439,7 +484,7 @@ int board_set_active_charge_port(int port) * Turn off the other ports' sink path FETs, before enabling the * requested charge port. */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + for (i = 0; i < board_get_usb_pd_port_count(); i++) { if (i == port) continue; @@ -678,9 +723,36 @@ void board_init(void) int on; gpio_enable_interrupt(GPIO_USB_C0_INT_ODL); - gpio_enable_interrupt(GPIO_SUB_USB_C1_INT_ODL); check_c0_line(); - check_c1_line(); + + if (get_cbi_fw_config_db() == DB_1A_HDMI) { + /* Disable i2c on HDMI pins */ + gpio_config_pin(MODULE_I2C, + GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, 0); + gpio_config_pin(MODULE_I2C, + GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, 0); + + /* Set HDMI and sub-rail enables to output */ + gpio_set_flags(GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, + chipset_in_state(CHIPSET_STATE_ON) ? + GPIO_ODR_LOW : GPIO_ODR_HIGH); + gpio_set_flags(GPIO_SUB_C1_INT_EN_RAILS_ODL, GPIO_ODR_HIGH); + + /* Select HDMI option */ + gpio_set_level(GPIO_HDMI_SEL_L, 0); + + /* Enable interrupt for passing through HPD */ + gpio_enable_interrupt(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL); + + } else { + /* Set SDA as an input */ + gpio_set_flags(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, + GPIO_INPUT); + + /* Enable C1 interrupt and check if it needs processing */ + gpio_enable_interrupt(GPIO_SUB_C1_INT_EN_RAILS_ODL); + check_c1_line(); + } /* Enable gpio interrupt for base accelgyro sensor */ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); @@ -857,7 +929,8 @@ uint16_t tcpc_get_alert_status(void) } } - if (!gpio_get_level(GPIO_SUB_USB_C1_INT_ODL)) { + if (board_get_usb_pd_port_count() > 1 && + !gpio_get_level(GPIO_SUB_C1_INT_EN_RAILS_ODL)) { if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) diff --git a/board/magolor/board.h b/board/magolor/board.h index f2b9c476c9..6f7af1338e 100644 --- a/board/magolor/board.h +++ b/board/magolor/board.h @@ -44,7 +44,7 @@ #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) /* GPIO for C1 interrupts, for baseboard use */ -#define GPIO_USB_C1_INT_ODL GPIO_SUB_USB_C1_INT_ODL +#define GPIO_USB_C1_INT_ODL GPIO_SUB_C1_INT_EN_RAILS_ODL /* Keyboard */ #ifdef BOARD_MAGOLOR @@ -109,6 +109,15 @@ #define I2C_ADDR_EEPROM_FLAGS 0x50 /* 7b address */ +/* + * I2C pin names for baseboard + * + * Note: these lines will be set as i2c on start-up, but this should be + * okay since they're ODL. + */ +#define GPIO_EC_I2C_SUB_USB_C1_SCL GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL +#define GPIO_EC_I2C_SUB_USB_C1_SDA GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL + /* Sensors */ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO diff --git a/board/magolor/gpio.inc b/board/magolor/gpio.inc index 1fc059143e..4e47ae38b0 100644 --- a/board/magolor/gpio.inc +++ b/board/magolor/gpio.inc @@ -26,7 +26,8 @@ GPIO_INT(PG_PP1050_ST_OD, PIN(4, 2), GPIO_INT_BOTH, power_signal_interrupt) /* USB-C interrupts */ GPIO_INT(USB_C0_INT_ODL, PIN(6, 2), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c0_interrupt) -GPIO_INT(SUB_USB_C1_INT_ODL, PIN(F, 5), GPIO_INT_FALLING | GPIO_PULL_UP, sub_usb_c1_interrupt) +GPIO_INT(SUB_C1_INT_EN_RAILS_ODL, PIN(F, 5), GPIO_INT_FALLING | GPIO_PULL_UP, sub_usb_c1_interrupt) /* C1 interrupt OR 5V power en */ +GPIO_INT(EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, PIN(9, 1), GPIO_INT_BOTH, sub_hdmi_hpd_interrupt) /* C1 I2C SDA OR HDMI_HPD */ /* Button interrupts */ GPIO_INT(H1_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) @@ -46,8 +47,7 @@ GPIO(EC_I2C_SENSOR_SCL, PIN(B, 5), GPIO_INPUT) GPIO(EC_I2C_SENSOR_SDA, PIN(B, 4), GPIO_INPUT) GPIO(EC_I2C_USB_C0_SCL, PIN(9, 0), GPIO_INPUT) GPIO(EC_I2C_USB_C0_SDA, PIN(8, 7), GPIO_INPUT) -GPIO(EC_I2C_SUB_USB_C1_SCL, PIN(9, 2), GPIO_INPUT) -GPIO(EC_I2C_SUB_USB_C1_SDA, PIN(9, 1), GPIO_INPUT) +GPIO(EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, PIN(9, 2), GPIO_INPUT) /* C1 I2C SCL OR HDMI en */ /* Extra Sub-board I/O pins */ |