diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-02-03 18:34:29 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-02-09 19:51:01 -0800 |
commit | 0251aacd4332a0228f757fd390baaa58fda650e2 (patch) | |
tree | cba2b86bf2170c4e858a91c0aa65669686a7dd1d | |
parent | 9c053ea898fa2ed890df4f60064dcfee465b6e0f (diff) | |
download | chrome-ec-0251aacd4332a0228f757fd390baaa58fda650e2.tar.gz |
mec1322: i2c: Print port name on failure
Referring to i2c ports as i2c0 thru i2c4 is confusing, due to the
special naming of controller 0 ports, so use their actual names from the
datasheet.
BUG=None
TEST=Trigger failure on i2c0_1, verify that "i2c0_1 bad status .." is
seen on console.
BRANCH=glados, strago
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ibd0d638e5af1c0a64e6f4b1a709b790b6b10d5e6
Reviewed-on: https://chromium-review.googlesource.com/325822
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | chip/mec1322/i2c.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/chip/mec1322/i2c.c b/chip/mec1322/i2c.c index efa0532d14..ce3e618c24 100644 --- a/chip/mec1322/i2c.c +++ b/chip/mec1322/i2c.c @@ -58,7 +58,7 @@ enum i2c_transaction_state { }; /* I2C controller state data */ -struct { +static struct { /* Transaction timeout, or 0 to use default. */ uint32_t timeout_us; /* Task waiting on port, or TASK_ID_INVALID if none. */ @@ -66,6 +66,15 @@ struct { enum i2c_transaction_state transaction_state; } cdata[I2C_CONTROLLER_COUNT]; +/* Map port number to port name in datasheet, for debug prints. */ +static const char *i2c_port_names[MEC1322_I2C_PORT_COUNT] = { + [MEC1322_I2C0_0] = "0_0", + [MEC1322_I2C0_1] = "0_1", + [MEC1322_I2C1] = "1", + [MEC1322_I2C2] = "2", + [MEC1322_I2C3] = "3", +}; + static void configure_controller_speed(int controller, int kbps) { int t_low, t_high; @@ -254,7 +263,8 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, (((reg & (STS_BER | STS_LAB)) || !(reg & STS_NBB)) || (get_line_level(controller) != I2C_LINE_IDLE))) { - CPRINTS("I2C%d bad status 0x%02x, SCL=%d, SDA=%d", port, reg, + CPRINTS("i2c%s bad status 0x%02x, SCL=%d, SDA=%d", + i2c_port_names[port], reg, get_line_level(controller) & I2C_LINE_SCL_HIGH, get_line_level(controller) & I2C_LINE_SDA_HIGH); |