summaryrefslogtreecommitdiff
path: root/driver/retimer
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2020-05-04 19:44:49 -0600
committerCommit Bot <commit-bot@chromium.org>2020-05-05 05:51:26 +0000
commitaf09e1bdd78924850fd6f1c188c9203c77757153 (patch)
treed96e77265566d50845815bd49d534d03e1389687 /driver/retimer
parent773db9a931ccc9ee591c04a6c610a805d74bdad8 (diff)
downloadchrome-ec-af09e1bdd78924850fd6f1c188c9203c77757153.tar.gz
pi3hdx1204: Add driver.
Add simple driver to just turn power on and off via I2C. BUG=b:154874071 BRANCH=none TEST=check i2c writes Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I836340dbd7a9e41380d1469dac0a94e268bd2bf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2181793 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'driver/retimer')
-rw-r--r--driver/retimer/pi3hdx1204.c23
-rw-r--r--driver/retimer/pi3hdx1204.h22
2 files changed, 45 insertions, 0 deletions
diff --git a/driver/retimer/pi3hdx1204.c b/driver/retimer/pi3hdx1204.c
new file mode 100644
index 0000000000..30db590c61
--- /dev/null
+++ b/driver/retimer/pi3hdx1204.c
@@ -0,0 +1,23 @@
+/* Copyright 2020 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.
+ *
+ * PI3HDX1204 retimer.
+ */
+
+#include "i2c.h"
+#include "pi3hdx1204.h"
+
+int pi3hdx1204_enable(const int i2c_port,
+ const uint16_t i2c_addr_flags,
+ const int enable)
+{
+ uint8_t buf[PI3HDX1204_ENABLE_OFFSET + 1] = {0};
+
+ buf[PI3HDX1204_ENABLE_OFFSET] =
+ enable ? PI3HDX1204_ENABLE_ALL_CHANNELS : 0;
+
+ return i2c_xfer(i2c_port, i2c_addr_flags,
+ buf, PI3HDX1204_ENABLE_OFFSET + 1,
+ NULL, 0);
+}
diff --git a/driver/retimer/pi3hdx1204.h b/driver/retimer/pi3hdx1204.h
new file mode 100644
index 0000000000..4ae9eeaa3b
--- /dev/null
+++ b/driver/retimer/pi3hdx1204.h
@@ -0,0 +1,22 @@
+/* Copyright 2020 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.
+ *
+ * PI3HDX1204 retimer.
+ */
+
+#ifndef __CROS_EC_USB_RETIMER_PI3HDX1204_H
+#define __CROS_EC_USB_RETIMER_PI3HDX1204_H
+
+#define PI3HDX1204_I2C_ADDR_FLAGS 0x60
+
+/* Register Offset 2 - Enable */
+#define PI3HDX1204_ENABLE_OFFSET 2
+#define PI3HDX1204_ENABLE_ALL_CHANNELS 0xF0
+
+/* Enable or disable the PI3HDX1204. */
+int pi3hdx1204_enable(const int i2c_port,
+ const uint16_t i2c_addr_flags,
+ const int enable);
+
+#endif /* __CROS_EC_USB_RETIMER_PI3HDX1204_H */