From 5b21ec1b453f114e892ffa8f972f50339d6ee3fc Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Tue, 21 Jan 2020 23:21:40 -0800 Subject: pi3usb3x532: Pack i2c port in port_addr The PI3USB3X532 driver in the EC assumes that all superspeed muxes are on the same i2c bus, I2C_PORT_USB_MUX. However, that may not be true for some boards. This commit utilizes the MUX_PORT(...) macro to determine the i2c port to use from the usb_mux table. The boards that use this driver have been updated to pack the i2c port in the port_addr member. There should be no functional changes to those boards. BUG=b:147689445 BRANCH=None TEST=`make -j buildall` Change-Id: If6460b84a5e39610d658f06a42ca1db0bd4da048 Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013658 Tested-by: Aseda Aboagye Reviewed-by: Diana Z Commit-Queue: Aseda Aboagye Auto-Submit: Aseda Aboagye --- driver/usb_mux/pi3usb3x532.c | 6 ++---- driver/usb_mux/pi3usb3x532.h | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'driver/usb_mux') diff --git a/driver/usb_mux/pi3usb3x532.c b/driver/usb_mux/pi3usb3x532.c index c11cacf8d2..2d69f4c647 100644 --- a/driver/usb_mux/pi3usb3x532.c +++ b/driver/usb_mux/pi3usb3x532.c @@ -20,8 +20,7 @@ static int pi3usb3x532_read(int port, uint8_t reg, uint8_t *val) * Second byte read will be vendor ID. * Third byte read will be selection control. */ - res = i2c_read16(I2C_PORT_USB_MUX, MUX_ADDR(port), - 0, &read); + res = i2c_read16(MUX_PORT(port), MUX_ADDR(port), 0, &read); if (res) return res; @@ -38,8 +37,7 @@ static int pi3usb3x532_write(int port, uint8_t reg, uint8_t val) if (reg != PI3USB3X532_REG_CONTROL) return EC_ERROR_UNKNOWN; - return i2c_write8(I2C_PORT_USB_MUX, MUX_ADDR(port), - 0, val); + return i2c_write8(MUX_PORT(port), MUX_ADDR(port), 0, val); } static int pi3usb3x532_reset(int port) diff --git a/driver/usb_mux/pi3usb3x532.h b/driver/usb_mux/pi3usb3x532.h index acbc269673..b8a8fc1691 100644 --- a/driver/usb_mux/pi3usb3x532.h +++ b/driver/usb_mux/pi3usb3x532.h @@ -14,6 +14,12 @@ #include "usb_pd.h" +/* I2C Addresses */ +#define PI3USB3X532_I2C_ADDR0 0x54 +#define PI3USB3X532_I2C_ADDR1 0x55 +#define PI3USB3X532_I2C_ADDR2 0x56 +#define PI3USB3X532_I2C_ADDR3 0x57 + /* USB switch registers */ #define PI3USB3X532_REG_ADDR 0x00 #define PI3USB3X532_REG_VENDOR 0x01 -- cgit v1.2.1