diff options
author | Diana Z <dzigterman@chromium.org> | 2020-03-05 13:10:55 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-16 19:11:45 +0000 |
commit | b9d829a21f2c4ea85d96ba7df8426720591cc75c (patch) | |
tree | 5ed66707d084332f084b2159a2cfc9096e61ee14 /driver | |
parent | bf3e265541b3596359ae3d579657e07598c02ae5 (diff) | |
download | chrome-ec-b9d829a21f2c4ea85d96ba7df8426720591cc75c.tar.gz |
TUSB544: Add driver structure declaration
This adds the extern declaration for the tusb544_drv structure for
boards to use, clarifies the name of the I2C address flag, and updates
to the new redriver driver type.
BUG=None
BRANCH=None
TEST=builds
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I045b76599f6cc5a4c64ae88bda7cd72c94a19e40
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2101218
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/retimer/tusb544.c | 38 | ||||
-rw-r--r-- | driver/retimer/tusb544.h | 4 |
2 files changed, 22 insertions, 20 deletions
diff --git a/driver/retimer/tusb544.c b/driver/retimer/tusb544.c index 3d8cb9119e..3c9549c15b 100644 --- a/driver/retimer/tusb544.c +++ b/driver/retimer/tusb544.c @@ -8,49 +8,49 @@ #include "tusb544.h" #include "usb_mux.h" -static int tusb544_write(int port, int offset, int data) +static int tusb544_write(const struct usb_mux *me, int offset, int data) { - return i2c_write8(usb_retimers[port].i2c_port, - usb_retimers[port].i2c_addr_flags, + return i2c_write8(me->i2c_port, + me->i2c_addr_flags, offset, data); } -static int tusb544_read(int port, int offset, int *data) +static int tusb544_read(const struct usb_mux *me, int offset, int *data) { - return i2c_read8(usb_retimers[port].i2c_port, - usb_retimers[port].i2c_addr_flags, - offset, data); + return i2c_read8(me->i2c_port, + me->i2c_addr_flags, + offset, data); } -static int tusb544_enter_low_power_mode(int port) +static int tusb544_enter_low_power_mode(const struct usb_mux *me) { int reg; int rv; - rv = tusb544_read(port, TUSB544_REG_GENERAL4, ®); + rv = tusb544_read(me, TUSB544_REG_GENERAL4, ®); if (rv) return rv; /* Setting CTL_SEL[0,1] to 0 powers down, per Table 5 */ reg &= ~TUSB544_GEN4_CTL_SEL; - return tusb544_write(port, TUSB544_REG_GENERAL4, reg); + return tusb544_write(me, TUSB544_REG_GENERAL4, reg); } -static int tusb544_init(int port) +static int tusb544_init(const struct usb_mux *me) { return EC_SUCCESS; } -static int tusb544_set_mux(int port, mux_state_t mux_state) +static int tusb544_set_mux(const struct usb_mux *me, mux_state_t mux_state) { int reg; int rv; if (mux_state == USB_PD_MUX_NONE) - return tusb544_enter_low_power_mode(port); + return tusb544_enter_low_power_mode(me); - rv = tusb544_read(port, TUSB544_REG_GENERAL4, ®); + rv = tusb544_read(me, TUSB544_REG_GENERAL4, ®); if (rv) return rv; @@ -69,24 +69,24 @@ static int tusb544_set_mux(int port, mux_state_t mux_state) else if (mux_state & USB_PD_MUX_USB_ENABLED) reg |= TUSB544_CTL_SEL_USB_ONLY; - rv = tusb544_write(port, TUSB544_REG_GENERAL4, reg); + rv = tusb544_write(me, TUSB544_REG_GENERAL4, reg); if (rv) return rv; - rv = tusb544_read(port, TUSB544_REG_GENERAL6, ®); + rv = tusb544_read(me, TUSB544_REG_GENERAL6, ®); if (rv) return rv; reg &= ~TUSB544_GEN6_DIR_SEL; - if (pd_get_power_role(port) == PD_ROLE_SOURCE) + if (pd_get_power_role(me->usb_port) == PD_ROLE_SOURCE) reg |= TUSB544_DIR_SEL_USB_DP_SRC; else reg |= TUSB544_DIR_SEL_USB_DP_SNK; - return tusb544_write(port, TUSB544_REG_GENERAL6, reg); + return tusb544_write(me, TUSB544_REG_GENERAL6, reg); } -const struct usb_retimer_driver tusb544_usb_redriver_drv = { +const struct usb_mux_driver tusb544_drv = { .enter_low_power_mode = &tusb544_enter_low_power_mode, .init = &tusb544_init, .set = &tusb544_set_mux, diff --git a/driver/retimer/tusb544.h b/driver/retimer/tusb544.h index 7a1b0a82cd..2c63a159ca 100644 --- a/driver/retimer/tusb544.h +++ b/driver/retimer/tusb544.h @@ -8,7 +8,7 @@ #ifndef __CROS_EC_USB_REDRIVER_TUSB544_H #define __CROS_EC_USB_REDRIVER_TUSB544_H -#define TUSB544_ADDR_FLAGS0 0x44 +#define TUSB544_I2C_ADDR_FLAGS0 0x44 #define TUSB544_REG_GENERAL4 0x0A #define TUSB544_GEN4_CTL_SEL GENMASK(1, 0) @@ -46,4 +46,6 @@ enum tusb544_dir_sel { #define TUSB544_DP4_AUX_SBU_OVR GENMASK(5, 4) #define TUSB544_DP4_AUX_SNOOP_DISABLE BIT(7) +extern const struct usb_mux_driver tusb544_drv; + #endif |