summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/ioexpander.c10
-rw-r--r--include/config.h7
-rw-r--r--include/ioexpander.h19
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
*