riscv: sophgo: Add ethernet support for SG2044
Subsystems (7)
Inochi Amaoto
maintainerv2 cover riscv: sophgo: Add ethernet support for SG2044
The ethernet controller of SG2044 is Synopsys DesignWare IP with custom clock. Add glue layer for it.
Since v2, these patch depends on that following patch that provides helper function to compute rgmii clock:
https://lore.kernel.org/netdev/[email protected]/
Changed from v1:
1. patch 2: remove sophgo,syscon as this mac delay is resolved.
2. patch 2: apply all the properties unconditionally.
3. patch 4: remove sophgo,syscon code as this mac delay is resolved.
4. patch 4: use the helper function to compute rgmii clock.
5. patch 4: use remove instead of remove_new for the platform driver.
Inochi Amaoto (4):
dt-bindings: net: snps,dwmac: Add dwmac-5.30a version
dt-bindings: net: Add support for Sophgo SG2044 dwmac
net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string
net: stmmac: Add glue layer for Sophgo SG2044 SoC
.../devicetree/bindings/net/snps,dwmac.yaml | 4 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 124 ++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 109 +++++++++++++++ .../ethernet/stmicro/stmmac/stmmac_platform.c | 3 +- 6 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
--
2.47.0
Inochi Amaoto
maintainerPATCH v2 1/4 dt-bindings: net: snps,dwmac: Add dwmac-5.30a version
Add compatible string for dwmac-5.30a IP.
--- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +3 -0
@@ -31,6 +31,7 @@ select: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10
@@ -95,6 +96,7 @@ properties: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 - starfive,jh7100-dwmac
@@ -627,6 +629,7 @@ allOf: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 - st,spear600-gmac
Signature · 1 line
2.47.0
Re: [PATCH v2 1/4] dt-bindings: net: snps,dwmac: Add dwmac-5.30a version
Quoted 12 lines · Inochi Amaoto
Add compatible string for dwmac-5.30a IP.
Signed-off-by Inochi Amaoto <[email protected]>--- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/net/snps,dwmac.yaml +0
-0
Documentation/devicetree/bindings/net/snps,dwmac.yaml select: · line 34
Quoted 4 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +1
-0@@ -31,6 +31,7 @@ select: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a
Same as for Enclustra patchset... this is incomplete approach. These are just fallbacks, visible by "contains" keyword and you should come with proper specific compatible. Look how other compatibles are arranged.
Best regards,
Krzysztof
Inochi Amaoto
maintainerPATCH v2 2/4 dt-bindings: net: Add support for Sophgo SG2044 dwmac
In reply to Inochi AmaotoThe GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
--- .../devicetree/bindings/net/snps,dwmac.yaml | 1 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 124 ++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
Documentation/devicetree/bindings/net/snps,dwmac.yaml +1 -0
@@ -99,6 +99,7 @@ properties: - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 + - sophgo,sg2044-dwmac - starfive,jh7100-dwmac - starfive,jh7110-dwmac
Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
2.47.0
Re: [PATCH v2 2/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
Quoted 7 lines · Inochi Amaoto
The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
Signed-off-by Inochi Amaoto <[email protected]>---
This should be squashed with a corrected previous patch (why do you need to select snps,dwmac-5.30a?), so we clearly see which the fallback and specific compatibles being added.
Quoted 4 lines
.../devicetree/bindings/net/snps,dwmac.yaml | 1 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 124 ++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
Best regards,
Krzysztof
Inochi Amaoto
maintainerRe: [PATCH v2 2/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
Quoted 10 lines · Krzysztof Kozlowski
Quoted 7 lines · Inochi Amaoto
The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
Signed-off-by Inochi Amaoto <[email protected]>---
This should be squashed with a corrected previous patch
Good, I will.
Quoted 1 line
(why do you need to select snps,dwmac-5.30a?),
The is because the driver use the fallback versioned compatible string to set up some common arguments. (This is what the patch 3 does). It is also better to have a accurate fallback compatible if we already know what it is.
Regards,
Inochi
Re: [PATCH v2 2/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
Quoted 10 lines · Inochi Amaoto
Quoted 9 lines · Krzysztof Kozlowski
Quoted 7 lines · Inochi Amaoto
The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
Signed-off-by Inochi Amaoto <[email protected]>---
Quoted 8 lines
Quoted 1 line
This should be squashed with a corrected previous patch
Good, I will.
Quoted 1 line
(why do you need to select snps,dwmac-5.30a?),
The is because the driver use the fallback versioned compatible string to set up some common arguments. (This is what the patch
Nope. Driver never relies on schema doing select. That's just incorrect.
Quoted 2 lines
3 does). It is also better to have a accurate fallback compatible if we already know what it is.
Best regards,
Krzysztof
Inochi Amaoto
maintainerRe: [PATCH v2 2/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Inochi Amaoto
Quoted 10 lines · Krzysztof Kozlowski
Quoted 7 lines · Inochi Amaoto
The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
Signed-off-by Inochi Amaoto <[email protected]>---
This should be squashed with a corrected previous patch
Quoted 9 lines
Quoted 6 lines
Good, I will.
Quoted 1 line
(why do you need to select snps,dwmac-5.30a?),
The is because the driver use the fallback versioned compatible string to set up some common arguments. (This is what the patch
Nope. Driver never relies on schema doing select. That's just incorrect.
Yeah, I make a mistake on understanding you. For me, I just followed what others do. But there is a comment before this select.
"""
Select every compatible, including the deprecated ones. This way, we will be able to report a warning when we have that compatible, since we will validate the node thanks to the select, but won't report it as a valid value in the compatible property description """
By reading this, I think there may be some historical reason? Maybe someone can explain this.
Regards,
Inochi
Re: [PATCH v2 2/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
Quoted 34 lines · Inochi Amaoto
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Inochi Amaoto
Quoted 10 lines · Krzysztof Kozlowski
Quoted 7 lines · Inochi Amaoto
The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
Signed-off-by Inochi Amaoto <[email protected]>---
This should be squashed with a corrected previous patch
Quoted 9 lines
Quoted 6 lines
Good, I will.
Quoted 1 line
(why do you need to select snps,dwmac-5.30a?),
The is because the driver use the fallback versioned compatible string to set up some common arguments. (This is what the patch
Nope. Driver never relies on schema doing select. That's just incorrect.
Yeah, I make a mistake on understanding you. For me, I just followed what others do. But there is a comment before this select.
"""
Select every compatible, including the deprecated ones. This way, we will be able to report a warning when we have that compatible, since we will validate the node thanks to the select, but won't report it as a valid value in the compatible property description """
Quoted 2 lines
By reading this, I think there may be some historical reason? Maybe someone can explain this.
I think this is left-over from older times before all specific compatibles were added here and in their bindings. This binding has been waiting for some cleanup for a while now, so this is fine.
I still think the patches should be merged, though.
Best regards,
Krzysztof
Inochi Amaoto
maintainerRe: [PATCH v2 2/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
Quoted 38 lines · Krzysztof Kozlowski
Quoted 34 lines · Inochi Amaoto
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Inochi Amaoto
Quoted 10 lines · Krzysztof Kozlowski
Quoted 7 lines · Inochi Amaoto
The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC with some extra clock.
Add necessary compatible string for this device.
Signed-off-by Inochi Amaoto <[email protected]>---
This should be squashed with a corrected previous patch
Quoted 9 lines
Quoted 6 lines
Good, I will.
Quoted 1 line
(why do you need to select snps,dwmac-5.30a?),
The is because the driver use the fallback versioned compatible string to set up some common arguments. (This is what the patch
Nope. Driver never relies on schema doing select. That's just incorrect.
Yeah, I make a mistake on understanding you. For me, I just followed what others do. But there is a comment before this select.
"""
Select every compatible, including the deprecated ones. This way, we will be able to report a warning when we have that compatible, since we will validate the node thanks to the select, but won't report it as a valid value in the compatible property description """Quoted 2 lines
By reading this, I think there may be some historical reason? Maybe someone can explain this.
Quoted 9 lines
I think this is left-over from older times before all specific compatibles were added here and in their bindings. This binding has been waiting for some cleanup for a while now, so this is fine.
I still think the patches should be merged, though.
Best regards,
Krzysztof
Thanks, I will squash this patch in the next version
Regards,
Inochi
Inochi Amaoto
maintainerPATCH v2 3/4 net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string
In reply to Inochi AmaotoAdd "snps,dwmac-5.30a" compatible string for 5.30a version that can avoid to define some platform data in the glue layer.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -1
@@ -555,7 +555,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)of_device_is_compatible (np,"snps,dwmac-4.10a" ) ||of_device_is_compatible (np,"snps,dwmac-4.20a" ) ||of_device_is_compatible (np,"snps,dwmac-5.10a" ) || - of_device_is_compatible(np, "snps,dwmac-5.20")) { +of_device_is_compatible (np,"snps,dwmac-5.20" ) || + of_device_is_compatible(np, "snps,dwmac-5.30a")) { plat->has_gmac4 = 1; plat->has_gmac =0 ; plat->pmt =1 ;
Signature · 1 line
2.47.0
Re: [PATCH v2 3/4] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string
From: Inochi Amaoto <[email protected]>
Date: Fri, 25 Oct 2024 09:09:59 +0800
Quoted 13 lines
Add "snps,dwmac-5.30a" compatible string for 5.30a version that can avoid to define some platform data in the glue layer.
Signed-off-by Inochi Amaoto <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) · line 559
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2
-1@@ -555,7 +555,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)of_device_is_compatible (np,"snps,dwmac-4.10a" ) ||of_device_is_compatible (np,"snps,dwmac-4.20a" ) ||of_device_is_compatible (np,"snps,dwmac-5.10a" ) || - of_device_is_compatible(np, "snps,dwmac-5.20")) { +of_device_is_compatible (np,"snps,dwmac-5.20" ) || + of_device_is_compatible(np, "snps,dwmac-5.30a")) {
Please convert this to a const char * const [] table with all these strings + one of_device_compatible_match().
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) · line 562
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-0plat->has_gmac4 =1 ; plat->has_gmac =0 ; plat->pmt =1 ;
Thanks,
Olek
Inochi Amaoto
maintainerRe: [PATCH v2 3/4] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string
Quoted 11 lines · Alexander Lobakin
From: Inochi Amaoto <[email protected]>
Date: Fri, 25 Oct 2024 09:09:59 +0800Quoted 8 lines
Add "snps,dwmac-5.30a" compatible string for 5.30a version that can avoid to define some platform data in the glue layer.
Signed-off-by Inochi Amaoto <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 15 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) · line 559
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2
-1@@ -555,7 +555,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)of_device_is_compatible (np,"snps,dwmac-4.10a" ) ||of_device_is_compatible (np,"snps,dwmac-4.20a" ) ||of_device_is_compatible (np,"snps,dwmac-5.10a" ) || - of_device_is_compatible(np, "snps,dwmac-5.20")) { +of_device_is_compatible (np,"snps,dwmac-5.20" ) || + of_device_is_compatible(np, "snps,dwmac-5.30a")) {Please convert this to a const char * const [] table with all these strings + one
of_device_compatible_match().
I will, this make the check more clear, thanks.
Regards,
Inochi
Inochi Amaoto
maintainerPATCH v2 4/4 net: stmmac: Add glue layer for Sophgo SG2044 SoC
In reply to Inochi AmaotoAdds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
--- drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 109 ++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
@@ -169,6 +169,17 @@ config DWMAC_SOCFPGA for the stmmac device driver. This driver is used for arria5 and cyclone5 FPGA SoCs. +config DWMAC_SOPHGO + tristate "Sophgo dwmac support" + depends on OF && (ARCH_SOPHGO || COMPILE_TEST) + default m if ARCH_SOPHGO + help + Support for ethernet controllers on Sophgo RISC-V SoCs + + This selects the Sophgo SoC specific glue layer support + for the stmmac device driver. This driver is used for the + ethernet controllers on various Sophgo SoCs. + config DWMAC_STARFIVE tristate "StarFive dwmac support" depends on OF && (ARCH_STARFIVE || COMPILE_TEST)
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o +obj-$(CONFIG_DWMAC_SOPHGO) += dwmac-sophgo.o obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.47.0
kernel test robot
build botRe: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
kernel test robot noticed the following build warnings:
Hi Inochi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on robh/for-next]
[also build test WARNING on sophgo/for-next sophgo/fixes net-next/main net/main linus/master v6.12-rc4 next-20241025] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Inochi-Amaoto/dt-bindings-net-snps-dwmac-Add-dwmac-5-30a-version/20241025-091315 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20241025011000.244350-5-inochiama%40gmail.com patch subject: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC config: um-allyesconfig (https://download.01.org/0day-ci/archive/20241025/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c: In function 'sophgo_dwmac_fix_mac_speed':
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:30:16: error: implicit declaration of function 'rgmii_clock' [-Werror=implicit-function-declaration]
30 | rate = rgmii_clock(speed);
| ^~~~~~~~~~~
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c: In function 'sophgo_sg2044_dwmac_init':
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:46:13: warning: unused variable 'ret' [-Wunused-variable]
46 | int ret;
| ^~~
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c: In function 'sophgo_dwmac_fix_mac_speed':
>> drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:31:12: warning: 'ret' is used uninitialized [-Wuninitialized]
31 | if (ret < 0) {
| ^
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:28:13: note: 'ret' was declared here
28 | int ret;
| ^~~cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=n] || GCC_PLUGINS [=y]) && MODULES [=y]
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [y]:
- RESOURCE_KUNIT_TEST [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]
vim +/ret +31 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
23
24 static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
25 {
26 struct sophgo_dwmac *dwmac = priv;
27 long rate;
28 int ret;
29
30 rate = rgmii_clock(speed);
> 31 if (ret < 0) {
32 dev_err(dwmac->dev, "invalid speed %u\n", speed);
33 return;
34 }
35
36 ret = clk_set_rate(dwmac->clk_tx, rate);
37 if (ret)
38 dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
39 }
40 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
In reply to Inochi AmaotoFrom: Inochi Amaoto <[email protected]>
Date: Fri, 25 Oct 2024 09:10:00 +0800
Quoted 9 lines
Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
Signed-off-by Inochi Amaoto <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 109 ++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
[...]
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 6
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +6
-0@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Sophgo DWMAC platform driver +* +* Copyright (C) 2024 Inochi Amaoto <[email protected]> +*
This empty line is redundant I guess?
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 15
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +9
-0+*/ + +#include <linux/bits.h> +#include <linux/mod_devicetable.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/mfd/syscon.h> +#include <linux/phy.h> +#include <linux/regmap.h>
Here should be alphabetical order.
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +6
-0+ +#include "stmmac_platform.h" + +struct sophgo_dwmac { +struct device *dev; +struct clk *clk_tx;
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 31
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +10
-0+}; + +static void sophgo_dwmac_fix_mac_speed (void *priv,unsigned int speed,unsigned int mode) +{ +struct sophgo_dwmac *dwmac = priv; +long rate; +int ret; + + rate =rgmii_clock (speed); +if (ret <0 ) {
Did you mean if (rate < 0)?
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 38
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +7
-0+dev_err (dwmac->dev,"invalid speed %u\n" , speed); +return ; + } + + ret =clk_set_rate (dwmac->clk_tx, rate); +if (ret) +dev_err (dwmac->dev,"failed to set tx rate %lu\n" , rate);
Don't you want to print the error code here?
"failed to set tx rate %lu: %pe\n", rate, ERR_PTR(ret));
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 46
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +8
-0+} + +static int sophgo_sg2044_dwmac_init (struct platform_device *pdev, +struct plat_stmmacenet_data *plat_dat, +struct stmmac_resources *stmmac_res) +{ +struct sophgo_dwmac *dwmac; +int ret;
Unused var.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +9
-0+ + dwmac =devm_kzalloc (&pdev->dev,sizeof (*dwmac),GFP_KERNEL ); +if (!dwmac) +return -ENOMEM ; + + dwmac->clk_tx =devm_clk_get_enabled (&pdev->dev,"tx" ); +if (IS_ERR (dwmac->clk_tx)) +return dev_err_probe (&pdev->dev,PTR_ERR (dwmac->clk_tx), +"failed to get tx clock\n" );
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 65
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +10
-0+ + dwmac->dev = &pdev->dev; + plat_dat->bsp_priv = dwmac; + plat_dat->flags |=STMMAC_FLAG_SPH_DISABLE ; + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed; + plat_dat->multicast_filter_bins =0 ; + plat_dat->unicast_filter_entries =1 ; + +return 0 ; +}
[...]
+ see the build bot report.
Thanks,
Olek
Inochi Amaoto
maintainerRe: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
Quoted 30 lines · Alexander Lobakin
From: Inochi Amaoto <[email protected]>
Date: Fri, 25 Oct 2024 09:10:00 +0800Quoted 9 lines
Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
Signed-off-by Inochi Amaoto <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 109 ++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c[...]
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 6
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +6
-0@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Sophgo DWMAC platform driver +* +* Copyright (C) 2024 Inochi Amaoto <[email protected]> +* This empty line is redundant I guess?
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 15
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +9
-0+*/ + +#include <linux/bits.h> +#include <linux/mod_devicetable.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/mfd/syscon.h> +#include <linux/phy.h> +#include <linux/regmap.h> Here should be alphabetical order.
Thanks, I forgot to reorder it when adding new include.
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +10
-0+ +#include "stmmac_platform.h" + +struct sophgo_dwmac { +struct device *dev; +struct clk *clk_tx; +}; + +static void sophgo_dwmac_fix_mac_speed (void *priv,unsigned int speed,unsigned int mode) +{
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 31
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +6
-0+struct sophgo_dwmac *dwmac = priv; +long rate; +int ret; + + rate =rgmii_clock (speed); +if (ret <0 ) {Did you mean
if (rate < 0)?
Yeah, it seems I forgot to modify it.
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 38
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +7
-0+dev_err (dwmac->dev,"invalid speed %u\n" , speed); +return ; + } + + ret =clk_set_rate (dwmac->clk_tx, rate); +if (ret) +dev_err (dwmac->dev,"failed to set tx rate %lu\n" , rate);Don't you want to print the error code here?
Quoted 2 lines
"failed to set tx rate %lu: %pe\n", rate, ERR_PTR(ret));
Thanks, it is more clear now.
Quoted 33 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c line 46
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +8
-0+} + +static int sophgo_sg2044_dwmac_init (struct platform_device *pdev, +struct plat_stmmacenet_data *plat_dat, +struct stmmac_resources *stmmac_res) +{ +struct sophgo_dwmac *dwmac; +int ret;Unused var.
Quoted 19 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +19
-0+ + dwmac =devm_kzalloc (&pdev->dev,sizeof (*dwmac),GFP_KERNEL ); +if (!dwmac) +return -ENOMEM ; + + dwmac->clk_tx =devm_clk_get_enabled (&pdev->dev,"tx" ); +if (IS_ERR (dwmac->clk_tx)) +return dev_err_probe (&pdev->dev,PTR_ERR (dwmac->clk_tx), +"failed to get tx clock\n" ); + + dwmac->dev = &pdev->dev; + plat_dat->bsp_priv = dwmac; + plat_dat->flags |=STMMAC_FLAG_SPH_DISABLE ; + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed; + plat_dat->multicast_filter_bins =0 ; + plat_dat->unicast_filter_entries =1 ; + +return 0 ; +}[...]
Quoted 4 lines
+ see the build bot report.
Thanks,
Olek
Thanks, I will fix it.
Regards,
Inochi
kernel test robot
build botRe: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
In reply to Inochi Amaotokernel test robot noticed the following build errors:
Hi Inochi,
kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on sophgo/for-next sophgo/fixes net-next/main net/main linus/master v6.12-rc4 next-20241025] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Inochi-Amaoto/dt-bindings-net-snps-dwmac-Add-dwmac-5-30a-version/20241025-091315 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20241025011000.244350-5-inochiama%40gmail.com patch subject: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20241025/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c: In function 'sophgo_dwmac_fix_mac_speed':
>> drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:30:16: error: implicit declaration of function 'rgmii_clock' [-Wimplicit-function-declaration]
30 | rate = rgmii_clock(speed);
| ^~~~~~~~~~~
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c: In function 'sophgo_sg2044_dwmac_init':
>> drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:46:13: warning: unused variable 'ret' [-Wunused-variable]
46 | int ret;
| ^~~vim +/rgmii_clock +30 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
23
24 static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
25 {
26 struct sophgo_dwmac *dwmac = priv;
27 long rate;
28 int ret;
29
> 30 rate = rgmii_clock(speed);
31 if (ret < 0) {
32 dev_err(dwmac->dev, "invalid speed %u\n", speed);
33 return;
34 }
35
36 ret = clk_set_rate(dwmac->clk_tx, rate);
37 if (ret)
38 dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
39 }
40
41 static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
42 struct plat_stmmacenet_data *plat_dat,
43 struct stmmac_resources *stmmac_res)
44 {
45 struct sophgo_dwmac *dwmac;
> 46 int ret;
47
48 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
49 if (!dwmac)
50 return -ENOMEM;
51
52 dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
53 if (IS_ERR(dwmac->clk_tx))
54 return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
55 "failed to get tx clock\n");
56
57 dwmac->dev = &pdev->dev;
58 plat_dat->bsp_priv = dwmac;
59 plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
60 plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed;
61 plat_dat->multicast_filter_bins = 0;
62 plat_dat->unicast_filter_entries = 1;
63
64 return 0;
65 }
66 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
In reply to Inochi Amaotokernel test robot noticed the following build errors:
Hi Inochi,
kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on sophgo/for-next sophgo/fixes net-next/main net/main linus/master v6.12-rc4 next-20241025] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Inochi-Amaoto/dt-bindings-net-snps-dwmac-Add-dwmac-5-30a-version/20241025-091315 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20241025011000.244350-5-inochiama%40gmail.com patch subject: [PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20241026/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 5886454669c3c9026f7f27eab13509dd0241f2d6) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241026/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:11:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:14:
In file included from include/linux/phy.h:16:
In file included from include/linux/ethtool.h:18:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:14:
In file included from include/linux/phy.h:16:
In file included from include/linux/ethtool.h:18:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:14:
In file included from include/linux/phy.h:16:
In file included from include/linux/ethtool.h:18:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:30:9: error: call to undeclared function 'rgmii_clock'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
30 | rate = rgmii_clock(speed);
| ^
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c:46:6: warning: unused variable 'ret' [-Wunused-variable]
46 | int ret;
| ^~~17 warnings and 1 error generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]
vim +/rgmii_clock +30 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
23
24 static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
25 {
26 struct sophgo_dwmac *dwmac = priv;
27 long rate;
28 int ret;
29
> 30 rate = rgmii_clock(speed);
31 if (ret < 0) {
32 dev_err(dwmac->dev, "invalid speed %u\n", speed);
33 return;
34 }
35
36 ret = clk_set_rate(dwmac->clk_tx, rate);
37 if (ret)
38 dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
39 }
40 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Simon Horman
reviewerQuoted 6 lines · Inochi Amaoto
The ethernet controller of SG2044 is Synopsys DesignWare IP with custom clock. Add glue layer for it.
Since v2, these patch depends on that following patch that provides helper function to compute rgmii clock:
https://lore.kernel.org/netdev/[email protected]/
For future reference: patchsets for Networking, which have not-yet-in-tree dependancies should be marked as an RFC. Our CI doesn't know how to handle these and we don't have a mechanism to re-run it once the dependencies are present:
the patchset needs to be sent again.
Also, I'm assuming this patch-set is targeted at net-next. If so, that should be included in the subject like this:
[PATCH net-next vX] ...
I would wait for review before posting any updated patchset.
Thanks!
...
Signature · 1 line
pw-bot: changes-requested
Inochi Amaoto
maintainerQuoted 14 lines · Simon Horman
Quoted 6 lines · Inochi Amaoto
The ethernet controller of SG2044 is Synopsys DesignWare IP with custom clock. Add glue layer for it.
Since v2, these patch depends on that following patch that provides helper function to compute rgmii clock:
https://lore.kernel.org/netdev/[email protected]/For future reference: patchsets for Networking, which have not-yet-in-tree dependancies should be marked as an RFC. Our CI doesn't know how to handle these and we don't have a mechanism to re-run it once the dependencies are present:
the patchset needs to be sent again.
Quoted 9 lines
Also, I'm assuming this patch-set is targeted at net-next. If so, that should be included in the subject like this:
[PATCH net-next vX] ...
I would wait for review before posting any updated patchset.
Thanks!
Thanks for your explanation. I apologize for missing these rules. I will change it to the right title when sumbiting the next patch.
Regards,
Inochi