Lines Matching refs:msg
56 struct cros_ec_command *msg) in prepare_tx() argument
63 if (msg->outsize + sizeof(*request) > ec_dev->dout_size) in prepare_tx()
70 request->command = msg->command; in prepare_tx()
71 request->command_version = msg->version; in prepare_tx()
73 request->data_len = msg->outsize; in prepare_tx()
79 memcpy(out + sizeof(*request), msg->data, msg->outsize); in prepare_tx()
80 for (i = 0; i < msg->outsize; i++) in prepare_tx()
81 csum += msg->data[i]; in prepare_tx()
85 return sizeof(*request) + msg->outsize; in prepare_tx()
89 struct cros_ec_command *msg) in prepare_tx_legacy() argument
95 if (msg->outsize > EC_PROTO2_MAX_PARAM_SIZE) in prepare_tx_legacy()
99 out[0] = EC_CMD_VERSION0 + msg->version; in prepare_tx_legacy()
100 out[1] = msg->command; in prepare_tx_legacy()
101 out[2] = msg->outsize; in prepare_tx_legacy()
103 for (i = 0; i < msg->outsize; i++) in prepare_tx_legacy()
104 csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->data[i]; in prepare_tx_legacy()
105 out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = csum; in prepare_tx_legacy()
107 return EC_MSG_TX_PROTO_BYTES + msg->outsize; in prepare_tx_legacy()
110 static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) in cros_ec_xfer_command() argument
113 int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg); in cros_ec_xfer_command()
130 trace_cros_ec_request_start(msg); in cros_ec_xfer_command()
131 ret = (*xfer_fxn)(ec_dev, msg); in cros_ec_xfer_command()
132 trace_cros_ec_request_done(msg, ret); in cros_ec_xfer_command()
140 struct cros_ec_command msg; in cros_ec_wait_until_complete() member
143 struct cros_ec_command *msg = &buf.msg; in cros_ec_wait_until_complete() local
147 msg->version = 0; in cros_ec_wait_until_complete()
148 msg->command = EC_CMD_GET_COMMS_STATUS; in cros_ec_wait_until_complete()
149 msg->insize = sizeof(*status); in cros_ec_wait_until_complete()
150 msg->outsize = 0; in cros_ec_wait_until_complete()
156 ret = cros_ec_xfer_command(ec_dev, msg); in cros_ec_wait_until_complete()
162 *result = msg->result; in cros_ec_wait_until_complete()
163 if (msg->result != EC_RES_SUCCESS) in cros_ec_wait_until_complete()
181 static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) in cros_ec_send_command() argument
183 int ret = cros_ec_xfer_command(ec_dev, msg); in cros_ec_send_command()
185 if (msg->result == EC_RES_IN_PROGRESS) in cros_ec_send_command()
186 ret = cros_ec_wait_until_complete(ec_dev, &msg->result); in cros_ec_send_command()
202 struct cros_ec_command *msg) in cros_ec_prepare_tx() argument
205 return prepare_tx(ec_dev, msg); in cros_ec_prepare_tx()
207 return prepare_tx_legacy(ec_dev, msg); in cros_ec_prepare_tx()
225 struct cros_ec_command *msg) in cros_ec_check_result() argument
227 switch (msg->result) { in cros_ec_check_result()
232 msg->command); in cros_ec_check_result()
236 msg->command, msg->result); in cros_ec_check_result()
257 struct cros_ec_command *msg; in cros_ec_get_host_event_wake_mask() local
261 msg = kzalloc(sizeof(*msg) + sizeof(*r), GFP_KERNEL); in cros_ec_get_host_event_wake_mask()
262 if (!msg) in cros_ec_get_host_event_wake_mask()
265 msg->command = EC_CMD_HOST_EVENT_GET_WAKE_MASK; in cros_ec_get_host_event_wake_mask()
266 msg->insize = sizeof(*r); in cros_ec_get_host_event_wake_mask()
268 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_host_event_wake_mask()
272 mapped = cros_ec_map_error(msg->result); in cros_ec_get_host_event_wake_mask()
283 r = (struct ec_response_host_event_mask *)msg->data; in cros_ec_get_host_event_wake_mask()
287 kfree(msg); in cros_ec_get_host_event_wake_mask()
293 struct cros_ec_command *msg; in cros_ec_get_proto_info() local
301 msg = kzalloc(sizeof(*msg) + sizeof(*info), GFP_KERNEL); in cros_ec_get_proto_info()
302 if (!msg) in cros_ec_get_proto_info()
305 msg->command = EC_CMD_PASSTHRU_OFFSET(devidx) | EC_CMD_GET_PROTOCOL_INFO; in cros_ec_get_proto_info()
306 msg->insize = sizeof(*info); in cros_ec_get_proto_info()
308 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_proto_info()
317 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_proto_info()
326 mapped = cros_ec_map_error(msg->result); in cros_ec_get_proto_info()
337 info = (struct ec_response_get_protocol_info *)msg->data; in cros_ec_get_proto_info()
365 kfree(msg); in cros_ec_get_proto_info()
371 struct cros_ec_command *msg; in cros_ec_get_proto_info_legacy() local
378 msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*response)), GFP_KERNEL); in cros_ec_get_proto_info_legacy()
379 if (!msg) in cros_ec_get_proto_info_legacy()
382 msg->command = EC_CMD_HELLO; in cros_ec_get_proto_info_legacy()
383 msg->insize = sizeof(*response); in cros_ec_get_proto_info_legacy()
384 msg->outsize = sizeof(*params); in cros_ec_get_proto_info_legacy()
386 params = (struct ec_params_hello *)msg->data; in cros_ec_get_proto_info_legacy()
389 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_proto_info_legacy()
395 mapped = cros_ec_map_error(msg->result); in cros_ec_get_proto_info_legacy()
398 dev_err(ec_dev->dev, "EC responded to v2 hello with error: %d\n", msg->result); in cros_ec_get_proto_info_legacy()
407 response = (struct ec_response_hello *)msg->data; in cros_ec_get_proto_info_legacy()
426 kfree(msg); in cros_ec_get_proto_info_legacy()
450 struct cros_ec_command *msg; in cros_ec_get_host_command_version_mask() local
453 msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), in cros_ec_get_host_command_version_mask()
455 if (!msg) in cros_ec_get_host_command_version_mask()
458 msg->version = 0; in cros_ec_get_host_command_version_mask()
459 msg->command = EC_CMD_GET_CMD_VERSIONS; in cros_ec_get_host_command_version_mask()
460 msg->insize = sizeof(*rver); in cros_ec_get_host_command_version_mask()
461 msg->outsize = sizeof(*pver); in cros_ec_get_host_command_version_mask()
463 pver = (struct ec_params_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
466 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_get_host_command_version_mask()
470 mapped = cros_ec_map_error(msg->result); in cros_ec_get_host_command_version_mask()
481 rver = (struct ec_response_get_cmd_versions *)msg->data; in cros_ec_get_host_command_version_mask()
485 kfree(msg); in cros_ec_get_host_command_version_mask()
607 int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) in cros_ec_cmd_xfer() argument
622 if (msg->insize > ec_dev->max_response) { in cros_ec_cmd_xfer()
624 msg->insize = ec_dev->max_response; in cros_ec_cmd_xfer()
627 if (msg->command < EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX)) { in cros_ec_cmd_xfer()
628 if (msg->outsize > ec_dev->max_request) { in cros_ec_cmd_xfer()
631 msg->outsize, in cros_ec_cmd_xfer()
637 if (msg->outsize > ec_dev->max_passthru) { in cros_ec_cmd_xfer()
640 msg->outsize, in cros_ec_cmd_xfer()
647 ret = cros_ec_send_command(ec_dev, msg); in cros_ec_cmd_xfer()
668 struct cros_ec_command *msg) in cros_ec_cmd_xfer_status() argument
672 ret = cros_ec_cmd_xfer(ec_dev, msg); in cros_ec_cmd_xfer_status()
676 mapped = cros_ec_map_error(msg->result); in cros_ec_cmd_xfer_status()
679 msg->result, mapped); in cros_ec_cmd_xfer_status()
688 struct cros_ec_command *msg, in get_next_event_xfer() argument
694 msg->version = version; in get_next_event_xfer()
695 msg->command = EC_CMD_GET_NEXT_EVENT; in get_next_event_xfer()
696 msg->insize = size; in get_next_event_xfer()
697 msg->outsize = 0; in get_next_event_xfer()
699 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in get_next_event_xfer()
711 struct cros_ec_command msg; in get_next_event() member
714 struct cros_ec_command *msg = &buf.msg; in get_next_event() local
718 memset(msg, 0, sizeof(*msg)); in get_next_event()
725 return get_next_event_xfer(ec_dev, msg, event, 0, in get_next_event()
728 return get_next_event_xfer(ec_dev, msg, event, cmd_version, in get_next_event()
736 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; in get_keyboard_state_event() local
738 msg->version = 0; in get_keyboard_state_event()
739 msg->command = EC_CMD_MKBP_STATE; in get_keyboard_state_event()
740 msg->insize = sizeof(ec_dev->event_data.data); in get_keyboard_state_event()
741 msg->outsize = 0; in get_keyboard_state_event()
743 ec_dev->event_size = cros_ec_cmd_xfer_status(ec_dev, msg); in get_keyboard_state_event()
745 memcpy(&ec_dev->event_data.data, msg->data, in get_keyboard_state_event()
941 struct cros_ec_command *msg; in cros_ec_get_sensor_count() local
945 msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*resp)), in cros_ec_get_sensor_count()
947 if (!msg) in cros_ec_get_sensor_count()
950 msg->version = 1; in cros_ec_get_sensor_count()
951 msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset; in cros_ec_get_sensor_count()
952 msg->outsize = sizeof(*params); in cros_ec_get_sensor_count()
953 msg->insize = sizeof(*resp); in cros_ec_get_sensor_count()
955 params = (struct ec_params_motion_sense *)msg->data; in cros_ec_get_sensor_count()
958 ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); in cros_ec_get_sensor_count()
962 resp = (struct ec_response_motion_sense *)msg->data; in cros_ec_get_sensor_count()
965 kfree(msg); in cros_ec_get_sensor_count()
1012 struct cros_ec_command *msg; in cros_ec_cmd() local
1015 msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL); in cros_ec_cmd()
1016 if (!msg) in cros_ec_cmd()
1019 msg->version = version; in cros_ec_cmd()
1020 msg->command = command; in cros_ec_cmd()
1021 msg->outsize = outsize; in cros_ec_cmd()
1022 msg->insize = insize; in cros_ec_cmd()
1025 memcpy(msg->data, outdata, outsize); in cros_ec_cmd()
1027 ret = cros_ec_cmd_xfer_status(ec_dev, msg); in cros_ec_cmd()
1032 memcpy(indata, msg->data, insize); in cros_ec_cmd()
1034 kfree(msg); in cros_ec_cmd()