Revert "i2c: Support command version numbers"

This reverts commit b983290238458f88a897ce3cfb06faae9ec79a40

Dependent on reverted change.

Change-Id: I3bb4c6acf4ff327f956ee5e1b6deefcd84dc8fbb
Reviewed-on: https://gerrit.chromium.org/gerrit/28138
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Randall Spangler
2012-07-22 12:24:59 -07:00
committed by Gerrit
parent 7143c4544c
commit fbfc353cef
3 changed files with 15 additions and 57 deletions

View File

@@ -41,8 +41,8 @@
static uint16_t i2c_sr1[NUM_PORTS];
static struct mutex i2c_mutex;
/* buffer for host commands (including version, error code and checksum) */
static uint8_t host_buffer[EC_HOST_PARAM_SIZE + 4];
/* buffer for host commands (including error code and checksum) */
static uint8_t host_buffer[EC_HOST_PARAM_SIZE + 2];
static struct host_cmd_handler_args host_cmd_args;
/* current position in host buffer for reception */
@@ -127,14 +127,10 @@ static void i2c_send_response(struct host_cmd_handler_args *args)
const uint8_t *data = args->response;
int size = args->response_size;
uint8_t *out = host_buffer;
int sum = 0, i;
int sum, i;
*out++ = args->result;
if (!args->i2c_old_response) {
*out++ = size;
sum = args->result + size;
}
for (i = 0; i < size; i++, data++, out++) {
for (i = 0, sum = 0; i < size; i++, data++, out++) {
if (data != out)
*out = *data;
sum += *data;
@@ -148,43 +144,18 @@ static void i2c_send_response(struct host_cmd_handler_args *args)
/* Process the command in the i2c host buffer */
static void i2c_process_command(void)
{
struct host_cmd_handler_args *args = &host_cmd_args;
char *buff = host_buffer;
args->command = *buff;
args->result = EC_RES_SUCCESS;
if (args->command >= EC_CMD_VERSION0) {
int csum, i;
/* Read version and data size */
args->version = args->command - EC_CMD_VERSION0;
args->command = buff[1];
args->params_size = buff[2];
/* Verify checksum */
for (csum = i = 0; i < args->params_size + 3; i++)
csum += buff[i];
if ((uint8_t)csum != buff[i])
args->result = EC_RES_INVALID_CHECKSUM;
buff += 3;
args->i2c_old_response = 0;
} else {
/* Old style command */
args->version = 0;
args->params_size = EC_HOST_PARAM_SIZE; /* unknown */
buff++;
args->i2c_old_response = 1;
}
/* we have an available command : execute it */
args->send_response = i2c_send_response;
args->params = buff;
/* skip room for error code, arglen */
args->response = host_buffer + 2;
args->response_max = EC_HOST_PARAM_SIZE;
args->response_size = 0;
host_command_received(args);
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)

View File

@@ -942,18 +942,6 @@ struct ec_params_reboot_ec {
*/
#define EC_CMD_REBOOT 0xd1 /* Think "die" */
/*
* This header byte on a command indicate version 0. Any header byte less
* than this means that we are talking to an old EC which doesn't support
* versioning. In that case, we assume version 0.
*
* Header bytes greater than this indicate a later version. For example,
* EC_CMD_VERSION0 + 1 means we are using version 1.
*
* The old EC interface must not use commands 0dc or higher.
*/
#define EC_CMD_VERSION0 0xdc
#endif /* !__ACPI__ */
#endif /* __CROS_EC_COMMANDS_H */

View File

@@ -22,7 +22,6 @@ struct host_cmd_handler_args {
uint8_t command; /* Command (e.g., EC_CMD_FLASH_GET_INFO) */
uint8_t version; /* Version of command (0-31) */
uint8_t params_size; /* Size of input parameters in bytes */
uint8_t i2c_old_response; /* (for I2C) send an old-style response */
const uint8_t *params; /* Input parameters */
/*
* Pointer to output response data buffer. On input to the handler,