summaryrefslogtreecommitdiff
path: root/include/i2c_bitbang.h
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2019-10-23 20:02:10 +0800
committerCommit Bot <commit-bot@chromium.org>2019-12-16 08:06:04 +0000
commit7b61704fd1a09c5aae26f163e096d9695e479f21 (patch)
tree2692c9bdf01c6a73625b46c3bc5092bbb9ffaf06 /include/i2c_bitbang.h
parent7c89289e32ba60dca6d00aca6827b6ebe82f87ba (diff)
downloadchrome-ec-7b61704fd1a09c5aae26f163e096d9695e479f21.tar.gz
i2c: add support for i2c bit-banging
Krane/Jacuzzi need a 100KHz SMBus port for battery, in addition to the existing two i2c ports. This CL adds a bit-bang driver that supports i2c/smbus bit-banging through a set of pre-defined gpio pins. BUG=b:138161741,b:138415463 TEST=On a reworked jacuzzi (battery i2c connected to other gpios), 1) `battery` shows reasonable output (this verifies i2c_readN, i2c_read_string) 2) `i2cscan` works for port 3 (bitbang port) 3) `cutoff` (verifies i2c_writeN) 4) `i2ctest` stress test BRANCH=master Change-Id: I78020e5c51707c3d9f0fd54f2c299e2f29cabe2f Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1765110 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'include/i2c_bitbang.h')
-rw-r--r--include/i2c_bitbang.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/i2c_bitbang.h b/include/i2c_bitbang.h
new file mode 100644
index 0000000000..f3c07baf76
--- /dev/null
+++ b/include/i2c_bitbang.h
@@ -0,0 +1,23 @@
+/* Copyright 2019 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.
+ */
+#ifndef __CROS_EC_I2C_BITBANG_H
+#define __CROS_EC_I2C_BITBANG_H
+
+#include "i2c.h"
+
+extern const struct i2c_drv bitbang_drv;
+
+extern const struct i2c_port_t i2c_bitbang_ports[];
+extern const unsigned int i2c_bitbang_ports_used;
+
+/* expose static functions for testing */
+#ifdef TEST_BUILD
+int bitbang_start_cond(const struct i2c_port_t *i2c_port);
+void bitbang_stop_cond(const struct i2c_port_t *i2c_port);
+int bitbang_write_byte(const struct i2c_port_t *i2c_port, uint8_t byte);
+void bitbang_set_started(int val);
+#endif
+
+#endif /* __CROS_EC_I2C_BITBANG_H */