summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-01-07 18:00:34 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-08 06:52:47 +0000
commit494adea44a92c3c3737f98021a8959434efa7906 (patch)
tree5a05ea8c8db7f31284ef730ce4f031471d21a79e
parent52524e690df2538c30b64b40b41874701ea529ee (diff)
downloadchrome-ec-494adea44a92c3c3737f98021a8959434efa7906.tar.gz
driver/usb_mux: Make pi3usb30532 more generic
The Pericom PI3USB30532 usb mux driver will actually also work for the PI3USB31532. This commit renames the driver to reflect this while also adding the PI3USB31532 to the list of supported USB muxes. BUG=b:146654043 BRANCH=None TEST=`make -j buildall` Change-Id: Ic8e2852a3e038b05eb18d1d9db210b7fdce957d7 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1990362 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
-rw-r--r--board/glados/board.c2
-rw-r--r--board/mchpevb1/board.c2
-rw-r--r--board/oak/board.c4
-rw-r--r--board/reef_it8320/board.c2
-rw-r--r--board/strago/board.c2
-rw-r--r--driver/build.mk3
-rw-r--r--driver/usb_mux/pi3usb30532.h65
-rw-r--r--driver/usb_mux/pi3usb3x532.c (renamed from driver/usb_mux/pi3usb30532.c)62
-rw-r--r--driver/usb_mux/pi3usb3x532.h69
-rw-r--r--include/config.h3
-rw-r--r--include/usb_mux.h2
11 files changed, 112 insertions, 104 deletions
diff --git a/board/glados/board.c b/board/glados/board.c
index 8003e91906..55eb42a689 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -167,7 +167,7 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.port_addr = 0x54,
- .driver = &pi3usb30532_usb_mux_driver,
+ .driver = &pi3usb3x532_usb_mux_driver,
},
{
.port_addr = 0x10,
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index d6532bd59e..0e3306a066 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -390,7 +390,7 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.port_addr = 0x54,
- .driver = &pi3usb30532_usb_mux_driver,
+ .driver = &pi3usb3x532_usb_mux_driver,
},
{
.port_addr = 0x10,
diff --git a/board/oak/board.c b/board/oak/board.c
index e7b0653907..59c900422d 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -177,12 +177,12 @@ BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.port_addr = 0x54,
- .driver = &pi3usb30532_usb_mux_driver,
+ .driver = &pi3usb3x532_usb_mux_driver,
},
#if (BOARD_REV <= OAK_REV4)
{
.port_addr = 0x55,
- .driver = &pi3usb30532_usb_mux_driver,
+ .driver = &pi3usb3x532_usb_mux_driver,
},
#else
{
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index e268de83ed..a1cc1a69d9 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -163,7 +163,7 @@ 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,
- .driver = &pi3usb30532_usb_mux_driver,
+ .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 d96f09834f..0af3f03b37 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -142,7 +142,7 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.port_addr = 0x55,
- .driver = &pi3usb30532_usb_mux_driver,
+ .driver = &pi3usb3x532_usb_mux_driver,
},
};
diff --git a/driver/build.mk b/driver/build.mk
index 9e048f7c42..0f530dce78 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -152,7 +152,8 @@ driver-$(CONFIG_USBC_SS_MUX)+=usb_mux/usb_mux.o
driver-$(CONFIG_USB_MUX_AMD_FP5)+=usb_mux/amd_fp5.o
driver-$(CONFIG_USB_MUX_ANX7440)+=usb_mux/anx7440.o
driver-$(CONFIG_USB_MUX_IT5205)+=usb_mux/it5205.o
-driver-$(CONFIG_USB_MUX_PI3USB30532)+=usb_mux/pi3usb30532.o
+driver-$(CONFIG_USB_MUX_PI3USB30532)+=usb_mux/pi3usb3x532.o
+driver-$(CONFIG_USB_MUX_PI3USB31532)+=usb_mux/pi3usb3x532.o
driver-$(CONFIG_USB_MUX_PS8740)+=usb_mux/ps874x.o
driver-$(CONFIG_USB_MUX_PS8743)+=usb_mux/ps874x.o
driver-$(CONFIG_USB_MUX_VIRTUAL)+=usb_mux/virtual.o
diff --git a/driver/usb_mux/pi3usb30532.h b/driver/usb_mux/pi3usb30532.h
deleted file mode 100644
index 7f120a9f85..0000000000
--- a/driver/usb_mux/pi3usb30532.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Pericom PI3USB30532 USB port switch driver.
- */
-
-#ifndef __CROS_EC_PI3USB30532_H
-#define __CROS_EC_PI3USB30532_H
-
-#include "usb_pd.h"
-
-/* USB switch registers */
-#define PI3USB30532_REG_ADDR 0x00
-#define PI3USB30532_REG_VENDOR 0x01
-#define PI3USB30532_REG_CONTROL 0x02
-/* Control register field */
-#define PI3USB30532_CTRL_MASK 0x7
-#define PI3USB30532_CTRL_RSVD 0
-/* Switch vendor ID */
-#define PI3USB30532_VENDOR_ID 0
-
-/* PI3USB30532 control flags */
-#define PI3USB30532_BIT_SWAP BIT(0)
-#define PI3USB30532_BIT_DP BIT(1)
-#define PI3USB30532_BIT_USB BIT(2)
-
-/* PI3USB30532 modes */
-/* Power down, switch open */
-#define PI3USB30532_MODE_POWERDOWN 0
-/* Keep power on, switch open */
-#define PI3USB30532_MODE_POWERON 1
-/* 4-lane DP 1.2
- * dp0~3 : rx2, tx2, tx1, rx1
- * hpd+/-: rfu1, rfu2
- */
-#define PI3USB30532_MODE_DP PI3USB30532_BIT_DP
-/* 4-lane DP 1.2 swap
- * dp0~3 : rx1, tx1, tx2, rx2
- * hpd+/-: rfu2, rfu1
- */
-#define PI3USB30532_MODE_DP_SWAP (PI3USB30532_MODE_DP | PI3USB30532_BIT_SWAP)
-/* USB3
- * tx/rx : tx1, rx1
- */
-#define PI3USB30532_MODE_USB PI3USB30532_BIT_USB
-/* USB3 swap
- * tx/rx : tx2, rx2
- */
-#define PI3USB30532_MODE_USB_SWAP (PI3USB30532_MODE_USB | PI3USB30532_BIT_SWAP)
-/* 2-lane DP 1.2 + USB3
- * tx/rx : tx1, rx1
- * dp0~1 : rx2, tx2
- * hpd+/-: rfu1, rfu2
- */
-#define PI3USB30532_MODE_DP_USB (PI3USB30532_BIT_DP | PI3USB30532_BIT_USB)
-/* 2-lane DP 1.2 + USB3, swap
- * tx/rx : tx2, rx2
- * dp0-1 : rx1, tx1
- * hpd+/-: rfu2, rfu1
- */
-#define PI3USB30532_MODE_DP_USB_SWAP (PI3USB30532_MODE_DP_USB | \
- PI3USB30532_BIT_SWAP)
-
-#endif /* __CROS_EC_PI3USB30532_H */
diff --git a/driver/usb_mux/pi3usb30532.c b/driver/usb_mux/pi3usb3x532.c
index e5af1b90a6..c11cacf8d2 100644
--- a/driver/usb_mux/pi3usb30532.c
+++ b/driver/usb_mux/pi3usb3x532.c
@@ -2,16 +2,16 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
- * Pericom PI3USB30532 USB port switch driver.
+ * Pericom PI3USB3X532 USB port switch driver.
*/
#include "common.h"
#include "i2c.h"
-#include "pi3usb30532.h"
+#include "pi3usb3x532.h"
#include "usb_mux.h"
#include "util.h"
-static int pi3usb30532_read(int port, uint8_t reg, uint8_t *val)
+static int pi3usb3x532_read(int port, uint8_t reg, uint8_t *val)
{
int read, res;
@@ -25,88 +25,88 @@ static int pi3usb30532_read(int port, uint8_t reg, uint8_t *val)
if (res)
return res;
- if (reg == PI3USB30532_REG_VENDOR)
+ if (reg == PI3USB3X532_REG_VENDOR)
*val = read & 0xff;
- else /* reg == PI3USB30532_REG_CONTROL */
+ else /* reg == PI3USB3X532_REG_CONTROL */
*val = (read >> 8) & 0xff;
return EC_SUCCESS;
}
-static int pi3usb30532_write(int port, uint8_t reg, uint8_t val)
+static int pi3usb3x532_write(int port, uint8_t reg, uint8_t val)
{
- if (reg != PI3USB30532_REG_CONTROL)
+ if (reg != PI3USB3X532_REG_CONTROL)
return EC_ERROR_UNKNOWN;
return i2c_write8(I2C_PORT_USB_MUX, MUX_ADDR(port),
0, val);
}
-static int pi3usb30532_reset(int port)
+static int pi3usb3x532_reset(int port)
{
- return pi3usb30532_write(
+ return pi3usb3x532_write(
port,
- PI3USB30532_REG_CONTROL,
- (PI3USB30532_MODE_POWERDOWN & PI3USB30532_CTRL_MASK) |
- PI3USB30532_CTRL_RSVD);
+ PI3USB3X532_REG_CONTROL,
+ (PI3USB3X532_MODE_POWERDOWN & PI3USB3X532_CTRL_MASK) |
+ PI3USB3X532_CTRL_RSVD);
}
-static int pi3usb30532_init(int port)
+static int pi3usb3x532_init(int port)
{
uint8_t val;
int res;
- res = pi3usb30532_reset(port);
+ res = pi3usb3x532_reset(port);
if (res)
return res;
- res = pi3usb30532_read(port, PI3USB30532_REG_VENDOR, &val);
+ res = pi3usb3x532_read(port, PI3USB3X532_REG_VENDOR, &val);
if (res)
return res;
- if (val != PI3USB30532_VENDOR_ID)
+ if (val != PI3USB3X532_VENDOR_ID)
return EC_ERROR_UNKNOWN;
return EC_SUCCESS;
}
/* Writes control register to set switch mode */
-static int pi3usb30532_set_mux(int port, mux_state_t mux_state)
+static int pi3usb3x532_set_mux(int port, mux_state_t mux_state)
{
uint8_t reg = 0;
if (mux_state & MUX_USB_ENABLED)
- reg |= PI3USB30532_MODE_USB;
+ reg |= PI3USB3X532_MODE_USB;
if (mux_state & MUX_DP_ENABLED)
- reg |= PI3USB30532_MODE_DP;
+ reg |= PI3USB3X532_MODE_DP;
if (mux_state & MUX_POLARITY_INVERTED)
- reg |= PI3USB30532_BIT_SWAP;
+ reg |= PI3USB3X532_BIT_SWAP;
- return pi3usb30532_write(port, PI3USB30532_REG_CONTROL,
- reg | PI3USB30532_CTRL_RSVD);
+ return pi3usb3x532_write(port, PI3USB3X532_REG_CONTROL,
+ reg | PI3USB3X532_CTRL_RSVD);
}
/* Reads control register and updates mux_state accordingly */
-static int pi3usb30532_get_mux(int port, mux_state_t *mux_state)
+static int pi3usb3x532_get_mux(int port, mux_state_t *mux_state)
{
uint8_t reg = 0;
uint8_t res;
*mux_state = 0;
- res = pi3usb30532_read(port, PI3USB30532_REG_CONTROL, &reg);
+ res = pi3usb3x532_read(port, PI3USB3X532_REG_CONTROL, &reg);
if (res)
return res;
- if (reg & PI3USB30532_MODE_USB)
+ if (reg & PI3USB3X532_MODE_USB)
*mux_state |= MUX_USB_ENABLED;
- if (reg & PI3USB30532_MODE_DP)
+ if (reg & PI3USB3X532_MODE_DP)
*mux_state |= MUX_DP_ENABLED;
- if (reg & PI3USB30532_BIT_SWAP)
+ if (reg & PI3USB3X532_BIT_SWAP)
*mux_state |= MUX_POLARITY_INVERTED;
return EC_SUCCESS;
}
-const struct usb_mux_driver pi3usb30532_usb_mux_driver = {
- .init = pi3usb30532_init,
- .set = pi3usb30532_set_mux,
- .get = pi3usb30532_get_mux,
+const struct usb_mux_driver pi3usb3x532_usb_mux_driver = {
+ .init = pi3usb3x532_init,
+ .set = pi3usb3x532_set_mux,
+ .get = pi3usb3x532_get_mux,
};
diff --git a/driver/usb_mux/pi3usb3x532.h b/driver/usb_mux/pi3usb3x532.h
new file mode 100644
index 0000000000..acbc269673
--- /dev/null
+++ b/driver/usb_mux/pi3usb3x532.h
@@ -0,0 +1,69 @@
+/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Pericom PI3USB3X532 USB port switch driver.
+ *
+ * Supported switches:
+ * - PI3USB30532
+ * - PI3USB31532
+ */
+
+#ifndef __CROS_EC_PI3USB3X532_H
+#define __CROS_EC_PI3USB3X532_H
+
+#include "usb_pd.h"
+
+/* USB switch registers */
+#define PI3USB3X532_REG_ADDR 0x00
+#define PI3USB3X532_REG_VENDOR 0x01
+#define PI3USB3X532_REG_CONTROL 0x02
+/* Control register field */
+#define PI3USB3X532_CTRL_MASK 0x7
+#define PI3USB3X532_CTRL_RSVD 0
+/* Switch vendor ID */
+#define PI3USB3X532_VENDOR_ID 0
+
+/* PI3USB3X532 control flags */
+#define PI3USB3X532_BIT_SWAP BIT(0)
+#define PI3USB3X532_BIT_DP BIT(1)
+#define PI3USB3X532_BIT_USB BIT(2)
+
+/* PI3USB3X532 modes */
+/* Power down, switch open */
+#define PI3USB3X532_MODE_POWERDOWN 0
+/* Keep power on, switch open */
+#define PI3USB3X532_MODE_POWERON 1
+/* 4-lane DP 1.2
+ * dp0~3 : rx2, tx2, tx1, rx1
+ * hpd+/-: rfu1, rfu2
+ */
+#define PI3USB3X532_MODE_DP PI3USB3X532_BIT_DP
+/* 4-lane DP 1.2 swap
+ * dp0~3 : rx1, tx1, tx2, rx2
+ * hpd+/-: rfu2, rfu1
+ */
+#define PI3USB3X532_MODE_DP_SWAP (PI3USB3X532_MODE_DP | PI3USB3X532_BIT_SWAP)
+/* USB3
+ * tx/rx : tx1, rx1
+ */
+#define PI3USB3X532_MODE_USB PI3USB3X532_BIT_USB
+/* USB3 swap
+ * tx/rx : tx2, rx2
+ */
+#define PI3USB3X532_MODE_USB_SWAP (PI3USB3X532_MODE_USB | PI3USB3X532_BIT_SWAP)
+/* 2-lane DP 1.2 + USB3
+ * tx/rx : tx1, rx1
+ * dp0~1 : rx2, tx2
+ * hpd+/-: rfu1, rfu2
+ */
+#define PI3USB3X532_MODE_DP_USB (PI3USB3X532_BIT_DP | PI3USB3X532_BIT_USB)
+/* 2-lane DP 1.2 + USB3, swap
+ * tx/rx : tx2, rx2
+ * dp0-1 : rx1, tx1
+ * hpd+/-: rfu2, rfu1
+ */
+#define PI3USB3X532_MODE_DP_USB_SWAP (PI3USB3X532_MODE_DP_USB | \
+ PI3USB3X532_BIT_SWAP)
+
+#endif /* __CROS_EC_PI3USB3X532_H */
diff --git a/include/config.h b/include/config.h
index 59a221d62a..3ada3d5460 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4257,6 +4257,9 @@
/* Support the Pericom PI3USB30532 USB3.0/DP1.2 Matrix Switch */
#undef CONFIG_USB_MUX_PI3USB30532
+/* Support the Pericom PI3USB31532 USB3.1/DP1.4 Matrix Switch */
+#undef CONFIG_USB_MUX_PI3USB31532
+
/* Support the Parade PS8740 Type-C Redriving Switch */
#undef CONFIG_USB_MUX_PS8740
diff --git a/include/usb_mux.h b/include/usb_mux.h
index e2cc72a62b..0569beb44e 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -133,7 +133,7 @@ struct usb_mux {
extern const struct usb_mux_driver amd_fp5_usb_mux_driver;
extern const struct usb_mux_driver anx7440_usb_mux_driver;
extern const struct usb_mux_driver it5205_usb_mux_driver;
-extern const struct usb_mux_driver pi3usb30532_usb_mux_driver;
+extern const struct usb_mux_driver pi3usb3x532_usb_mux_driver;
extern const struct usb_mux_driver ps874x_usb_mux_driver;
extern const struct usb_mux_driver tcpm_usb_mux_driver;
extern const struct usb_mux_driver virtual_usb_mux_driver;