netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] Add MxL Ethernet driver & devicetree binding
@ 2025-08-26  3:10 Jack Ping CHNG
  2025-08-26  3:10 ` [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC Jack Ping CHNG
  2025-08-26  3:10 ` [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC Jack Ping CHNG
  0 siblings, 2 replies; 11+ messages in thread
From: Jack Ping CHNG @ 2025-08-26  3:10 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: davem, andrew+netdev, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, yzhu, sureshnagaraj, Jack Ping CHNG

Hello netdev maintainers,

This patch series adds support for the MaxLinear LGM SoC's Ethernet
controller, including:

Patch 1: Introduces the devicetree binding documentation for the MaxLinear
LGM Network Processor.
Patch 2: Adds build infrastructure and the main driver for the MaxLinear
LGM SoC Ethernet controller.

The driver supports multi-port operation and is integrated with standard
Linux network device driver framework. The devicetree binding documents
the required properties for the hardware description.

Changelog:
v1 -> v2:
  - Moved devicetree bindings to the first patch in the series
  - Verified bindings with 'make dt_binding_check DT_SCHEMA_FILES=mxl,lgm-eth.yaml'
  - Reformatted commit messages to follow Linux kernel submission guidelines.
  - Removed redundant code and addressed all reviewer comments.

links:
v1: https://lore.kernel.org/netdev/20250822090809.1464232-1-jchng@maxlinear.com/

Jack Ping CHNG (2):
  dt-bindings: net: mxl: Add MxL LGM Network Processor SoC
  net: maxlinear: Add support for MxL LGM SoC

 .../devicetree/bindings/net/mxl,lgm-eth.yaml  |  73 +++++++
 .../device_drivers/ethernet/index.rst         |   1 +
 .../device_drivers/ethernet/maxlinear/mxl.rst |  61 ++++++
 MAINTAINERS                                   |   8 +
 drivers/net/ethernet/Kconfig                  |   1 +
 drivers/net/ethernet/Makefile                 |   1 +
 drivers/net/ethernet/maxlinear/Kconfig        |  15 ++
 drivers/net/ethernet/maxlinear/Makefile       |   6 +
 drivers/net/ethernet/maxlinear/mxl_eth.c      | 189 ++++++++++++++++++
 9 files changed, 355 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml
 create mode 100644 Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst
 create mode 100644 drivers/net/ethernet/maxlinear/Kconfig
 create mode 100644 drivers/net/ethernet/maxlinear/Makefile
 create mode 100644 drivers/net/ethernet/maxlinear/mxl_eth.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC
  2025-08-26  3:10 [PATCH net-next v2 0/2] Add MxL Ethernet driver & devicetree binding Jack Ping CHNG
@ 2025-08-26  3:10 ` Jack Ping CHNG
  2025-08-26 12:45   ` Andrew Lunn
                     ` (2 more replies)
  2025-08-26  3:10 ` [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC Jack Ping CHNG
  1 sibling, 3 replies; 11+ messages in thread
From: Jack Ping CHNG @ 2025-08-26  3:10 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: davem, andrew+netdev, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, yzhu, sureshnagaraj, Jack Ping CHNG

Introduce device-tree binding documentation for MaxLinear LGM Network
Processor

Signed-off-by: Jack Ping CHNG <jchng@maxlinear.com>
---
 .../devicetree/bindings/net/mxl,lgm-eth.yaml  | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml

diff --git a/Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml b/Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml
new file mode 100644
index 000000000000..aa1c7d3609ab
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/mxl,lgm-eth.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MaxLinear LGM Ethernet Controller
+
+maintainers:
+  - Jack Ping Chng <jchng@maxlinear.com>
+
+description:
+  Binding for MaxLinear LGM Ethernet controller
+
+properties:
+  compatible:
+    enum:
+      - mxl,lgm-eth
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: ethif
+
+  resets:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+  '#size-cells':
+    const: 0
+
+patternProperties:
+  "^interface@[1-4]$":
+    type: object
+    properties:
+      compatible:
+        const: mxl,lgm-mac
+
+      reg:
+        minimum: 1
+        maximum: 4
+
+    required:
+      - compatible
+      - reg
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - '#address-cells'
+  - '#size-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    eth {
+      compatible = "mxl,lgm-eth";
+      clocks = <&cgu0 32>;
+      clock-names = "ethif";
+      resets = <&rcu0 0x70 8>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      mac: interface@1 {
+        compatible = "mxl,eth-mac";
+        reg = <1>;
+      };
+    };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC
  2025-08-26  3:10 [PATCH net-next v2 0/2] Add MxL Ethernet driver & devicetree binding Jack Ping CHNG
  2025-08-26  3:10 ` [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC Jack Ping CHNG
@ 2025-08-26  3:10 ` Jack Ping CHNG
  2025-08-26 13:03   ` Andrew Lunn
                     ` (2 more replies)
  1 sibling, 3 replies; 11+ messages in thread
From: Jack Ping CHNG @ 2025-08-26  3:10 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: davem, andrew+netdev, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, yzhu, sureshnagaraj, Jack Ping CHNG

Introduce the build system integration and initial implementation for the
MaxLinear LGM SoC Ethernet driver. This patch adds Kconfig and Makefile
entries, the main driver source file, and documentation.

Signed-off-by: Jack Ping CHNG <jchng@maxlinear.com>
---
 .../device_drivers/ethernet/index.rst         |   1 +
 .../device_drivers/ethernet/maxlinear/mxl.rst |  61 ++++++
 MAINTAINERS                                   |   8 +
 drivers/net/ethernet/Kconfig                  |   1 +
 drivers/net/ethernet/Makefile                 |   1 +
 drivers/net/ethernet/maxlinear/Kconfig        |  15 ++
 drivers/net/ethernet/maxlinear/Makefile       |   6 +
 drivers/net/ethernet/maxlinear/mxl_eth.c      | 189 ++++++++++++++++++
 8 files changed, 282 insertions(+)
 create mode 100644 Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst
 create mode 100644 drivers/net/ethernet/maxlinear/Kconfig
 create mode 100644 drivers/net/ethernet/maxlinear/Makefile
 create mode 100644 drivers/net/ethernet/maxlinear/mxl_eth.c

diff --git a/Documentation/networking/device_drivers/ethernet/index.rst b/Documentation/networking/device_drivers/ethernet/index.rst
index 40ac552641a3..13d3cbc96e87 100644
--- a/Documentation/networking/device_drivers/ethernet/index.rst
+++ b/Documentation/networking/device_drivers/ethernet/index.rst
@@ -44,6 +44,7 @@ Contents:
    marvell/octeontx2
    marvell/octeon_ep
    marvell/octeon_ep_vf
+   maxlinear/mxl
    mellanox/mlx5/index
    meta/fbnic
    microsoft/netvsc
diff --git a/Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst b/Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst
new file mode 100644
index 000000000000..7954c47347e7
--- /dev/null
+++ b/Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst
@@ -0,0 +1,61 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===============================================
+MaxLinear Multi-MAC Network Processor (NP)
+===============================================
+
+Copyright(c) 2025 MaxLinear, Inc.
+
+Overview
+========
+
+This document describes the Linux driver for the MaxLinear Network Processor
+(NP), a high-performance controller supporting multiple MACs and
+advanced packet processing capabilities.
+
+The MaxLinear Network processor integrates programmable hardware accelerators
+for tasks such as Layer 2, 3, 4 forwarding, flow steering, and traffic shaping.
+It is designed to operate in high-throughput applications, including data
+center switching, virtualized environments, and telco infrastructure.
+
+Key Features
+============
+
+- Support for up to 4 independent 10 Gbit/s MAC interfaces
+- Full-duplex 10G operation
+- Multiqueue support for parallel RX/TX paths (per MAC)
+
+Supported Devices
+=================
+
+The driver supports the following MaxLinear NPU family devices:
+- MaxLinear LGM
+
+Each device supports multiple MACs and high-performance data pipelines managed
+through internal firmware and programmable engines.
+
+Kernel Configuration
+====================
+
+The driver is located in the menu structure at:
+
+  -> Device Drivers
+    -> Network device support
+      -> Ethernet driver support
+        -> MaxLinear NPU Ethernet driver
+
+Or set in your kernel config:
+  CONFIG_NET_VENDOR_MAXLINEAR=y
+  CONFIG_MAXLINEAR_ETH=y
+
+Maintainers
+===========
+
+See the MAINTAINERS file:
+
+    MAXLINEAR ETHERNET DRIVER
+    M: Jack Ping Chng <jchng@maxlinear.com>
+    L: netdev@vger.kernel.org
+    S: Supported
+    F: drivers/net/ethernet/maxlinear/
+
diff --git a/MAINTAINERS b/MAINTAINERS
index fe168477caa4..e4765bd73615 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15102,6 +15102,14 @@ W:	https://linuxtv.org
 T:	git git://linuxtv.org/media.git
 F:	drivers/media/radio/radio-maxiradio*
 
+MAXLINEAR ETHERNET DRIVER
+M:	Jack Ping Chng <jchng@maxlinear.com>
+L:	netdev@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml
+F:	Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst
+F:	drivers/net/ethernet/maxlinear/mxl_eth.c
+
 MAXLINEAR ETHERNET PHY DRIVER
 M:	Xu Liang <lxu@maxlinear.com>
 L:	netdev@vger.kernel.org
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index f86d4557d8d7..3e94ff7922c8 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -121,6 +121,7 @@ config LANTIQ_XRX200
 source "drivers/net/ethernet/adi/Kconfig"
 source "drivers/net/ethernet/litex/Kconfig"
 source "drivers/net/ethernet/marvell/Kconfig"
+source "drivers/net/ethernet/maxlinear/Kconfig"
 source "drivers/net/ethernet/mediatek/Kconfig"
 source "drivers/net/ethernet/mellanox/Kconfig"
 source "drivers/net/ethernet/meta/Kconfig"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index 67182339469a..760d598df197 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_LANTIQ_ETOP) += lantiq_etop.o
 obj-$(CONFIG_LANTIQ_XRX200) += lantiq_xrx200.o
 obj-$(CONFIG_NET_VENDOR_LITEX) += litex/
 obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/
