Skip to content

Commit fdaa24c

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 b6e44a4 commit fdaa24c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/ethernet/eth_lan9250.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,27 @@ 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+
704+
/* See Section 19.6.3 from the LAN9250 Data Sheet
705+
*
706+
* trstia is 200 microseconds min (use 250 us)
707+
* tcfg is 15 milliseconds min (use 20 ms for after reset)
708+
*/
709+
gpio_pin_set_dt(&config->reset, 1);
710+
k_usleep(250);
711+
gpio_pin_set_dt(&config->reset, 0);
712+
k_msleep(20);
713+
}
714+
694715
/* Reset and wait for ready on the LAN9250 SPI device */
695716
ret = lan9250_sw_reset(dev);
696717
if (ret < 0) {
@@ -727,6 +748,7 @@ static int lan9250_init(const struct device *dev)
727748
static const struct lan9250_config lan9250_##inst##_config = { \
728749
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8)), \
729750
.interrupt = GPIO_DT_SPEC_INST_GET(inst, int_gpios), \
751+
.reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}), \
730752
.timeout = CONFIG_ETH_LAN9250_BUF_ALLOC_TIMEOUT, \
731753
.random_mac = DT_INST_PROP(inst, zephyr_random_mac_address), \
732754
}; \

0 commit comments

Comments
 (0)