drivers: enc424j600: convert to new GPIO API
Convert ENC424J600 controller driver to new GPIO API.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
diff --git a/boards/shields/link_board_eth/link_board_eth.overlay b/boards/shields/link_board_eth/link_board_eth.overlay
index f157f89..90cb78d 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_enc424j600.c b/drivers/ethernet/eth_enc424j600.c
index 792d174..aafaba9 100644
--- a/drivers/ethernet/eth_enc424j600.c
+++ b/drivers/ethernet/eth_enc424j600.c
@@ -630,10 +630,8 @@
}
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 @@
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 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 2fdba54..3040003 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,enc424j600.yaml b/dts/bindings/ethernet/microchip,enc424j600.yaml
index e890f29..db1d5d7 100644
--- a/dts/bindings/ethernet/microchip,enc424j600.yaml
+++ b/dts/bindings/ethernet/microchip,enc424j600.yaml
@@ -12,3 +12,8 @@
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.