summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-05-24 14:15:17 -0600
committerCommit Bot <commit-bot@chromium.org>2021-05-25 19:43:02 +0000
commit4d34f8f2180b0dd671219154eab2e420dcf96734 (patch)
treeb8f9a78d14a4656b2bebbd646b425969c1fc2a4e
parent3bc00128c407e78b55adc0b6f2d1cf5dcb3050e4 (diff)
downloadchrome-ec-4d34f8f2180b0dd671219154eab2e420dcf96734.tar.gz
TDP142: Initial driver
Initial driver for the TDP142, a DisplayPort redriver chip. The initial implementation simply provides access to the chip's control selection since it must be explicitly enabled after the chip powers on. BRANCH=None BUG=b:187856682 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I4afe4b0453ef49154b766166f608bd3d0fb8848f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2915823 Reviewed-by: Rob Barnes <robbarnes@google.com>
-rw-r--r--driver/build.mk3
-rw-r--r--driver/retimer/tdp142.c42
-rw-r--r--driver/retimer/tdp142.h38
-rw-r--r--include/config.h5
-rw-r--r--zephyr/Kconfig7
-rw-r--r--zephyr/shim/include/config_chip.h5
6 files changed, 100 insertions, 0 deletions
diff --git a/driver/build.mk b/driver/build.mk
index 72bbd46a89..93536b76f7 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -75,6 +75,9 @@ driver-$(CONFIG_CHARGER_RT9467)+=charger/rt946x.o
driver-$(CONFIG_CHARGER_SY21612)+=charger/sy21612.o
driver-$(CONFIG_CHARGER_SM5803)+=charger/sm5803.o
+# DP Redrivers
+driver-$(CONFIG_DP_REDRIVER_TDP142)+=retimer/tdp142.o
+
# Fingerprint Sensors
include $(_driver_cur_dir)fingerprint/build.mk
diff --git a/driver/retimer/tdp142.c b/driver/retimer/tdp142.c
new file mode 100644
index 0000000000..e1632150d0
--- /dev/null
+++ b/driver/retimer/tdp142.c
@@ -0,0 +1,42 @@
+/* Copyright 2021 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.
+ *
+ * Texas Instruments TDP142 DisplayPort Linear Redriver
+ */
+
+#include "common.h"
+#include "ec_commands.h"
+#include "i2c.h"
+#include "tdp142.h"
+
+static enum ec_error_list tdp142_write(int offset, int data)
+{
+ return i2c_write8(TDP142_I2C_PORT,
+ TDP142_I2C_ADDR,
+ offset, data);
+
+}
+
+static enum ec_error_list tdp142_read(int offset, int *regval)
+{
+ return i2c_read8(TDP142_I2C_PORT,
+ TDP142_I2C_ADDR,
+ offset, regval);
+
+}
+
+enum ec_error_list tdp142_set_ctlsel(enum tdp142_ctlsel selection)
+{
+ int regval;
+ enum ec_error_list rv;
+
+ rv = tdp142_read(TDP142_REG_GENERAL, &regval);
+ if (rv)
+ return rv;
+
+ regval &= ~TDP142_GENERAL_CTLSEL;
+ regval |= selection;
+
+ return tdp142_write(TDP142_REG_GENERAL, regval);
+}
diff --git a/driver/retimer/tdp142.h b/driver/retimer/tdp142.h
new file mode 100644
index 0000000000..8346a233a5
--- /dev/null
+++ b/driver/retimer/tdp142.h
@@ -0,0 +1,38 @@
+/* Copyright 2021 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.
+ *
+ * Texas Instruments TDP142 DisplayPort Linear Redriver
+ */
+
+#ifndef __CROS_EC_REDRIVER_TDP142_H
+#define __CROS_EC_REDRIVER_TDP142_H
+
+#include "compile_time_macros.h"
+
+/*
+ * Note: Since DP redrivers do not have a standard EC structure, define a
+ * TDP142_I2C_PORT and TDP142_I2C_ADDR in board.h
+ */
+#define TDP142_I2C_ADDR0 0x44
+#define TDP142_I2C_ADDR1 0x47
+#define TDP142_I2C_ADDR2 0x0C
+#define TDP142_I2C_ADDR3 0x0F
+
+/* Registers */
+#define TDP142_REG_GENERAL 0x0A
+#define TDP142_GENERAL_CTLSEL GENMASK(1, 0)
+#define TDP142_GENERAL_HPDIN_OVRRIDE BIT(3)
+#define TDP142_GENERAL_EQ_OVERRIDE BIT(4)
+#define TDP142_GENERAL_SWAP_HPDIN BIT(5)
+
+enum tdp142_ctlsel {
+ TDP142_CTLSEL_SHUTDOWN,
+ TDP142_CTLSEL_DISABLED,
+ TDP142_CTLSEL_ENABLED,
+};
+
+/* Control redriver enable */
+enum ec_error_list tdp142_set_ctlsel(enum tdp142_ctlsel selection);
+
+#endif /* __CROS_EC_REDRIVER_TDP142_H */
diff --git a/include/config.h b/include/config.h
index 9a04773412..a7c063298b 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4505,6 +4505,11 @@
#undef CONFIG_USBC_RETIMER_TUSB544
/*
+ * DP redriver drivers to be used.
+ */
+#undef CONFIG_DP_REDRIVER_TDP142
+
+/*
* Define this to enable Type-C retimer firmware update. Each Type-C retimer
* indicates its capability of supporting firmware update in usb_mux_driver.
* This feature is available to TCPMv2 PD stack, also requires
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 356eaf262d..593966f7b8 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -266,6 +266,13 @@ config PLATFORM_EC_DEBUG_ASSERT
Note: There is also ASSERT() which is an alias of assert(), used in
host code where cstdlib is used.
+config PLATFORM_EC_DP_REDRIVER_TDP142
+ bool "Include TDP142 DisplayPort redriver driver"
+ default n
+ help
+ Include a driver for the Texas Instruments TDP142 DisplayPort linear
+ redriver chip.
+
menuconfig PLATFORM_EC_ESPI
bool "eSPI"
depends on ESPI && AP
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index ca93ba1b4a..063b7fbbe0 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -905,6 +905,11 @@
#define CONFIG_USB_PD_ALT_MODE_UFP
#endif
+#undef CONFIG_DP_REDRIVER_TDP142
+#ifdef CONFIG_PLATFORM_EC_DP_REDRIVER_TDP142
+#define CONFIG_DP_REDRIVER_TDP142
+#endif
+
#undef CONFIG_USBC_RETIMER_FW_UPDATE
#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE
#define CONFIG_USBC_RETIMER_FW_UPDATE