drivers: gpio_intel_apl: add support for pin validation

Add the common config structure as a prefix of the driver-specific
config structure and use the hard-coded device-specific pin count to
initialize it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2019-12-11 10:39:04 -06:00 committed by Carles Cufí
commit 8236d8209a

View file

@ -102,6 +102,8 @@ BUILD_ASSERT(DT_INST_0_INTEL_APL_GPIO_IRQ_0 == 14);
#define PAD_CFG1_IOSSTATE_IGNORE (0x0F << PAD_CFG1_IOSSTATE_POS)
struct gpio_intel_apl_config {
/* gpio_driver_config needs to be first */
struct gpio_driver_config common;
u32_t reg_base;
u8_t pin_offset;
@ -653,6 +655,9 @@ int gpio_intel_apl_init(struct device *dev)
#define GPIO_INTEL_APL_DEV_CFG_DATA(dir_l, dir_u, pos) \
static const struct gpio_intel_apl_config \
gpio_intel_apl_cfg_##dir_l##_##pos = { \
.common = { \
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_ALIAS_GPIO_##dir_u##_##pos##_NGPIOS), \
}, \
.reg_base = (DT_ALIAS_GPIO_##dir_u##_##pos##_BASE_ADDRESS \
& 0xFFFFFF00), \
.pin_offset = DT_ALIAS_GPIO_##dir_u##_##pos##_PIN_OFFSET, \