diff --git a/boards/shields/link_board_eth/link_board_eth.overlay b/boards/shields/link_board_eth/link_board_eth.overlay index f157f89dc9f68..90cb78db509e7 100644 --- a/boards/shields/link_board_eth/link_board_eth.overlay +++ b/boards/shields/link_board_eth/link_board_eth.overlay @@ -11,7 +11,7 @@ enc424j600@0 { compatible = "microchip,enc424j600"; spi-max-frequency = <14000000>; - int-gpios = <&arduino_header 15 0>; /* D9 */ + int-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ status = "okay"; label = "ETH_0"; reg = <0>; diff --git a/drivers/ethernet/eth_enc28j60.c b/drivers/ethernet/eth_enc28j60.c index abe4e44cd217d..adc7939b08380 100644 --- a/drivers/ethernet/eth_enc28j60.c +++ b/drivers/ethernet/eth_enc28j60.c @@ -694,10 +694,8 @@ static int eth_enc28j60_init(struct device *dev) } if (gpio_pin_configure(context->gpio, config->gpio_pin, - (GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE - | GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE))) { - LOG_ERR("Unable to configure GPIO pin %u", - config->gpio_pin); + GPIO_INPUT | config->gpio_flags)) { + LOG_ERR("Unable to configure GPIO pin %u", config->gpio_pin); return -EINVAL; } @@ -708,9 +706,9 @@ static int eth_enc28j60_init(struct device *dev) return -EINVAL; } - if (gpio_pin_enable_callback(context->gpio, config->gpio_pin)) { - return -EINVAL; - } + gpio_pin_interrupt_configure(context->gpio, + config->gpio_pin, + GPIO_INT_EDGE_TO_ACTIVE); if (eth_enc28j60_soft_reset(dev)) { LOG_ERR("Soft-reset failed"); @@ -763,6 +761,7 @@ static struct eth_enc28j60_runtime eth_enc28j60_0_runtime = { static const struct eth_enc28j60_config eth_enc28j60_0_config = { .gpio_port = DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_CONTROLLER, .gpio_pin = DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_PIN, + .gpio_flags = DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_FLAGS, .spi_port = DT_INST_0_MICROCHIP_ENC28J60_BUS_NAME, .spi_freq = DT_INST_0_MICROCHIP_ENC28J60_SPI_MAX_FREQUENCY, .spi_slave = DT_INST_0_MICROCHIP_ENC28J60_BASE_ADDRESS, diff --git a/drivers/ethernet/eth_enc28j60_priv.h b/drivers/ethernet/eth_enc28j60_priv.h index dbbb356cec714..a0fff3b7003bc 100644 --- a/drivers/ethernet/eth_enc28j60_priv.h +++ b/drivers/ethernet/eth_enc28j60_priv.h @@ -216,6 +216,7 @@ struct eth_enc28j60_config { const char *gpio_port; u8_t gpio_pin; + gpio_devicetree_flags_t gpio_flags; const char *spi_port; u8_t spi_cs_pin; const char *spi_cs_port; diff --git a/drivers/ethernet/eth_enc424j600.c b/drivers/ethernet/eth_enc424j600.c index 792d174076eaf..aafaba95f0b54 100644 --- a/drivers/ethernet/eth_enc424j600.c +++ b/drivers/ethernet/eth_enc424j600.c @@ -630,10 +630,8 @@ static int enc424j600_init(struct device *dev) } if (gpio_pin_configure(context->gpio, config->gpio_pin, - (GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE - | GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE))) { - LOG_ERR("Unable to configure GPIO pin %u", - config->gpio_pin); + GPIO_INPUT | config->gpio_flags)) { + LOG_ERR("Unable to configure GPIO pin %u", config->gpio_pin); return -EINVAL; } @@ -644,9 +642,9 @@ static int enc424j600_init(struct device *dev) return -EINVAL; } - if (gpio_pin_enable_callback(context->gpio, config->gpio_pin)) { - return -EINVAL; - } + gpio_pin_interrupt_configure(context->gpio, + config->gpio_pin, + GPIO_INT_EDGE_TO_ACTIVE); /* Check SPI connection */ do { @@ -756,6 +754,7 @@ static struct enc424j600_runtime enc424j600_0_runtime = { static const struct enc424j600_config enc424j600_0_config = { .gpio_port = DT_INST_0_MICROCHIP_ENC424J600_INT_GPIOS_CONTROLLER, .gpio_pin = DT_INST_0_MICROCHIP_ENC424J600_INT_GPIOS_PIN, + .gpio_flags = DT_INST_0_MICROCHIP_ENC424J600_INT_GPIOS_FLAGS, .spi_port = DT_INST_0_MICROCHIP_ENC424J600_BUS_NAME, .spi_freq = DT_INST_0_MICROCHIP_ENC424J600_SPI_MAX_FREQUENCY, .spi_slave = DT_INST_0_MICROCHIP_ENC424J600_BASE_ADDRESS, diff --git a/drivers/ethernet/eth_enc424j600_priv.h b/drivers/ethernet/eth_enc424j600_priv.h index 2fdba54b95bed..304000341164e 100644 --- a/drivers/ethernet/eth_enc424j600_priv.h +++ b/drivers/ethernet/eth_enc424j600_priv.h @@ -275,6 +275,7 @@ struct enc424j600_config { const char *gpio_port; u8_t gpio_pin; + gpio_devicetree_flags_t gpio_flags; const char *spi_port; u8_t spi_cs_pin; const char *spi_cs_port; diff --git a/dts/bindings/ethernet/microchip,enc28j60.yaml b/dts/bindings/ethernet/microchip,enc28j60.yaml index 8a285339767c4..9e500e4b7d5cd 100644 --- a/dts/bindings/ethernet/microchip,enc28j60.yaml +++ b/dts/bindings/ethernet/microchip,enc28j60.yaml @@ -11,3 +11,8 @@ properties: int-gpios: type: phandle-array required: true + description: Interrupt pin. + + The interrupt pin of ENC28J60 is active low. + If connected directly the MCU pin should be configured + as active low. diff --git a/dts/bindings/ethernet/microchip,enc424j600.yaml b/dts/bindings/ethernet/microchip,enc424j600.yaml index e890f29245fc9..db1d5d7cdc5f6 100644 --- a/dts/bindings/ethernet/microchip,enc424j600.yaml +++ b/dts/bindings/ethernet/microchip,enc424j600.yaml @@ -12,3 +12,8 @@ properties: int-gpios: type: phandle-array required: true + description: Interrupt pin. + + The interrupt pin of ENC424J600 is active low. + If connected directly the MCU pin should be configured + as active low.