summaryrefslogtreecommitdiff
path: root/driver/retimer/pi3dpx1207.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/retimer/pi3dpx1207.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/retimer/pi3dpx1207.c')
-rw-r--r--driver/retimer/pi3dpx1207.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/driver/retimer/pi3dpx1207.c b/driver/retimer/pi3dpx1207.c
index 74eb80aac1..9254c3d4bb 100644
--- a/driver/retimer/pi3dpx1207.c
+++ b/driver/retimer/pi3dpx1207.c
@@ -21,8 +21,7 @@ static uint8_t buf[PI3DPX1207_NUM_REGISTERS];
/**
* Local utility functions
*/
-static int pi3dpx1207_i2c_write(int i2c_port,
- uint16_t addr_flags,
+static int pi3dpx1207_i2c_write(const struct usb_mux *me,
uint8_t offset,
uint8_t val)
{
@@ -45,7 +44,7 @@ static int pi3dpx1207_i2c_write(int i2c_port,
attempt = 0;
do {
attempt++;
- rv = i2c_xfer(i2c_port, addr_flags,
+ rv = i2c_xfer(me->i2c_port, me->i2c_addr_flags,
NULL, 0, buf, offset);
} while ((rv != EC_SUCCESS) && (attempt < I2C_MAX_RETRIES));
}
@@ -56,15 +55,16 @@ static int pi3dpx1207_i2c_write(int i2c_port,
attempt = 0;
do {
attempt++;
- rv = i2c_xfer(i2c_port, addr_flags,
+ rv = i2c_xfer(me->i2c_port, me->i2c_addr_flags,
buf, offset + 1, NULL, 0);
} while ((rv != EC_SUCCESS) && (attempt < I2C_MAX_RETRIES));
}
return rv;
}
-static void pi3dpx1207_shutoff_power(int port)
+static void pi3dpx1207_shutoff_power(const struct usb_mux *me)
{
+ const int port = me->usb_port;
const int gpio_enable = pi3dpx1207_controls[port].enable_gpio;
const int gpio_dp_enable = pi3dpx1207_controls[port].dp_enable_gpio;
@@ -75,27 +75,26 @@ static void pi3dpx1207_shutoff_power(int port)
/**
* Driver interface code
*/
-static int pi3dpx1207_init(int port)
+static int pi3dpx1207_init(const struct usb_mux *me)
{
+ const int port = me->usb_port;
const int gpio_enable = pi3dpx1207_controls[port].enable_gpio;
gpio_or_ioex_set_level(gpio_enable, 1);
return EC_SUCCESS;
}
-static int pi3dpx1207_enter_low_power_mode(int port)
+static int pi3dpx1207_enter_low_power_mode(const struct usb_mux *me)
{
- pi3dpx1207_shutoff_power(port);
+ pi3dpx1207_shutoff_power(me);
return EC_SUCCESS;
}
-static int pi3dpx1207_set_mux(int port, mux_state_t mux_state)
+static int pi3dpx1207_set_mux(const struct usb_mux *me, mux_state_t mux_state)
{
int rv = EC_SUCCESS;
uint8_t mode_val = PI3DPX1207_MODE_WATCHDOG_EN;
-
- const int i2c_port = usb_retimers[port].i2c_port;
- const uint16_t i2c_addr_flags = usb_retimers[port].i2c_addr_flags;
+ const int port = me->usb_port;
const int gpio_enable = pi3dpx1207_controls[port].enable_gpio;
const int gpio_dp_enable = pi3dpx1207_controls[port].dp_enable_gpio;
@@ -127,18 +126,16 @@ static int pi3dpx1207_set_mux(int port, mux_state_t mux_state)
}
/* Nothing enabled, power down the retimer */
else {
- pi3dpx1207_shutoff_power(port);
+ pi3dpx1207_shutoff_power(me);
return EC_SUCCESS;
}
/* Write the retimer config byte */
- rv = pi3dpx1207_i2c_write(i2c_port, i2c_addr_flags,
- PI3DPX1207_MODE_OFFSET,
- mode_val);
+ rv = pi3dpx1207_i2c_write(me, PI3DPX1207_MODE_OFFSET, mode_val);
return rv;
}
-const struct usb_retimer_driver pi3dpx1207_usb_retimer = {
+const struct usb_mux_driver pi3dpx1207_usb_retimer = {
.init = pi3dpx1207_init,
.set = pi3dpx1207_set_mux,
.enter_low_power_mode = pi3dpx1207_enter_low_power_mode,