summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-03-09 15:02:47 -0700
committerCommit Bot <commit-bot@chromium.org>2022-03-15 16:55:10 +0000
commit219b8c53616c23797e6a4fde75d7ac028e2b151e (patch)
tree3aef6648a9429444b9b3bdf1f7a5c5892d40a1b6
parent8a9b0e111480131f9a6d495018494b6872e1f31f (diff)
downloadchrome-ec-219b8c53616c23797e6a4fde75d7ac028e2b151e.tar.gz
ANX7483: Add Driver
Add driver support for the ANX7483 linear redriver. More functions may be added later to access and modify the equalizer/flat gain/output swing. BRANCH=None BUG=b:208515128,b:219898719 TEST=zmake testall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iec2872bf2e35276f5161a6ef8750aad1c5c346ba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3514504 Tested-by: Jonathon Murphy <jpmurphy@google.com> Reviewed-by: Andrew McRae <amcrae@google.com> Commit-Queue: Andrew McRae <amcrae@google.com>
-rw-r--r--driver/build.mk1
-rw-r--r--driver/retimer/anx7483.c123
-rw-r--r--driver/retimer/anx7483.h18
-rw-r--r--include/config.h1
-rw-r--r--include/driver/retimer/anx7483_public.h22
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/Kconfig.retimer7
-rw-r--r--zephyr/shim/include/config_chip.h5
8 files changed, 179 insertions, 0 deletions
diff --git a/driver/build.mk b/driver/build.mk
index 5b9c256ae3..650c818e21 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -173,6 +173,7 @@ driver-$(CONFIG_USB_PD_TCPM_FUSB307)+=tcpm/fusb307.o
driver-$(CONFIG_USB_PD_TCPM_STM32GX)+=tcpm/stm32gx.o
# Type-C Retimer drivers
+driver-$(CONFIG_USBC_RETIMER_ANX7483)+=retimer/anx7483.o
driver-$(CONFIG_USBC_RETIMER_INTEL_BB)+=retimer/bb_retimer.o
driver-$(CONFIG_USBC_RETIMER_KB800X)+=retimer/kb800x.o
driver-$(CONFIG_USBC_RETIMER_NB7V904M)+=retimer/nb7v904m.o
diff --git a/driver/retimer/anx7483.c b/driver/retimer/anx7483.c
new file mode 100644
index 0000000000..b58b2baab1
--- /dev/null
+++ b/driver/retimer/anx7483.c
@@ -0,0 +1,123 @@
+/* Copyright 2022 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.
+ *
+ * ANX7483: Active redriver with linear equilzation
+ */
+
+#include "anx7483.h"
+#include "chipset.h"
+#include "common.h"
+#include "console.h"
+#include "i2c.h"
+#include "timer.h"
+#include "usb_mux.h"
+#include "util.h"
+
+/*
+ * Programming guide specifies it may be as much as 30ms after chip power on
+ * before it's ready for i2c
+ */
+#define ANX7483_I2C_WAKE_TIMEOUT_MS 30
+#define ANX7483_I2C_WAKE_RETRY_DELAY_US 5000
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+
+static inline int anx7483_read(const struct usb_mux *me,
+ uint8_t reg, int *val)
+{
+ return i2c_read8(me->i2c_port, me->i2c_addr_flags, reg, val);
+}
+
+static inline int anx7483_write(const struct usb_mux *me,
+ uint8_t reg, uint8_t val)
+{
+ return i2c_write8(me->i2c_port, me->i2c_addr_flags, reg, val);
+}
+
+static int anx7483_init(const struct usb_mux *me)
+{
+ timestamp_t start;
+ int rv;
+ int val;
+
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ /* Keep reading control register until mux wakes up or times out */
+ start = get_time();
+ do {
+ rv = anx7483_read(me, ANX7483_ANALOG_STATUS_CTRL, &val);
+ if (!rv)
+ break;
+ usleep(ANX7483_I2C_WAKE_RETRY_DELAY_US);
+ } while (time_since32(start) < ANX7483_I2C_WAKE_TIMEOUT_MS * MSEC);
+
+ if (rv) {
+ CPRINTS("ANX7483: Failed to wake mux rv:%d", rv);
+ return EC_ERROR_TIMEOUT;
+ }
+
+ /* Configure for i2c control */
+ val |= ANX7483_CTRL_REG_EN;
+ RETURN_ERROR(anx7483_write(me, ANX7483_ANALOG_STATUS_CTRL, val));
+
+ return EC_SUCCESS;
+}
+
+static int anx7483_set(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
+{
+ int reg;
+
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
+ /*
+ * Mux is not powered in Z1
+ */
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ /*
+ * Always ensure i2c control is set and state machine is enabled
+ * (setting ANX7483_CTRL_REG_BYPASS_EN disables state machine)
+ */
+ reg = ANX7483_CTRL_REG_EN;
+ if (mux_state & USB_PD_MUX_USB_ENABLED)
+ reg |= ANX7483_CTRL_USB_EN;
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ reg |= ANX7483_CTRL_DP_EN;
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ reg |= ANX7483_CTRL_FLIP_EN;
+
+ return anx7483_write(me, ANX7483_ANALOG_STATUS_CTRL, reg);
+}
+
+static int anx7483_get(const struct usb_mux *me, mux_state_t *mux_state)
+{
+ int reg;
+
+ /* Mux is not powered in Z1 */
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ return USB_PD_MUX_NONE;
+
+ *mux_state = 0;
+ RETURN_ERROR(anx7483_read(me, ANX7483_ANALOG_STATUS_CTRL, &reg));
+
+ if (reg & ANX7483_CTRL_USB_EN)
+ *mux_state |= USB_PD_MUX_USB_ENABLED;
+ if (reg & ANX7483_CTRL_DP_EN)
+ *mux_state |= USB_PD_MUX_DP_ENABLED;
+ if (reg & ANX7483_CTRL_FLIP_EN)
+ *mux_state |= USB_PD_MUX_POLARITY_INVERTED;
+
+ return EC_SUCCESS;
+}
+
+const struct usb_mux_driver anx7483_usb_retimer_driver = {
+ .init = anx7483_init,
+ .set = anx7483_set,
+ .get = anx7483_get,
+};
diff --git a/driver/retimer/anx7483.h b/driver/retimer/anx7483.h
new file mode 100644
index 0000000000..0a0e9812cb
--- /dev/null
+++ b/driver/retimer/anx7483.h
@@ -0,0 +1,18 @@
+/* Copyright 2022 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.
+ *
+ * ANX7483: Active redriver with linear equilzation
+ */
+
+#ifndef __CROS_EC_USB_RETIMER_ANX7483_H
+#define __CROS_EC_USB_RETIMER_ANX7483_H
+
+#define ANX7483_ANALOG_STATUS_CTRL 0x07
+#define ANX7483_CTRL_REG_BYPASS_EN BIT(5)
+#define ANX7483_CTRL_REG_EN BIT(4)
+#define ANX7483_CTRL_FLIP_EN BIT(2)
+#define ANX7483_CTRL_DP_EN BIT(1)
+#define ANX7483_CTRL_USB_EN BIT(0)
+
+#endif /* __CROS_EC_USB_RETIMER_ANX7483_H */
diff --git a/include/config.h b/include/config.h
index 05f16f07f8..2117518481 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4787,6 +4787,7 @@
/*
* Type-C retimer drivers to be used.
*/
+#undef CONFIG_USBC_RETIMER_ANX7483
#undef CONFIG_USBC_RETIMER_INTEL_BB
#undef CONFIG_USBC_RETIMER_KB800X
#undef CONFIG_USBC_RETIMER_NB7V904M
diff --git a/include/driver/retimer/anx7483_public.h b/include/driver/retimer/anx7483_public.h
new file mode 100644
index 0000000000..3d856a3cae
--- /dev/null
+++ b/include/driver/retimer/anx7483_public.h
@@ -0,0 +1,22 @@
+/* Copyright 2022 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.
+ *
+ * ANX7483: Active redriver with linear equilzation
+ *
+ * Public functions, definitions, and structures.
+ */
+
+#ifndef __CROS_EC_USB_RETIMER_ANX7483_PUBLIC_H
+#define __CROS_EC_USB_RETIMER_ANX7483_PUBLIC_H
+
+#include "usb_mux.h"
+
+/* I2C interface addresses */
+#define ANX7483_I2C_ADDR0_FLAGS 0x3E
+#define ANX7483_I2C_ADDR1_FLAGS 0x38
+#define ANX7483_I2C_ADDR2_FLAGS 0x40
+#define ANX7483_I2C_ADDR3_FLAGS 0x44
+
+extern const struct usb_mux_driver anx7483_usb_retimer_driver;
+#endif /* __CROS_EC_USB_RETIMER_ANX7483_PUBLIC_H */
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 3fd43a73eb..31de4f9752 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -391,6 +391,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_PD
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE
"${PLATFORM_EC}/common/usbc/usb_retimer_fw_update.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483
+ "${PLATFORM_EC}/driver/retimer/anx7483.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
"${PLATFORM_EC}/driver/retimer/bb_retimer.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818
diff --git a/zephyr/Kconfig.retimer b/zephyr/Kconfig.retimer
index 7d8000fd54..8a69a64866 100644
--- a/zephyr/Kconfig.retimer
+++ b/zephyr/Kconfig.retimer
@@ -47,6 +47,13 @@ config PLATFORM_EC_USBC_RETIMER_ANX7451
ANX7451 has built-in re-timers to recover both the USB and DP signals
with loss compensation of 23dB for USB and up to 27dB for DP.
+config PLATFORM_EC_USBC_RETIMER_ANX7483
+ bool "Support Analogix ANX7483 10G Active Retimer"
+ help
+ ANX7483 is a 4x4 re-driver capable of switching DisplayPort and
+ USB3.2 Gen 2 10Gbps signals to support type-C (USB-C) ports with
+ DisplayPort Alternate Mode.
+
config PLATFORM_EC_USBC_RETIMER_PS8811
bool "Support Parade PS8811 Single Port USB 3.1 Gen 2 10G Retimer"
help
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 4505091c40..69eefc12ec 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1428,6 +1428,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USBC_RETIMER_ANX7451
#endif
+#undef CONFIG_USBC_RETIMER_ANX7483
+#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483
+#define CONFIG_USBC_RETIMER_ANX7483
+#endif
+
#undef CONFIG_USBC_RETIMER_PS8811
#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811
#define CONFIG_USBC_RETIMER_PS8811