Add support for Actions Semi Owl Ethernet MAC
v3 cover Add support for Actions Semi Owl Ethernet MAC
This patch series adds support for the Ethernet MAC found on the Actions Semi Owl family of SoCs.
For the moment I have only tested the driver on RoseapplePi SBC, which is based on the S500 SoC variant. It might work on S900 as well, but I cannot tell for sure since the S900 datasheet I currently have doesn't provide any information regarding the MAC registers - so I couldn't check the compatibility with S500.
Similar story for S700: the datasheet I own is incomplete, but it seems the MAC is advertised with Gigabit capabilities. For that reason most probably we need to extend the current implementation in order to support this SoC variant as well.
Please note that for testing the driver it is also necessary to update the S500 clock subsystem:
https://lore.kernel.org/lkml/[email protected]/
The DTS changes for the S500 SBCs will be provided separately.
Thanks,
Cristi
Changes in v3:
- Dropped the 'debug' module parameter and passed the default NETIF_MSG flags
to netif_msg_init(), according to David's review
- Removed the owl_emac_generate_mac_addr() function and the relatedOWL_EMAC_GEN_ADDR_SYS_SN config option until a portable solution to get the system serial number is found - when building on arm64 the following error is thrown (as reported by Rob's kernel bot):
'[...]/owl-emac.c:9:10: fatal error: asm/system_info.h: No such file or directory'
- Rebased patchset on v5.12-rc4
Changes in v2:
* According to Philipp's review
- Requested exclusive control over serial line via devm_reset_control_get_exclusive()
- Optimized error handling by using dev_err_probe()
* According to Andrew's review
- Dropped the inline keywords
- Applied Reverse Christmas Tree format to local variable declarations
- Renamed owl_emac_phy_config() to owl_emac_update_link_state()
- Documented the purpose of the special descriptor used in the context of owl_emac_setup_frame_xmit()
- Updated comment inside owl_emac_mdio_clock_enable() regarding the MDC clock divider setup
- Indicated MAC support for symmetric pause via phy_set_sym_pause() in owl_emac_phy_init()
- Changed the MAC addr generation algorithm in owl_emac_generate_mac_addr() by setting the locally administered bit in byte 0 and replacing bytes 1 & 2 with additional entries from enc_sn
- Moved devm_add_action_or_reset() before clk_set_rate() in owl_emac_probe()
* Other
- Added SMII interface support: updated owl_emac_core_sw_reset(), added owl_emac_clk_set_rate(), updated description in the YAML binding
- Changed OWL_EMAC_TX_TIMEOUT from 0.05*HZ to 2*HZ
- Rebased patchset on v5.12-rc3
Cristian Ciocaltea (3):
dt-bindings: net: Add Actions Semi Owl Ethernet MAC binding
net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
MAINTAINERS: Add entries for Actions Semi Owl Ethernet MAC
.../bindings/net/actions,owl-emac.yaml | 92 + MAINTAINERS | 2 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/actions/Kconfig | 26 + drivers/net/ethernet/actions/Makefile | 6 + drivers/net/ethernet/actions/owl-emac.c | 1625 +++++++++++++++++ drivers/net/ethernet/actions/owl-emac.h | 280 +++ 8 files changed, 2033 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/actions,owl-emac.yaml create mode 100644 drivers/net/ethernet/actions/Kconfig create mode 100644 drivers/net/ethernet/actions/Makefile create mode 100644 drivers/net/ethernet/actions/owl-emac.c create mode 100644 drivers/net/ethernet/actions/owl-emac.h
Signature · 1 line
2.31.0
PATCH v3 1/3 dt-bindings: net: Add Actions Semi Owl Ethernet MAC binding
Add devicetree binding for the Ethernet MAC present on the Actions Semi Owl family of SoCs.
For the moment advertise only the support for the Actions Semi S500 SoC variant.
--- .../bindings/net/actions,owl-emac.yaml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/actions,owl-emac.yaml
Documentation/devicetree/bindings/net/actions,owl-emac.yaml new file +92 -0
@@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/actions,owl-emac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Actions Semi Owl SoCs Ethernet MAC Controller + +maintainers: + - Cristian Ciocaltea <[email protected]> + +description: | + This Ethernet MAC is used on the Owl family of SoCs from Actions Semi. + It provides the RMII and SMII interfaces and is compliant with the + IEEE 802.3 CSMA/CD standard, supporting both half-duplex and full-duplex + operation modes at 10/100 Mb/s data transfer rates. + +allOf: + - $ref: "ethernet-controller.yaml#" + +properties: + compatible: + oneOf: + - const: actions,owl-emac + - items: + - enum: + - actions,s500-emac + - const: actions,owl-emac + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + additionalItems: false + items: + - const: eth + - const: rmii + + resets: + maxItems: 1 + + actions,ethcfg: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the device containing custom config. + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - phy-mode + - phy-handle + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/actions,s500-cmu.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/actions,s500-reset.h> + + ethernet@b0310000 { + compatible = "actions,s500-emac", "actions,owl-emac"; + reg = <0xb0310000 0x10000>; + interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cmu 59 /*CLK_ETHERNET*/>, <&cmu CLK_RMII_REF>; + clock-names = "eth", "rmii"; + resets = <&cmu RESET_ETHERNET>; + phy-mode = "rmii"; + phy-handle = <ð_phy>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + eth_phy: ethernet-phy@3 { + reg = <0x3>; + interrupt-parent = <&sirq>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + }; + }; + };
Signature · 1 line
2.31.0
PATCH v3 2/3 net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
In reply to Cristian CiocalteaAdd new driver for the Ethernet MAC used on the Actions Semi Owl family of SoCs.
Currently this has been tested only on the Actions Semi S500 SoC variant.
--- drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/actions/Kconfig | 26 + drivers/net/ethernet/actions/Makefile | 6 + drivers/net/ethernet/actions/owl-emac.c | 1625 +++++++++++++++++++++++ drivers/net/ethernet/actions/owl-emac.h | 280 ++++ 6 files changed, 1939 insertions(+) create mode 100644 drivers/net/ethernet/actions/Kconfig create mode 100644 drivers/net/ethernet/actions/Makefile create mode 100644 drivers/net/ethernet/actions/owl-emac.c create mode 100644 drivers/net/ethernet/actions/owl-emac.h
drivers/net/ethernet/Kconfig +1 -0
@@ -19,6 +19,7 @@ config SUNGEM_PHY tristate source "drivers/net/ethernet/3com/Kconfig" +source "drivers/net/ethernet/actions/Kconfig" source "drivers/net/ethernet/adaptec/Kconfig" source "drivers/net/ethernet/aeroflex/Kconfig" source "drivers/net/ethernet/agere/Kconfig"
drivers/net/ethernet/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_NET_VENDOR_3COM) += 3com/ obj-$(CONFIG_NET_VENDOR_8390) += 8390/ +obj-$(CONFIG_NET_VENDOR_ACTIONS) += actions/ obj-$(CONFIG_NET_VENDOR_ADAPTEC) += adaptec/ obj-$(CONFIG_GRETH) += aeroflex/ obj-$(CONFIG_NET_VENDOR_AGERE) += agere/
drivers/net/ethernet/actions/Kconfig new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config NET_VENDOR_ACTIONS + bool "Actions Semi devices" + default y + depends on ARCH_ACTIONS + help + If you have a network (Ethernet) card belonging to this class, say Y. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all the + questions about Actions Semi devices. If you say Y, you will be + asked for your specific card in the following questions. + +if NET_VENDOR_ACTIONS + +config OWL_EMAC + tristate "Actions Semi Owl Ethernet MAC support" + select PHYLIB + help + This driver supports the Actions Semi Ethernet Media Access + Controller (EMAC) found on the S500 and S900 SoCs. The controller + is compliant with the IEEE 802.3 CSMA/CD standard and supports + both half-duplex and full-duplex operation modes at 10/100 Mb/s. + +endif # NET_VENDOR_ACTIONS
drivers/net/ethernet/actions/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for the Actions Semi Owl SoCs built-in ethernet macs +# + +obj-$(CONFIG_OWL_EMAC) += owl-emac.o
drivers/net/ethernet/actions/owl-emac.c new file +1625 -0
1,625 lines not on this page · raw message
drivers/net/ethernet/actions/owl-emac.h new file +280 -0
280 lines not on this page · raw message
Signature · 1 line
2.31.0
Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
Hi Christian,
Quoted 7 lines · Cristian Ciocaltea
Add new driver for the Ethernet MAC used on the Actions Semi Owl family of SoCs.
Currently this has been tested only on the Actions Semi S500 SoC variant.
Signed-off-by Cristian Ciocaltea <[email protected]>
[snip]
Do you know the story behind this Ethernet controller? The various receive/transmit descriptor definitions are 99% those defined in drivers/net/ethernet/stmmicro/stmmac/descs.h for the normal descriptor.
The register layout of the MAC looks completely different from a dwmac100 or dwmac1000 however.
Signature · 1 line
Florian
Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
Hi Florian,
Quoted 6 lines · Florian Fainelli
Hi Christian,
Quoted 3 lines · Cristian Ciocaltea
Add new driver for the Ethernet MAC used on the Actions Semi Owl family of SoCs.
Quoted 8 lines
Quoted 4 lines
Currently this has been tested only on the Actions Semi S500 SoC variant.
Signed-off-by Cristian Ciocaltea <[email protected]>[snip]
Do you know the story behind this Ethernet controller?
I just happened to get a board based on the S500 SoC, so I took this opportunity to help improving the mainline kernel support, but other than that I do not really know much about the hardware history.
Quoted 3 lines
The various
receive/transmit descriptor definitions are 99% those defined indrivers/net/ethernet/stmmicro/stmmac/descs.hfor the normal descriptor.
That's an interesting observation. I could only assume the vendor did not want to reinvent the wheel here, but I cannot say if this is a common design scheme or is something specific to STMicroelectronics only.
Quoted 2 lines
The register layout of the MAC looks completely different from a dwmac100 or dwmac1000 however.
Most probably this is Actions specific..
Quoted 2 lines
Signature · 1 line
Florian
Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
Hi,
Quoted 6 lines
Quoted 1 line
Do you know the story behind this Ethernet controller?
I just happened to get a board based on the S500 SoC, so I took this opportunity to help improving the mainline kernel support, but other than that I do not really know much about the hardware history.
Quoted 8 lines
Quoted 3 lines
The various
receive/transmit descriptor definitions are 99% those defined indrivers/net/ethernet/stmmicro/stmmac/descs.hfor the normal descriptor.That's an interesting observation. I could only assume the vendor did not want to reinvent the wheel here, but I cannot say if this is a common design scheme or is something specific to STMicroelectronics only.
I am not entirely sure about it but it looks like it *may* only need to have a glue driver to
connect to DWMAC.
For instance, on the U-boot[1] side (S700 is one of 64bit OWL SoC from actions), we kind of re-uses already
existing DWMAC and provide a glue code, and on the Linux side as well have some similar implementation (locally).
Thanks
-Amit.
[1]: https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/dwmac_s700.c
Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
Hi Amit,
Quoted 12 lines · Amit Tomer
Hi,
Quoted 10 lines
Quoted 1 line
Do you know the story behind this Ethernet controller?
I just happened to get a board based on the S500 SoC, so I took this opportunity to help improving the mainline kernel support, but other than that I do not really know much about the hardware history.
Quoted 3 lines
The various
receive/transmit descriptor definitions are 99% those defined indrivers/net/ethernet/stmmicro/stmmac/descs.hfor the normal descriptor.
Quoted 8 lines
Quoted 4 lines
That's an interesting observation. I could only assume the vendor did not want to reinvent the wheel here, but I cannot say if this is a common design scheme or is something specific to STMicroelectronics only.
I am not entirely sure about it but it looks like it *may* only need to have a glue driver to
connect to DWMAC.
From the RX/TX descriptors perspective, this looks like a Synopsys IP, but the MAC register layout is not similar at all.
Thanks to Mani, a request for clarification has been also sent to Actions, but they could not confirm. Hence, at the moment, we do not have clear evidences that it is based on Designware.
Quoted 4 lines
For instance, on the U-boot[1] side (S700 is one of 64bit OWL SoC from actions), we kind of re-uses already
existing DWMAC and provide a glue code, and on the Linux side as well have some similar implementation (locally).
The S700 SoC provides Gigabit ethernet capabilities and I assume the controller is quite different from the 10/100 variant present on S500. As a matter of fact, Actions has confirmed that in the case of S700, the licensing was obtained from a third party IP company, although they were not certain if the provider had previous agreements with Synopsys.
Regards,
Cristi
Quoted 4 lines
Thanks
-Amit.[1]: https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/dwmac_s700.c
Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
In reply to Cristian CiocalteaQuoted 4 lines
drivers/net/ethernet/actions/owl-emac.c new file +4
-0+static void owl_emac_set_multicast (struct net_device *netdev,int count) +{ +struct owl_emac_priv *priv =netdev_priv (netdev); +struct netdev_hw_addr *ha;
drivers/net/ethernet/actions/owl-emac.c line 1117
Quoted 10 lines
drivers/net/ethernet/actions/owl-emac.c new file +10
-0+int index =0 ; + +if (count <=0 ) { + priv->mcaddr_list.count =0 ; +return ; + } + +netdev_for_each_mc_addr (ha, netdev) { +if (!is_multicast_ether_addr (ha->addr)) +continue ;
Is this possible?
Quoted 37 lines
drivers/net/ethernet/actions/owl-emac.c new file +37
-0+ +WARN_ON (index >=OWL_EMAC_MAX_MULTICAST_ADDRS ); +ether_addr_copy (priv->mcaddr_list.addrs[index++], ha->addr); + } + + priv->mcaddr_list.count = index; + +owl_emac_setup_frame_xmit (priv); +} + +static void owl_emac_ndo_set_rx_mode (struct net_device *netdev) +{ +struct owl_emac_priv *priv =netdev_priv (netdev); +u32 status, val =0 ; +int mcast_count =0 ; + +if (netdev->flags &IFF_PROMISC ) { + val =OWL_EMAC_BIT_MAC_CSR6_PR ; + }else if (netdev->flags &IFF_ALLMULTI ) { + val =OWL_EMAC_BIT_MAC_CSR6_PM ; + }else if (netdev->flags &IFF_MULTICAST ) { + mcast_count =netdev_mc_count (netdev); + +if (mcast_count >OWL_EMAC_MAX_MULTICAST_ADDRS ) { + val =OWL_EMAC_BIT_MAC_CSR6_PM ; + mcast_count =0 ; + } + } + +spin_lock_bh (&priv->lock); + +/* Temporarily stop DMA TX & RX. */ + status =owl_emac_dma_cmd_stop (priv); + +/* Update operation modes. */ + owl_emac_reg_update(priv, OWL_EMAC_REG_MAC_CSR6, + OWL_EMAC_BIT_MAC_CSR6_PR | OWL_EMAC_BIT_MAC_CSR6_PM,
drivers/net/ethernet/actions/owl-emac.c line 1164
Quoted 10 lines
drivers/net/ethernet/actions/owl-emac.c new file +10
-0+ val); + +/* Restore DMA TX & RX status. */ +owl_emac_dma_cmd_set (priv, status); + +spin_unlock_bh (&priv->lock); + +/* Set/reset multicast addr list. */ +owl_emac_set_multicast (netdev, mcast_count); +}
I think this can be simplified. At least, you had me going around in circles a while trying to see if WARN_ON() could be triggered from user space.
If you have more than OWL_EMAC_MAX_MULTICAST_ADDRS MC addresses, you go into promisc mode. Can you then skip calling owl_emac_set_multicast(), which appears not to do too much useful when passed 0?
Andrew
Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
Quoted 8 lines · Andrew Lunn
Quoted 8 lines
drivers/net/ethernet/actions/owl-emac.c new file +8
-0+static void owl_emac_set_multicast (struct net_device *netdev,int count) +{ +struct owl_emac_priv *priv =netdev_priv (netdev); +struct netdev_hw_addr *ha; +int index =0 ; + +if (count <=0 ) { + priv->mcaddr_list.count =0 ;
Quoted 8 lines
drivers/net/ethernet/actions/owl-emac.c line 1117
Quoted 6 lines
drivers/net/ethernet/actions/owl-emac.c new file +6
-0+return ; + } + +netdev_for_each_mc_addr (ha, netdev) { +if (!is_multicast_ether_addr (ha->addr)) +continue ;Is this possible?
I remember I've seen this in one of the drivers I have studied, but I'm not really sure it is actually necessary. I added it to be on the safe side..
Quoted 52 lines
Quoted 37 lines
drivers/net/ethernet/actions/owl-emac.c new file +37
-0+ +WARN_ON (index >=OWL_EMAC_MAX_MULTICAST_ADDRS ); +ether_addr_copy (priv->mcaddr_list.addrs[index++], ha->addr); + } + + priv->mcaddr_list.count = index; + +owl_emac_setup_frame_xmit (priv); +} + +static void owl_emac_ndo_set_rx_mode (struct net_device *netdev) +{ +struct owl_emac_priv *priv =netdev_priv (netdev); +u32 status, val =0 ; +int mcast_count =0 ; + +if (netdev->flags &IFF_PROMISC ) { + val =OWL_EMAC_BIT_MAC_CSR6_PR ; + }else if (netdev->flags &IFF_ALLMULTI ) { + val =OWL_EMAC_BIT_MAC_CSR6_PM ; + }else if (netdev->flags &IFF_MULTICAST ) { + mcast_count =netdev_mc_count (netdev); + +if (mcast_count >OWL_EMAC_MAX_MULTICAST_ADDRS ) { + val =OWL_EMAC_BIT_MAC_CSR6_PM ; + mcast_count =0 ; + } + } + +spin_lock_bh (&priv->lock); + +/* Temporarily stop DMA TX & RX. */ + status =owl_emac_dma_cmd_stop (priv); + +/* Update operation modes. */ + owl_emac_reg_update(priv, OWL_EMAC_REG_MAC_CSR6, + OWL_EMAC_BIT_MAC_CSR6_PR | OWL_EMAC_BIT_MAC_CSR6_PM,drivers/net/ethernet/actions/owl-emac.c line 1164
Quoted 10 lines
drivers/net/ethernet/actions/owl-emac.c new file +10
-0+ val); + +/* Restore DMA TX & RX status. */ +owl_emac_dma_cmd_set (priv, status); + +spin_unlock_bh (&priv->lock); + +/* Set/reset multicast addr list. */ +owl_emac_set_multicast (netdev, mcast_count); +}I think this can be simplified. At least, you had me going around in circles a while trying to see if
WARN_ON()could be triggered from user space.
Quoted 4 lines
If you have more than
OWL_EMAC_MAX_MULTICAST_ADDRSMC addresses, you go into promisc mode. Can you then skip callingowl_emac_set_multicast(), which appears not to do too much useful when passed 0?
The main purpose of always calling owl_emac_set_multicast() is to ensure the size of the mcaddr_list is correctly updated (either set or reset). This prevents owl_emac_setup_frame_xmit() using obsolete data, when invoked from different contexts (i.e. MAC address changed).
A conditional call involves splitting the mcaddr_list management logic (i.e. moving the 'reset' operation from the callee to the caller), which IMO would make the usage of a separate function less justified.
Thanks,
Cristi
Quoted 2 lines
Andrew
PATCH v3 3/3 MAINTAINERS: Add entries for Actions Semi Owl Ethernet MAC
In reply to Cristian CiocalteaAdd entries for Actions Semi Owl Ethernet MAC binding and driver.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -1530,6 +1530,7 @@ F: Documentation/devicetree/bindings/dma/owl-dma.yaml F: Documentation/devicetree/bindings/i2c/i2c-owl.yaml F: Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.yaml F: Documentation/devicetree/bindings/mmc/owl-mmc.yaml +F: Documentation/devicetree/bindings/net/actions,owl-emac.yaml F: Documentation/devicetree/bindings/pinctrl/actions,* F: Documentation/devicetree/bindings/power/actions,owl-sps.txt F: Documentation/devicetree/bindings/timer/actions,owl-timer.txt
@@ -1542,6 +1543,7 @@ F: drivers/dma/owl-dma.c F: drivers/i2c/busses/i2c-owl.c F: drivers/irqchip/irq-owl-sirq.c F: drivers/mmc/host/owl-mmc.c +F: drivers/net/ethernet/actions/ F: drivers/pinctrl/actions/* F: drivers/soc/actions/ F: include/dt-bindings/power/owl-*
Signature · 1 line
2.31.0
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Mon, 22 Mar 2021 01:29:42 +0200 you wrote:
This patch series adds support for the Ethernet MAC found on the Actions Semi Owl family of SoCs.
For the moment I have only tested the driver on RoseapplePi SBC, which is based on the S500 SoC variant. It might work on S900 as well, but I cannot tell for sure since the S900 datasheet I currently have doesn't provide any information regarding the MAC registers - so I couldn't check the compatibility with S500.
[...]
Here is the summary with links:
- [v3,1/3] dt-bindings: net: Add Actions Semi Owl Ethernet MAC binding
https://git.kernel.org/netdev/net-next/c/fd42327f31bb - [v3,2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver https://git.kernel.org/netdev/net-next/c/de6e0b198239 - [v3,3/3] MAINTAINERS: Add entries for Actions Semi Owl Ethernet MAC https://git.kernel.org/netdev/net-next/c/b31f51832acf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html