diff --git a/board/reef/board.c b/board/reef/board.c index 6c15020742..19abd156ef 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -238,6 +238,22 @@ void board_reset_pd_mcu(void) gpio_set_level(GPIO_USB_C0_PD_RST_L, 1); } +#ifdef CONFIG_USB_PD_TCPC_FW_VERSION +void board_print_tcpc_fw_version(int port) +{ + int rv; + int version; + + if (port) + rv = ps8751_tcpc_get_fw_version(port, &version); + else + rv = anx74xx_tcpc_get_fw_version(port, &version); + + if (!rv) + CPRINTS("TCPC p%d FW VER: 0x%x", port, version); +} +#endif + void board_tcpc_init(void) { /* Only reset TCPC if not sysjump */ diff --git a/board/reef/board.h b/board/reef/board.h index f3bf64e101..9420e1caf1 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -80,6 +80,7 @@ #define CONFIG_USB_PD_PORT_COUNT 2 #define CONFIG_USB_PD_QUIRK_SLOW_CC_STATUS #define CONFIG_USB_PD_VBUS_DETECT_CHARGER +#define CONFIG_USB_PD_TCPC_FW_VERSION #define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */ #define CONFIG_USB_PD_TCPM_ANX74XX #define CONFIG_USB_PD_TCPM_PS8751 @@ -280,6 +281,7 @@ void board_reset_pd_mcu(void); int board_get_version(void); void board_set_tcpc_power_mode(int port, int mode); +void board_print_tcpc_fw_version(int port); /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK \ diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index 3da89c108c..65d826cb88 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -545,6 +545,13 @@ static int anx74xx_tcpm_set_polarity(int port, int polarity) return rv; } +#ifdef CONFIG_USB_PD_TCPC_FW_VERSION +int anx74xx_tcpc_get_fw_version(int port, int *version) +{ + return tcpc_read(port, ANX74XX_REG_FW_VERSION, version); +} +#endif + static int anx74xx_tcpm_set_vconn(int port, int enable) { int reg, rv = EC_SUCCESS; @@ -852,6 +859,10 @@ int anx74xx_tcpm_init(int port) if (rv) return EC_ERROR_UNKNOWN; +#ifdef CONFIG_USB_PD_TCPC_FW_VERSION + board_print_tcpc_fw_version(port); +#endif + return EC_SUCCESS; } diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h index 7d9d026fe2..de8d2b7fab 100644 --- a/driver/tcpm/anx74xx.h +++ b/driver/tcpm/anx74xx.h @@ -160,5 +160,6 @@ extern const struct usb_mux_driver anx74xx_tcpm_usb_mux_driver; void anx74xx_tcpc_set_vbus(int port, int enable); void anx74xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq); void anx74xx_tcpc_clear_hpd_status(int port); +int anx74xx_tcpc_get_fw_version(int port, int *version); #endif /* __CROS_EC_USB_PD_TCPM_ANX74XX_H */ diff --git a/driver/tcpm/ps8751.c b/driver/tcpm/ps8751.c index fdcb6416cf..b9419a4696 100644 --- a/driver/tcpm/ps8751.c +++ b/driver/tcpm/ps8751.c @@ -60,3 +60,10 @@ void ps8751_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq) dp_set_irq(port, hpd_irq); } } + +#ifdef CONFIG_USB_PD_TCPC_FW_VERSION +int ps8751_tcpc_get_fw_version(int port, int *version) +{ + return tcpc_read(port, PS8751_REG_VERSION, version); +} +#endif diff --git a/driver/tcpm/ps8751.h b/driver/tcpm/ps8751.h index 859981cc27..e0abb491ba 100644 --- a/driver/tcpm/ps8751.h +++ b/driver/tcpm/ps8751.h @@ -12,10 +12,12 @@ #define PS8751_VENDOR_ID 0x1DA0 #define PS8751_PRODUCT_ID 0x8751 +#define PS8751_REG_VERSION 0x90 #define PS8751_REG_CTRL_1 0xD0 #define PS8751_REG_CTRL_1_HPD (1 << 0) #define PS8751_REG_CTRL_1_IRQ (1 << 1) void ps8751_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq); +int ps8751_tcpc_get_fw_version(int port, int *version); #endif /* __CROS_EC_USB_PD_TCPM_PS8751_H */ diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 2c38b3bbcd..f69e8a96d6 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -36,6 +36,10 @@ static int init_alert_mask(int port) /* Set the alert mask in TCPC */ rv = tcpc_write16(port, TCPC_REG_ALERT_MASK, mask); +#ifdef CONFIG_USB_PD_TCPC_FW_VERSION + board_print_tcpc_fw_version(port); +#endif + return rv; } diff --git a/include/config.h b/include/config.h index 0a9c96d6bc..391ad49bab 100644 --- a/include/config.h +++ b/include/config.h @@ -2038,6 +2038,9 @@ /* Use TCPC module (type-C port controller) */ #undef CONFIG_USB_PD_TCPC +/* Get TCPC firmware version */ +#undef CONFIG_USB_PD_TCPC_FW_VERSION + /* * Track VBUS level in TCPC module. This will only be needed if we're acting * as an external TCPC.