diff --git a/board/coral/board.c b/board/coral/board.c index f32b81dc73..4bb5144465 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -252,7 +252,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { [USB_PD_PORT_PS8751] = { .i2c_host_port = NPCX_I2C_PORT0_1, .i2c_slave_addr = 0x16, - .drv = &tcpci_tcpm_drv, + .drv = &ps8xxx_tcpm_drv, .pol = TCPC_ALERT_ACTIVE_LOW, }, }; diff --git a/board/fizz/board.c b/board/fizz/board.c index d72b9c8415..842a75d1b0 100644 --- a/board/fizz/board.c +++ b/board/fizz/board.c @@ -114,7 +114,7 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { - {NPCX_I2C_PORT0_0, I2C_ADDR_TCPC0, &tcpci_tcpm_drv, + {NPCX_I2C_PORT0_0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv, TCPC_ALERT_ACTIVE_LOW}, }; diff --git a/board/kahlee/board.c b/board/kahlee/board.c index f95808c4ef..b825d9b124 100644 --- a/board/kahlee/board.c +++ b/board/kahlee/board.c @@ -183,13 +183,13 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { [0] = { .i2c_host_port = NPCX_I2C_PORT0_0, .i2c_slave_addr = 0x16, - .drv = &tcpci_tcpm_drv, + .drv = &ps8xxx_tcpm_drv, .pol = TCPC_ALERT_ACTIVE_LOW, }, [1] = { .i2c_host_port = NPCX_I2C_PORT0_1, .i2c_slave_addr = 0x16, - .drv = &tcpci_tcpm_drv, + .drv = &ps8xxx_tcpm_drv, .pol = TCPC_ALERT_ACTIVE_LOW, }, }; diff --git a/board/poppy/board.c b/board/poppy/board.c index 6aacaa08fe..5d1bb89a96 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -362,7 +362,7 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { {NPCX_I2C_PORT0_0, 0x50, &anx74xx_tcpm_drv, TCPC_ALERT_ACTIVE_LOW}, - {NPCX_I2C_PORT0_0, 0x16, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW}, + {NPCX_I2C_PORT0_0, 0x16, &ps8xxx_tcpm_drv, TCPC_ALERT_ACTIVE_LOW}, }; struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { diff --git a/board/reef/board.c b/board/reef/board.c index 786a8e56b3..0e6b01fca2 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -250,7 +250,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { [USB_PD_PORT_PS8751] = { .i2c_host_port = NPCX_I2C_PORT0_1, .i2c_slave_addr = 0x16, - .drv = &tcpci_tcpm_drv, + .drv = &ps8xxx_tcpm_drv, .pol = TCPC_ALERT_ACTIVE_LOW, }, }; diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index e2a3d8b5df..bbabb854ab 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -13,6 +13,7 @@ #include "common.h" #include "ps8xxx.h" +#include "tcpci.h" #include "tcpm.h" #include "timer.h" #include "usb_pd.h" @@ -91,6 +92,45 @@ int ps8xxx_tcpc_get_fw_version(int port, int *version) return tcpc_read(port, FW_VER_REG, version); } +static int ps8xxx_tcpm_release(int port) +{ + int version; + int status; + + status = tcpc_read(port, FW_VER_REG, &version); + if (status != 0) { + /* wait for chip to wake up */ + msleep(10); + } + + return tcpci_tcpm_release(port); +} + +const struct tcpm_drv ps8xxx_tcpm_drv = { + .init = &tcpci_tcpm_init, + .release = &ps8xxx_tcpm_release, + .get_cc = &tcpci_tcpm_get_cc, +#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC + .get_vbus_level = &tcpci_tcpm_get_vbus_level, +#endif + .select_rp_value = &tcpci_tcpm_select_rp_value, + .set_cc = &tcpci_tcpm_set_cc, + .set_polarity = &tcpci_tcpm_set_polarity, + .set_vconn = &tcpci_tcpm_set_vconn, + .set_msg_header = &tcpci_tcpm_set_msg_header, + .set_rx_enable = &tcpci_tcpm_set_rx_enable, + .get_message = &tcpci_tcpm_get_message, + .transmit = &tcpci_tcpm_transmit, + .tcpc_alert = &tcpci_tcpc_alert, +#ifdef CONFIG_USB_PD_DISCHARGE_TCPC + .tcpc_discharge_vbus = &tcpci_tcpc_discharge_vbus, +#endif +#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE + .drp_toggle = &tcpci_tcpc_drp_toggle, +#endif + .get_chip_info = &tcpci_get_chip_info, +}; + #ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC struct i2c_stress_test_dev ps8xxx_i2c_stress_test_dev = { .reg_info = { diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h index f0ca91b4d3..1035af8077 100644 --- a/driver/tcpm/ps8xxx.h +++ b/driver/tcpm/ps8xxx.h @@ -35,9 +35,12 @@ #endif +extern const struct tcpm_drv ps8xxx_tcpm_drv; void ps8xxx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq); int ps8xxx_tcpc_get_fw_version(int port, int *version); + #ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC extern struct i2c_stress_test_dev ps8xxx_i2c_stress_test_dev; #endif /* defined(CONFIG_CMD_I2C_STRESS_TEST_TCPC) */ + #endif /* defined(__CROS_EC_USB_PD_TCPM_PS8XXX_H) */ diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index a8abfc5689..11c7283124 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -108,7 +108,7 @@ int tcpci_tcpm_select_rp_value(int port, int rp) } #ifdef CONFIG_USB_PD_DISCHARGE_TCPC -static void tcpci_tcpc_discharge_vbus(int port, int enable) +void tcpci_tcpc_discharge_vbus(int port, int enable) { int reg; @@ -137,7 +137,7 @@ int tcpci_tcpm_set_cc(int port, int pull) } #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE -static int tcpci_tcpc_drp_toggle(int port, int enable) +int tcpci_tcpc_drp_toggle(int port, int enable) { int rv; diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h index ce1b082fca..cc6fb3c4d1 100644 --- a/driver/tcpm/tcpci.h +++ b/driver/tcpm/tcpci.h @@ -122,6 +122,8 @@ extern const struct tcpm_drv tcpci_tcpm_drv; extern const struct usb_mux_driver tcpci_tcpm_usb_mux_driver; +void tcpci_tcpc_alert(int port); +int tcpci_tcpm_init(int port); int tcpci_tcpm_get_cc(int port, int *cc1, int *cc2); int tcpci_tcpm_get_vbus_level(int port); int tcpci_tcpm_select_rp_value(int port, int rp); @@ -133,6 +135,13 @@ int tcpci_tcpm_set_rx_enable(int port, int enable); int tcpci_tcpm_get_message(int port, uint32_t *payload, int *head); int tcpci_tcpm_transmit(int port, enum tcpm_transmit_type type, uint16_t header, const uint32_t *data); +int tcpci_tcpm_release(int port); +#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE +int tcpci_tcpc_drp_toggle(int port, int enable); +#endif +#ifdef CONFIG_USB_PD_DISCHARGE_TCPC +void tcpci_tcpc_discharge_vbus(int port, int enable); +#endif int tcpci_tcpm_mux_init(int i2c_addr); int tcpci_tcpm_mux_set(int i2c_addr, mux_state_t mux_state);