From 1a91ab29a3b91e6a5e3829b6e6bcb2954bb283bd Mon Sep 17 00:00:00 2001 From: Lu Zhang Date: Wed, 3 Jun 2020 21:33:48 +0800 Subject: vilboz: Remove PCAL6408 entirely and enable HDMI BUG=b:157182792, b:158125500 BRANCH=none TEST=make BOARD=vilboz Signed-off-by: Edward Hill Change-Id: I71e38117309277c39ed245535643d601e8759d28 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2227782 Reviewed-by: Denis Brockus Reviewed-by: Lu Zhang Commit-Queue: Lu Zhang --- board/dalboz/board.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ board/dalboz/board.h | 12 +++++++++++ 2 files changed, 69 insertions(+) (limited to 'board/dalboz') diff --git a/board/dalboz/board.c b/board/dalboz/board.c index 3de145881c..37f1eba31e 100644 --- a/board/dalboz/board.c +++ b/board/dalboz/board.c @@ -9,6 +9,7 @@ #include "driver/accel_lis2dw12.h" #include "driver/accelgyro_lsm6dsm.h" #include "driver/ioexpander/pcal6408.h" +#include "driver/tcpm/nct38xx.h" #include "driver/usb_mux/ps8740.h" #include "driver/usb_mux/ps8743.h" #include "extpower.h" @@ -16,6 +17,7 @@ #include "fan_chip.h" #include "gpio.h" #include "hooks.h" +#include "ioexpander.h" #include "lid_switch.h" #include "power.h" #include "power_button.h" @@ -38,6 +40,23 @@ void c1_tcpc_interrupt(enum gpio_signal signal) c1_tcpc_config_interrupt(signal); } +static void hdmi_hpd_handler(void) +{ + int hpd = 0; + + /* Pass HPD through from DB OPT1 HDMI connector to AP's DP1. */ + ioex_get_level(IOEX_HDMI_CONN_HPD_3V3_DB, &hpd); + gpio_set_level(GPIO_DP1_HPD, hpd); + ccprints("HDMI HPD %d", hpd); +} +DECLARE_DEFERRED(hdmi_hpd_handler); + +void hdmi_hpd_interrupt(enum ioex_signal signal) +{ + /* Debounce for 2 msec. */ + hook_call_deferred(&hdmi_hpd_handler_data, (2 * MSEC)); +} + #include "gpio_list.h" #ifdef HAS_TASK_MOTIONSENSE @@ -241,6 +260,44 @@ const struct pwm_t pwm_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); +struct ioexpander_config_t ioex_config[] = { + [IOEX_C0_NCT3807] = { + .i2c_host_port = I2C_PORT_TCPC0, + .i2c_slave_addr = NCT38XX_I2C_ADDR1_1_FLAGS, + .drv = &nct38xx_ioexpander_drv, + }, + [IOEX_C1_NCT3807] = { + .i2c_host_port = I2C_PORT_TCPC1, + .i2c_slave_addr = NCT38XX_I2C_ADDR1_1_FLAGS, + .drv = &nct38xx_ioexpander_drv, + .flags = IOEX_FLAGS_DISABLED, + }, + [IOEX_HDMI_PCAL6408] = { + .i2c_host_port = I2C_PORT_TCPC1, + .i2c_slave_addr = PCAL6408_I2C_ADDR0, + .drv = &pcal6408_ioexpander_drv, + .flags = IOEX_FLAGS_DISABLED, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT); + +int usb_port_enable[USBA_PORT_COUNT] = { + IOEX_EN_USB_A0_5V, + IOEX_EN_USB_A1_5V_DB_OPT1, +}; + +static void usba_retimer_on(void) +{ + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, usba_retimer_on, HOOK_PRIO_DEFAULT); + +static void usba_retimer_off(void) +{ + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, usba_retimer_off, HOOK_PRIO_DEFAULT); + /* * If the battery is found on the V0 I2C port then re-map the battery port. * Use HOOK_PRIO_INIT_I2C so we re-map before init_battery_type() and diff --git a/board/dalboz/board.h b/board/dalboz/board.h index 9b8b21d413..ce492613bf 100644 --- a/board/dalboz/board.h +++ b/board/dalboz/board.h @@ -20,6 +20,7 @@ #define CONFIG_SYSTEM_UNLOCKED #define CONFIG_I2C_DEBUG +#define CONFIG_IO_EXPANDER_PCAL6408 #define CONFIG_MKBP_USE_GPIO /* Power LEDs */ @@ -82,6 +83,17 @@ enum pwm_channel { PWM_CH_COUNT }; +enum ioex_port { + IOEX_C0_NCT3807 = 0, + IOEX_C1_NCT3807, + IOEX_HDMI_PCAL6408, + IOEX_PORT_COUNT +}; + +#define PORT_TO_HPD(port) ((port == 0) \ + ? GPIO_USB3_C0_DP2_HPD \ + : GPIO_DP1_HPD) + /***************************************************************************** * CBI EC FW Configuration -- cgit v1.2.1