int cros_ec_lpc_command(struct udevice *udev, uint8_t cmd, int cmd_version,
#define debug_trace(fmt, b...) debug(fmt, ##b)
#define debug_trace(fmt, b...)
static int wait_for_sync(struct cros_ec_dev *dev)
while (inb(EC_LPC_ADDR_HOST_CMD) & EC_LPC_STATUS_BUSY_MASK) {
if (get_timer(start) > 1000) {
debug("%s: Timeout waiting for CROS_EC sync\n",
int cros_ec_lpc_packet(struct udevice *udev, int out_bytes, int in_bytes)
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
if (out_bytes > EC_LPC_HOST_PACKET_SIZE)
return log_msg_ret("Cannot send that many bytes\n", -E2BIG);
if (in_bytes > EC_LPC_HOST_PACKET_SIZE)
return log_msg_ret("Cannot receive that many bytes\n", -E2BIG);
return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT);
for (i = 0, d = (uint8_t *)dev->dout; i < out_bytes; i++, d++)
outb(*d, EC_LPC_ADDR_HOST_PACKET + i);
outb(EC_COMMAND_PROTOCOL_3, EC_LPC_ADDR_HOST_CMD);