diff options
author | Tony Zou <zoutao@huaqin.corp-partner.google.com> | 2019-01-29 15:29:31 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-19 12:46:01 -0800 |
commit | ab40ba67c55799594ef8482b16a30373bf9da53c (patch) | |
tree | 274632a553a45a958a571132ff340a21813c48c6 /include | |
parent | d9a3b7c58a441cfcfb32b05fe3bd112c9caf78d6 (diff) | |
download | chrome-ec-ab40ba67c55799594ef8482b16a30373bf9da53c.tar.gz |
i2c: Support 16-bit address register read & write
wireless receiver charger IDT P9221 I2C reg addr is 16bit.
command
i2cxfer r/r16/w/w16 port offset [value]
When offset is 4 digit (e.g. 0x00ab), it reads/writes 16 bit offset
registers. Otherwise, it reads/writes 8-bit offset registers.
BRANCH=none
BUG=b:123504007
TEST=1:) Build flapjack EC and flash to DUT ,
EC can read/write P9221 register.
2:) Build kukui EC , build pass.
TEST=buildall
Change-Id: If0df532f5ca136bf1312a1857b13e8455e897943
Reviewed-on: https://chromium-review.googlesource.com/1445133
Commit-Ready: Tony Zou <zoutao@huaqin.corp-partner.google.com>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/i2c.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/i2c.h b/include/i2c.h index bb7f28000d..b749d04b08 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -265,6 +265,35 @@ int i2c_read8(int port, int slave_addr, int offset, int *data); int i2c_write8(int port, int slave_addr, int offset, int data); /** + * Read one or two bytes data from the slave at 8-bit slave address + * * <slaveaddr>, at 16-bit <offset> in the slave's address space. + */ +int i2c_read_offset16(int port, int slave_addr, uint16_t offset, + int *data, int len); + +/** + * Write one or two bytes data to the slave at 8-bit slave address + * <slaveaddr>, at 16-bit <offset> in the slave's address space. + */ +int i2c_write_offset16(int port, int slave_addr, uint16_t offset, + int data, int len); + +/** + * Read <len> bytes block data from the slave at 8-bit slave address + * * <slaveaddr>, at 16-bit <offset> in the slave's address space. + */ +int i2c_read_offset16_block(int port, int slave_addr, uint16_t offset, + uint8_t *data, int len); + +/** + * Write <len> bytes block data to the slave at 8-bit slave address + * <slaveaddr>, at 16-bit <offset> in the slave's address space. + */ +int i2c_write_offset16_block(int port, int slave_addr, uint16_t offset, + const uint8_t *data, int len); + + +/** * @return non-zero if i2c bus is busy */ int i2c_is_busy(int port); |