diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/backlight.h | 5 | ||||
-rw-r--r-- | include/chipset.h | 4 | ||||
-rw-r--r-- | include/gpio.h | 25 | ||||
-rw-r--r-- | include/gpio.wrap | 26 | ||||
-rw-r--r-- | include/gpio_list.h | 29 | ||||
-rw-r--r-- | include/gpio_signal.h | 8 | ||||
-rw-r--r-- | include/jtag.h | 6 | ||||
-rw-r--r-- | include/keyboard_raw.h | 4 | ||||
-rw-r--r-- | include/power.h | 4 | ||||
-rw-r--r-- | include/switch.h | 4 | ||||
-rw-r--r-- | include/uart.h | 5 |
11 files changed, 85 insertions, 35 deletions
diff --git a/include/backlight.h b/include/backlight.h index be905d0f47..4a11e15a4a 100644 --- a/include/backlight.h +++ b/include/backlight.h @@ -9,6 +9,7 @@ #define __CROS_EC_BACKLIGHT_H #include "common.h" +#include "gpio.h" /** * Interrupt handler for backlight. @@ -18,7 +19,7 @@ #ifdef CONFIG_BACKLIGHT_REQ_GPIO void backlight_interrupt(enum gpio_signal signal); #else -#define backlight_interrupt NULL -#endif +static inline void backlight_interrupt(enum gpio_signal signal) { } +#endif /* !CONFIG_BACKLIGHT_REQ_GPIO */ #endif /* __CROS_EC_BACKLIGHT_H */ diff --git a/include/chipset.h b/include/chipset.h index 952c243663..0237767fbf 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -14,6 +14,7 @@ #define __CROS_EC_CHIPSET_H #include "common.h" +#include "gpio.h" /* * Chipset state mask @@ -95,8 +96,7 @@ static inline void chipset_exit_hard_off(void) { } static inline void chipset_throttle_cpu(int throttle) { } static inline void chipset_force_shutdown(void) { } static inline void chipset_reset(int cold_reset) { } - -#define power_interrupt NULL +static inline void power_interrupt(enum gpio_signal signal) { } #endif /* !HAS_TASK_CHIPSET */ diff --git a/include/gpio.h b/include/gpio.h index f71622dfe6..0441ff6096 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -45,6 +45,15 @@ #define GPIO_INT_ANY (GPIO_INT_BOTH | GPIO_INT_LEVEL) #define GPIO_INT_BOTH_DSLEEP (GPIO_INT_BOTH | GPIO_INT_DSLEEP) +/* NOTE: This is normally included from board.h, thru config.h and common.h But, + * some boards and unit tests don't have a gpio_signal enum defined, so we + * define an emtpy one here.*/ +#ifndef __CROS_EC_GPIO_SIGNAL_H +enum gpio_signal { + NULL +}; +#endif /* __CROS_EC_GPIO_SIGNAL_H */ + /* GPIO signal definition structure, for use by board.c */ struct gpio_info { /* Signal name */ @@ -58,18 +67,20 @@ struct gpio_info { /* Flags (GPIO_*; see above) */ uint32_t flags; - - /* - * Interrupt handler. If non-NULL, and the signal's interrupt is - * enabled, this will be called in the context of the GPIO interrupt - * handler. - */ - void (*irq_handler)(enum gpio_signal signal); }; /* Signal information from board.c. Must match order from enum gpio_signal. */ extern const struct gpio_info gpio_list[]; +/* Interrupt handler table for those GPIOs which have IRQ handlers. + * + * If the signal's interrupt is enabled, this will be called in the + * context of the GPIO interrupt handler. + */ +extern void (* const gpio_irq_handlers[])(enum gpio_signal signal); +extern const int gpio_ih_count; +#define GPIO_IH_COUNT gpio_ih_count + /* GPIO alternate function structure, for use by board.c */ struct gpio_alt_func { /* Port base address */ diff --git a/include/gpio.wrap b/include/gpio.wrap index cf4fbb319a..1eb9f3643e 100644 --- a/include/gpio.wrap +++ b/include/gpio.wrap @@ -8,15 +8,26 @@ /* * The GPIO macro is used to define a new GPIO pin name and function. * - * The name is used to populate the gpio_signal enum by first prepending GPIO_ - * to the name. It is also used to construct the string name that is presented - * in the shell interface. Similarly, the port parameter has GPIO_ prepended to - * it before it is used to initialize the port base address of a gpio_info - * struct. The pin number is used to create a bitmask. The flags and signal - * parameters are passed on to the gpio_info directly. + * The name is used to populate the gpio_signal enum by first + * prepending GPIO_ to the name. It is also used to construct the + * string name that is presented in the shell interface. Similarly, + * the port parameter has GPIO_ prepended to it before it is used to + * initialize the port base address of a gpio_info struct. The pin + * number is used to create a bitmask. The flags parameter is passed + * on to the gpio_info directly. */ #ifndef GPIO -#define GPIO(name, port, pin, flags, signal) +#define GPIO(name, port, pin, flags) +#endif + +/* + * The GPIO_INT macro is used to define a GPIOs that have an IRQ handler. + * + * The IRQ handler pointers are stored as elements in the gpio_irq_handlers + * array. + */ +#ifndef GPIO_INT +#define GPIO_INT(name, port, pin, flags, signal) #endif /* @@ -61,5 +72,6 @@ * Once the gpio.inc file has been included these macros are no longer needed. */ #undef GPIO +#undef GPIO_INT #undef ALTERNATE #undef UNIMPLEMENTED diff --git a/include/gpio_list.h b/include/gpio_list.h index c7e2962747..c9bdd5668d 100644 --- a/include/gpio_list.h +++ b/include/gpio_list.h @@ -3,17 +3,21 @@ * found in the LICENSE file. */ +#include "gpio_signal.h" + #ifdef CONFIG_COMMON_GPIO_SHORTNAMES -#define GPIO(name, port, pin, flags, signal) \ - {#port#pin, GPIO_##port, (1 << pin), flags, signal}, +#define GPIO(name, port, pin, flags) \ + {#port#pin, GPIO_##port, (1 << pin), flags}, #else -#define GPIO(name, port, pin, flags, signal) \ - {#name, GPIO_##port, (1 << pin), flags, signal}, +#define GPIO(name, port, pin, flags) \ + {#name, GPIO_##port, (1 << pin), flags}, #endif #define UNIMPLEMENTED(name) \ - {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT, NULL}, + {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT}, +#define GPIO_INT(name, port, pin, flags, signal) \ + GPIO(name, port, pin, flags) /* GPIO signal list. */ const struct gpio_info gpio_list[] = { #include "gpio.wrap" @@ -33,3 +37,18 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + +/* GPIO Interrupt Handlers */ +#define GPIO_INT(name, port, pin, flags, signal) signal, +void (* const gpio_irq_handlers[])(enum gpio_signal signal) = { + #include "gpio.wrap" +}; +const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers); + +/* + * ALL GPIOs with interrupt handlers must be declared at the top of the gpio.inc + * file. + */ +#define GPIO_INT(name, port, pin, flags, signal) \ + BUILD_ASSERT(GPIO_##name < ARRAY_SIZE(gpio_irq_handlers)); +#include "gpio.wrap" diff --git a/include/gpio_signal.h b/include/gpio_signal.h index 83e9dfe6fa..bcec1b522f 100644 --- a/include/gpio_signal.h +++ b/include/gpio_signal.h @@ -3,10 +3,16 @@ * found in the LICENSE file. */ -#define GPIO(name, port, pin, flags, signal) GPIO_##name, +#ifndef __CROS_EC_GPIO_SIGNAL_H +#define __CROS_EC_GPIO_SIGNAL_H + +#define GPIO(name, port, pin, flags) GPIO_##name, #define UNIMPLEMENTED(name) GPIO_##name, +#define GPIO_INT(name, port, pin, flags, signal) GPIO_##name, enum gpio_signal { #include "gpio.wrap" GPIO_COUNT }; + +#endif /* __CROS_EC_GPIO_SIGNAL_H */ diff --git a/include/jtag.h b/include/jtag.h index 9c7835dfd0..cf927c2e2d 100644 --- a/include/jtag.h +++ b/include/jtag.h @@ -9,6 +9,7 @@ #define __CROS_EC_JTAG_H #include "common.h" +#include "gpio.h" /** * Pre-initialize the JTAG module. @@ -23,8 +24,7 @@ void jtag_pre_init(void); */ void jtag_interrupt(enum gpio_signal signal); #else -#define jtag_interrupt NULL -#endif - +static inline void jtag_interrupt(enum gpio_signal signal) { } +#endif /* !CONFIG_LOW_POWER_IDLE */ #endif /* __CROS_EC_JTAG_H */ diff --git a/include/keyboard_raw.h b/include/keyboard_raw.h index 9bdd1cce8f..8591700b47 100644 --- a/include/keyboard_raw.h +++ b/include/keyboard_raw.h @@ -68,7 +68,7 @@ void keyboard_raw_enable_interrupt(int enable); void keyboard_raw_gpio_interrupt(enum gpio_signal signal); #else -#define keyboard_raw_gpio_interrupt NULL -#endif +static inline void keyboard_raw_gpio_interrupt(enum gpio_signal signal) { } +#endif /* !HAS_TASK_KEYSCAN */ #endif /* __CROS_EC_KEYBOARD_RAW_H */ diff --git a/include/power.h b/include/power.h index 36054e8bd1..8f11c14868 100644 --- a/include/power.h +++ b/include/power.h @@ -100,7 +100,7 @@ enum power_state power_handle_state(enum power_state state); #ifdef HAS_TASK_CHIPSET void power_signal_interrupt(enum gpio_signal signal); #else -#define power_signal_interrupt NULL -#endif +static inline void power_signal_interrupt(enum gpio_signal signal) { } +#endif /* !HAS_TASK_CHIPSET */ #endif /* __CROS_EC_POWER_H */ diff --git a/include/switch.h b/include/switch.h index f59e56df52..c2b67393d0 100644 --- a/include/switch.h +++ b/include/switch.h @@ -19,7 +19,7 @@ */ void switch_interrupt(enum gpio_signal signal); #else -#define switch_interrupt NULL -#endif /* CONFIG_SWITCH */ +static inline void switch_interrupt(enum gpio_signal signal) { } +#endif /* !CONFIG_SWITCH */ #endif /* __CROS_EC_SWITCH_H */ diff --git a/include/uart.h b/include/uart.h index 6128962726..6499eb9453 100644 --- a/include/uart.h +++ b/include/uart.h @@ -10,6 +10,7 @@ #include <stdarg.h> /* For va_list */ #include "common.h" +#include "gpio.h" /** * Initialize the UART module. @@ -224,8 +225,8 @@ void uart_exit_dsleep(void); */ void uart_deepsleep_interrupt(enum gpio_signal signal); #else -#define uart_deepsleep_interrupt NULL -#endif +static inline void uart_deepsleep_interrupt(enum gpio_signal signal) { } +#endif /* !CONFIG_LOW_POWER_IDLE */ #ifdef CONFIG_UART_INPUT_FILTER /** |