Skip to contentSkip to conversation

Add Ethernet support on STM32F429

PATCH Superseded Alexandre TORGUE 5 participants 11 messages Feb 26, 2016 – Mar 4, 2016

Subsystems (6)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add Ethernet support on STM32F429

STM32F429 Chip embeds a Synopsys 3.50a MAC IP. This series:
-enhance current stmmac driver to control it (code already
available) and adds basic glue for STM32F429 chip.
-Enable basic Net config in kernel.

Note that DT patches are not present because STM32 pinctrl code is not yet avalaible.

Changes since v2:
-Fix alphabetic order in Kconfig and Makefile.
-Improve code according to Joachim review.
-Binding: remove useless entry.

Changes since v1:
-Fix Kbuild issue in Kconfig.
-Remove init/exit callbacks. Suspend/Resume and remove driver is no more
driven in stmmac_pltfr but directly in dwmac-stm32 glue driver.
-Take into account Joachim review.

Regards.

Alexandre.

Alexandre TORGUE (4):
net: ethernet: dwmac: add Ethernet glue logic for stm32 chip
Documentation: Bindings: Add STM32 DWMAC glue
net: ethernet: stmmac: add support of Synopsys 3.50a MAC IP
ARM: STM32: Enable Ethernet in stm32_defconfig

 .../devicetree/bindings/net/stm32-dwmac.txt        |  40 +++++
 arch/arm/configs/stm32_defconfig                   |   9 +
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |  12 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c  | 193 +++++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   1 +
 6 files changed, 256 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/stm32-dwmac.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/4 net: ethernet: dwmac: add Ethernet glue logic for stm32 chip

stm324xx family chips support Synopsys MAC 3.510 IP. This patch adds settings for logical glue logic:
-clocks
-mode selection MII or RMII.

drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index cec147d..235d679 100644
@@ -104,6 +104,18 @@ config DWMAC_STI
 	  device driver. This driver is used on for the STi series
 	  SOCs GMAC ethernet controller.
 
+config DWMAC_STM32
+	tristate "STM32 DWMAC support"
+	default ARCH_STM32
+	depends on OF && HAS_IOMEM
+	select MFD_SYSCON
+	---help---
+	  Support for ethernet controller on STM32 SOCs.
+
+	  This selects STM32 SoC glue layer support for the stmmac
+	  device driver. This driver is used on for the STM32 series
+	  SOCs GMAC ethernet controller.
+
 config DWMAC_SUNXI
 	tristate "Allwinner GMAC support"
 	default ARCH_SUNXI
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index b390161..5f7ff0a 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-socfpga.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
+obj-$(CONFIG_DWMAC_STM32)	+= dwmac-stm32.o
 obj-$(CONFIG_DWMAC_SUNXI)	+= dwmac-sunxi.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
 stmmac-platform-objs:= stmmac_platform.o
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c new file +193 -0

193 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v3 2/4 Documentation: Bindings: Add STM32 DWMAC glue

In reply to Alexandre TORGUE
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +40 -0
new file mode 100644
index 0000000..67fceda
@@ -0,0 +1,40 @@
+STMicroelectronics STM32 / MCU DWMAC glue layer controller
+
+This file documents platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+The device node has following properties.
+
+Required properties:
+- compatible:  Should be "st,stm32-dwmac" to select glue, and
+	       "snps,dwmac-3.50a" to select IP vesrion.
+- clocks: Should contain the GMAC main clock, and tx clock
+- compatible:  Should be "st,stm32-dwmac" to select glue and
+	       "snps,dwmac-3.50a" to select IP version.
+- clocks: Should contain the MAC main clock
+- clock-names: Should contain the clock names "stmmaceth".
+- st,syscon : Should be phandle/offset pair. The phandle to the syscon node which
+	      encompases the glue register, and the offset of the control register.
+
+Optional properties:
+- clocks: Could contain:
+	- the tx clock,
+	- the rx clock
+- clock-names: Could contain the clock names "tx-clk", "rx-clk"
+
+Example:
+
+		ethernet0: dwmac at 40028000 {
+			compatible = "st,stm32-dwmac", "snps,dwmac-3.50a";
+			status = "disabled";
+			reg = <0x40028000 0x8000>;
+			reg-names = "stmmaceth";
+			interrupts = <0 61 0>, <0 62 0>;
+			interrupt-names = "macirq", "eth_wake_irq";
+			clock-names = "stmmaceth", "tx-clk", "rx-clk";
+			clocks = <&rcc 0 25>, <&rcc 0 26>, <&rcc 0 27>;
+			st,syscon = <&syscfg 0x4>;
+			snps,pbl = <8>;
+			snps,mixed-burst;
+			dma-ranges;
+		};
Signature · 1 line
1.9.1
#7 lore raw

