Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions drivers/ethernet/eth_sensry_sy1xx_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct sy1xx_mac_dev_config {
uint32_t base_addr;
/* optional - enable promiscuous mode */
bool promiscuous_mode;
/* optional - random mac */
bool use_zephyr_random_mac;

struct net_eth_mac_config mcfg;

/* phy config */
const struct device *phy_dev;
Expand Down Expand Up @@ -203,13 +203,6 @@ static int sy1xx_mac_start(const struct device *dev)
sys_write32(0x0001, cfg->ctrl_addr + SY1XX_MAC_CTRL_REG);
sys_write32(0x0000, cfg->ctrl_addr + SY1XX_MAC_CTRL_REG);

if (cfg->use_zephyr_random_mac) {
/* prio 1 -- generate random, if set in device tree */
sys_rand_get(&data->mac_addr, 6);
/* Set MAC address locally administered, unicast (LAA) */
data->mac_addr[0] |= 0x02;
}

sy1xx_mac_set_mac_addr(dev);

sy1xx_mac_set_promiscuous_mode(dev, cfg->promiscuous_mode);
Expand Down Expand Up @@ -315,6 +308,8 @@ static void sy1xx_mac_iface_init(struct net_if *iface)

data->iface = iface;

(void)net_eth_mac_load(&cfg->mcfg, data->mac_addr);

ethernet_init(iface);

if (device_is_ready(cfg->phy_dev)) {
Expand Down Expand Up @@ -570,14 +565,13 @@ const struct ethernet_api sy1xx_mac_driver_api = {
.base_addr = DT_INST_REG_ADDR_BY_NAME(n, data), \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
.promiscuous_mode = DT_INST_PROP_OR(n, promiscuous_mode, false), \
.use_zephyr_random_mac = DT_INST_PROP(n, zephyr_random_mac_address), \
.phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, phy_handle))}; \
.mcfg = NET_ETH_MAC_DT_INST_CONFIG_INIT(n), \
.phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(n, phy_handle))}; \
\
static struct sy1xx_mac_dma_buffers __attribute__((section(".udma_access"))) \
__aligned(4) sy1xx_mac_dma_buffers_##n; \
\
static struct sy1xx_mac_dev_data sy1xx_mac_dev_data##n = { \
.mac_addr = DT_INST_PROP_OR(n, local_mac_address, {0}), \
.dma_buffers = &sy1xx_mac_dma_buffers_##n, \
}; \
\
Expand Down