diff options
author | CHLin <CHLIN56@nuvoton.com> | 2019-08-05 15:02:19 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-20 18:12:14 +0000 |
commit | 5040fdcc897188ad674b0503bf31d5c26f9f76d4 (patch) | |
tree | 646e5033fcf570b1a4d3267280ba2ee31813e747 /include/gpio_list.h | |
parent | 8aaeb9fd05ab185a7807f3650e491d2c3042637a (diff) | |
download | chrome-ec-5040fdcc897188ad674b0503bf31d5c26f9f76d4.tar.gz |
IO Expander: add the interrupt support to IOEX framework
This CL creates interfaces which bring the IOEX framework to support
interrupt feature.
To declare an IOEX IO which supports the interrupt function, file its
declaration in gpio.inc with the format:
IOEX_INT(name, expin, flags, signal)
Note: like GPIO, all IOEX IOs with interrupt handlers must be declared
at the top of the IOEX's declaration in the gpio.inc
The following two APIs are added to enable/disable each IOEX IO's
interrupt function:
1. ioex_enable_interrupt
2. ioex_disable_interrupt
BRANCH=none
BUG=none
TEST=No error for "make buildall"
TEST=Apply this and related CLs, manually test each IO pins; make sure
each pin's interrupt handler is correctly executed.
Change-Id: Icbf54c09120e37b68c647c884cd6aa28d9313167
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1734947
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: CH Lin <chlin56@nuvoton.com>
Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'include/gpio_list.h')
-rw-r--r-- | include/gpio_list.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/include/gpio_list.h b/include/gpio_list.h index 4fed0d60d6..180841bb9b 100644 --- a/include/gpio_list.h +++ b/include/gpio_list.h @@ -54,6 +54,8 @@ const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers); #include "gpio.wrap" #include "ioexpander.h" +#define IOEX_EXPIN(ioex, port, index) (ioex), (port), BIT(index) + /* * Define the IO expander IO in gpio.inc by the format: * IOEX(name, EXPIN(ioex_port, port, offset), flags) @@ -66,9 +68,21 @@ const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers); * - flags: the same as the flags of GPIO. * */ -#define IOEX_EXPIN(ioex, port, index) (ioex), (port), BIT(index) - #define IOEX(name, expin, flags) {#name, IOEX_##expin, flags}, +/* + * Define the IO expander IO which supports interrupt in gpio.inc by + * the format: + * IOEX_INT(name, EXPIN(ioex_port, port, offset), flags, handler) + * - name: the name of this IO pin + * - EXPIN(ioex, port, offset) + * - ioex: the IO expander port (defined in board.c) this IO + * pin belongs to. + * - port: the port number in the IO expander chip. + * - offset: the bit offset in the port above. + * - flags: the same as the flags of GPIO. + * - handler: the IOEX IO's interrupt handler. + */ +#define IOEX_INT(name, expin, flags, handler) IOEX(name, expin, flags) /* IO expander signal list. */ const struct ioex_info ioex_list[] = { @@ -76,7 +90,23 @@ const struct ioex_info ioex_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(ioex_list) == IOEX_COUNT); +/* IO Expander Interrupt Handlers */ +#define IOEX_INT(name, expin, flags, handler) handler, +void (* const ioex_irq_handlers[])(enum ioex_signal signal) = { + #include "gpio.wrap" +}; +const int ioex_ih_count = ARRAY_SIZE(ioex_irq_handlers); +/* + * All IOEX IOs with interrupt handlers must be declared at the top of the + * IOEX's declaration in the gpio.inc + * file. + */ +#define IOEX_INT(name, expin, flags, handler) \ + BUILD_ASSERT(IOEX_##name < ARRAY_SIZE(ioex_irq_handlers)); +#include "gpio.wrap" + #define IOEX(name, expin, flags) expin +#define IOEX_INT(name, expin, flags, handler) expin /* The compiler will complain if we use the same name twice or the controller * number declared is greater or equal to CONFIG_IO_EXPANDER_PORT_COUNT. |