diff options
author | Michał Barnaś <mb@semihalf.com> | 2021-01-19 18:55:50 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-23 19:12:32 +0000 |
commit | 3a8d8b16790ea15bceec6e11d3ed091f5462ce44 (patch) | |
tree | 2ac4ce6dab7f884f1174533b8b953ca9551083d5 | |
parent | 4057eedf924fd5d3a9850b3d9ae8ed749474bc5e (diff) | |
download | chrome-ec-3a8d8b16790ea15bceec6e11d3ed091f5462ce44.tar.gz |
ioexpander: Add support to read levels on whole IOEX port
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ś <mb@semihalf.com>
Change-Id: I472385a4ef4f5db23ce92d017194f8c737b7607e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2700295
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/ioexpander.c | 10 | ||||
-rw-r--r-- | include/config.h | 7 | ||||
-rw-r--r-- | include/ioexpander.h | 19 |
3 files changed, 36 insertions, 0 deletions
diff --git a/common/ioexpander.c b/common/ioexpander.c index 1e3f22764b..ccf3cc7c4a 100644 --- a/common/ioexpander.c +++ b/common/ioexpander.c @@ -152,6 +152,16 @@ int ioex_set_level(enum ioex_signal signal, int value) g->mask, value); } +#ifdef CONFIG_IO_EXPANDER_SUPPORT_GET_PORT +int ioex_get_port(int ioex, int port, int *val) +{ + if (ioex_config[ioex].drv->get_port == NULL) + return EC_ERROR_UNIMPLEMENTED; + + return ioex_config[ioex].drv->get_port(ioex, port, val); +} +#endif + int ioex_init(int ioex) { const struct ioex_info *g = ioex_list; diff --git a/include/config.h b/include/config.h index 4b7a0bedbd..e9e3105e5f 100644 --- a/include/config.h +++ b/include/config.h @@ -1468,6 +1468,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 * |