summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorDeepti Deshatty <deepti.deshatty@intel.corp-partner.google.com>2021-10-05 23:26:29 +0530
committerCommit Bot <commit-bot@chromium.org>2021-10-21 05:43:39 +0000
commit37dae4e7457390e520147ae20563ba8502de0be5 (patch)
tree73e99b64d4b052c6ee74e6f8b7021b262feaca5a /driver
parent79314936518fdd93f874eb1e01c7a995186f2f29 (diff)
downloadchrome-ec-37dae4e7457390e520147ae20563ba8502de0be5.tar.gz
driver/tusb1064 : support for TUSB1044 type-c redriver
New config CONFIG_USB_MUX_TUSB1044 introduced to compile existing tusb1064 driver for tusb1044. New api tusb1044_hpd_update() is implemented to update the HPD bit in Gerenal_1 register based on the HPD information received. BRANCH=none TEST=Redriver is enabled on ADL-N and type-c display verified Signed-off-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Change-Id: Ia38aae2ff5c8a545272e5f99b3728e8bbbb4e716 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205431 Reviewed-by: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/build.mk3
-rw-r--r--driver/usb_mux/tusb1064.c37
-rw-r--r--driver/usb_mux/tusb1064.h13
3 files changed, 52 insertions, 1 deletions
diff --git a/driver/build.mk b/driver/build.mk
index eaf5772ae2..cb7262e778 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -190,8 +190,9 @@ driver-$(CONFIG_USB_MUX_PI3USB31532)+=usb_mux/pi3usb3x532.o
driver-$(CONFIG_USB_MUX_PS8740)+=usb_mux/ps8740.o
driver-$(CONFIG_USB_MUX_PS8742)+=usb_mux/ps8740.o
driver-$(CONFIG_USB_MUX_PS8743)+=usb_mux/ps8743.o
-driver-$(CONFIG_USB_MUX_TUSB1064)+=usb_mux/tusb1064.o
driver-$(CONFIG_USB_MUX_PS8822)+=usb_mux/ps8822.o
+driver-$(CONFIG_USB_MUX_TUSB1044)+=usb_mux/tusb1064.o
+driver-$(CONFIG_USB_MUX_TUSB1064)+=usb_mux/tusb1064.o
driver-$(CONFIG_USB_MUX_VIRTUAL)+=usb_mux/virtual.o
# USB Hub with I2C interface
diff --git a/driver/usb_mux/tusb1064.c b/driver/usb_mux/tusb1064.c
index 1c0f0e4701..c236e3d1ab 100644
--- a/driver/usb_mux/tusb1064.c
+++ b/driver/usb_mux/tusb1064.c
@@ -10,6 +10,10 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+#if defined(CONFIG_USB_MUX_TUSB1044) && defined(CONFIG_USB_MUX_TUSB1064)
+#error "Must choose CONFIG_USB_MUX_TUSB1044 or CONFIG_USB_MUX_TUSB1064"
+#endif
+
/*
* configuration bits which never change in the General Register
* e.g. REG_GENERAL_DP_EN_CTRL or REG_GENERAL_EQ_OVERRIDE
@@ -31,6 +35,31 @@ static int tusb1064_write(const struct usb_mux *me, uint8_t reg, uint8_t val)
(int)reg, (int)val);
}
+#if defined(CONFIG_USB_MUX_TUSB1044)
+void tusb1044_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
+{
+ int res;
+ uint8_t reg;
+
+ res = tusb1064_read(me, TUSB1064_REG_GENERAL, &reg);
+ if (res)
+ return;
+
+ /*
+ * Overrides HPDIN pin state.
+ Settings of this bit will enable the Display port lanes.
+ 0h = HPD_IN based on HPD_IN pin.
+ 1h = HPD_IN high.
+ */
+ if (mux_state & USB_PD_MUX_HPD_LVL)
+ reg |= REG_GENERAL_HPDIN_OVERRIDE;
+ else
+ reg &= ~REG_GENERAL_HPDIN_OVERRIDE;
+
+ tusb1064_write(me, TUSB1064_REG_GENERAL, reg);
+}
+#endif
+
/* Writes control register to set switch mode */
static int tusb1064_set_mux(const struct usb_mux *me, mux_state_t mux_state,
bool *ack_required)
@@ -46,6 +75,10 @@ static int tusb1064_set_mux(const struct usb_mux *me, mux_state_t mux_state,
reg |= REG_GENERAL_CTLSEL_ANYDP;
if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
reg |= REG_GENERAL_FLIPSEL;
+#if defined(CONFIG_USB_MUX_TUSB1044)
+ if (mux_state & USB_PD_MUX_HPD_LVL)
+ reg |= REG_GENERAL_HPDIN_OVERRIDE;
+#endif
return tusb1064_write(me, TUSB1064_REG_GENERAL, reg);
}
@@ -67,6 +100,10 @@ static int tusb1064_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
*mux_state |= USB_PD_MUX_DP_ENABLED;
if (reg & REG_GENERAL_FLIPSEL)
*mux_state |= USB_PD_MUX_POLARITY_INVERTED;
+#if defined(CONFIG_USB_MUX_TUSB1044)
+ if (reg & REG_GENERAL_HPDIN_OVERRIDE)
+ *mux_state |= USB_PD_MUX_HPD_LVL;
+#endif
return EC_SUCCESS;
}
diff --git a/driver/usb_mux/tusb1064.h b/driver/usb_mux/tusb1064.h
index e860cc539a..f6aa8e612e 100644
--- a/driver/usb_mux/tusb1064.h
+++ b/driver/usb_mux/tusb1064.h
@@ -39,7 +39,11 @@
#define REG_GENERAL_CTLSEL_USB3 BIT(0)
#define REG_GENERAL_CTLSEL_ANYDP BIT(1)
#define REG_GENERAL_FLIPSEL BIT(2)
+#if defined(CONFIG_USB_MUX_TUSB1044)
+#define REG_GENERAL_HPDIN_OVERRIDE BIT(3)
+#else
#define REG_GENERAL_DP_EN_CTRL BIT(3)
+#endif
#define REG_GENERAL_EQ_OVERRIDE BIT(4)
/* AUX and DP Lane Control Register */
@@ -127,4 +131,13 @@
#define TUSB1064_USB_EQ_UFP_10_7_DB 0xE
#define TUSB1064_USB_EQ_UFP_11_1_DB 0xF
+#if defined(CONFIG_USB_MUX_TUSB1044)
+/*
+ * This api is used to override the HPD infomartion received on HPD_IN pin
+ * or when no HPD physical pin is connected.
+ * Writes HPD infomration to the General_1 Registor.
+ */
+void tusb1044_hpd_update(const struct usb_mux *me, mux_state_t mux_state);
+#endif
+
#endif /* __CROS_EC_TUSB1064_H */