Skip to content

Commit f0705d6

Browse files
committed
drivers: ethernet: eth_lan865x: Support MAC address config
Update the microchip,lan9250 ethernet driver to use a MAC address configuration struct. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 7670121 commit f0705d6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/ethernet/eth_lan9250.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,15 @@ static int lan9250_init(const struct device *dev)
697697
return ret;
698698
}
699699
lan9250_configure(dev);
700+
701+
ret = net_eth_mac_load(&config->mac_cfg, context->mac_address);
702+
if (ret == -ENODATA) {
703+
LOG_WRN("No MAC address configured for %s", dev->name);
704+
} else if (ret < 0) {
705+
LOG_ERR("Failed to load MAC address (%d)", ret);
706+
return ret;
707+
}
708+
700709
lan9250_set_macaddr(dev);
701710

702711
k_thread_create(&context->thread, context->thread_stack,
@@ -710,7 +719,6 @@ static int lan9250_init(const struct device *dev)
710719

711720
#define LAN9250_DEFINE(inst) \
712721
static struct lan9250_runtime lan9250_##inst##_runtime = { \
713-
.mac_address = DT_INST_PROP_OR(inst, local_mac_address, {0}), \
714722
.tx_rx_sem = Z_SEM_INITIALIZER(lan9250_##inst##_runtime.tx_rx_sem, 1, UINT_MAX), \
715723
.int_sem = Z_SEM_INITIALIZER(lan9250_##inst##_runtime.int_sem, 0, UINT_MAX), \
716724
}; \
@@ -719,6 +727,7 @@ static int lan9250_init(const struct device *dev)
719727
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8)), \
720728
.interrupt = GPIO_DT_SPEC_INST_GET(inst, int_gpios), \
721729
.timeout = CONFIG_ETH_LAN9250_BUF_ALLOC_TIMEOUT, \
730+
.mac_cfg = NET_ETH_MAC_DT_INST_CONFIG_INIT(inst), \
722731
}; \
723732
\
724733
ETH_NET_DEVICE_DT_INST_DEFINE(inst, lan9250_init, NULL, &lan9250_##inst##_runtime, \

drivers/ethernet/eth_lan9250_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <zephyr/kernel.h>
99
#include <zephyr/drivers/gpio.h>
1010
#include <zephyr/drivers/spi.h>
11+
#include <zephyr/net/ethernet.h>
1112

1213
#ifndef _LAN9250_
1314
#define _LAN9250_
@@ -312,6 +313,7 @@ struct lan9250_config {
312313
struct gpio_dt_spec reset;
313314
uint8_t full_duplex;
314315
int32_t timeout;
316+
struct net_eth_mac_config mac_cfg;
315317
};
316318

317319
struct lan9250_runtime {

0 commit comments

Comments
 (0)