Lines Matching full:ec
7 * The Wilco EC is similar to a typical ChromeOS embedded controller.
9 * protocol, but with some important differences. The EC firmware does
21 #include <linux/platform_data/wilco-ec.h>
32 /* Version of EC protocol */
41 /* EC response flags */
43 #define EC_CMDR_PENDING BIT(1) /* Write pending to EC */
44 #define EC_CMDR_BUSY BIT(2) /* EC is busy processing a command */
48 * wilco_ec_response_timed_out() - Wait for EC response.
49 * @ec: EC device.
51 * Return: true if EC timed out, false if EC did not time out.
53 static bool wilco_ec_response_timed_out(struct wilco_ec_device *ec) in wilco_ec_response_timed_out() argument
58 if (!(inb(ec->io_command->start) & in wilco_ec_response_timed_out()
87 * wilco_ec_prepare() - Prepare the request structure for the EC.
88 * @msg: EC message with request information.
89 * @rq: EC request structure to fill.
108 * @ec: EC device.
109 * @msg: EC message data for request and response.
112 * Context: ec->mailbox_lock should be held while using this function.
115 static int wilco_ec_transfer(struct wilco_ec_device *ec, in wilco_ec_transfer() argument
133 outb(EC_MAILBOX_START_COMMAND, ec->io_command->start); in wilco_ec_transfer()
135 /* For some commands (eg shutdown) the EC will not respond, that's OK */ in wilco_ec_transfer()
137 dev_dbg(ec->dev, "EC does not respond to this command\n"); in wilco_ec_transfer()
142 if (wilco_ec_response_timed_out(ec)) { in wilco_ec_transfer()
143 dev_dbg(ec->dev, "response timed out\n"); in wilco_ec_transfer()
148 flag = inb(ec->io_data->start); in wilco_ec_transfer()
150 dev_dbg(ec->dev, "bad response: 0x%02x\n", flag); in wilco_ec_transfer()
155 rs = ec->data_buffer; in wilco_ec_transfer()
162 dev_dbg(ec->dev, "bad packet checksum 0x%02x\n", rs->checksum); in wilco_ec_transfer()
167 dev_dbg(ec->dev, "EC reported failure: 0x%02x\n", rs->result); in wilco_ec_transfer()
172 dev_dbg(ec->dev, "unexpected packet size (%u != %u)\n", in wilco_ec_transfer()
178 dev_dbg(ec->dev, "EC didn't return enough data (%u < %zu)\n", in wilco_ec_transfer()
189 * wilco_ec_mailbox() - Send EC request and receive EC response.
190 * @ec: EC device.
191 * @msg: EC message data for request and response.
202 int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg) in wilco_ec_mailbox() argument
207 dev_dbg(ec->dev, "type=%04x flags=%02x rslen=%zu rqlen=%zu\n", in wilco_ec_mailbox()
210 mutex_lock(&ec->mailbox_lock); in wilco_ec_mailbox()
212 rq = ec->data_buffer; in wilco_ec_mailbox()
215 ret = wilco_ec_transfer(ec, msg, rq); in wilco_ec_mailbox()
216 mutex_unlock(&ec->mailbox_lock); in wilco_ec_mailbox()