Skip to content

Commit 659344d

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 c2b1c41 commit 659344d

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
@@ -690,6 +690,19 @@ static int lan9250_init(const struct device *dev)
690690

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

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

0 commit comments

Comments
 (0)