drivers: gpio_dw: add support for pin validation

Add the common config structure as a prefix of the driver-specific
config structure and use the devicetree GPIO pin counts to initialize
it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2019-12-03 13:15:04 -06:00 committed by Carles Cufí
commit cbe207377e
2 changed files with 14 additions and 0 deletions

View file

@ -642,6 +642,9 @@ static int gpio_dw_initialize(struct device *port)
static void gpio_config_0_irq(struct device *port);
static const struct gpio_dw_config gpio_config_0 = {
.common = {
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_0_SNPS_DESIGNWARE_GPIO_NGPIOS),
},
#ifdef CONFIG_GPIO_DW_0_IRQ_DIRECT
.irq_num = DT_GPIO_DW_0_IRQ,
#endif
@ -701,6 +704,9 @@ static void gpio_config_0_irq(struct device *port)
static void gpio_config_1_irq(struct device *port);
static const struct gpio_dw_config gpio_dw_config_1 = {
.common = {
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_1_SNPS_DESIGNWARE_GPIO_NGPIOS),
},
#ifdef CONFIG_GPIO_DW_1_IRQ_DIRECT
.irq_num = DT_GPIO_DW_1_IRQ,
#endif
@ -759,6 +765,9 @@ static void gpio_config_1_irq(struct device *port)
static void gpio_config_2_irq(struct device *port);
static const struct gpio_dw_config gpio_dw_config_2 = {
.common = {
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_2_SNPS_DESIGNWARE_GPIO_NGPIOS),
},
#ifdef CONFIG_GPIO_DW_2_IRQ_DIRECT
.irq_num = DT_GPIO_DW_2_IRQ,
#endif
@ -817,6 +826,9 @@ static void gpio_config_2_irq(struct device *port)
static void gpio_config_3_irq(struct device *port);
static const struct gpio_dw_config gpio_dw_config_3 = {
.common = {
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_3_SNPS_DESIGNWARE_GPIO_NGPIOS),
},
#ifdef CONFIG_GPIO_DW_3_IRQ_DIRECT
.irq_num = DT_GPIO_DW_3_IRQ,
#endif

View file

@ -18,6 +18,8 @@ extern "C" {
typedef void (*gpio_config_irq_t)(struct device *port);
struct gpio_dw_config {
/* gpio_driver_config needs to be first */
struct gpio_driver_config common;
u32_t bits;
u32_t irq_num; /* set to 0 if GPIO port cannot interrupt */
gpio_config_irq_t config_func;