summaryrefslogtreecommitdiff
path: root/include/linux/platform_data/cros_ec_chardev.h
diff options
context:
space:
mode:
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>2019-09-02 18:08:48 +0200
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>2019-09-12 16:20:54 +0200
commit96a0a80738461d6d2421ae64ee9990b702efd2a6 (patch)
tree2e76f435ee7540f036e20cda22f6197a1c29bce0 /include/linux/platform_data/cros_ec_chardev.h
parent71cddb7097e2b0feb855d7fd7d59afd12cbee4bb (diff)
platform/chrome: cros_ec_chardev: Add a poll handler to receive MKBP events
Allow to poll on the cros_ec device to receive the MKBP events. The /dev/cros_[ec|fp|..] file operations now implements the poll operation. The userspace can now receive specific MKBP events by doing the following: - Open the /dev/cros_XX file. - Call the CROS_EC_DEV_IOCEVENTMASK ioctl with the bitmap of the MKBP events it wishes to receive as argument. - Poll on the file descriptor. - When it gets POLLIN, do a read on the file descriptor, the first queued event will be returned (using the struct ec_response_get_next_event format: one byte of event type, then the payload). The read() operation returns at most one event even if there are several queued, and it might be truncated if the buffer is smaller than the event (but the caller should know the maximum size of the events it is reading). read() used to return the EC version string, it still does it when no event mask or an empty event is set for backward compatibility (despite nobody really using this feature). This will be used, for example, by the userspace daemon to receive and treat the EC_MKBP_EVENT_FINGERPRINT sent by the FP MCU. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'include/linux/platform_data/cros_ec_chardev.h')
-rw-r--r--include/linux/platform_data/cros_ec_chardev.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/platform_data/cros_ec_chardev.h b/include/linux/platform_data/cros_ec_chardev.h
index 973b2615aa02..7de8faaf77df 100644
--- a/include/linux/platform_data/cros_ec_chardev.h
+++ b/include/linux/platform_data/cros_ec_chardev.h
@@ -33,5 +33,6 @@ struct cros_ec_readmem {
#define CROS_EC_DEV_IOC 0xEC
#define CROS_EC_DEV_IOCXCMD _IOWR(CROS_EC_DEV_IOC, 0, struct cros_ec_command)
#define CROS_EC_DEV_IOCRDMEM _IOWR(CROS_EC_DEV_IOC, 1, struct cros_ec_readmem)
+#define CROS_EC_DEV_IOCEVENTMASK _IO(CROS_EC_DEV_IOC, 2)
#endif /* _CROS_EC_DEV_H_ */