Skip to content

Commit

Permalink
Merge pull request #15572 from dylad/pr/cpu/sam0/ethernet
Browse files Browse the repository at this point in the history
cpu/sam0: add initial ethernet support
  • Loading branch information
benpicco committed Dec 14, 2020
2 parents cc55d4c + c934d5d commit 5f7a7bc
Show file tree
Hide file tree
Showing 16 changed files with 678 additions and 1 deletion.
5 changes: 5 additions & 0 deletions boards/same54-xpro/Makefile.dep
Expand Up @@ -10,3 +10,8 @@ ifneq (,$(filter mtd,$(USEMODULE)))
FEATURES_REQUIRED += periph_spi_on_qspi
USEMODULE += mtd_spi_nor
endif

# enables sam0_eth as default network device
ifneq (,$(filter netdev_default,$(USEMODULE)))
USEMODULE += sam0_eth
endif
1 change: 1 addition & 0 deletions boards/same54-xpro/Makefile.features
Expand Up @@ -3,6 +3,7 @@ CPU_MODEL = same54p20a

# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_dac
FEATURES_PROVIDED += periph_eth
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_rtt
Expand Down
22 changes: 22 additions & 0 deletions boards/same54-xpro/include/periph_conf.h
Expand Up @@ -361,6 +361,28 @@ static const adc_conf_chan_t adc_channels[] = {
#define DAC_VREF DAC_CTRLB_REFSEL_VREFPU
/** @} */

/**
* @name Ethernet peripheral configuration
* @{
*/
static const sam0_common_gmac_config_t sam_gmac_config[] = {
{
.dev = GMAC,
.refclk = GPIO_PIN(PA, 14),
.txen = GPIO_PIN(PA, 17),
.txd0 = GPIO_PIN(PA, 18),
.txd1 = GPIO_PIN(PA, 19),
.crsdv = GPIO_PIN(PC, 20),
.rxd0 = GPIO_PIN(PA, 13),
.rxd1 = GPIO_PIN(PA, 12),
.rxer = GPIO_PIN(PA, 15),
.mdc = GPIO_PIN(PC, 11),
.mdio = GPIO_PIN(PC, 12),
.rst_pin = GPIO_PIN(PC, 21),
.int_pin = GPIO_PIN(PD, 12),
}
};

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions cpu/sam0_common/Makefile
@@ -1,3 +1,7 @@
DIRS = periph

ifneq (, $(filter sam0_eth, $(USEMODULE)))
DIRS += sam0_eth
endif

include $(RIOTBASE)/Makefile.base
7 changes: 7 additions & 0 deletions cpu/sam0_common/Makefile.dep
Expand Up @@ -12,4 +12,11 @@ USEMODULE += pm_layered
# include sam0 common periph drivers
USEMODULE += sam0_common_periph

ifneq (,$(filter sam0_eth,$(USEMODULE)))
USEMODULE += netdev_eth
USEMODULE += netopt
USEMODULE += xtimer
USEMODULE += iolist
FEATURES_REQUIRED += periph_eth
endif
include $(RIOTCPU)/cortexm_common/Makefile.dep
4 changes: 4 additions & 0 deletions cpu/sam0_common/Makefile.include
Expand Up @@ -31,5 +31,9 @@ LINKER_SCRIPT ?= cortexm.ld

INCLUDES += -I$(RIOTCPU)/sam0_common/include

ifneq (,$(filter sam0_eth,$(USEMODULE)))
INCLUDES += -I$(RIOTCPU)/sam0_common/sam0_eth/
endif

PSEUDOMODULES += periph_rtc
PSEUDOMODULES += periph_rtt
43 changes: 43 additions & 0 deletions cpu/sam0_common/include/periph_cpu_common.h
Expand Up @@ -141,6 +141,7 @@ typedef enum {
GPIO_MUX_F = 0x5, /**< select peripheral function F */
GPIO_MUX_G = 0x6, /**< select peripheral function G */
GPIO_MUX_H = 0x7, /**< select peripheral function H */
GPIO_MUX_L = 0xb,
} gpio_mux_t;
#endif

Expand Down Expand Up @@ -767,6 +768,48 @@ typedef struct {
uint32_t muxpos; /**< ADC channel pin multiplexer value */
} adc_conf_chan_t;

/**
* @name Ethernet peripheral parameters
* @{
*/
#ifndef ETH_RX_BUFFER_COUNT
#define ETH_RX_BUFFER_COUNT (4)
#endif

#ifndef ETH_TX_BUFFER_COUNT
#define ETH_TX_BUFFER_COUNT (4)
#endif

#ifndef ETH_RX_BUFFER_SIZE
#define ETH_RX_BUFFER_SIZE (1536)
#endif

#ifndef ETH_TX_BUFFER_SIZE
#define ETH_TX_BUFFER_SIZE (1536)
#endif
/** @} */

/**
* @brief Ethernet parameters struct
*/
#if defined(GMAC_INST_NUM) || defined(DOXYGEN)
typedef struct {
Gmac *dev; /**< ptr to the device registers */
gpio_t refclk; /**< REFCLK gpio */
gpio_t txen; /**< TXEN gpio */
gpio_t txd0; /**< TXD0 gpio */
gpio_t txd1; /**< TXD1 gpio */
gpio_t crsdv; /**< CRSDV gpio */
gpio_t rxd0; /**< RXD0 gpio */
gpio_t rxd1; /**< RXD1 gpio */
gpio_t rxer; /**< RXER gpio */
gpio_t mdc; /**< MII interface, clock gpio */
gpio_t mdio; /**< MII interface, data gpio */
gpio_t rst_pin; /**< PHY reset gpio */
gpio_t int_pin; /**< PHY interrupt gpio */
} sam0_common_gmac_config_t;
#endif

/**
* @brief USB peripheral parameters
*/
Expand Down

0 comments on commit 5f7a7bc

Please sign in to comment.