summaryrefslogtreecommitdiff
path: root/driver/usb_mux
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 /driver/usb_mux
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>
Diffstat (limited to 'driver/usb_mux')
-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
3 files changed, 100 insertions, 96 deletions
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 */