summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-07-15 02:48:21 +0100
committerGerrit <chrome-bot@google.com>2012-07-22 00:36:39 -0700
commit37a6387fa906e43115417c4a89069be043e2c554 (patch)
treed2f056cf887ef8383240b7f90a736a61199c70c0
parent949d525e2a4de87da034f7fd89c6cb0f04d8f1c4 (diff)
downloadchrome-ec-37a6387fa906e43115417c4a89069be043e2c554.tar.gz
i2c: Move host command processing into a function
We are about to add more logic here, so move it this code out of the event handler and into its own function. BUG=chrome-os-partner:11317 TEST=manual and a bit ad-hoc: (note, this testing is not completed yet) Check that snow and link still process commands correctly over I2C from U-Boot. At this stage only the old interface is supported. SMDK5250 # mkbp test Old interface: New interface: Version 0: ec_command() returned error Test failed with error -1 SMDK5250 # Change-Id: I5387eb5533ab6faa27769f4cf21075387357371d Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27469
-rw-r--r--chip/stm32/i2c.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c
index 248eed7237..31c5174c55 100644
--- a/chip/stm32/i2c.c
+++ b/chip/stm32/i2c.c
@@ -141,6 +141,23 @@ static void i2c_send_response(struct host_cmd_handler_args *args)
i2c_write_raw(I2C2, host_buffer, out - host_buffer);
}
+/* Process the command in the i2c host buffer */
+static void i2c_process_command(void)
+{
+ /* we have an available command : execute it */
+ host_cmd_args.command = host_buffer[0];
+ host_cmd_args.result = EC_RES_SUCCESS;
+ host_cmd_args.send_response = i2c_send_response;
+ host_cmd_args.version = 0;
+ host_cmd_args.params = host_buffer + 1;
+ host_cmd_args.params_size = EC_HOST_PARAM_SIZE;
+ /* skip room for error code */
+ host_cmd_args.response = host_buffer + 1;
+ host_cmd_args.response_max = EC_HOST_PARAM_SIZE;
+ host_cmd_args.response_size = 0;
+ host_command_received(&host_cmd_args);
+}
+
static void i2c_event_handler(int port)
{
@@ -174,19 +191,7 @@ static void i2c_event_handler(int port)
if (i2c_sr1[port] & (1 << 7)) {
if (port == I2C2) { /* AP is waiting for EC response */
if (rx_index) {
- /* we have an available command : execute it */
- host_cmd_args.command = host_buffer[0];
- host_cmd_args.result = EC_RES_SUCCESS;
- host_cmd_args.send_response =
- i2c_send_response;
- host_cmd_args.version = 0;
- host_cmd_args.params = host_buffer + 1;
- host_cmd_args.params_size = EC_HOST_PARAM_SIZE;
- /* skip room for error code */
- host_cmd_args.response = host_buffer + 1;
- host_cmd_args.response_max = EC_HOST_PARAM_SIZE;
- host_cmd_args.response_size = 0;
- host_command_received(&host_cmd_args);
+ i2c_process_command();
/* reset host buffer after end of transfer */
rx_index = 0;
} else {