From d8872b6cb7e9d0f0320e62c3199da321a14cacd6 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Tue, 8 May 2012 22:22:56 -0700 Subject: [PATCH] stm32: set default i2c mode to noop This CL initializes the default transmit mode for I2C to CMDC_NOP. When we introduced the protocol, we changed the default mode to send message protocol version. This didn't take into account that U-Boot's probe command (and probably other userspace commands) do a single-byte read to probe. So when the probe was asking for a single byte, by default we were sending multiple bytes for the version message. This CL also makes the EC reset the mode to noop after each EC-to-AP transmission. This will help ensure that the EC ends up in a known state e.g. if the system is reset. That will require the AP to set the mode before requesting any real data, but that's how we do things now anyway. BUG=chrome-os-partner:9556 TEST=Tested on Daisy. Tested by running "i2c dev 4; i2c probe" at U-Boot prompt, booting system, and typing on keyboard. Everything seems to work okay. Signed-off-by: David Hendricks Change-Id: I0849c94588a9a60ade657af8f941f7267553e316 --- chip/stm32/i2c.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index 2a143e4112..8ed60e1fe7 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -39,9 +39,12 @@ static uint16_t i2c_sr1[NUM_PORTS]; static unsigned int tx_byte_count; static unsigned int rx_byte_count; -/* i2c_xmit_mode determines what EC sends when AP initiates a - read transaction */ -static enum message_cmd_t i2c_xmit_mode[NUM_PORTS]; +/* + * i2c_xmit_mode determines what EC sends when AP initiates a + * read transaction. If AP has not set a transmit mode, then + * default to NOP. + */ +static enum message_cmd_t i2c_xmit_mode[NUM_PORTS] = { CMDC_NOP, CMDC_NOP }; /* * Our output buffers. These must be large enough for our largest message, @@ -124,6 +127,9 @@ void i2c2_work_task(void) CPRINTF("%s: unexpected mode %u\n", __func__, i2c_xmit_mode[I2C2]); } + + /* reset EC mode to NOP after transfer is finished */ + i2c_xmit_mode[I2C2] = CMDC_NOP; } } }