Skip to content

Commit c5e45ea

Browse files
committed
drivers: ethernet: lan9250: add in the reset gpio configurate
The reset gpio field was in the config structure but was not coded into the initialization path. So, add the appropriate code to handle the gpio setup when it is defined in the device tree. Signed-off-by: Charles Hardin <ckhardin@gmail.com>
1 parent 7490d9c commit c5e45ea

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/ethernet/eth_lan9250.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,19 @@ static int lan9250_init(const struct device *dev)
691691

692692
gpio_pin_interrupt_configure_dt(&config->interrupt, GPIO_INT_EDGE_TO_ACTIVE);
693693

694+
if (config->reset.port) {
695+
if (!gpio_is_ready_dt(&config->reset)) {
696+
LOG_ERR("GPIO port %s not ready", config->reset.port->name);
697+
return -EINVAL;
698+
}
699+
if (gpio_pin_configure_dt(&config->reset, GPIO_OUTPUT)) {
700+
LOG_ERR("Unable to configure GPIO pin %u", config->reset.pin);
701+
return -EINVAL;
702+
}
703+
gpio_pin_set_dt(&config->reset, 0);
704+
k_usleep(500);
705+
}
706+
694707
/* Reset and wait for ready on the LAN9250 SPI device */
695708
ret = lan9250_sw_reset(dev);
696709
if (ret < 0) {
@@ -727,6 +740,7 @@ static int lan9250_init(const struct device *dev)
727740
static const struct lan9250_config lan9250_##inst##_config = { \
728741
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8)), \
729742
.interrupt = GPIO_DT_SPEC_INST_GET(inst, int_gpios), \
743+
.reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}), \
730744
.timeout = CONFIG_ETH_LAN9250_BUF_ALLOC_TIMEOUT, \
731745
.random_mac = DT_INST_PROP(inst, zephyr_random_mac_address), \
732746
}; \

0 commit comments

Comments
 (0)