+obj-$(CONFIG_NET_VENDOR_MAXLINEAR) += maxlinear/
 obj-$(CONFIG_NET_VENDOR_MEDIATEK) += mediatek/
 obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/
 obj-$(CONFIG_NET_VENDOR_META) += meta/
diff --git a/drivers/net/ethernet/maxlinear/Kconfig b/drivers/net/ethernet/maxlinear/Kconfig
new file mode 100644
index 000000000000..b88cdd9675fb
--- /dev/null
+++ b/drivers/net/ethernet/maxlinear/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config NET_VENDOR_MAXLINEAR
+	bool "MaxLinear devices"
+	help
+	  If you have a MaxLinear SoC with ethernet, say Y.
+
+if NET_VENDOR_MAXLINEAR
+
+config MXL_NPU
+	tristate "MaxLinear NPU Ethernet driver"
+	help
+	  This driver supports the MaxLinear NPU Ethernet.
+
+endif #NET_VENDOR_MAXLINEAR
+
diff --git a/drivers/net/ethernet/maxlinear/Makefile b/drivers/net/ethernet/maxlinear/Makefile
new file mode 100644
index 000000000000..0577b325494c
--- /dev/null
+++ b/drivers/net/ethernet/maxlinear/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for the MaxLinear network device drivers.
+#
+
+obj-$(CONFIG_MXL_NPU) += mxl_eth.o
diff --git a/drivers/net/ethernet/maxlinear/mxl_eth.c b/drivers/net/ethernet/maxlinear/mxl_eth.c
new file mode 100644
index 000000000000..093ad9b27a81
--- /dev/null
+++ b/drivers/net/ethernet/maxlinear/mxl_eth.c
@@ -0,0 +1,189 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025  MaxLinear, Inc.
+ */
+#include <linux/clk.h>
+#include <linux/etherdevice.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+
+#define ETH_TX_TIMEOUT		(10 * HZ)
+#define MXL_NUM_TX_RING		8
+#define MXL_NUM_RX_RING		8
+#define MXL_NUM_PORT		2
+
+struct mxl_eth_drvdata {
+	struct net_device *ndevs[MXL_NUM_PORT];
+	struct clk *clks;
+};
+
+struct eth_priv {
+	struct platform_device *pdev;
+	struct device_node *np;
+};
+
+static int mxl_eth_open(struct net_device *ndev)
+{
+	netif_carrier_on(ndev);
+	netif_start_queue(ndev);
+	return 0;
+}
+
+static int mxl_eth_stop(struct net_device *ndev)
+{
+	netif_stop_queue(ndev);
+	netif_carrier_off(ndev);
+	return 0;
+}
+
+static int mxl_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+	dev_kfree_skb(skb);
+	return NETDEV_TX_OK;
+}
+
+static const struct net_device_ops mxl_eth_netdev_ops = {
+	.ndo_open       = mxl_eth_open,
+	.ndo_stop       = mxl_eth_stop,
+	.ndo_start_xmit = mxl_eth_start_xmit,
+};
+
+static int mxl_eth_create_ndev(struct platform_device *pdev,
+			       struct device_node *np,
+			       struct net_device **ndev_out)
+{
+	struct net_device *ndev;
+	struct eth_priv *priv;
+	int ret;
+
+	ndev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(struct eth_priv),
+				       MXL_NUM_TX_RING, MXL_NUM_RX_RING);
+	if (!ndev) {
+		dev_err(&pdev->dev, "alloc_etherdev_mq failed\n");
+		return -ENOMEM;
+	}
+
+	ndev->netdev_ops = &mxl_eth_netdev_ops;
+	ndev->watchdog_timeo = ETH_TX_TIMEOUT;
+	ndev->max_mtu = ETH_FRAME_LEN;
+	ndev->min_mtu = ETH_MIN_MTU;
+	SET_NETDEV_DEV(ndev, &pdev->dev);
+
+	priv = netdev_priv(ndev);
+	priv->pdev = pdev;
+	priv->np = np;
+
+	ret = register_netdev(ndev);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to register net device\n");
+		return ret;
+	}
+
+	*ndev_out = ndev;
+	return 0;
+}
+
+static void mxl_eth_cleanup(struct mxl_eth_drvdata *drvdata)
+{
+	int i;
+
+	for (i = 0; i < MXL_NUM_PORT && drvdata->ndevs[i]; i++) {
+		unregister_netdev(drvdata->ndevs[i]);
+		drvdata->ndevs[i] = NULL;
+	}
+}
+
+static int mxl_eth_probe(struct platform_device *pdev)
+{
+	struct mxl_eth_drvdata *drvdata;
+	struct reset_control *rst;
+	struct net_device *ndev;
+	struct device_node *np;
+	int ret, i;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	drvdata->clks = devm_clk_get_enabled(&pdev->dev, "ethif");
+	if (IS_ERR(drvdata->clks))
+		return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->clks),
+				     "failed to get/enable clock\n");
+
+	rst = devm_reset_control_get_optional(&pdev->dev, NULL);
+	if (IS_ERR(rst)) {
+		dev_err(&pdev->dev,
+			"failed to get optional reset control: %ld\n",
+			PTR_ERR(rst));
+		ret = PTR_ERR(rst);
+		goto err_cleanup;
+	}
+
+	if (rst) {
+		ret = reset_control_assert(rst);
+		if (ret)
+			goto err_cleanup;
+
+		udelay(1);
+
+		ret = reset_control_deassert(rst);
+		if (ret)
+			goto err_cleanup;
+	}
+
+	platform_set_drvdata(pdev, drvdata);
+
+	i = 0;
+	for_each_available_child_of_node(pdev->dev.of_node, np) {
+		if (!of_device_is_compatible(np, "mxl,eth-mac"))
+			continue;
+
+		ret = mxl_eth_create_ndev(pdev, np, &ndev);
+		if (ret)
+			goto err_cleanup;
+
+		drvdata->ndevs[i++] = ndev;
+		if (i >= MXL_NUM_PORT)
+			break;
+	}
+
+	return 0;
+
+err_cleanup:
+	mxl_eth_cleanup(drvdata);
+	return ret;
+}
+
+static void mxl_eth_remove(struct platform_device *pdev)
+{
+	struct mxl_eth_drvdata *drvdata = platform_get_drvdata(pdev);
+
+	mxl_eth_cleanup(drvdata);
+}
+
+/* Device Tree match table */
+static const struct of_device_id mxl_eth_of_match[] = {
+	{ .compatible = "mxl,lgm-eth" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxl_eth_of_match);
+
+/* Platform driver struct */
+static struct platform_driver mxl_eth_drv = {
+	.probe    = mxl_eth_probe,
+	.remove   = mxl_eth_remove,
+	.driver = {
+		.name = KBUILD_MODNAME,
+		.of_match_table = mxl_eth_of_match,
+	},
+};
+
+module_platform_driver(mxl_eth_drv);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Ethernet driver for MxL SoC");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC
  2025-08-26  3:10 ` [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC Jack Ping CHNG
@ 2025-08-26 12:45   ` Andrew Lunn
  2025-08-26 13:05   ` Rob Herring (Arm)
  2025-08-27 12:33   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-08-26 12:45 UTC (permalink / raw)
  To: Jack Ping CHNG
  Cc: netdev, devicetree, davem, andrew+netdev, edumazet, kuba, pabeni,
	robh, krzk+dt, conor+dt, yzhu, sureshnagaraj

> +patternProperties:
> +  "^interface@[1-4]$":
> +    type: object
> +    properties:
> +      compatible:
> +        const: mxl,lgm-mac

Shouldn't you be referencing
Documentation/devicetree/bindings/net/ethernet-controller.yaml here?

How do you specify the MAC address? Link to the PHY, indicate there is
an SFP, describe LEDs?

	Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC
  2025-08-26  3:10 ` [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC Jack Ping CHNG
@ 2025-08-26 13:03   ` Andrew Lunn
  2025-08-27 10:41     ` Jack Ping Chng
  2025-08-26 13:09   ` Jakub Kicinski
  2025-08-27 12:33   ` Krzysztof Kozlowski
  2 siblings, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2025-08-26 13:03 UTC (permalink / raw)
  To: Jack Ping CHNG
  Cc: netdev, devicetree, davem, andrew+netdev, edumazet, kuba, pabeni,
	robh, krzk+dt, conor+dt, yzhu, sureshnagaraj

> +Maintainers
> +===========
> +
> +See the MAINTAINERS file:
> +
> +    MAXLINEAR ETHERNET DRIVER
> +    M: Jack Ping Chng <jchng@maxlinear.com>
> +    L: netdev@vger.kernel.org
> +    S: Supported
> +    F: drivers/net/ethernet/maxlinear/

Please don't duplicate what is in MAINTAINERs. We have scripts which
monitor how active Maintainers are, and update the file, removing
inactive Maintainers. This duplication will not be updated.

> +
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fe168477caa4..e4765bd73615 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -15102,6 +15102,14 @@ W:	https://linuxtv.org
>  T:	git git://linuxtv.org/media.git
>  F:	drivers/media/radio/radio-maxiradio*
>  
> +MAXLINEAR ETHERNET DRIVER
> +M:	Jack Ping Chng <jchng@maxlinear.com>
> +L:	netdev@vger.kernel.org
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml
> +F:	Documentation/networking/device_drivers/ethernet/maxlinear/mxl.rst
> +F:	drivers/net/ethernet/maxlinear/mxl_eth.c

It is probably better to just use drivers/net/ethernet/maxlinear/ so
all files in that directory are covered, like the Makefile, Kconfig
etc.

> +static int mxl_eth_probe(struct platform_device *pdev)
> +{
> +	struct mxl_eth_drvdata *drvdata;
> +	struct reset_control *rst;
> +	struct net_device *ndev;
> +	struct device_node *np;
> +	int ret, i;
> +
> +	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> +	if (!drvdata)
> +		return -ENOMEM;
> +
> +	drvdata->clks = devm_clk_get_enabled(&pdev->dev, "ethif");
> +	if (IS_ERR(drvdata->clks))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->clks),
> +				     "failed to get/enable clock\n");
> +
> +	rst = devm_reset_control_get_optional(&pdev->dev, NULL);

Why is this optional? Are there some variants which don't have a
reset?

> +	i = 0;
> +	for_each_available_child_of_node(pdev->dev.of_node, np) {
> +		if (!of_device_is_compatible(np, "mxl,eth-mac"))
> +			continue;

Are there going to be other devices here, with different compatibles?

> +
> +		ret = mxl_eth_create_ndev(pdev, np, &ndev);

Shouldn't you validate reg before creating the device?

	Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC
  2025-08-26  3:10 ` [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC Jack Ping CHNG
  2025-08-26 12:45   ` Andrew Lunn
@ 2025-08-26 13:05   ` Rob Herring (Arm)
  2025-08-27 12:33   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 11+ messages in thread
From: Rob Herring (Arm) @ 2025-08-26 13:05 UTC (permalink / raw)
  To: Jack Ping CHNG
  Cc: davem, pabeni, conor+dt, sureshnagaraj, edumazet, devicetree,
	andrew+netdev, kuba, krzk+dt, yzhu, netdev


On Tue, 26 Aug 2025 11:10:43 +0800, Jack Ping CHNG wrote:
> Introduce device-tree binding documentation for MaxLinear LGM Network
> Processor
> 
> Signed-off-by: Jack Ping CHNG <jchng@maxlinear.com>
> ---
>  .../devicetree/bindings/net/mxl,lgm-eth.yaml  | 73 +++++++++++++++++++
>  1 file changed, 73 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/mxl,lgm-eth.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/mxl,lgm-eth.example.dtb: eth (mxl,lgm-eth): interface@1:compatible:0: 'mxl,lgm-mac' was expected
	from schema $id: http://devicetree.org/schemas/net/mxl,lgm-eth.yaml#
Documentation/devicetree/bindings/net/mxl,lgm-eth.example.dtb: /example-0/eth/interface@1: failed to match any schema with compatible: ['mxl,eth-mac']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250826031044.563778-2-jchng@maxlinear.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC
  2025-08-26  3:10 ` [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC Jack Ping CHNG
  2025-08-26 13:03   ` Andrew Lunn
@ 2025-08-26 13:09   ` Jakub Kicinski
  2025-08-27 12:33   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2025-08-26 13:09 UTC (permalink / raw)
  To: Jack Ping CHNG
  Cc: netdev, devicetree, davem, andrew+netdev, edumazet, pabeni, robh,
	krzk+dt, conor+dt, yzhu, sureshnagaraj

On Tue, 26 Aug 2025 11:10:44 +0800 Jack Ping CHNG wrote:
> +	for_each_available_child_of_node(pdev->dev.of_node, np) {
> +		if (!of_device_is_compatible(np, "mxl,eth-mac"))
> +			continue;
> +
> +		ret = mxl_eth_create_ndev(pdev, np, &ndev);
> +		if (ret)
> +			goto err_cleanup;
> +
> +		drvdata->ndevs[i++] = ndev;
> +		if (i >= MXL_NUM_PORT)
> +			break;
> +	}

You need a of_node_put(np) before the goto and the break;
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC
  2025-08-26 13:03   ` Andrew Lunn
@ 2025-08-27 10:41     ` Jack Ping Chng
  2025-08-27 12:16       ` Andrew Lunn
  0 siblings, 1 reply; 11+ messages in thread
From: Jack Ping Chng @ 2025-08-27 10:41 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
	davem@davemloft.net, andrew+netdev@lunn.ch, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, Yi xin Zhu,
	Suresh Nagaraj

Hi Andrew,

On Tue, 26 Aug 2025 15:03:08 +0200
Andrew Lunn <andrew@lunn.ch> wrote:

> > +     rst = devm_reset_control_get_optional(&pdev->dev, NULL);
> 
> Why is this optional? Are there some variants which don't have a
> reset?

Thanks for the review.
Will change to devm_reset_control_get()

> > +     i = 0;
> > +     for_each_available_child_of_node(pdev->dev.of_node, np) {
> > +             if (!of_device_is_compatible(np, "mxl,eth-mac"))
> > +                     continue;
> 
> Are there going to be other devices here, with different compatibles?

Yes, other devices will be added in the next patch series.

> > +
> > +             ret = mxl_eth_create_ndev(pdev, np, &ndev);
> 
> Shouldn't you validate reg before creating the device?

Will add of_address_to_resource()

Jack

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC
  2025-08-27 10:41     ` Jack Ping Chng
@ 2025-08-27 12:16       ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-08-27 12:16 UTC (permalink / raw)
  To: Jack Ping Chng
  Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
	davem@davemloft.net, andrew+netdev@lunn.ch, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, Yi xin Zhu,
	Suresh Nagaraj

> > > +     i = 0;
> > > +     for_each_available_child_of_node(pdev->dev.of_node, np) {
> > > +             if (!of_device_is_compatible(np, "mxl,eth-mac"))
> > > +                     continue;
> > 
> > Are there going to be other devices here, with different compatibles?
> 
> Yes, other devices will be added in the next patch series.

DT describes the hardware. The hardware is not going to change, so you
might want to add the full DT binding now to describe it. That will
also help justify this compatible, which is a bit odd.

	Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC
  2025-08-26  3:10 ` [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC Jack Ping CHNG
  2025-08-26 13:03   ` Andrew Lunn
  2025-08-26 13:09   ` Jakub Kicinski
@ 2025-08-27 12:33   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-27 12:33 UTC (permalink / raw)
  To: Jack Ping CHNG, netdev, devicetree
  Cc: davem, andrew+netdev, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, yzhu, sureshnagaraj

On 26/08/2025 05:10, Jack Ping CHNG wrote:
> Introduce the build system integration and initial implementation for the

Nothing improved - do not describe how kernel works, builds. We all know
Kconfig.

Describe the driver and hardware.

> MaxLinear LGM SoC Ethernet driver. This patch adds Kconfig and Makefile

Please do not use "This commit/patch/change", but imperative mood. See
longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95


...

> +
> +static int mxl_eth_probe(struct platform_device *pdev)
> +{
> +	struct mxl_eth_drvdata *drvdata;
> +	struct reset_control *rst;
> +	struct net_device *ndev;
> +	struct device_node *np;
> +	int ret, i;
> +
> +	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> +	if (!drvdata)
> +		return -ENOMEM;
> +
> +	drvdata->clks = devm_clk_get_enabled(&pdev->dev, "ethif");
> +	if (IS_ERR(drvdata->clks))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->clks),

That's correct...

> +				     "failed to get/enable clock\n");
> +
> +	rst = devm_reset_control_get_optional(&pdev->dev, NULL);
> +	if (IS_ERR(rst)) {
> +		dev_err(&pdev->dev,
> +			"failed to get optional reset control: %ld\n",
> +			PTR_ERR(rst));


But here nothing improved.

Please look how ALL DRIVERS do it? What syntax they use?

Do your homework and really work on this driver. If I pointed issue on
clocks, YOU MUST fix it everywhere, not just clocks.


> +		ret = PTR_ERR(rst);
> +		goto err_cleanup;
> +	}
> +
> +	if (rst) {
> +		ret = reset_control_assert(rst);
> +		if (ret)
> +			goto err_cleanup;
> +
> +		udelay(1);
> +
> +		ret = reset_control_deassert(rst);
> +		if (ret)
> +			goto err_cleanup;
> +	}
> +
> +	platform_set_drvdata(pdev, drvdata);
> +
> +	i = 0;
> +	for_each_available_child_of_node(pdev->dev.of_node, np) {
> +		if (!of_device_is_compatible(np, "mxl,eth-mac"))
> +			continue;
> +
> +		ret = mxl_eth_create_ndev(pdev, np, &ndev);
> +		if (ret)
> +			goto err_cleanup;

You leak of node. Use scoped loop.

> +
> +		drvdata->ndevs[i++] = ndev;
> +		if (i >= MXL_NUM_PORT)
> +			break;
> +	}
> +
> +	return 0;
> +
> +err_cleanup:
> +	mxl_eth_cleanup(drvdata);
> +	return ret;
> +}
> +
> +static void mxl_eth_remove(struct platform_device *pdev)
> +{
> +	struct mxl_eth_drvdata *drvdata = platform_get_drvdata(pdev);
> +
> +	mxl_eth_cleanup(drvdata);
> +}
> +
> +/* Device Tree match table */
> +static const struct of_device_id mxl_eth_of_match[] = {
> +	{ .compatible = "mxl,lgm-eth" },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxl_eth_of_match);
> +
> +/* Platform driver struct */
> +static struct platform_driver mxl_eth_drv = {
> +	.probe    = mxl_eth_probe,
> +	.remove   = mxl_eth_remove,
> +	.driver = {
> +		.name = KBUILD_MODNAME,
> +		.of_match_table = mxl_eth_of_match,
> +	},
> +};
> +
> +module_platform_driver(mxl_eth_drv);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("Ethernet driver for MxL SoC");


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC
  2025-08-26  3:10 ` [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC Jack Ping CHNG
  2025-08-26 12:45   ` Andrew Lunn
  2025-08-26 13:05   ` Rob Herring (Arm)
@ 2025-08-27 12:33   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-27 12:33 UTC (permalink / raw)
  To: Jack Ping CHNG, netdev, devicetree
  Cc: davem, andrew+netdev, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, yzhu, sureshnagaraj

On 26/08/2025 05:10, Jack Ping CHNG wrote:
> +maintainers:
> +  - Jack Ping Chng <jchng@maxlinear.com>
> +
> +description:
> +  Binding for MaxLinear LGM Ethernet controller
> +
> +properties:
> +  compatible:
> +    enum:
> +      - mxl,lgm-eth

No such vendor prefix.

> +
> +  clocks:
> +    maxItems: 1
> +
> +  clock-names:
> +    items:
> +      - const: ethif
> +
> +  resets:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1

Blank line

> +  '#size-cells':
> +    const: 0
> +
> +patternProperties:
> +  "^interface@[1-4]$":

Use consistent quotes, either ' or "

I don't quite get what's this node is for.

> +    type: object
> +    properties:
> +      compatible:
> +        const: mxl,lgm-mac
> +
> +      reg:
> +        minimum: 1
> +        maximum: 4
> +
> +    required:
> +      - compatible
> +      - reg
> +
> +required:
> +  - compatible
> +  - clocks
> +  - clock-names
> +  - '#address-cells'
> +  - '#size-cells'
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    eth {

ethernet? How is it called everywhere else?

Node names should be generic. See also an explanation and list of
examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

> +      compatible = "mxl,lgm-eth";
> +      clocks = <&cgu0 32>;
> +      clock-names = "ethif";
> +      resets = <&rcu0 0x70 8>;
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      mac: interface@1 {
> +        compatible = "mxl,eth-mac";
> +        reg = <1>;

No resources here, so this is not really a subnode... unless you wanted
to reference something from ethernet controllers.

This looks pretty incomplete.

> +      };
> +    };


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-27 12:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26  3:10 [PATCH net-next v2 0/2] Add MxL Ethernet driver & devicetree binding Jack Ping CHNG
2025-08-26  3:10 ` [PATCH net-next v2 1/2] dt-bindings: net: mxl: Add MxL LGM Network Processor SoC Jack Ping CHNG
2025-08-26 12:45   ` Andrew Lunn
2025-08-26 13:05   ` Rob Herring (Arm)
2025-08-27 12:33   ` Krzysztof Kozlowski
2025-08-26  3:10 ` [PATCH net-next v2 2/2] net: maxlinear: Add support for MxL LGM SoC Jack Ping CHNG
2025-08-26 13:03   ` Andrew Lunn
2025-08-27 10:41     ` Jack Ping Chng
2025-08-27 12:16       ` Andrew Lunn
2025-08-26 13:09   ` Jakub Kicinski
2025-08-27 12:33   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).