drivers: gpio_sam: 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
afd987fe9f
commit
02676d1b3c
1 changed files with 17 additions and 0 deletions
|
@ -16,6 +16,8 @@
|
|||
typedef void (*config_func_t)(struct device *dev);
|
||||
|
||||
struct gpio_sam_config {
|
||||
/* gpio_driver_config needs to be first */
|
||||
struct gpio_driver_config common;
|
||||
Pio *regs;
|
||||
config_func_t config_func;
|
||||
u32_t periph_id;
|
||||
|
@ -406,6 +408,9 @@ int gpio_sam_init(struct device *dev)
|
|||
static void port_a_sam_config_func(struct device *dev);
|
||||
|
||||
static const struct gpio_sam_config port_a_sam_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_0_ATMEL_SAM_GPIO_NGPIOS),
|
||||
},
|
||||
.regs = (Pio *)DT_GPIO_SAM_PORTA_BASE_ADDRESS,
|
||||
.periph_id = DT_GPIO_SAM_PORTA_PERIPHERAL_ID,
|
||||
.config_func = port_a_sam_config_func,
|
||||
|
@ -431,6 +436,9 @@ static void port_a_sam_config_func(struct device *dev)
|
|||
static void port_b_sam_config_func(struct device *dev);
|
||||
|
||||
static const struct gpio_sam_config port_b_sam_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_1_ATMEL_SAM_GPIO_NGPIOS),
|
||||
},
|
||||
.regs = (Pio *)DT_GPIO_SAM_PORTB_BASE_ADDRESS,
|
||||
.periph_id = DT_GPIO_SAM_PORTB_PERIPHERAL_ID,
|
||||
.config_func = port_b_sam_config_func,
|
||||
|
@ -456,6 +464,9 @@ static void port_b_sam_config_func(struct device *dev)
|
|||
static void port_c_sam_config_func(struct device *dev);
|
||||
|
||||
static const struct gpio_sam_config port_c_sam_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_2_ATMEL_SAM_GPIO_NGPIOS),
|
||||
},
|
||||
.regs = (Pio *)DT_GPIO_SAM_PORTC_BASE_ADDRESS,
|
||||
.periph_id = DT_GPIO_SAM_PORTC_PERIPHERAL_ID,
|
||||
.config_func = port_c_sam_config_func,
|
||||
|
@ -481,6 +492,9 @@ static void port_c_sam_config_func(struct device *dev)
|
|||
static void port_d_sam_config_func(struct device *dev);
|
||||
|
||||
static const struct gpio_sam_config port_d_sam_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_3_ATMEL_SAM_GPIO_NGPIOS),
|
||||
},
|
||||
.regs = (Pio *)DT_GPIO_SAM_PORTD_BASE_ADDRESS,
|
||||
.periph_id = DT_GPIO_SAM_PORTD_PERIPHERAL_ID,
|
||||
.config_func = port_d_sam_config_func,
|
||||
|
@ -506,6 +520,9 @@ static void port_d_sam_config_func(struct device *dev)
|
|||
static void port_e_sam_config_func(struct device *dev);
|
||||
|
||||
static const struct gpio_sam_config port_e_sam_config = {
|
||||
.common = {
|
||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_4_ATMEL_SAM_GPIO_NGPIOS),
|
||||
},
|
||||
.regs = (Pio *)DT_GPIO_SAM_PORTE_BASE_ADDRESS,
|
||||
.periph_id = DT_GPIO_SAM_PORTE_PERIPHERAL_ID,
|
||||
.config_func = port_e_sam_config_func,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue