Skip to content

Commit ea85a8b

Browse files
pdgendtnashif
authored andcommitted
drivers: ethernet: eth_lan865x: Support MAC address config
Update the microchip,lan865x ethernet driver to use a MAC address configuration struct. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 3da552b commit ea85a8b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/ethernet/eth_lan865x.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ static int lan865x_init(const struct device *dev)
426426
return ret;
427427
}
428428

429+
ret = net_eth_mac_load(&cfg->mac_cfg, ctx->mac_address);
430+
if (ret == -ENODATA) {
431+
LOG_DBG("No MAC address configured for %s", dev->name);
432+
} else if (ret < 0) {
433+
LOG_ERR("Failed to load MAC address (%d)", ret);
434+
return ret;
435+
}
436+
429437
return lan865x_gpio_reset(dev);
430438
}
431439

@@ -475,12 +483,13 @@ static const struct ethernet_api lan865x_api_func = {
475483
.reset = GPIO_DT_SPEC_INST_GET(inst, rst_gpios), \
476484
.timeout = CONFIG_ETH_LAN865X_TIMEOUT, \
477485
.phy = DEVICE_DT_GET( \
478-
DT_CHILD(DT_INST_CHILD(inst, lan865x_mdio), ethernet_phy_##inst))}; \
486+
DT_CHILD(DT_INST_CHILD(inst, lan865x_mdio), ethernet_phy_##inst)), \
487+
.mac_cfg = NET_ETH_MAC_DT_INST_CONFIG_INIT(inst), \
488+
}; \
479489
\
480490
struct oa_tc6 oa_tc6_##inst = { \
481491
.cps = 64, .protected = 0, .spi = &lan865x_config_##inst.spi}; \
482492
static struct lan865x_data lan865x_data_##inst = { \
483-
.mac_address = DT_INST_PROP_OR(inst, local_mac_address, {0}), \
484493
.tx_rx_sem = Z_SEM_INITIALIZER((lan865x_data_##inst).tx_rx_sem, 1, 1), \
485494
.int_sem = Z_SEM_INITIALIZER((lan865x_data_##inst).int_sem, 0, 1), \
486495
.tc6 = &oa_tc6_##inst}; \

drivers/ethernet/eth_lan865x_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <zephyr/drivers/gpio.h>
1313
#include <zephyr/drivers/spi.h>
1414
#include <zephyr/net/net_if.h>
15+
#include <zephyr/net/ethernet.h>
1516
#include <ethernet/eth_stats.h>
1617
#include "oa_tc6.h"
1718

@@ -50,6 +51,7 @@ struct lan865x_config {
5051
struct gpio_dt_spec interrupt;
5152
struct gpio_dt_spec reset;
5253
int32_t timeout;
54+
struct net_eth_mac_config mac_cfg;
5355

5456
/* MAC */
5557
bool tx_cut_through_mode; /* 1 - tx cut through, 0 - Store and forward */

0 commit comments

Comments
 (0)