Skip to contentSkip to conversation

Add support for Actions Semi Owl Ethernet MAC

PATCH Superseded Cristian Ciocaltea 3 participants 7 messages Mar 15, 2021 – Mar 20, 2021

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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 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          |   39 +
 drivers/net/ethernet/actions/Makefile         |    6 +
 drivers/net/ethernet/actions/owl-emac.c       | 1703 +++++++++++++++++
 drivers/net/ethernet/actions/owl-emac.h       |  280 +++
 8 files changed, 2124 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.30.2
#1 lore raw

PATCH v2 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
new file mode 100644
index 000000000000..1626e0a821b0
@@ -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 = <&eth_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.30.2
#2 lore raw

PATCH v2 2/3 net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver

In reply to 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.

---
 drivers/net/ethernet/Kconfig            |    1 +
 drivers/net/ethernet/Makefile           |    1 +
 drivers/net/ethernet/actions/Kconfig    |   39 +
 drivers/net/ethernet/actions/Makefile   |    6 +
 drivers/net/ethernet/actions/owl-emac.c | 1703 +++++++++++++++++++++++
 drivers/net/ethernet/actions/owl-emac.h |  280 ++++
 6 files changed, 2030 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
index ad04660b97b8..4b85f2b74872 100644
@@ -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
index 1e7dc8a7762d..9394493e8187 100644
@@ -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 +39 -0
new file mode 100644
index 000000000000..1f1480efc236
@@ -0,0 +1,39 @@
+# 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.
+
+config OWL_EMAC_GEN_ADDR_SYS_SN
+	bool "Enable generating MAC address based on system serial"
+	depends on OWL_EMAC
+	select CRYPTO
+	select CRYPTO_DES
+	select CRYPTO_ECB
+	select CRYPTO_SKCIPHER
+	default n
+	help
+	  If you say Y here and no MAC address is available, the Actions Semi
+	  Owl EMAC driver will generate the address based on the system serial
+	  number.  The fallback is to use a randomly generated MAC address.
+
+endif # NET_VENDOR_ACTIONS
drivers/net/ethernet/actions/Makefile new file +6 -0
new file mode 100644
index 000000000000..fde8001d538a
@@ -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 +1703 -0

1,703 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.30.2
#3 lore raw

Re: [PATCH v2 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver

From: Cristian Ciocaltea <[email protected]>
Date: Mon, 15 Mar 2021 13:29:17 +0200

drivers/net/ethernet/actions/owl-emac.c line 27

Quoted 5 lines
drivers/net/ethernet/actions/owl-emac.c new file +5 -0
+
+#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
+static int debug = -1;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");

Module parameters are strongly discouraged in networking drivers, pplease delete this ad just pass the default to netif_mdg_init(), thanks!

#4 lore raw

Re: [PATCH v2 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver

Quoted 11 lines · David Miller

From: Cristian Ciocaltea <[email protected]>
Date: Mon, 15 Mar 2021 13:29:17 +0200

drivers/net/ethernet/actions/owl-emac.c line 27

Quoted 5 lines
drivers/net/ethernet/actions/owl-emac.c new file +5 -0
+
+#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
+static int debug = -1;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");

Module parameters are strongly discouraged in networking drivers, pplease delete this ad just pass the default to netif_mdg_init(), thanks!

Ups, I was not aware of this since I've seen it in quite a lot of drivers.

Thanks for pointing this out, I will take care of it in the next revision.

Kind regards,
Cristi

#5 lore raw

Re: [PATCH v2 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver

In reply to Cristian Ciocaltea
Thank you for the patch! Yet something to improve:

Hi Cristian,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on robh/for-next]
[also build test ERROR on net-next/master net/master linus/master sparc-next/master v5.12-rc3 next-20210319] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Cristian-Ciocaltea/Add-support-for-Actions-Semi-Owl-Ethernet-MAC/20210315-193141
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1c4a01e3cce738ac75d55fa6a1cbd8f5a5dfcd61
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Cristian-Ciocaltea/Add-support-for-Actions-Semi-Owl-Ethernet-MAC/20210315-193141 git checkout 1c4a01e3cce738ac75d55fa6a1cbd8f5a5dfcd61
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> drivers/net/ethernet/actions/owl-emac.c:9:10: fatal error: asm/system_info.h: No such file or directory

9 | #include <asm/system_info.h>
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.

vim +9 drivers/net/ethernet/actions/owl-emac.c

   > 9	#include <asm/system_info.h>
    10	#include <crypto/skcipher.h>
    11	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#6 lore raw

PATCH v2 3/3 MAINTAINERS: Add entries for Actions Semi Owl Ethernet MAC

In reply to Cristian Ciocaltea

Add entries for Actions Semi Owl Ethernet MAC binding and driver.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 411df197e4a1..20b8e37ea34c 100644
@@ -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.30.2