PATCH v3 3/4 net: ethernet: stmmac: add support of Synopsys 3.50a MAC IP

In reply to Alexandre TORGUE

Adds support of Synopsys 3.50a MAC IP in stmmac driver.

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
index 6a52fa1..6cca626 100644
@@ -178,6 +178,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	 * once needed on other platforms.
 	 */
 	if (of_device_is_compatible(np, "st,spear600-gmac") ||
+		of_device_is_compatible(np, "snps,dwmac-3.50a") ||
 		of_device_is_compatible(np, "snps,dwmac-3.70a") ||
 		of_device_is_compatible(np, "snps,dwmac")) {
 		/* Note that the max-frame-size parameter as defined in the
Signature · 1 line
1.9.1
#8 lore raw

PATCH v3 4/4 ARM: STM32: Enable Ethernet in stm32_defconfig

In reply to Alexandre TORGUE

Enable basic Ethernet support (IPV4) for stm32 defconfig.

arch/arm/configs/stm32_defconfig +9 -0
index ec52505..8b8abe0 100644
@@ -33,11 +33,20 @@ CONFIG_XIP_PHYS_ADDR=0x08008000
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_SHARED_FLAT=y
 # CONFIG_COREDUMP is not set
+CONFIG_NET=y
+CONFIG_INET=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_IPV6 is not set
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_FW_LOADER is not set
 # CONFIG_BLK_DEV is not set
 CONFIG_EEPROM_93CX6=y
+CONFIG_NETDEVICES=y
+CONFIG_STMMAC_ETH=y
+# CONFIG_WLAN is not set
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
Signature · 1 line
1.9.1
Acked-by on v3 2/4
#4 lore raw

Re: [PATCH v3 2/4] Documentation: Bindings: Add STM32 DWMAC glue

In reply to Alexandre TORGUE

Hi Alexandre,

Quoted 38 lines · Alexandre TORGUE
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +30 -0
new file mode 100644
index 0000000..67fceda
@@ -0,0 +1,40 @@
+STMicroelectronics STM32 / MCU DWMAC glue layer controller
+
+This file documents platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+The device node has following properties.
+
+Required properties:
+- compatible:  Should be "st,stm32-dwmac" to select glue, and
+              "snps,dwmac-3.50a" to select IP vesrion.
+- clocks: Should contain the GMAC main clock, and tx clock
+- compatible:  Should be "st,stm32-dwmac" to select glue and
+              "snps,dwmac-3.50a" to select IP version.
+- clocks: Should contain the MAC main clock
+- clock-names: Should contain the clock names "stmmaceth".
+- st,syscon : Should be phandle/offset pair. The phandle to the syscon node which
+             encompases the glue register, and the offset of the control register.
+
+Optional properties:
+- clocks: Could contain:
+       - the tx clock,
+       - the rx clock
+- clock-names: Could contain the clock names "tx-clk", "rx-clk"
+
+Example:
+
+               ethernet0: dwmac at 40028000 {
+                       compatible = "st,stm32-dwmac", "snps,dwmac-3.50a";
+                       status = "disabled";
+                       reg = <0x40028000 0x8000>;

Documentation/devicetree/bindings/net/stm32-dwmac.txt line 40

Quoted 10 lines
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +10 -0
+                       reg-names = "stmmaceth";
+                       interrupts = <0 61 0>, <0 62 0>;
+                       interrupt-names = "macirq", "eth_wake_irq";
+                       clock-names = "stmmaceth", "tx-clk", "rx-clk";
+                       clocks = <&rcc 0 25>, <&rcc 0 26>, <&rcc 0 27>;
+                       st,syscon = <&syscfg 0x4>;
+                       snps,pbl = <8>;
+                       snps,mixed-burst;
+                       dma-ranges;
+               };

Looks just like any other dwmac-driver binding so:

regards,
Joachim Eastwood

Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH v3 1/4] net: ethernet: dwmac: add Ethernet glue logic for stm32 chip

In reply to Alexandre TORGUE

Hi Alexandre,

When people comment on your patch please CC them on the next version.

Quoted 6 lines · Alexandre TORGUE

stm324xx family chips support Synopsys MAC 3.510 IP. This patch adds settings for logical glue logic:

(quoted diff) +0 -2
-clocks
-mode selection MII or RMII.

Driver looks good now, thanks.

regards,
Joachim Eastwood

Acked-by on the v3 series
#10 lore raw
In reply to Alexandre TORGUE
Quoted 20 lines · Alexandre TORGUE

STM32F429 Chip embeds a Synopsys 3.50a MAC IP. This series:
-enhance current stmmac driver to control it (code already
available) and adds basic glue for STM32F429 chip.
-Enable basic Net config in kernel.

Note that DT patches are not present because STM32 pinctrl code is not yet avalaible.

Changes since v2:
-Fix alphabetic order in Kconfig and Makefile.
-Improve code according to Joachim review.
-Binding: remove useless entry.

Changes since v1:
-Fix Kbuild issue in Kconfig.
-Remove init/exit callbacks. Suspend/Resume and remove driver is no more
driven in stmmac_pltfr but directly in dwmac-stm32 glue driver.
-Take into account Joachim review.

Quoted 3 lines

Regards.

Alexandre.

thanks Alex, for the series please consider my:

Quoted 17 lines

Alexandre TORGUE (4):
net: ethernet: dwmac: add Ethernet glue logic for stm32 chip
Documentation: Bindings: Add STM32 DWMAC glue
net: ethernet: stmmac: add support of Synopsys 3.50a MAC IP
ARM: STM32: Enable Ethernet in stm32_defconfig

  .../devicetree/bindings/net/stm32-dwmac.txt        |  40 +++++
  arch/arm/configs/stm32_defconfig                   |   9 +
  drivers/net/ethernet/stmicro/stmmac/Kconfig        |  12 ++
  drivers/net/ethernet/stmicro/stmmac/Makefile       |   1 +
  drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c  | 193 +++++++++++++++++++++
  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   1 +
  6 files changed, 256 insertions(+)

create mode 100644 Documentation/devicetree/bindings/net/stm32-dwmac.txt create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c

maintainer
#9 lore raw

Re: [PATCH v3 4/4] ARM: STM32: Enable Ethernet in stm32_defconfig

In reply to Alexandre TORGUE

Hi Alex, Arnd,

Quoted 20 lines · Alexandre TORGUE

Enable basic Ethernet support (IPV4) for stm32 defconfig.

arch/arm/configs/stm32_defconfig +6 -0
index ec52505..8b8abe0 100644
@@ -33,11 +33,20 @@ CONFIG_XIP_PHYS_ADDR=0x08008000
  CONFIG_BINFMT_FLAT=y
  CONFIG_BINFMT_SHARED_FLAT=y
  # CONFIG_COREDUMP is not set
+CONFIG_NET=y
+CONFIG_INET=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_IPV6 is not set
  CONFIG_DEVTMPFS=y

arch/arm/configs/stm32_defconfig CONFIG_XIP_PHYS_ADDR=0x08008000 · line 52

Quoted 10 lines
arch/arm/configs/stm32_defconfig +3 -0
  CONFIG_DEVTMPFS_MOUNT=y
  # CONFIG_FW_LOADER is not set
  # CONFIG_BLK_DEV is not set
  CONFIG_EEPROM_93CX6=y
+CONFIG_NETDEVICES=y
+CONFIG_STMMAC_ETH=y
+# CONFIG_WLAN is not set
  # CONFIG_INPUT is not set
  # CONFIG_SERIO is not set
  # CONFIG_VT is not set

The patch looks good, but I'm not sure I should apply it. Indeed, not all the stm32 boards have Ethernet interface, and stm32 internal flash size is rather limited (2MB).
Note that your glue layer can be compiled with COMPILE_TEST, so its build will be covered anyway.

Arnd, do you think we could use Kconfig fragments to enable features like USB, Ethernet, MTD, etc...?
Maybe we could have a subdirectory in arch/arm/configs where these stm32 specifics fragments could leave?

For example, we could have:
arch/arm/configs/stm32/eth.config
arch/arm/configs/stm32/usb.config

For configuring the Discovery board we would use:
make stm32_defconfig stm32/usb.config

For the Eval board, we cwould use:
make stm32_defconfig eth.config

It would make easy to be able to boot every boards without multiplying the defconfigs.

Regards,
Maxime

maintainer
#5 lore raw

Re: [PATCH v3 2/4] Documentation: Bindings: Add STM32 DWMAC glue

In reply to Alexandre TORGUE
Quoted 21 lines · Alexandre TORGUE
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +13 -0
new file mode 100644
index 0000000..67fceda
@@ -0,0 +1,40 @@
+STMicroelectronics STM32 / MCU DWMAC glue layer controller
+
+This file documents platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+The device node has following properties.
+
+Required properties:
+- compatible:  Should be "st,stm32-dwmac" to select glue, and
+	       "snps,dwmac-3.50a" to select IP vesrion.
+- clocks: Should contain the GMAC main clock, and tx clock
+- compatible:  Should be "st,stm32-dwmac" to select glue and
+	       "snps,dwmac-3.50a" to select IP version.

Documentation/devicetree/bindings/net/stm32-dwmac.txt line 23

Quoted 10 lines
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +10 -0
+- clocks: Should contain the MAC main clock
+- clock-names: Should contain the clock names "stmmaceth".
+- st,syscon : Should be phandle/offset pair. The phandle to the syscon node which
+	      encompases the glue register, and the offset of the control register.
+
+Optional properties:
+- clocks: Could contain:
+	- the tx clock,
+	- the rx clock
+- clock-names: Could contain the clock names "tx-clk", "rx-clk"

Either the IP block has 3 clocks or it has 1. If you have a case where 1 clock feeds all 3 inputs, then list the clock 3 times.

Rob

#6 lore raw

Re: [PATCH v3 2/4] Documentation: Bindings: Add STM32 DWMAC glue

Hi Rob,

2016-03-02 19:33 GMT+01:00 Rob Herring <[email protected]>:

Quoted 27 lines · Alexandre TORGUE
Quoted 26 lines
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +18 -0
new file mode 100644
index 0000000..67fceda
@@ -0,0 +1,40 @@
+STMicroelectronics STM32 / MCU DWMAC glue layer controller
+
+This file documents platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+The device node has following properties.
+
+Required properties:
+- compatible:  Should be "st,stm32-dwmac" to select glue, and
+            "snps,dwmac-3.50a" to select IP vesrion.
+- clocks: Should contain the GMAC main clock, and tx clock
+- compatible:  Should be "st,stm32-dwmac" to select glue and
+            "snps,dwmac-3.50a" to select IP version.
+- clocks: Should contain the MAC main clock
+- clock-names: Should contain the clock names "stmmaceth".
+- st,syscon : Should be phandle/offset pair. The phandle to the syscon node which
+           encompases the glue register, and the offset of the control register.
+
Quoted 8 lines

Documentation/devicetree/bindings/net/stm32-dwmac.txt line 23

Quoted 5 lines
Documentation/devicetree/bindings/net/stm32-dwmac.txt new file +5 -0
+Optional properties:
+- clocks: Could contain:
+     - the tx clock,
+     - the rx clock
+- clock-names: Could contain the clock names "tx-clk", "rx-clk"

Either the IP block has 3 clocks or it has 1. If you have a case where 1 clock feeds all 3 inputs, then list the clock 3 times.

I agree. I will move rx/tx clock to required properties and then send a v4.

Regards.

Alexandre

Quoted 2 lines

Rob