diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-05-22 17:17:47 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-27 19:40:00 +0000 |
commit | 1b2f6b64510c061ddabd8d6a3d5e01fc71a68712 (patch) | |
tree | a1564c27d1bce516e8ab4433aeff30b7526124fe /chip/mec1322/i2c.c | |
parent | 315afdff429f08dd91193883348bc74e4f9edfb1 (diff) | |
download | chrome-ec-1b2f6b64510c061ddabd8d6a3d5e01fc71a68712.tar.gz |
i2c: Make i2c_xfer a wrapper function to chip_i2c_xfer
i2c_xfer was previously implemented at the chip-level, but now we want
to add some global retry logic. Rename the chip-level i2c_xfer functions
to chip_i2c_xfer and add a new global wrapper function i2c_xfer.
BUG=chrome-os-partner:39613
TEST=Run "battery" from EC console on Cyan, verify that values + strings
are correctly printed.
BRANCH=None
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: If37c85cc3cf94fd53feb6931553e10c30ad6cad6
Reviewed-on: https://chromium-review.googlesource.com/272939
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/mec1322/i2c.c')
-rw-r--r-- | chip/mec1322/i2c.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/chip/mec1322/i2c.c b/chip/mec1322/i2c.c index e7254a01f9..e80d6cb5f8 100644 --- a/chip/mec1322/i2c.c +++ b/chip/mec1322/i2c.c @@ -212,8 +212,8 @@ static inline void push_in_buf(uint8_t **in, uint8_t val, int skip) } } -int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, - uint8_t *in, int in_size, int flags) +int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, + uint8_t *in, int in_size, int flags) { int i; int controller; @@ -267,11 +267,11 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, for (i = 0; i < out_size; ++i) { if (wait_byte_done(controller)) - goto err_i2c_xfer; + goto err_chip_i2c_xfer; MEC1322_I2C_DATA(controller) = out[i]; } if (wait_byte_done(controller)) - goto err_i2c_xfer; + goto err_chip_i2c_xfer; /* * Send STOP bit if the stop flag is on, and caller @@ -302,12 +302,12 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, for (i = 0; i < bytes_to_read; ++i) { if (wait_byte_done(controller)) - goto err_i2c_xfer; + goto err_chip_i2c_xfer; push_in_buf(&in, MEC1322_I2C_DATA(controller), skip); skip = 0; } if (wait_byte_done(controller)) - goto err_i2c_xfer; + goto err_chip_i2c_xfer; if (send_stop) { /* @@ -317,7 +317,7 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, MEC1322_I2C_CTRL(controller) = CTRL_ESO | CTRL_ENI; push_in_buf(&in, MEC1322_I2C_DATA(controller), skip); if (wait_byte_done(controller)) - goto err_i2c_xfer; + goto err_chip_i2c_xfer; /* Send STOP */ MEC1322_I2C_CTRL(controller) = @@ -339,7 +339,7 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, return EC_ERROR_UNKNOWN; return EC_SUCCESS; -err_i2c_xfer: +err_chip_i2c_xfer: /* Send STOP and return error */ MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | CTRL_STO | CTRL_ACK; |