drivers: gpio_mcux: 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:
parent
5eebc35d8b
commit
56f975fbb4
1 changed files with 17 additions and 0 deletions
|
@ -15,6 +15,8 @@
|
|||
#include "gpio_utils.h"
|
||||
|
||||
struct gpio_mcux_config {
|
||||
/* gpio_driver_config needs to be first */
|
||||
struct gpio_driver_config common;
|
||||
GPIO_Type *gpio_base;
|
||||
PORT_Type *port_base;
|
||||
unsigned int flags;
|
||||
|
@ -350,6 +352,9 @@ static const struct gpio_driver_api gpio_mcux_driver_api = {
|
|||
static int gpio_mcux_porta_init(struct device *dev);
|
||||
|
||||
static const struct gpio_mcux_config gpio_mcux_porta_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_0_NXP_KINETIS_GPIO_NGPIOS),
|
||||
},
|
||||
.gpio_base = (GPIO_Type *) DT_NXP_KINETIS_GPIO_GPIO_A_BASE_ADDRESS,
|
||||
.port_base = PORTA,
|
||||
#ifdef DT_NXP_KINETIS_GPIO_GPIO_A_IRQ_0
|
||||
|
@ -383,6 +388,9 @@ static int gpio_mcux_porta_init(struct device *dev)
|
|||
static int gpio_mcux_portb_init(struct device *dev);
|
||||
|
||||
static const struct gpio_mcux_config gpio_mcux_portb_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_1_NXP_KINETIS_GPIO_NGPIOS),
|
||||
},
|
||||
.gpio_base = (GPIO_Type *) DT_NXP_KINETIS_GPIO_GPIO_B_BASE_ADDRESS,
|
||||
.port_base = PORTB,
|
||||
#ifdef DT_NXP_KINETIS_GPIO_GPIO_B_IRQ_0
|
||||
|
@ -416,6 +424,9 @@ static int gpio_mcux_portb_init(struct device *dev)
|
|||
static int gpio_mcux_portc_init(struct device *dev);
|
||||
|
||||
static const struct gpio_mcux_config gpio_mcux_portc_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_2_NXP_KINETIS_GPIO_NGPIOS),
|
||||
},
|
||||
.gpio_base = (GPIO_Type *) DT_NXP_KINETIS_GPIO_GPIO_C_BASE_ADDRESS,
|
||||
.port_base = PORTC,
|
||||
#ifdef DT_NXP_KINETIS_GPIO_GPIO_C_IRQ_0
|
||||
|
@ -449,6 +460,9 @@ static int gpio_mcux_portc_init(struct device *dev)
|
|||
static int gpio_mcux_portd_init(struct device *dev);
|
||||
|
||||
static const struct gpio_mcux_config gpio_mcux_portd_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_3_NXP_KINETIS_GPIO_NGPIOS),
|
||||
},
|
||||
.gpio_base = (GPIO_Type *) DT_NXP_KINETIS_GPIO_GPIO_D_BASE_ADDRESS,
|
||||
.port_base = PORTD,
|
||||
#ifdef DT_NXP_KINETIS_GPIO_GPIO_D_IRQ_0
|
||||
|
@ -482,6 +496,9 @@ static int gpio_mcux_portd_init(struct device *dev)
|
|||
static int gpio_mcux_porte_init(struct device *dev);
|
||||
|
||||
static const struct gpio_mcux_config gpio_mcux_porte_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_4_NXP_KINETIS_GPIO_NGPIOS),
|
||||
},
|
||||
.gpio_base = (GPIO_Type *) DT_NXP_KINETIS_GPIO_GPIO_E_BASE_ADDRESS,
|
||||
.port_base = PORTE,
|
||||
#ifdef DT_NXP_KINETIS_GPIO_GPIO_E_IRQ_0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue