summaryrefslogtreecommitdiff
path: root/driver/usb_mux/anx7440.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2020-02-21 14:21:05 -0700
committerCommit Bot <commit-bot@chromium.org>2020-02-28 22:47:11 +0000
commit9c194fd057558a1dfadee419e92aca31953a86fc (patch)
tree001ae7c162a4152312a180574ae58e19a3763eb8 /driver/usb_mux/anx7440.c
parentab35b456ad8c52f336ea793b17155cfc796c4e44 (diff)
downloadchrome-ec-9c194fd057558a1dfadee419e92aca31953a86fc.tar.gz
usb_mux: retimer: mux as chained mux and retimer
This makes retimers appear as generic muxes. By allowing a chain of muxes they can be stacked up to the new configurations that zork requires and will continue to work as they did before on configurations that only have a single mux. The code used to have two different arrays, 1) muxes and 2) retimers. On one of the zork configurations the processor MUX stopped being the primary mux and the retimer took its place. In a different configuration of that same platform it left the primary and secondary alone but the mux_set FLIP operation had to be ignored. Since the same interfaces needed to be available for both it stopped making sense to have two different structures and two different methods of handling them. This consolodates the two into one. The platforms that do not have retimers, this change will not make any difference. For platforms like zork, it will remove the retimers and make them chained muxes. So testing on trembyle makes sense to verify, BUG=b:147593660 BRANCH=none TEST=verify USB still works on trembyle Change-Id: I286cf1e302f9bd3dd7e81098ec08514a2a009fe3 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2066794 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/usb_mux/anx7440.c')
-rw-r--r--driver/usb_mux/anx7440.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/driver/usb_mux/anx7440.c b/driver/usb_mux/anx7440.c
index 1c9633c536..df3a9c2682 100644
--- a/driver/usb_mux/anx7440.c
+++ b/driver/usb_mux/anx7440.c
@@ -16,14 +16,16 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-static inline int anx7440_read(int port, uint8_t reg, int *val)
+static inline int anx7440_read(const struct usb_mux *me,
+ uint8_t reg, int *val)
{
- return i2c_read8(I2C_PORT_USB_MUX, MUX_ADDR(port), reg, val);
+ return i2c_read8(me->i2c_port, me->i2c_addr_flags, reg, val);
}
-static inline int anx7440_write(int port, uint8_t reg, uint8_t val)
+static inline int anx7440_write(const struct usb_mux *me,
+ uint8_t reg, uint8_t val)
{
- return i2c_write8(I2C_PORT_USB_MUX, MUX_ADDR(port), reg, val);
+ return i2c_write8(me->i2c_port, me->i2c_addr_flags, reg, val);
}
struct anx7440_id_t {
@@ -39,7 +41,7 @@ static const struct anx7440_id_t anx7440_device_ids[] = {
{ ANX7440_DEVICE_VERSION, ANX7440_REG_DEVICE_VERSION },
};
-static int anx7440_init(int port)
+static int anx7440_init(const struct usb_mux *me)
{
int i;
int val;
@@ -47,7 +49,7 @@ static int anx7440_init(int port)
/* Verify device id / version registers */
for (i = 0; i < ARRAY_SIZE(anx7440_device_ids); i++) {
- res = anx7440_read(port, anx7440_device_ids[i].reg, &val);
+ res = anx7440_read(me, anx7440_device_ids[i].reg, &val);
if (res)
return res;
@@ -59,11 +61,11 @@ static int anx7440_init(int port)
}
/* Writes control register to set switch mode */
-static int anx7440_set_mux(int port, mux_state_t mux_state)
+static int anx7440_set_mux(const struct usb_mux *me, mux_state_t mux_state)
{
int reg, res;
- res = anx7440_read(port, ANX7440_REG_CHIP_CTRL, &reg);
+ res = anx7440_read(me, ANX7440_REG_CHIP_CTRL, &reg);
if (res)
return res;
@@ -75,16 +77,16 @@ static int anx7440_set_mux(int port, mux_state_t mux_state)
if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
reg |= ANX7440_CHIP_CTRL_SW_FLIP;
- return anx7440_write(port, ANX7440_REG_CHIP_CTRL, reg);
+ return anx7440_write(me, ANX7440_REG_CHIP_CTRL, reg);
}
/* Reads control register and updates mux_state accordingly */
-static int anx7440_get_mux(int port, mux_state_t *mux_state)
+static int anx7440_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
{
int reg, res;
*mux_state = 0;
- res = anx7440_read(port, ANX7440_REG_CHIP_CTRL, &reg);
+ res = anx7440_read(me, ANX7440_REG_CHIP_CTRL, &reg);
if (res)
return res;