From 3f2162b401bb8059709ae2caf0bf0eb2b353618f Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 6 Mar 2017 14:55:45 +0800 Subject: [PATCH] pyro: Name USB port numbers appropriately Some USB PD port numbers are not named. Some numbers are named using I2C port names. This patch fixes them Follow reef setting. BUG=none BRANCH=reef TEST=make buildall Change-Id: I4a9d3a765f6de84ac1a6f3e903171a505bc37d6c Signed-off-by: Bruce.Wan Reviewed-on: https://chromium-review.googlesource.com/449123 Commit-Ready: Keith Tzeng Tested-by: Keith Tzeng Reviewed-by: Aaron Durbin --- board/pyro/board.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/board/pyro/board.c b/board/pyro/board.c index a6250c25d1..ec7b9c7970 100644 --- a/board/pyro/board.c +++ b/board/pyro/board.c @@ -62,6 +62,9 @@ #define IN_PGOOD_PP3300 POWER_SIGNAL_MASK(X86_PGOOD_PP3300) #define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000) +#define USB_PD_PORT_ANX74XX 0 +#define USB_PD_PORT_PS8751 1 + static void tcpc_alert_event(enum gpio_signal signal) { if ((signal == GPIO_USB_C0_PD_INT_ODL) && @@ -88,7 +91,7 @@ static void anx74xx_cable_det_handler(void) * handle only the attach event. */ if (level) - anx74xx_handle_power_mode(NPCX_I2C_PORT0_0, + anx74xx_handle_power_mode(USB_PD_PORT_ANX74XX, ANX74XX_NORMAL_MODE); /* confirm if cable_det is asserted */ @@ -235,8 +238,18 @@ const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests); #endif /* CONFIG_CMD_I2C_STRESS_TEST */ 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_1, 0x16, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW}, + [USB_PD_PORT_ANX74XX] = { + .i2c_host_port = NPCX_I2C_PORT0_0, + .i2c_slave_addr = 0x50, + .drv = &anx74xx_tcpm_drv, + .pol = TCPC_ALERT_ACTIVE_LOW, + }, + [USB_PD_PORT_PS8751] = { + .i2c_host_port = NPCX_I2C_PORT0_1, + .i2c_slave_addr = 0x16, + .drv = &tcpci_tcpm_drv, + .pol = TCPC_ALERT_ACTIVE_LOW, + }, }; uint16_t tcpc_get_alert_status(void) @@ -266,12 +279,12 @@ const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { { - .port_addr = 0, /* don't care / unused */ + .port_addr = USB_PD_PORT_ANX74XX, /* don't care / unused */ .driver = &anx74xx_tcpm_usb_mux_driver, .hpd_update = &anx74xx_tcpc_update_hpd_status, }, { - .port_addr = 1, + .port_addr = USB_PD_PORT_PS8751, .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8751_tcpc_update_hpd_status, } @@ -512,8 +525,8 @@ int pd_snk_is_vbus_provided(int port) enum bd9995x_charge_port bd9995x_port; switch (port) { - case 0: - case 1: + case USB_PD_PORT_ANX74XX: + case USB_PD_PORT_PS8751: bd9995x_port = bd9995x_pd_port_to_chg_port(port); break; default: @@ -549,8 +562,8 @@ int board_set_active_charge_port(int charge_port) return -1; switch (charge_port) { - case 0: - case 1: + case USB_PD_PORT_ANX74XX: + case USB_PD_PORT_PS8751: /* Don't charge from a source port */ if (board_vbus_source_enabled(charge_port)) return -1;