diff options
-rw-r--r-- | baseboard/hatch/baseboard.c | 15 | ||||
-rw-r--r-- | baseboard/hatch/baseboard.h | 7 | ||||
-rw-r--r-- | baseboard/hatch/usb_pd_policy.c | 12 | ||||
-rw-r--r-- | board/hatch/board.c | 5 | ||||
-rw-r--r-- | board/hatch/board.h | 8 | ||||
-rw-r--r-- | board/hatch/gpio.inc | 9 |
6 files changed, 56 insertions, 0 deletions
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c index 1347b066a7..326e1eb036 100644 --- a/baseboard/hatch/baseboard.c +++ b/baseboard/hatch/baseboard.c @@ -4,6 +4,7 @@ */ /* Hatch family-specific configuration */ +#include "atomic.h" #include "battery_fuel_gauge.h" #include "charge_manager.h" #include "charge_state_v2.h" @@ -204,6 +205,8 @@ void baseboard_tcpc_init(void) gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL); gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); + /* Enable HDMI HPD interrupt. */ + gpio_enable_interrupt(GPIO_HDMI_CONN_HPD); } DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 1); @@ -331,3 +334,15 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } + +void baseboard_mst_enable_control(enum mst_source src, int level) +{ + static uint32_t mst_input_levels; + + if (level) + atomic_or(&mst_input_levels, 1 << src); + else + atomic_clear(&mst_input_levels, 1 << src); + + gpio_set_level(GPIO_EN_MST, mst_input_levels ? 1 : 0); +} diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h index aa14d7796e..b3f14e1154 100644 --- a/baseboard/hatch/baseboard.h +++ b/baseboard/hatch/baseboard.h @@ -143,8 +143,15 @@ enum power_signal { POWER_SIGNAL_COUNT }; +enum mst_source { + MST_TYPE_C0, + MST_TYPE_C1, + MST_HDMI, +}; + /* Forward declare common (within Hatch) board-specific functions */ void board_reset_pd_mcu(void); +void baseboard_mst_enable_control(enum mst_source, int level); #endif /* !__ASSEMBLER__ */ diff --git a/baseboard/hatch/usb_pd_policy.c b/baseboard/hatch/usb_pd_policy.c index c1e1a12b68..2eb1cb6f4d 100644 --- a/baseboard/hatch/usb_pd_policy.c +++ b/baseboard/hatch/usb_pd_policy.c @@ -328,6 +328,10 @@ static void svdm_dp_post_config(int port) if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) return; mux->hpd_update(port, 1, 0); +#ifdef USB_PD_PORT_TCPC + if (port == USB_PD_PORT_TCPC) + baseboard_mst_enable_control(port, 1); +#endif } static int svdm_dp_attention(int port, uint32_t *payload) @@ -343,6 +347,10 @@ static int svdm_dp_attention(int port, uint32_t *payload) return 1; } mux->hpd_update(port, lvl, irq); +#ifdef USB_PD_PORT_TCPC + if (port == USB_PD_PORT_TCPC) + baseboard_mst_enable_control(port, lvl); +#endif /* ack */ return 1; @@ -354,6 +362,10 @@ static void svdm_exit_dp_mode(int port) svdm_safe_dp_mode(port); mux->hpd_update(port, 0, 0); +#ifdef USB_PD_PORT_TCPC + if (port == USB_PD_PORT_TCPC) + baseboard_mst_enable_control(port, 0); +#endif } static int svdm_enter_gfu_mode(int port, uint32_t mode_caps) diff --git a/board/hatch/board.c b/board/hatch/board.c index 44ffa432cb..e6cf4dfafa 100644 --- a/board/hatch/board.c +++ b/board/hatch/board.c @@ -69,6 +69,11 @@ static void tcpc_alert_event(enum gpio_signal signal) schedule_deferred_pd_interrupt(port); } +static void hdmi_hpd_interrupt(enum gpio_signal signal) +{ + baseboard_mst_enable_control(MST_HDMI, gpio_get_level(signal)); +} + #include "gpio_list.h" /* Must come after other header files. */ /******************************************************************************/ diff --git a/board/hatch/board.h b/board/hatch/board.h index 3cfc6aff0a..b246a51c9d 100644 --- a/board/hatch/board.h +++ b/board/hatch/board.h @@ -37,6 +37,14 @@ #define CONFIG_THROTTLE_AP #define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B +/* MST */ +/* + * TDOD (b/124068003): This inherently assumes the MST chip is connected to only + * one Type C port. This will need to be chagned to support 2 Type C ports + * connected to the same MST chip. + */ +#define USB_PD_PORT_TCPC 1 + /* * Macros for GPIO signals used in common code that don't match the * schematic names. Signal names in gpio.inc match the schematic and are diff --git a/board/hatch/gpio.inc b/board/hatch/gpio.inc index a2355b44b1..d6e77f795a 100644 --- a/board/hatch/gpio.inc +++ b/board/hatch/gpio.inc @@ -29,6 +29,14 @@ GPIO_INT(USB_C1_PPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, ppc_interrupt) GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, tcpc_alert_event) GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, tcpc_alert_event) +GPIO_INT(HDMI_CONN_HPD, PIN(7, 2), GPIO_INT_BOTH, hdmi_hpd_interrupt) +/* + * This signal is not used by the EC for MST control, but leaving it here as an + * input as it may be useful for debugging/hw validation purposes. This can + * removed when EVT units are available. + */ +GPIO(TCPC_USB_C1_HPD, PIN(9, 3), GPIO_INPUT) + GPIO(SYS_RESET_L, PIN(0, 2), GPIO_ODR_HIGH) /* SYS_RST_ODL */ GPIO(ENTERING_RW, PIN(E, 3), GPIO_OUT_LOW) /* EC_ENTERING_RW */ GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_ODR_HIGH) /* EC_PCH_WAKE_ODL */ @@ -58,6 +66,7 @@ GPIO(LED_3_L, PIN(C, 2), GPIO_OUT_HIGH) GPIO(LED_4_L, PIN(6, 0), GPIO_OUT_HIGH) GPIO(EC_KB_BL_EN, PIN(8, 6), GPIO_OUT_LOW) /* Keyboard backlight */ GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_LOW) +GPIO(EN_MST, PIN(9, 6), GPIO_OUT_LOW) /* I2C pins - Alternate function below configures I2C module on these pins */ |