summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-01-21 23:21:40 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-24 12:42:53 +0000
commit5b21ec1b453f114e892ffa8f972f50339d6ee3fc (patch)
tree54f1b93ddcbadec16549bfca98f33bcdf0e765ea
parente5605acefadc9517b0475b91685e9c2a1ced7c48 (diff)
downloadchrome-ec-5b21ec1b453f114e892ffa8f972f50339d6ee3fc.tar.gz
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 <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013658 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/glados/board.c3
-rw-r--r--board/mchpevb1/board.c3
-rw-r--r--board/oak/board.c7
-rw-r--r--board/reef_it8320/board.c4
-rw-r--r--board/strago/board.c4
-rw-r--r--board/waddledoo/board.c6
-rw-r--r--driver/usb_mux/pi3usb3x532.c6
-rw-r--r--driver/usb_mux/pi3usb3x532.h6
8 files changed, 27 insertions, 12 deletions
diff --git a/board/glados/board.c b/board/glados/board.c
index 55eb42a689..2b70233631 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -166,7 +166,8 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x54,
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
+ PI3USB3X532_I2C_ADDR0),
.driver = &pi3usb3x532_usb_mux_driver,
},
{
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index 0e3306a066..e7daf0ef34 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -389,7 +389,8 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x54,
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
+ PI3USB3X532_I2C_ADDR0),
.driver = &pi3usb3x532_usb_mux_driver,
},
{
diff --git a/board/oak/board.c b/board/oak/board.c
index 59c900422d..4aa80304e4 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -22,6 +22,7 @@
#include "driver/als_opt3001.h"
#include "driver/tcpm/tcpci.h"
#include "driver/temp_sensor/tmp432.h"
+#include "driver/usb_mux/pi3usb3x532.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -176,12 +177,14 @@ BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x54,
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
+ PI3USB3X532_I2C_ADDR0),
.driver = &pi3usb3x532_usb_mux_driver,
},
#if (BOARD_REV <= OAK_REV4)
{
- .port_addr = 0x55,
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
+ PI3USB3X532_I2C_ADDR1),
.driver = &pi3usb3x532_usb_mux_driver,
},
#else
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index a1cc1a69d9..0a513c63a4 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -17,6 +17,7 @@
#include "driver/charger/bd9995x.h"
#include "driver/tcpm/it83xx_pd.h"
#include "driver/tcpm/tcpm.h"
+#include "driver/usb_mux/pi3usb3x532.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -162,7 +163,8 @@ static void it83xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x54,
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
+ PI3USB3X532_I2C_ADDR0),
.driver = &pi3usb3x532_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
diff --git a/board/strago/board.c b/board/strago/board.c
index 0af3f03b37..a45f0b4774 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -17,6 +17,7 @@
#include "driver/als_isl29035.h"
#include "driver/tcpm/tcpci.h"
#include "driver/temp_sensor/tmp432.h"
+#include "driver/usb_mux/pi3usb3x532.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -141,7 +142,8 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x55,
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
+ PI3USB3X532_I2C_ADDR1),
.driver = &pi3usb3x532_usb_mux_driver,
},
};
diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c
index 711b0dccf3..a4ba81d3ec 100644
--- a/board/waddledoo/board.c
+++ b/board/waddledoo/board.c
@@ -309,11 +309,13 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_C0, 0x54),
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_C0,
+ PI3USB3X532_I2C_ADDR0),
.driver = &pi3usb3x532_usb_mux_driver,
},
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_SUB_USB_C1, 0x54),
+ .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_SUB_USB_C1,
+ PI3USB3X532_I2C_ADDR0),
.driver = &pi3usb3x532_usb_mux_driver,
}
};
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