ec/google/wilco: Add mailbox helper functions
Add helper functions that make it more convenient to send and receive the most common types of commands to the Wilco embedded controller. Change-Id: I9cee1a3b2f9d507f6ecdfae9f4a34ba59056cb91 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://review.coreboot.org/29114 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
21dde8b25f
commit
5f6f1dab7d
|
@ -44,4 +44,77 @@ int wilco_ec_mailbox(enum wilco_ec_msg_type type, uint8_t command,
|
||||||
const void *request_data, size_t request_size,
|
const void *request_data, size_t request_size,
|
||||||
void *response_data, size_t response_size);
|
void *response_data, size_t response_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wilco_ec_send
|
||||||
|
*
|
||||||
|
* Send a basic EC command with a one byte parameter with no
|
||||||
|
* returned data;
|
||||||
|
*
|
||||||
|
* @command: Command to execute
|
||||||
|
* @param: Command parameter to send
|
||||||
|
*
|
||||||
|
* @return negative error code on failure
|
||||||
|
*/
|
||||||
|
static inline int wilco_ec_send(uint8_t command, uint8_t param)
|
||||||
|
{
|
||||||
|
return wilco_ec_mailbox(WILCO_EC_MSG_DEFAULT, command,
|
||||||
|
¶m, sizeof(param), NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wilco_ec_send_noargs
|
||||||
|
*
|
||||||
|
* Send a basic EC command with no parameters and no returned data.
|
||||||
|
*
|
||||||
|
* @command: Command to execute
|
||||||
|
*
|
||||||
|
* @return negative error code on failure
|
||||||
|
*/
|
||||||
|
static inline int wilco_ec_send_noargs(uint8_t command)
|
||||||
|
{
|
||||||
|
return wilco_ec_mailbox(WILCO_EC_MSG_DEFAULT, command,
|
||||||
|
NULL, 0, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wilco_ec_sendrecv
|
||||||
|
*
|
||||||
|
* Send a basic EC command with a one byte parameter, ignoring the
|
||||||
|
* first byte of returned data to match the common behavior.
|
||||||
|
* The maximum response size is 31 due to the ignored byte.
|
||||||
|
*
|
||||||
|
* @command: Command to execute
|
||||||
|
* @param: Command parameter to send
|
||||||
|
* @data: Response data buffer
|
||||||
|
* @size: Number of bytes in response data buffer (max 31)
|
||||||
|
*
|
||||||
|
* @return number of bytes received, negative error code on failure
|
||||||
|
*/
|
||||||
|
static inline int wilco_ec_sendrecv(uint8_t command, uint8_t param,
|
||||||
|
void *data, size_t size)
|
||||||
|
{
|
||||||
|
return wilco_ec_mailbox(WILCO_EC_MSG_DEFAULT, command,
|
||||||
|
¶m, sizeof(param), data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wilco_ec_sendrecv_noargs
|
||||||
|
*
|
||||||
|
* Send a basic EC command with no parameters, ignoring the
|
||||||
|
* first byte of returned data to match the common behavior.
|
||||||
|
* The maximum response size is 31 due to the ignored byte.
|
||||||
|
*
|
||||||
|
* @command: Command to execute
|
||||||
|
* @data: Response data buffer
|
||||||
|
* @size: Number of bytes in response data buffer (max 31)
|
||||||
|
*
|
||||||
|
* @return number of bytes received, negative error code on failure
|
||||||
|
*/
|
||||||
|
static inline int wilco_ec_sendrecv_noargs(uint8_t command,
|
||||||
|
void *data, size_t size)
|
||||||
|
{
|
||||||
|
return wilco_ec_mailbox(WILCO_EC_MSG_DEFAULT, command,
|
||||||
|
NULL, 0, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EC_GOOGLE_WILCO_EC_H */
|
#endif /* EC_GOOGLE_WILCO_EC_H */
|
||||||
|
|
Loading…
Reference in New Issue