summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dabros <jsd@semihalf.com>2021-04-15 23:47:04 +0200
committerCommit Bot <commit-bot@chromium.org>2021-04-22 14:15:38 +0000
commit888e830480de3840ab11299a708267b97a339927 (patch)
treefd02c4376257189b08a9be480589d62ccfead386
parenta1d6eed22f8b364a9eed261eb6f165a7d22698af (diff)
downloadchrome-ec-888e830480de3840ab11299a708267b97a339927.tar.gz
gl3590: Add a delay to allow hub release i2c lines
GL3590 (USB3 hub) chip may drive I2C_SDA and I2C_SCL lines after being released from reset. Max time for such "activities" is 200ms. In order to ensure correct operations on the i2c bus, we need to delay all i2c transactions in the system by such value. Implementation is using hook with higher priority than I2C_INIT. This guarantees that: * SoC won't start i2c transactions before 200ms mark after GL3590's RESETJ# pin deassertion; * Original order of loading all generic modules (e.g. ioex_init, board_init) won't need to be changed; * Workaround applied only in platform-specific code. BUG=b:181930164 BRANCH=main TEST=build and flash new servo_v4p1 firmware Plug in CHG and DUT cables. _Then_ plug in HOST cable and verify that green diode is lit on servo_v4p1 board indicating proper pass-through charging. Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: I32971d421eb541c788a87701ce5e8c62a8b35777 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2829770 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/gl3590.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/driver/gl3590.c b/driver/gl3590.c
index 2a73f44aad..cb8d914d8c 100644
--- a/driver/gl3590.c
+++ b/driver/gl3590.c
@@ -4,6 +4,7 @@
*/
#include "console.h"
+#include "hooks.h"
#include "i2c.h"
#include "system.h"
#include "util.h"
@@ -11,6 +12,7 @@
#include "gl3590.h"
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)
/* GL3590 is unique in terms of i2c_read, since it doesn't support repeated
@@ -118,6 +120,19 @@ void gl3590_init(int hub)
uhub_p->initialized = 1;
}
+/*
+ * GL3590 chip may drive I2C_SDA and I2C_SCL lines for 200ms (max) after it is
+ * released from reset (through gpio de-assertion in main()). In order to avoid
+ * broken I2C transactions, we need to add an extra delay before any activity on
+ * the I2C bus in the system.
+ */
+static void gl3590_delay_on_init(void)
+{
+ CPRINTS("Applying 200ms delay for GL3590 to release I2C lines");
+ udelay(200 * MSEC);
+}
+DECLARE_HOOK(HOOK_INIT, gl3590_delay_on_init, HOOK_PRIO_INIT_I2C - 1);
+
void gl3590_irq_handler(int hub)
{
uint8_t buf = 0;