Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
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
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 05cc07b8f48c..bc44b21c593f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -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)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index c2f0e91f6bf8..e1287b53047b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -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
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
new file mode 100644
index 000000000000..8f37bcf86a73
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Sophgo DWMAC platform driver
+ *
+ * Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com>
+ *
+ */
+
+#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>
+
+#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)
+{
+ struct sophgo_dwmac *dwmac = priv;
+ long rate;
+ int ret;
+
+ rate = rgmii_clock(speed);
+ if (ret < 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);
+}
+
+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;
+
+ 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;
+}
+
+static int sophgo_dwmac_probe(struct platform_device *pdev)
+{
+ struct plat_stmmacenet_data *plat_dat;
+ struct stmmac_resources stmmac_res;
+ int ret;
+
+ ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to get resources\n");
+
+ plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
+ if (IS_ERR(plat_dat))
+ return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat),
+ "dt configuration failed\n");
+
+ ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res);
+ if (ret)
+ return ret;
+
+ return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
+
+static const struct of_device_id sophgo_dwmac_match[] = {
+ { .compatible = "sophgo,sg2044-dwmac" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, sophgo_dwmac_match);
+
+static struct platform_driver sophgo_dwmac_driver = {
+ .probe = sophgo_dwmac_probe,
+ .remove = stmmac_pltfr_remove,
+ .driver = {
+ .name = "sophgo-dwmac",
+ .pm = &stmmac_pltfr_pm_ops,
+ .of_match_table = sophgo_dwmac_match,
+ },
+};
+module_platform_driver(sophgo_dwmac_driver);
+
+MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
+MODULE_DESCRIPTION("Sophgo DWMAC platform driver");
+MODULE_LICENSE("GPL");
--
2.47.0
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/202410260337.pPIMKkX6-lkp@intel.com/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/202410260337.pPIMKkX6-lkp@intel.com/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 <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410260337.pPIMKkX6-lkp@intel.com/ 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 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
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/202410252357.pCyOX2bg-lkp@intel.com/config) compiler: loongarch64-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/202410252357.pCyOX2bg-lkp@intel.com/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 <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410252357.pCyOX2bg-lkp@intel.com/ 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 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
From: Inochi Amaoto <inochiama@gmail.com> Date: Fri, 25 Oct 2024 09:10:00 +0800 > Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC. > > Signed-off-by: Inochi Amaoto <inochiama@gmail.com> > --- > 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 [...] > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c > new file mode 100644 > index 000000000000..8f37bcf86a73 > --- /dev/null > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c > @@ -0,0 +1,109 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Sophgo DWMAC platform driver > + * > + * Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com> > + * This empty line is redundant I guess? > + */ > + > +#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. > + > +#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) > +{ > + struct sophgo_dwmac *dwmac = priv; > + long rate; > + int ret; > + > + rate = rgmii_clock(speed); > + if (ret < 0) { Did you mean `if (rate < 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)); > +} > + > +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. > + > + 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; > +} [...] + see the build bot report. Thanks, Olek
On Fri, Oct 25, 2024 at 04:53:07PM +0200, Alexander Lobakin wrote: > From: Inochi Amaoto <inochiama@gmail.com> > Date: Fri, 25 Oct 2024 09:10:00 +0800 > > > Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC. > > > > Signed-off-by: Inochi Amaoto <inochiama@gmail.com> > > --- > > 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 > > [...] > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c > > new file mode 100644 > > index 000000000000..8f37bcf86a73 > > --- /dev/null > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c > > @@ -0,0 +1,109 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * Sophgo DWMAC platform driver > > + * > > + * Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com> > > + * > > This empty line is redundant I guess? > > > + */ > > + > > +#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. > > + > > +#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) > > +{ > > + 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. > > + 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)); > Thanks, it is more clear now. > > +} > > + > > +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. > > > + > > + 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; > > +} > > [...] > > + see the build bot report. > > Thanks, > Olek Thanks, I will fix it. Regards, Inochi
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/202410252215.79396yyg-lkp@intel.com/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/202410252215.79396yyg-lkp@intel.com/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 <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410252215.79396yyg-lkp@intel.com/ 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 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2024 Red Hat, Inc.