This is a patch series for Ethernet driver of Sunplus SP7021 SoC.
Subsystems (4)
v6 cover This is a patch series for Ethernet driver of Sunplus SP7021 SoC.
Sunplus SP7021 is an ARM Cortex A7 (4 cores) based SoC. It integrates many peripherals (ex: UART, I2C, SPI, SDIO, eMMC, USB, SD card and etc.) into a single chip. It is designed for industrial control applications.
Refer to:
https://sunplus.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html
Wells Lu (2):
devicetree: bindings: net: Add bindings doc for Sunplus SP7021.
net: ethernet: Add driver for Sunplus SP7021
.../bindings/net/sunplus,sp7021-emac.yaml | 140 +++++ MAINTAINERS | 8 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/sunplus/Kconfig | 36 ++ drivers/net/ethernet/sunplus/Makefile | 6 + drivers/net/ethernet/sunplus/spl2sw_define.h | 271 +++++++++ drivers/net/ethernet/sunplus/spl2sw_desc.c | 226 ++++++++ drivers/net/ethernet/sunplus/spl2sw_desc.h | 19 + drivers/net/ethernet/sunplus/spl2sw_driver.c | 603 +++++++++++++++++++++ drivers/net/ethernet/sunplus/spl2sw_driver.h | 12 + drivers/net/ethernet/sunplus/spl2sw_int.c | 253 +++++++++ drivers/net/ethernet/sunplus/spl2sw_int.h | 13 + drivers/net/ethernet/sunplus/spl2sw_mac.c | 346 ++++++++++++ drivers/net/ethernet/sunplus/spl2sw_mac.h | 19 + drivers/net/ethernet/sunplus/spl2sw_mdio.c | 126 +++++ drivers/net/ethernet/sunplus/spl2sw_mdio.h | 12 + drivers/net/ethernet/sunplus/spl2sw_phy.c | 92 ++++ drivers/net/ethernet/sunplus/spl2sw_phy.h | 12 + drivers/net/ethernet/sunplus/spl2sw_register.h | 86 +++ 20 files changed, 2282 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/sunplus,sp7021-emac.yaml create mode 100644 drivers/net/ethernet/sunplus/Kconfig create mode 100644 drivers/net/ethernet/sunplus/Makefile create mode 100644 drivers/net/ethernet/sunplus/spl2sw_define.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_desc.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_desc.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_driver.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_driver.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_int.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_int.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mac.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mac.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mdio.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mdio.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_phy.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_phy.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_register.h
Signature · 1 line
2.7.4
PATCH v6 1/2 devicetree: bindings: net: Add bindings doc for Sunplus SP7021.
Add bindings documentation for Sunplus SP7021 SoC.
---
Changes in v6
- Removed the second item of 'reg'.
- Removed 'reg-names'
.../bindings/net/sunplus,sp7021-emac.yaml | 140 +++++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 147 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/sunplus,sp7021-emac.yaml
Documentation/devicetree/bindings/net/sunplus,sp7021-emac.yaml new file +140 -0
@@ -0,0 +1,140 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) Sunplus Co., Ltd. 2021 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/sunplus,sp7021-emac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sunplus SP7021 Dual Ethernet MAC Device Tree Bindings + +maintainers: + - Wells Lu <[email protected]> + +description: | + Sunplus SP7021 dual 10M/100M Ethernet MAC controller. + Device node of the controller has following properties. + +properties: + compatible: + const: sunplus,sp7021-emac + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + ethernet-ports: + type: object + description: Ethernet ports to PHY + + properties: + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^port@[0-1]$": + type: object + description: Port to PHY + + properties: + reg: + minimum: 0 + maximum: 1 + + phy-handle: + maxItems: 1 + + phy-mode: + maxItems: 1 + + nvmem-cells: + items: + - description: nvmem cell address of MAC address + + nvmem-cell-names: + description: names corresponding to the nvmem cells + items: + - const: mac-address + + required: + - reg + - phy-handle + - phy-mode + - nvmem-cells + - nvmem-cell-names + + mdio: + $ref: mdio.yaml# + unevaluatedProperties: false + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - clocks + - resets + - pinctrl-0 + - pinctrl-names + - ethernet-ports + - mdio + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + ethernet@9c108000 { + compatible = "sunplus,sp7021-emac"; + reg = <0x9c108000 0x400>; + interrupt-parent = <&intc>; + interrupts = <66 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clkc 0xa7>; + resets = <&rstc 0x97>; + pinctrl-0 = <&emac_demo_board_v3_pins>; + pinctrl-names = "default"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + phy-handle = <ð_phy0>; + phy-mode = "rmii"; + nvmem-cells = <&mac_addr0>; + nvmem-cell-names = "mac-address"; + }; + + port@1 { + reg = <1>; + phy-handle = <ð_phy1>; + phy-mode = "rmii"; + nvmem-cells = <&mac_addr1>; + nvmem-cell-names = "mac-address"; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + eth_phy0: ethernet-phy@0 { + reg = <0>; + }; + + eth_phy1: ethernet-phy@1 { + reg = <1>; + }; + }; + }; +...
MAINTAINERS +7 -0
@@ -18837,6 +18837,13 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/dlink/sundance.c +SUNPLUS ETHERNET DRIVER +M: Wells Lu <[email protected]> +L: [email protected] +S: Maintained +W: https://sunplus.atlassian.net/wiki/spaces/doc/overview +F: Documentation/devicetree/bindings/net/sunplus,sp7021-emac.yaml + SUNPLUS OCOTP DRIVER M: Vincent Shih <[email protected]> S: Maintained
Signature · 1 line
2.7.4
PATCH v6 2/2 net: ethernet: Add driver for Sunplus SP7021
In reply to Wells LuAdd driver for Sunplus SP7021 SoC.
---
Changes in v6
- Removed the second item of 'reg'.
Address of the second item of 'reg'. is used to set polarity of RMII signals. The settings are moved to boot-loader.
MAINTAINERS | 1 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/sunplus/Kconfig | 36 ++ drivers/net/ethernet/sunplus/Makefile | 6 + drivers/net/ethernet/sunplus/spl2sw_define.h | 271 +++++++++++ drivers/net/ethernet/sunplus/spl2sw_desc.c | 226 +++++++++ drivers/net/ethernet/sunplus/spl2sw_desc.h | 19 + drivers/net/ethernet/sunplus/spl2sw_driver.c | 603 +++++++++++++++++++++++++ drivers/net/ethernet/sunplus/spl2sw_driver.h | 12 + drivers/net/ethernet/sunplus/spl2sw_int.c | 253 +++++++++++ drivers/net/ethernet/sunplus/spl2sw_int.h | 13 + drivers/net/ethernet/sunplus/spl2sw_mac.c | 346 ++++++++++++++ drivers/net/ethernet/sunplus/spl2sw_mac.h | 19 + drivers/net/ethernet/sunplus/spl2sw_mdio.c | 126 ++++++ drivers/net/ethernet/sunplus/spl2sw_mdio.h | 12 + drivers/net/ethernet/sunplus/spl2sw_phy.c | 92 ++++ drivers/net/ethernet/sunplus/spl2sw_phy.h | 12 + drivers/net/ethernet/sunplus/spl2sw_register.h | 86 ++++ 19 files changed, 2135 insertions(+) create mode 100644 drivers/net/ethernet/sunplus/Kconfig create mode 100644 drivers/net/ethernet/sunplus/Makefile create mode 100644 drivers/net/ethernet/sunplus/spl2sw_define.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_desc.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_desc.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_driver.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_driver.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_int.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_int.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mac.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mac.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mdio.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_mdio.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_phy.c create mode 100644 drivers/net/ethernet/sunplus/spl2sw_phy.h create mode 100644 drivers/net/ethernet/sunplus/spl2sw_register.h
MAINTAINERS +1 -0
@@ -18843,6 +18843,7 @@ L: [email protected] S: Maintained W: https://sunplus.atlassian.net/wiki/spaces/doc/overview F: Documentation/devicetree/bindings/net/sunplus,sp7021-emac.yaml +F: drivers/net/ethernet/sunplus/ SUNPLUS OCOTP DRIVER M: Vincent Shih <[email protected]>
drivers/net/ethernet/Kconfig +1 -0
@@ -179,6 +179,7 @@ source "drivers/net/ethernet/smsc/Kconfig" source "drivers/net/ethernet/socionext/Kconfig" source "drivers/net/ethernet/stmicro/Kconfig" source "drivers/net/ethernet/sun/Kconfig" +source "drivers/net/ethernet/sunplus/Kconfig" source "drivers/net/ethernet/synopsys/Kconfig" source "drivers/net/ethernet/tehuti/Kconfig" source "drivers/net/ethernet/ti/Kconfig"
drivers/net/ethernet/Makefile +1 -0
@@ -90,6 +90,7 @@ obj-$(CONFIG_NET_VENDOR_SMSC) += smsc/ obj-$(CONFIG_NET_VENDOR_SOCIONEXT) += socionext/ obj-$(CONFIG_NET_VENDOR_STMICRO) += stmicro/ obj-$(CONFIG_NET_VENDOR_SUN) += sun/ +obj-$(CONFIG_NET_VENDOR_SUNPLUS) += sunplus/ obj-$(CONFIG_NET_VENDOR_TEHUTI) += tehuti/ obj-$(CONFIG_NET_VENDOR_TI) += ti/ obj-$(CONFIG_NET_VENDOR_TOSHIBA) += toshiba/
drivers/net/ethernet/sunplus/Kconfig new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Sunplus network device configuration +# + +config NET_VENDOR_SUNPLUS + bool "Sunplus devices" + default y + depends on ARCH_SUNPLUS || COMPILE_TEST + help + If you have a network (Ethernet) card belonging to this + class, say Y here. + + 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 Sunplus cards. If you say Y, + you will be asked for your specific card in the following + questions. + +if NET_VENDOR_SUNPLUS + +config SP7021_EMAC + tristate "Sunplus Dual 10M/100M Ethernet devices" + depends on SOC_SP7021 || COMPILE_TEST + select PHYLIB + select PINCTRL_SPPCTL + select COMMON_CLK_SP7021 + select RESET_SUNPLUS + select NVMEM_SUNPLUS_OCOTP + help + If you have Sunplus dual 10M/100M Ethernet devices, say Y. + The network device creates two net-device interfaces. + To compile this driver as a module, choose M here. The + module will be called sp7021_emac. + +endif # NET_VENDOR_SUNPLUS
drivers/net/ethernet/sunplus/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the Sunplus network device drivers. +# +obj-$(CONFIG_SP7021_EMAC) += sp7021_emac.o +sp7021_emac-objs := spl2sw_driver.o spl2sw_int.o spl2sw_desc.o spl2sw_mac.o spl2sw_mdio.o spl2sw_phy.o
drivers/net/ethernet/sunplus/spl2sw_define.h new file +271 -0
271 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_desc.c new file +226 -0
226 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_desc.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright Sunplus Technology Co., Ltd. +* All rights reserved. +*/ + +#ifndef __SPL2SW_DESC_H__ +#define __SPL2SW_DESC_H__ + +void spl2sw_rx_descs_flush (struct spl2sw_common *comm); +void spl2sw_tx_descs_clean (struct spl2sw_common *comm); +void spl2sw_rx_descs_clean (struct spl2sw_common *comm); +void spl2sw_descs_clean (struct spl2sw_common *comm); +void spl2sw_descs_free (struct spl2sw_common *comm); +void spl2sw_tx_descs_init (struct spl2sw_common *comm); +int spl2sw_rx_descs_init (struct spl2sw_common *comm); +int spl2sw_descs_alloc (struct spl2sw_common *comm); +int spl2sw_descs_init (struct spl2sw_common *comm); + +#endif
drivers/net/ethernet/sunplus/spl2sw_driver.c new file +603 -0
603 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_driver.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright Sunplus Technology Co., Ltd. +* All rights reserved. +*/ + +#ifndef __SPL2SW_DRIVER_H__ +#define __SPL2SW_DRIVER_H__ + +#define SPL2SW_RX_NAPI_WEIGHT 16 +#define SPL2SW_TX_NAPI_WEIGHT 16 + +#endif
drivers/net/ethernet/sunplus/spl2sw_int.c new file +253 -0
253 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_int.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright Sunplus Technology Co., Ltd. +* All rights reserved. +*/ + +#ifndef __SPL2SW_INT_H__ +#define __SPL2SW_INT_H__ + +int spl2sw_rx_poll (struct napi_struct *napi,int budget); +int spl2sw_tx_poll (struct napi_struct *napi,int budget); +irqreturn_t spl2sw_ethernet_interrupt (int irq,void *dev_id); + +#endif
drivers/net/ethernet/sunplus/spl2sw_mac.c new file +346 -0
346 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_mac.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright Sunplus Technology Co., Ltd. +* All rights reserved. +*/ + +#ifndef __SPL2SW_MAC_H__ +#define __SPL2SW_MAC_H__ + +void spl2sw_mac_hw_stop (struct spl2sw_common *comm); +void spl2sw_mac_hw_start (struct spl2sw_common *comm); +int spl2sw_mac_addr_add (struct spl2sw_mac *mac); +int spl2sw_mac_addr_del (struct spl2sw_mac *mac); +int spl2sw_mac_addr_del_all (struct spl2sw_common *comm); +void spl2sw_mac_hw_init (struct spl2sw_common *comm); +void spl2sw_mac_rx_mode_set (struct spl2sw_mac *mac); +void spl2sw_mac_init (struct spl2sw_common *comm); +void spl2sw_mac_soft_reset (struct spl2sw_common *comm); + +#endif
drivers/net/ethernet/sunplus/spl2sw_mdio.c new file +126 -0
126 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_mdio.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright Sunplus Technology Co., Ltd. +* All rights reserved. +*/ + +#ifndef __SPL2SW_MDIO_H__ +#define __SPL2SW_MDIO_H__ + +u32 spl2sw_mdio_init (struct spl2sw_common *comm); +void spl2sw_mdio_remove (struct spl2sw_common *comm); + +#endif
drivers/net/ethernet/sunplus/spl2sw_phy.c new file +92 -0
92 lines not on this page · raw message
drivers/net/ethernet/sunplus/spl2sw_phy.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright Sunplus Technology Co., Ltd. +* All rights reserved. +*/ + +#ifndef __SPL2SW_PHY_H__ +#define __SPL2SW_PHY_H__ + +int spl2sw_phy_connect (struct spl2sw_common *comm); +void spl2sw_phy_remove (struct spl2sw_common *comm); + +#endif
drivers/net/ethernet/sunplus/spl2sw_register.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.7.4
kernel test robot
build botRe: [PATCH net-next v6 2/2] net: ethernet: Add driver for Sunplus SP7021
I love your patch! Perhaps something to improve:
Hi Wells,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net/master]
[also build test WARNING on robh/for-next linus/master v5.18-rc1 next-20220405] [cannot apply to net-next/master]
[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/intel-lab-lkp/linux/commits/Wells-Lu/This-is-a-patch-series-for-Ethernet-driver-of-Sunplus-SP7021-SoC/20220404-040949 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 692930cc435099580a4b9e32fa781b0688c18439 config: alpha-randconfig-c004-20220405 (https://download.01.org/0day-ci/archive/20220406/[email protected]/config) compiler: alpha-linux-gcc (GCC) 11.2.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/intel-lab-lkp/linux/commit/d8d2085594ea52869669a553bb6d60e0b3a1f412
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Wells-Lu/This-is-a-patch-series-for-Ethernet-driver-of-Sunplus-SP7021-SoC/20220404-040949
git checkout d8d2085594ea52869669a553bb6d60e0b3a1f412
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/net/ethernet/sunplus/ drivers/pinctrl/sunplus/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/net/ethernet/sunplus/spl2sw_driver.c: In function 'spl2sw_get_eth_child_node':
drivers/net/ethernet/sunplus/spl2sw_driver.c:328:9: error: implicit declaration of function 'for_each_child_of_node'; did you mean 'for_each_online_node'? [-Werror=implicit-function-declaration]
328 | for_each_child_of_node(ether_np, port_np) {
| ^~~~~~~~~~~~~~~~~~~~~~
| for_each_online_node
drivers/net/ethernet/sunplus/spl2sw_driver.c:328:50: error: expected ';' before '{' token
328 | for_each_child_of_node(ether_np, port_np) {
| ^~
| ;
drivers/net/ethernet/sunplus/spl2sw_driver.c:326:13: warning: unused variable 'port_id' [-Wunused-variable]
326 | int port_id;
| ^~~~~~~
drivers/net/ethernet/sunplus/spl2sw_driver.c:342:1: error: no return statement in function returning non-void [-Werror=return-type]
342 | }
| ^
drivers/net/ethernet/sunplus/spl2sw_driver.c: In function 'spl2sw_probe':
drivers/net/ethernet/sunplus/spl2sw_driver.c:407:24: error: implicit declaration of function 'of_get_child_by_name' [-Werror=implicit-function-declaration]
407 | eth_ports_np = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
| ^~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/sunplus/spl2sw_driver.c:407:22: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
407 | eth_ports_np = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
| ^
drivers/net/ethernet/sunplus/spl2sw_driver.c:428:26: error: implicit declaration of function 'of_parse_phandle' [-Werror=implicit-function-declaration]
428 | phy_np = of_parse_phandle(port_np, "phy-handle", 0);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/sunplus/spl2sw_driver.c:428:24: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
428 | phy_np = of_parse_phandle(port_np, "phy-handle", 0);
| ^cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for PINCTRL_SPPCTL
Depends on PINCTRL && SOC_SP7021 && OF && HAS_IOMEM
Selected by
- SP7021_EMAC && NETDEVICES && ETHERNET && NET_VENDOR_SUNPLUS && (SOC_SP7021 || COMPILE_TEST
vim +407 drivers/net/ethernet/sunplus/spl2sw_driver.c
343
344 static int spl2sw_probe(struct platform_device *pdev)
345 {
346 struct device_node *eth_ports_np;
347 struct device_node *port_np;
348 struct spl2sw_common *comm;
349 struct device_node *phy_np;
350 phy_interface_t phy_mode;
351 struct net_device *ndev;
352 u8 mac_addr[ETH_ALEN];
353 struct spl2sw_mac *mac;
354 int irq, i;
355 int ret;
356
357 if (platform_get_drvdata(pdev))
358 return -ENODEV;
359
360 /* Allocate memory for 'spl2sw_common' area. */
361 comm = devm_kzalloc(&pdev->dev, sizeof(*comm), GFP_KERNEL);
362 if (!comm)
363 return -ENOMEM;
364 comm->pdev = pdev;
365
366 spin_lock_init(&comm->rx_lock);
367 spin_lock_init(&comm->tx_lock);
368 spin_lock_init(&comm->mdio_lock);
369
370 /* Get memory resource 0 from dts. */
371 comm->l2sw_reg_base = devm_platform_ioremap_resource(pdev, 0);
372 if (IS_ERR(comm->l2sw_reg_base))
373 return PTR_ERR(comm->l2sw_reg_base);
374
375 /* Get irq resource from dts. */
376 ret = platform_get_irq(pdev, 0);
377 if (ret < 0)
378 return ret;
379 irq = ret;
380
381 /* Get clock controller. */
382 comm->clk = devm_clk_get(&pdev->dev, NULL);
383 if (IS_ERR(comm->clk)) {
384 dev_err_probe(&pdev->dev, PTR_ERR(comm->clk),
385 "Failed to retrieve clock controller!\n");
386 return PTR_ERR(comm->clk);
387 }
388
389 /* Get reset controller. */
390 comm->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
391 if (IS_ERR(comm->rstc)) {
392 dev_err_probe(&pdev->dev, PTR_ERR(comm->rstc),
393 "Failed to retrieve reset controller!\n");
394 return PTR_ERR(comm->rstc);
395 }
396
397 /* Enable clock. */
398 clk_prepare_enable(comm->clk);
399 udelay(1);
400
401 reset_control_assert(comm->rstc);
402 udelay(1);
403 reset_control_deassert(comm->rstc);
404 udelay(1);
405
406 /* Get child node ethernet-ports. */
> 407 eth_ports_np = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
408 if (!eth_ports_np) {
409 dev_err(&pdev->dev, "No ethernet-ports child node found!\n");
410 ret = -ENODEV;
411 goto out_clk_disable;
412 }
413
414 for (i = 0; i < MAX_NETDEV_NUM; i++) {
415 /* Get port@i of node ethernet-ports. */
416 port_np = spl2sw_get_eth_child_node(eth_ports_np, i);
417 if (!port_np)
418 continue;
419
420 /* Get phy-mode. */
421 if (of_get_phy_mode(port_np, &phy_mode)) {
422 dev_err(&pdev->dev, "Failed to get phy-mode property of port@%d!\n",
423 i);
424 continue;
425 }
426
427 /* Get phy-handle. */
428 phy_np = of_parse_phandle(port_np, "phy-handle", 0);
429 if (!phy_np) {
430 dev_err(&pdev->dev, "Failed to get phy-handle property of port@%d!\n",
431 i);
432 continue;
433 }
434
435 /* Get mac-address from nvmem. */
436 ret = spl2sw_nvmem_get_mac_address(&pdev->dev, port_np, mac_addr);
437 if (ret) {
438 dev_info(&pdev->dev, "Generate a random mac address!\n");
439
440 /* Generate a mac address using OUI of Sunplus Technology
441 * and random controller number.
442 */
443 mac_addr[0] = 0xfc; /* OUI of Sunplus: fc:4b:bc */
444 mac_addr[1] = 0x4b;
445 mac_addr[2] = 0xbc;
446 mac_addr[3] = get_random_int() % 256;
447 mac_addr[4] = get_random_int() % 256;
448 mac_addr[5] = get_random_int() % 256;
449 }
450
451 /* Initialize the net device. */
452 ret = spl2sw_init_netdev(pdev, mac_addr, &ndev);
453 if (ret)
454 goto out_unregister_dev;
455
456 ndev->irq = irq;
457 comm->ndev[i] = ndev;
458 mac = netdev_priv(ndev);
459 mac->phy_node = phy_np;
460 mac->phy_mode = phy_mode;
461 mac->comm = comm;
462
463 mac->lan_port = 0x1 << i; /* forward to port i */
464 mac->to_vlan = 0x1 << i; /* vlan group: i */
465 mac->vlan_id = i; /* vlan group: i */
466
467 /* Set MAC address */
468 ret = spl2sw_mac_addr_add(mac);
469 if (ret)
470 goto out_unregister_dev;
471
472 spl2sw_mac_rx_mode_set(mac);
473 }
474
475 /* Find first valid net device. */
476 for (i = 0; i < MAX_NETDEV_NUM; i++) {
477 if (comm->ndev[i])
478 break;
479 }
480 if (i >= MAX_NETDEV_NUM) {
481 dev_err(&pdev->dev, "No valid ethernet port!\n");
482 ret = -ENODEV;
483 goto out_clk_disable;
484 }
485
486 /* Save first valid net device */
487 ndev = comm->ndev[i];
488 platform_set_drvdata(pdev, ndev);
489
490 /* Request irq. */
491 ret = devm_request_irq(&pdev->dev, irq, spl2sw_ethernet_interrupt,
492 0, ndev->name, ndev);
493 if (ret) {
494 netdev_err(ndev, "Failed to request irq #%d for \"%s\"!\n",
495 irq, ndev->name);
496 goto out_unregister_dev;
497 }
498
499 /* Initialize mdio bus */
500 ret = spl2sw_mdio_init(comm);
501 if (ret) {
502 netdev_err(ndev, "Failed to initialize mdio bus!\n");
503 goto out_unregister_dev;
504 }
505
506 ret = spl2sw_mac_addr_del_all(comm);
507 if (ret)
508 goto out_free_mdio;
509
510 ret = spl2sw_descs_init(comm);
511 if (ret) {
512 dev_err(&comm->pdev->dev, "Fail to initialize mac descriptors!\n");
513 spl2sw_descs_free(comm);
514 goto out_free_mdio;
515 }
516
517 spl2sw_mac_init(comm);
518
519 ret = spl2sw_phy_connect(comm);
520 if (ret) {
521 netdev_err(ndev, "Failed to connect phy!\n");
522 goto out_free_mdio;
523 }
524
525 netif_napi_add(ndev, &comm->rx_napi, spl2sw_rx_poll, SPL2SW_RX_NAPI_WEIGHT);
526 napi_enable(&comm->rx_napi);
527 netif_napi_add(ndev, &comm->tx_napi, spl2sw_tx_poll, SPL2SW_TX_NAPI_WEIGHT);
528 napi_enable(&comm->tx_napi);
529 return 0;
530
531 out_free_mdio:
532 spl2sw_mdio_remove(comm);
533
534 out_unregister_dev:
535 for (i = 0; i < MAX_NETDEV_NUM; i++)
536 if (comm->ndev[i])
537 unregister_netdev(comm->ndev[i]);
538
539 out_clk_disable:
540 clk_disable_unprepare(comm->clk);
541 return ret;
542 }
543
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botRe: [PATCH net-next v6 2/2] net: ethernet: Add driver for Sunplus SP7021
In reply to Wells LuI love your patch! Yet something to improve:
Hi Wells,
I love your patch! Yet something to improve:
[auto build test ERROR on net/master]
[also build test ERROR on robh/for-next linus/master v5.18-rc1 next-20220405] [cannot apply to net-next/master]
[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/intel-lab-lkp/linux/commits/Wells-Lu/This-is-a-patch-series-for-Ethernet-driver-of-Sunplus-SP7021-SoC/20220404-040949 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 692930cc435099580a4b9e32fa781b0688c18439 config: alpha-randconfig-c004-20220405 (https://download.01.org/0day-ci/archive/20220406/[email protected]/config) compiler: alpha-linux-gcc (GCC) 11.2.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/intel-lab-lkp/linux/commit/d8d2085594ea52869669a553bb6d60e0b3a1f412
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Wells-Lu/This-is-a-patch-series-for-Ethernet-driver-of-Sunplus-SP7021-SoC/20220404-040949 git checkout d8d2085594ea52869669a553bb6d60e0b3a1f412
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/pinctrl/sunplus/sppctl.c: In function 'sppctl_gpio_new':
>> drivers/pinctrl/sunplus/sppctl.c:559:14: error: 'struct gpio_chip' has no member named 'of_gpio_n_cells'
559 | gchip->of_gpio_n_cells = 2;
| ^~
--
drivers/net/ethernet/sunplus/spl2sw_driver.c: In function 'spl2sw_get_eth_child_node':
>> drivers/net/ethernet/sunplus/spl2sw_driver.c:328:9: error: implicit declaration of function 'for_each_child_of_node'; did you mean 'for_each_online_node'? [-Werror=implicit-function-declaration]
328 | for_each_child_of_node(ether_np, port_np) {
| ^~~~~~~~~~~~~~~~~~~~~~
| for_each_online_node
>> drivers/net/ethernet/sunplus/spl2sw_driver.c:328:50: error: expected ';' before '{' token
328 | for_each_child_of_node(ether_np, port_np) {
| ^~
| ;
drivers/net/ethernet/sunplus/spl2sw_driver.c:326:13: warning: unused variable 'port_id' [-Wunused-variable]
326 | int port_id;
| ^~~~~~~
drivers/net/ethernet/sunplus/spl2sw_driver.c:342:1: error: no return statement in function returning non-void [-Werror=return-type]
342 | }
| ^
drivers/net/ethernet/sunplus/spl2sw_driver.c: In function 'spl2sw_probe':
>> drivers/net/ethernet/sunplus/spl2sw_driver.c:407:24: error: implicit declaration of function 'of_get_child_by_name' [-Werror=implicit-function-declaration]
407 | eth_ports_np = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sunplus/spl2sw_driver.c:407:22: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
407 | eth_ports_np = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
| ^
>> drivers/net/ethernet/sunplus/spl2sw_driver.c:428:26: error: implicit declaration of function 'of_parse_phandle' [-Werror=implicit-function-declaration]
428 | phy_np = of_parse_phandle(port_np, "phy-handle", 0);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/sunplus/spl2sw_driver.c:428:24: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
428 | phy_np = of_parse_phandle(port_np, "phy-handle", 0);
| ^cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for PINCTRL_SPPCTL
Depends on PINCTRL && SOC_SP7021 && OF && HAS_IOMEM
Selected by
- SP7021_EMAC && NETDEVICES && ETHERNET && NET_VENDOR_SUNPLUS && (SOC_SP7021 || COMPILE_TEST
vim +328 drivers/net/ethernet/sunplus/spl2sw_driver.c
322
323 static struct device_node *spl2sw_get_eth_child_node(struct device_node *ether_np, int id)
324 {
325 struct device_node *port_np;
326 int port_id;
327
> 328 for_each_child_of_node(ether_np, port_np) {
329 /* It is not a 'port' node, continue. */
330 if (strcmp(port_np->name, "port"))
331 continue;
332
333 if (of_property_read_u32(port_np, "reg", &port_id) < 0)
334 continue;
335
336 if (port_id == id)
337 return port_np;
338 }
339
340 /* Not found! */
341 return NULL;
342 }
343
344 static int spl2sw_probe(struct platform_device *pdev)
345 {
346 struct device_node *eth_ports_np;
347 struct device_node *port_np;
348 struct spl2sw_common *comm;
349 struct device_node *phy_np;
350 phy_interface_t phy_mode;
351 struct net_device *ndev;
352 u8 mac_addr[ETH_ALEN];
353 struct spl2sw_mac *mac;
354 int irq, i;
355 int ret;
356
357 if (platform_get_drvdata(pdev))
358 return -ENODEV;
359
360 /* Allocate memory for 'spl2sw_common' area. */
361 comm = devm_kzalloc(&pdev->dev, sizeof(*comm), GFP_KERNEL);
362 if (!comm)
363 return -ENOMEM;
364 comm->pdev = pdev;
365
366 spin_lock_init(&comm->rx_lock);
367 spin_lock_init(&comm->tx_lock);
368 spin_lock_init(&comm->mdio_lock);
369
370 /* Get memory resource 0 from dts. */
371 comm->l2sw_reg_base = devm_platform_ioremap_resource(pdev, 0);
372 if (IS_ERR(comm->l2sw_reg_base))
373 return PTR_ERR(comm->l2sw_reg_base);
374
375 /* Get irq resource from dts. */
376 ret = platform_get_irq(pdev, 0);
377 if (ret < 0)
378 return ret;
379 irq = ret;
380
381 /* Get clock controller. */
382 comm->clk = devm_clk_get(&pdev->dev, NULL);
383 if (IS_ERR(comm->clk)) {
384 dev_err_probe(&pdev->dev, PTR_ERR(comm->clk),
385 "Failed to retrieve clock controller!\n");
386 return PTR_ERR(comm->clk);
387 }
388
389 /* Get reset controller. */
390 comm->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
391 if (IS_ERR(comm->rstc)) {
392 dev_err_probe(&pdev->dev, PTR_ERR(comm->rstc),
393 "Failed to retrieve reset controller!\n");
394 return PTR_ERR(comm->rstc);
395 }
396
397 /* Enable clock. */
398 clk_prepare_enable(comm->clk);
399 udelay(1);
400
401 reset_control_assert(comm->rstc);
402 udelay(1);
403 reset_control_deassert(comm->rstc);
404 udelay(1);
405
406 /* Get child node ethernet-ports. */
> 407 eth_ports_np = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
408 if (!eth_ports_np) {
409 dev_err(&pdev->dev, "No ethernet-ports child node found!\n");
410 ret = -ENODEV;
411 goto out_clk_disable;
412 }
413
414 for (i = 0; i < MAX_NETDEV_NUM; i++) {
415 /* Get port@i of node ethernet-ports. */
416 port_np = spl2sw_get_eth_child_node(eth_ports_np, i);
417 if (!port_np)
418 continue;
419
420 /* Get phy-mode. */
421 if (of_get_phy_mode(port_np, &phy_mode)) {
422 dev_err(&pdev->dev, "Failed to get phy-mode property of port@%d!\n",
423 i);
424 continue;
425 }
426
427 /* Get phy-handle. */
> 428 phy_np = of_parse_phandle(port_np, "phy-handle", 0); 429 if (!phy_np) {
430 dev_err(&pdev->dev, "Failed to get phy-handle property of port@%d!\n",
431 i);
432 continue;
433 }
434
435 /* Get mac-address from nvmem. */
436 ret = spl2sw_nvmem_get_mac_address(&pdev->dev, port_np, mac_addr);
437 if (ret) {
438 dev_info(&pdev->dev, "Generate a random mac address!\n");
439
440 /* Generate a mac address using OUI of Sunplus Technology
441 * and random controller number.
442 */
443 mac_addr[0] = 0xfc; /* OUI of Sunplus: fc:4b:bc */
444 mac_addr[1] = 0x4b;
445 mac_addr[2] = 0xbc;
446 mac_addr[3] = get_random_int() % 256;
447 mac_addr[4] = get_random_int() % 256;
448 mac_addr[5] = get_random_int() % 256;
449 }
450
451 /* Initialize the net device. */
452 ret = spl2sw_init_netdev(pdev, mac_addr, &ndev);
453 if (ret)
454 goto out_unregister_dev;
455
456 ndev->irq = irq;
457 comm->ndev[i] = ndev;
458 mac = netdev_priv(ndev);
459 mac->phy_node = phy_np;
460 mac->phy_mode = phy_mode;
461 mac->comm = comm;
462
463 mac->lan_port = 0x1 << i; /* forward to port i */
464 mac->to_vlan = 0x1 << i; /* vlan group: i */
465 mac->vlan_id = i; /* vlan group: i */
466
467 /* Set MAC address */
468 ret = spl2sw_mac_addr_add(mac);
469 if (ret)
470 goto out_unregister_dev;
471
472 spl2sw_mac_rx_mode_set(mac);
473 }
474
475 /* Find first valid net device. */
476 for (i = 0; i < MAX_NETDEV_NUM; i++) {
477 if (comm->ndev[i])
478 break;
479 }
480 if (i >= MAX_NETDEV_NUM) {
481 dev_err(&pdev->dev, "No valid ethernet port!\n");
482 ret = -ENODEV;
483 goto out_clk_disable;
484 }
485
486 /* Save first valid net device */
487 ndev = comm->ndev[i];
488 platform_set_drvdata(pdev, ndev);
489
490 /* Request irq. */
491 ret = devm_request_irq(&pdev->dev, irq, spl2sw_ethernet_interrupt,
492 0, ndev->name, ndev);
493 if (ret) {
494 netdev_err(ndev, "Failed to request irq #%d for \"%s\"!\n",
495 irq, ndev->name);
496 goto out_unregister_dev;
497 }
498
499 /* Initialize mdio bus */
500 ret = spl2sw_mdio_init(comm);
501 if (ret) {
502 netdev_err(ndev, "Failed to initialize mdio bus!\n");
503 goto out_unregister_dev;
504 }
505
506 ret = spl2sw_mac_addr_del_all(comm);
507 if (ret)
508 goto out_free_mdio;
509
510 ret = spl2sw_descs_init(comm);
511 if (ret) {
512 dev_err(&comm->pdev->dev, "Fail to initialize mac descriptors!\n");
513 spl2sw_descs_free(comm);
514 goto out_free_mdio;
515 }
516
517 spl2sw_mac_init(comm);
518
519 ret = spl2sw_phy_connect(comm);
520 if (ret) {
521 netdev_err(ndev, "Failed to connect phy!\n");
522 goto out_free_mdio;
523 }
524
525 netif_napi_add(ndev, &comm->rx_napi, spl2sw_rx_poll, SPL2SW_RX_NAPI_WEIGHT);
526 napi_enable(&comm->rx_napi);
527 netif_napi_add(ndev, &comm->tx_napi, spl2sw_tx_poll, SPL2SW_TX_NAPI_WEIGHT);
528 napi_enable(&comm->tx_napi);
529 return 0;
530
531 out_free_mdio:
532 spl2sw_mdio_remove(comm);
533
534 out_unregister_dev:
535 for (i = 0; i < MAX_NETDEV_NUM; i++)
536 if (comm->ndev[i])
537 unregister_netdev(comm->ndev[i]);
538
539 out_clk_disable:
540 clk_disable_unprepare(comm->clk);
541 return ret;
542 }
543
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp