mfd: cros-ec: Increase maximum mkbp event size

Having a 16 byte mkbp event size makes it possible to send CEC
messages from the EC to the AP directly inside the mkbp event
instead of first doing a notification and then a read.

Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Neil Armstrong 2018-07-04 17:08:18 +02:00 committed by Lee Jones
parent 9c229127ae
commit 57e94c8b97
3 changed files with 48 additions and 10 deletions

View File

@ -506,10 +506,31 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
} }
EXPORT_SYMBOL(cros_ec_cmd_xfer_status); EXPORT_SYMBOL(cros_ec_cmd_xfer_status);
static int get_next_event_xfer(struct cros_ec_device *ec_dev,
struct cros_ec_command *msg,
int version, uint32_t size)
{
int ret;
msg->version = version;
msg->command = EC_CMD_GET_NEXT_EVENT;
msg->insize = size;
msg->outsize = 0;
ret = cros_ec_cmd_xfer(ec_dev, msg);
if (ret > 0) {
ec_dev->event_size = ret - 1;
memcpy(&ec_dev->event_data, msg->data, ec_dev->event_size);
}
return ret;
}
static int get_next_event(struct cros_ec_device *ec_dev) static int get_next_event(struct cros_ec_device *ec_dev)
{ {
u8 buffer[sizeof(struct cros_ec_command) + sizeof(ec_dev->event_data)]; u8 buffer[sizeof(struct cros_ec_command) + sizeof(ec_dev->event_data)];
struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; struct cros_ec_command *msg = (struct cros_ec_command *)&buffer;
static int cmd_version = 1;
int ret; int ret;
if (ec_dev->suspended) { if (ec_dev->suspended) {
@ -517,18 +538,19 @@ static int get_next_event(struct cros_ec_device *ec_dev)
return -EHOSTDOWN; return -EHOSTDOWN;
} }
msg->version = 0; if (cmd_version == 1) {
msg->command = EC_CMD_GET_NEXT_EVENT; ret = get_next_event_xfer(ec_dev, msg, cmd_version,
msg->insize = sizeof(ec_dev->event_data); sizeof(struct ec_response_get_next_event_v1));
msg->outsize = 0; if (ret < 0 || msg->result != EC_RES_INVALID_VERSION)
return ret;
ret = cros_ec_cmd_xfer(ec_dev, msg); /* Fallback to version 0 for future send attempts */
if (ret > 0) { cmd_version = 0;
ec_dev->event_size = ret - 1;
memcpy(&ec_dev->event_data, msg->data,
sizeof(ec_dev->event_data));
} }
ret = get_next_event_xfer(ec_dev, msg, cmd_version,
sizeof(struct ec_response_get_next_event));
return ret; return ret;
} }

View File

@ -147,7 +147,7 @@ struct cros_ec_device {
bool mkbp_event_supported; bool mkbp_event_supported;
struct blocking_notifier_head event_notifier; struct blocking_notifier_head event_notifier;
struct ec_response_get_next_event event_data; struct ec_response_get_next_event_v1 event_data;
int event_size; int event_size;
u32 host_event_wake_mask; u32 host_event_wake_mask;
}; };

View File

@ -2093,12 +2093,28 @@ union ec_response_get_next_data {
uint32_t sysrq; uint32_t sysrq;
} __packed; } __packed;
union ec_response_get_next_data_v1 {
uint8_t key_matrix[16];
uint32_t host_event;
uint32_t buttons;
uint32_t switches;
uint32_t sysrq;
uint32_t cec_events;
uint8_t cec_message[16];
} __packed;
struct ec_response_get_next_event { struct ec_response_get_next_event {
uint8_t event_type; uint8_t event_type;
/* Followed by event data if any */ /* Followed by event data if any */
union ec_response_get_next_data data; union ec_response_get_next_data data;
} __packed; } __packed;
struct ec_response_get_next_event_v1 {
uint8_t event_type;
/* Followed by event data if any */
union ec_response_get_next_data_v1 data;
} __packed;
/* Bit indices for buttons and switches.*/ /* Bit indices for buttons and switches.*/
/* Buttons */ /* Buttons */
#define EC_MKBP_POWER_BUTTON 0 #define EC_MKBP_POWER_BUTTON 0