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 <dhendrix@chromium.org>

Change-Id: I0849c94588a9a60ade657af8f941f7267553e316
This commit is contained in:
David Hendricks
2012-05-08 22:22:56 -07:00
parent 9b169ce929
commit d8872b6cb7

View File

@@ -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;
}
}
}