From 3a8d8b16790ea15bceec6e11d3ed091f5462ce44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Barna=C5=9B?= Date: Tue, 19 Jan 2021 18:55:50 +0100 Subject: ioexpander: Add support to read levels on whole IOEX port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases it's needed to read many pins on the same IOEX port. To improve performance and remove redundant calls, it will be easier to read levels on whole IOEX port. To enable this functionality, CONFIG_IO_EXPANDER_SUPPORT_GET_PORT must be defined and driver must support it. BUG=b:168385201 BRANCH=main Signed-off-by: Michał Barnaś Change-Id: I472385a4ef4f5db23ce92d017194f8c737b7607e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2700295 Reviewed-by: Aseda Aboagye --- include/config.h | 7 +++++++ include/ioexpander.h | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'include') diff --git a/include/config.h b/include/config.h index 4b7a0bedbd..e9e3105e5f 100644 --- a/include/config.h +++ b/include/config.h @@ -1467,6 +1467,13 @@ */ #undef CONFIG_IO_EXPANDER +/* + * Enable reading levels for whole IO expander port with one call. + * This adds 'get_port' function pointer to 'ioexpander_drv' structure. + * Most drivers don't implement this functionality. + */ +#undef CONFIG_IO_EXPANDER_SUPPORT_GET_PORT + /* * EC's supporting powering down GPIO pins. * Add flag GPIO_POWER_DOWN and additional API's. diff --git a/include/ioexpander.h b/include/ioexpander.h index c04cf83c9a..e952e373a7 100644 --- a/include/ioexpander.h +++ b/include/ioexpander.h @@ -32,6 +32,9 @@ extern const struct ioex_info ioex_list[]; extern void (* const ioex_irq_handlers[])(enum ioex_signal signal); extern const int ioex_ih_count; +/* Get ioex_info structure for specified signal */ +#define IOEX_GET_INFO(signal) (ioex_list + (signal) - IOEX_SIGNAL_START) + struct ioexpander_drv { /* Initialize IO expander chip/driver */ int (*init)(int ioex); @@ -45,6 +48,10 @@ struct ioexpander_drv { int (*set_flags_by_mask)(int ioex, int port, int mask, int flags); /* Enable/disable interrupt for the IOEX pin */ int (*enable_interrupt)(int ioex, int port, int mask, int enable); +#ifdef CONFIG_IO_EXPANDER_SUPPORT_GET_PORT + /* Read levels for whole IOEX port */ + int (*get_port)(int ioex, int port, int *val); +#endif }; /* IO expander chip disabled. No I2C communication will be attempted. */ @@ -118,6 +125,18 @@ int ioex_get_level(enum ioex_signal signal, int *val); */ int ioex_set_level(enum ioex_signal signal, int value); +#ifdef CONFIG_IO_EXPANDER_SUPPORT_GET_PORT +/* + * Get the current levels on the IOEX port + * + * @param ioex Number of I/O expander + * @param port Number of port in ioex + * @param val Pointer to variable where port will be read + * @return EC_SUCCESS if successful, non-zero if error. + */ +int ioex_get_port(int ioex, int port, int *val); +#endif + /* * Initialize IO expander chip/driver * -- cgit v1.2.1