diff options
author | Edward Hill <ecgh@chromium.org> | 2019-12-19 23:06:34 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-20 17:54:17 +0000 |
commit | d9fa15722d45f4ff6aa1cc08059f1807a37768d7 (patch) | |
tree | 0d3e37e5227b483a5b05d6e403034d5c21767064 /driver/retimer/ps8818.c | |
parent | ad349a691d18eb433686c748e67ad76374dd7a6e (diff) | |
download | chrome-ec-d9fa15722d45f4ff6aa1cc08059f1807a37768d7.tar.gz |
retimer: Add PS8818 driver
BUG=b:139428235, b:145766506
BRANCH=none
TEST=USB3 device enumerates as 5G on Trembyle OPT1 USB-C1
Change-Id: I96ddd393626000630daf1ce517e003f6472c50cd
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1977983
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'driver/retimer/ps8818.c')
-rw-r--r-- | driver/retimer/ps8818.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/driver/retimer/ps8818.c b/driver/retimer/ps8818.c new file mode 100644 index 0000000000..d58d9966e2 --- /dev/null +++ b/driver/retimer/ps8818.c @@ -0,0 +1,46 @@ +/* Copyright 2019 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. + * + * PS8818 retimer. + */ + +#include "ps8818.h" +#include "common.h" +#include "console.h" +#include "gpio.h" +#include "i2c.h" +#include "ioexpander.h" +#include "usb_mux.h" + +static int ps8818_i2c_write(int port, int offset, int data) +{ + return i2c_write8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags, + offset, data); +} + +static int ps8818_set_mux(int port, mux_state_t mux_state) +{ + int val = 0; + int rv; + + if (mux_state & MUX_USB_ENABLED) + val |= PS8818_MODE_USB_ENABLE; + if (mux_state & MUX_DP_ENABLED) + val |= PS8818_MODE_DP_ENABLE; + + rv = ps8818_i2c_write(port, PS8818_REG_MODE, val); + if (rv) + return rv; + + val = 0; + if (mux_state & MUX_POLARITY_INVERTED) + val |= PS8818_FLIP_CONFIG; + + return ps8818_i2c_write(port, PS8818_REG_FLIP, val); +} + +const struct usb_retimer_driver ps8818_usb_retimer = { + .set = ps8818_set_mux, +}; |