From a28a60f16c747d7a36754ec0b1371b65215659ff Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 29 Nov 2020 23:10:37 +0100 Subject: [PATCH 1/2] cpu/stm32: periph_eth: register with netdev --- cpu/stm32/Makefile.dep | 1 - cpu/stm32/periph/eth.c | 17 ++++++----------- drivers/include/net/netdev.h | 1 + 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cpu/stm32/Makefile.dep b/cpu/stm32/Makefile.dep index e942224e88..398d6b212b 100644 --- a/cpu/stm32/Makefile.dep +++ b/cpu/stm32/Makefile.dep @@ -24,7 +24,6 @@ ifneq (,$(filter stm32_eth,$(USEMODULE))) FEATURES_REQUIRED += periph_eth USEMODULE += netdev_eth USEMODULE += iolist - USEMODULE += luid USEMODULE += xtimer endif diff --git a/cpu/stm32/periph/eth.c b/cpu/stm32/periph/eth.c index 1dfdf30c39..7e8ef14790 100644 --- a/cpu/stm32/periph/eth.c +++ b/cpu/stm32/periph/eth.c @@ -26,10 +26,10 @@ #include "bitarithm.h" #include "iolist.h" -#include "luid.h" #include "mii.h" #include "mutex.h" #include "net/ethernet.h" +#include "net/eui_provider.h" #include "net/netdev/eth.h" #include "periph/gpio.h" @@ -407,8 +407,6 @@ static int stm32_eth_init(netdev_t *netdev) _link_status_timer.callback = _timer_cb; _link_status_timer.arg = netdev; xtimer_set(&_link_status_timer, STM32_ETH_LINK_UP_TIMEOUT_US); -#else - (void)netdev; #endif /* enable APB2 clock */ RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; @@ -459,14 +457,11 @@ static int stm32_eth_init(netdev_t *netdev) | ETH_DMABMR_RDP_32Beat | ETH_DMABMR_PBL_32Beat | ETH_DMABMR_EDE; - if (eth_config.addr[0] != 0) { - stm32_eth_set_addr(eth_config.addr); - } - else { - eui48_t hwaddr; - luid_get_eui48(&hwaddr); - stm32_eth_set_addr(hwaddr.uint8); - } + netdev_register(netdev, NETDEV_STM32_ETH, 0); + + eui48_t hwaddr; + netdev_eui48_get(netdev, &hwaddr); + stm32_eth_set_addr(hwaddr.uint8); _init_buffer(); diff --git a/drivers/include/net/netdev.h b/drivers/include/net/netdev.h index bec1ad96ea..0dab2a548f 100644 --- a/drivers/include/net/netdev.h +++ b/drivers/include/net/netdev.h @@ -286,6 +286,7 @@ typedef enum { NETDEV_KW41ZRF, NETDEV_MRF24J40, NETDEV_NRF802154, + NETDEV_STM32_ETH, /* add more if needed */ } netdev_type_t; /** @} */ From 0ed34cdb4d77791af1c5e500ce2ee023785e4263 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 29 Nov 2020 23:11:14 +0100 Subject: [PATCH 2/2] cpu/stm32: periph_eth: drop addr from eth_conf_t MAC address is now supplied by EUI provider, no need to hard-code it for the board. --- boards/nucleo-f207zg/include/periph_conf.h | 1 - boards/nucleo-f746zg/include/periph_conf.h | 1 - boards/nucleo-f767zi/include/periph_conf.h | 1 - cpu/stm32/include/periph_cpu.h | 1 - 4 files changed, 4 deletions(-) diff --git a/boards/nucleo-f207zg/include/periph_conf.h b/boards/nucleo-f207zg/include/periph_conf.h index fe3ed343a9..3ce29f9a07 100644 --- a/boards/nucleo-f207zg/include/periph_conf.h +++ b/boards/nucleo-f207zg/include/periph_conf.h @@ -248,7 +248,6 @@ static const adc_conf_t adc_config[] = { */ static const eth_conf_t eth_config = { .mode = RMII, - .addr = { 0 }, .speed = MII_BMCR_SPEED_100 | MII_BMCR_FULL_DPLX, .dma = 6, .dma_chan = 8, diff --git a/boards/nucleo-f746zg/include/periph_conf.h b/boards/nucleo-f746zg/include/periph_conf.h index ce1cc54ee4..b0dc181311 100644 --- a/boards/nucleo-f746zg/include/periph_conf.h +++ b/boards/nucleo-f746zg/include/periph_conf.h @@ -219,7 +219,6 @@ static const spi_conf_t spi_config[] = { */ static const eth_conf_t eth_config = { .mode = RMII, - .addr = { 0 }, .speed = MII_BMCR_SPEED_100 | MII_BMCR_FULL_DPLX, .dma = 7, .dma_chan = 8, diff --git a/boards/nucleo-f767zi/include/periph_conf.h b/boards/nucleo-f767zi/include/periph_conf.h index 9f715925d0..8358b2cdc6 100644 --- a/boards/nucleo-f767zi/include/periph_conf.h +++ b/boards/nucleo-f767zi/include/periph_conf.h @@ -167,7 +167,6 @@ static const spi_conf_t spi_config[] = { */ static const eth_conf_t eth_config = { .mode = RMII, - .addr = { 0 }, .speed = MII_BMCR_SPEED_100 | MII_BMCR_FULL_DPLX, .dma = 3, .dma_chan = 8, diff --git a/cpu/stm32/include/periph_cpu.h b/cpu/stm32/include/periph_cpu.h index 5ca6def479..94ae88d428 100644 --- a/cpu/stm32/include/periph_cpu.h +++ b/cpu/stm32/include/periph_cpu.h @@ -1049,7 +1049,6 @@ typedef enum { */ typedef struct { eth_mode_t mode; /**< Select configuration mode */ - uint8_t addr[6]; /**< Ethernet MAC address */ uint16_t speed; /**< Speed selection */ uint8_t dma; /**< Locical CMA Descriptor used for TX */ uint8_t dma_chan; /**< DMA channel used for TX */