diff options
author | Ting Shen <phoenixshen@google.com> | 2019-10-23 20:02:10 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-16 08:06:04 +0000 |
commit | 7b61704fd1a09c5aae26f163e096d9695e479f21 (patch) | |
tree | 2692c9bdf01c6a73625b46c3bc5092bbb9ffaf06 /include/i2c.h | |
parent | 7c89289e32ba60dca6d00aca6827b6ebe82f87ba (diff) | |
download | chrome-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.h')
-rw-r--r-- | include/i2c.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/i2c.h b/include/i2c.h index bca96536b9..247306da7d 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -92,6 +92,15 @@ struct i2c_info_t { uint16_t addr_flags; }; +struct i2c_port_t; /* forward declaration */ + +struct i2c_drv { + int (*xfer)(const struct i2c_port_t *i2c_port, + const uint16_t slave_addr_flags, + const uint8_t *out, int out_size, + uint8_t *in, int in_size, int flags); +}; + /* Data structure to define I2C port configuration. */ struct i2c_port_t { const char *name; /* Port name */ @@ -103,6 +112,7 @@ struct i2c_port_t { * If the function is not defined, the default value is true. */ int (*passthru_allowed)(const struct i2c_port_t *port, uint16_t addr_flags); + const struct i2c_drv *drv; }; extern const struct i2c_port_t i2c_ports[]; |