From nobody Fri Sep 25 12:06:09 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E8153655FA; Tue, 15 Sep 2026 08:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789459587; cv=none; b=tjdOFw7LoasiYAqApUaeTVkaF2Zi4EYMl4AKyEK1r3hLZJlEEt2WA/dD+cKDFImOdVR+ZstSlT+TTHv3K4itvqQvEhN2a2dGEFuSb//BfLIkf7RSoZyQyJSk2YL9YcxlDJm13ofyQDsO4aEY8CEGPhkGRFURZYJClQ0S5/4RiXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789459587; c=relaxed/simple; bh=huJlGR1UrTSOSfs2sEbA6FJRf7N+rGl+NuBO9dz2gcQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fdUu0MY0Ynvse8VglgACRZFsFXOa4ioCElEqYgiNDk9ekFfz6VL+GYInWe8dh+amINcMMoNQZcaE7NNI131WrnmfJo98YVSLs9J2lj9eCz6EEHdECCrFRrN5+uzX/0jIHIdfRVQRWYf02vHfLSLO7wBzqu/WOLHW//R2OX2QAbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marmottus.net; spf=pass smtp.mailfrom=marmottus.net; dkim=pass (2048-bit key) header.d=marmottus.net header.i=@marmottus.net header.b=FZmF0iWd; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marmottus.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marmottus.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marmottus.net header.i=@marmottus.net header.b="FZmF0iWd" Received: by mail.gandi.net (Postfix) with ESMTPSA id 12A003EDB9; Tue, 15 Sep 2026 08:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1789459577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PQOlmpJvNxnVNPdsPSoEc1kTm76NavIIw7R+fCDLpuc=; b=FZmF0iWdFbz93h6n6HP5I8oXXVAAtrowhc/UZWwxgGbR8Qp49F7QZ8sPl0zEstv8ykluvy 9znEwO5mPF0gj1TQN845kA/EwuZJ7nawjgSrGU0pAKRIvMvltg8fnhOtMcTJD/J1Nu/GaZ QBhcRv3Lb1EsIWCty49UfeVpYZcftgnVTLyxe5t43btMnVRXpMDjXrBNKADjkZFGP1xIGj k4wQ8ktnlhwehQyo2sZTSSTD8RO0m60sYHTX0IKC0lB6yo/7e9uXMQp9auIK9UAUFhmbhi j5puTIC0n3Zd4rbJc+lw8l1MI4uis4R077uyq9YbPO7hpIq5NxabcjVLSVACHw== From: Arthur Crepin Leblond Date: Tue, 15 Sep 2026 10:06:02 +0200 Subject: [PATCH net-next v8 1/3] dt-bindings: net: wiznet,w5100: convert to DT schema Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-wiznet-link-gpio-v8-1-d173622474cc@marmottus.net> References: <20260915-wiznet-link-gpio-v8-0-d173622474cc@marmottus.net> In-Reply-To: <20260915-wiznet-link-gpio-v8-0-d173622474cc@marmottus.net> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Arnd Bergmann , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Crepin Leblond , Krzysztof Kozlowski X-Mailer: b4 0.15.2 X-GND-Sasl: arthur@marmottus.net X-GND-State: clean X-GND-Score: -100 X-GND-Cause: dmFkZTFnpE47byBS4rdGAgGi/KwVFJ4qnxfS+YMMkmf4ICKnnqaChMKgNZqONsmcW7seYZvnvzlktfYPsJWTBtQWd0M9YOGjgsNBByDMrfRuEsyOkhmKidw/4yAAkqS66N3H47W4MLATGbl9DduNFRfhsinJhgU7dH1+VUOYAZP0BYjrjfPpW4Vl/sTxyGuJ9AXMioXkPFLU/onSQc1VwkZBgD7f8xg1DqGxu1U5QyMyWudahuBdRpdo8pcJykJ4hFLtvj4RaXKaLDAcneQPWdBMY9KRg/Z79n9HXAUC9OGo3p2J7hVG8jUzb50ApuS2DGXtdwnfW8D4wMpmqTR2rIX9KsshP9TLXxiC8fGwBoeKq9yRvTLxsUkHH8TY2dFZW/7frL+EYVm9cSp00HaLpjgYVgRMHbwMuKI0xP3Z4isosqhQ3wz1k64C1P7eUmuoE+9hxiDQ+VjIipBdhNn+l0Jz6j/FO0n+V78Stprwv1Lg9x7sFWvqyKKBN+5dErt/SB5Lbvtx54nnpQ0XlTQUv041gQrfWo4ca2tUQ7ydG3NyBTeOcMo8C50veuAYNoPTM61MecwBD96Tzash7cwvkd1RZTDGHlsm8LdYb200yXftLpwP89Hur85cMRA2X5alF7WnGnMJ4PmfHuKOgsuSNe4ppU5Kdh2+CEBp/8lYw8YgCTk/nw Convert the Wiznet w5x00 SPI Ethernet controller binding from plain text to DT schema. Signed-off-by: Arthur Crepin Leblond Reviewed-by: Krzysztof Kozlowski --- v8: - Add a myself in MAINTAINERS - Address Sashiko reviews - Change edge-falling to level-low - Clarify the spi max frequency for all devices - Add main interrupt description v7: - No changes v6: - Put back the reviewed by tag from Krzysztof Kozlowski from v4 v5: - Remove gpio/gpio.h include from DT example - Fix DT bindings errors v4: - Update interrupts in DT bindings v3: - Fix DT binding errors v2: - Convert device tree binding to YAML --- .../devicetree/bindings/net/wiznet,w5100.yaml | 68 ++++++++++++++++++= ++++ .../devicetree/bindings/net/wiznet,w5x00.txt | 50 ---------------- MAINTAINERS | 6 ++ 3 files changed, 74 insertions(+), 50 deletions(-) diff --git a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml b/Docu= mentation/devicetree/bindings/net/wiznet,w5100.yaml new file mode 100644 index 000000000000..25098308eb6e --- /dev/null +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wiznet,w5100.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Wiznet w5100/w5200/w5500 SPI Ethernet Controller + +maintainers: + - Arthur Crepin Leblond + +description: | + This is a standalone 10/100 MBit Ethernet controller with SPI interface. + +allOf: + - $ref: /schemas/net/ethernet-controller.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + enum: + - wiznet,w5100 + - wiznet,w5200 + - wiznet,w5500 + + interrupts: + maxItems: 1 + description: Main interrupt (INT pin on the device). + + reg: + maxItems: 1 + + spi-max-frequency: + description: + According to the datasheets, w5500 and w5200 allow a maximum of 80 M= Hz + while w5100 is reported by users to allow a maximum of 14 MHz. Howev= er, + board designs may need to limit this value. + maximum: 80000000 + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + /* Example (for Raspberry Pi with pin control stuff for GPIO irq) */ + + #include + + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + ethernet@0 { + compatible =3D "wiznet,w5500"; + reg =3D <0>; + pinctrl-names =3D "default"; + pinctrl-0 =3D <ð1_pins>; + interrupt-parent =3D <&gpio>; + interrupts =3D <25 IRQ_TYPE_LEVEL_LOW>; + spi-max-frequency =3D <30000000>; + local-mac-address =3D [ a0 b0 c0 d0 e0 f0 ]; + }; + }; +... diff --git a/Documentation/devicetree/bindings/net/wiznet,w5x00.txt b/Docum= entation/devicetree/bindings/net/wiznet,w5x00.txt deleted file mode 100644 index e9665798c4be..000000000000 --- a/Documentation/devicetree/bindings/net/wiznet,w5x00.txt +++ /dev/null @@ -1,50 +0,0 @@ -* Wiznet w5x00 - -This is a standalone 10/100 MBit Ethernet controller with SPI interface. - -For each device connected to a SPI bus, define a child node within -the SPI master node. - -Required properties: -- compatible: Should be one of the following strings: - "wiznet,w5100" - "wiznet,w5200" - "wiznet,w5500" -- reg: Specify the SPI chip select the chip is wired to. -- interrupts: Specify the interrupt index within the interrupt controller = (referred - to above in interrupt-parent) and interrupt type. w5x00 nati= vely - generates falling edge interrupts, however, additional board= logic - might invert the signal. -- pinctrl-names: List of assigned state names, see pinctrl binding documen= tation. -- pinctrl-0: List of phandles to configure the GPIO pin used as interrupt = line, - see also generic and your platform specific pinctrl binding - documentation. - -Optional properties: -- spi-max-frequency: Maximum frequency of the SPI bus when accessing the w= 5500. - According to the w5500 datasheet, the chip allows a maximum of 80 MHz, h= owever, - board designs may need to limit this value. -- local-mac-address: See ethernet.txt in the same directory. - - -Example (for Raspberry Pi with pin control stuff for GPIO irq): - -&spi { - ethernet@0: w5500@0 { - compatible =3D "wiznet,w5500"; - reg =3D <0>; - pinctrl-names =3D "default"; - pinctrl-0 =3D <ð1_pins>; - interrupt-parent =3D <&gpio>; - interrupts =3D <25 IRQ_TYPE_EDGE_FALLING>; - spi-max-frequency =3D <30000000>; - }; -}; - -&gpio { - eth1_pins: eth1_pins { - brcm,pins =3D <25>; - brcm,function =3D <0>; /* in */ - brcm,pull =3D <0>; /* none */ - }; -}; diff --git a/MAINTAINERS b/MAINTAINERS index 0e04d92d1b09..624beed96f32 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -29440,6 +29440,12 @@ M: Miloslav Trmac S: Maintained F: drivers/input/misc/wistron_btns.c =20 +WIZNET W5100 ETHERNET DRIVER +M: Arthur Crepin Leblond +L: netdev@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/net/wiznet,w5100.yaml + WMI BINARY MOF DRIVER M: Armin Wolf R: Thomas Wei=C3=9Fschuh --=20 2.55.0 From nobody Fri Sep 25 12:06:09 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98ACC361668; Tue, 15 Sep 2026 08:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789459589; cv=none; b=uSpBO7mBSAXytdrNpHSe6AQCUG78lO/lWjR2MbH4GuEBdu/uC98l0Scm+sffUwgYHkQUTGU5/dGpoVnSPbZlPfRlP4H75bVRq28R8TpTYfVXlMk7dsnY8iYX57vPzTCiBcQG4Uw+LzctJsxS+Q2XVNbu/Iil1KoPW8Nlf9MS8SQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789459589; c=relaxed/simple; bh=0UtIK4EWaEM5NyLfWC9AQHfi3cx+W4riJmN7gPYqazU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b5hHOjlNgyesIyTXu75punBs5AXB2SiVneHE2qqrgNCooMWZao3PHL+SkkVTDW4Sgs+PDPYxrzrNaVm3EAW1YNEeu7bRpXZStSBPXwAWPTbBTqmxS+Df3N6BMeIpri0xwXl7NRpzIZ9aaM/dqzcV4ig1BkjLJvaKR+naP9Y0NtU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marmottus.net; spf=pass smtp.mailfrom=marmottus.net; dkim=pass (2048-bit key) header.d=marmottus.net header.i=@marmottus.net header.b=g/xpKYEg; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marmottus.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marmottus.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marmottus.net header.i=@marmottus.net header.b="g/xpKYEg" Received: by mail.gandi.net (Postfix) with ESMTPSA id 308F83EDE1; Tue, 15 Sep 2026 08:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1789459579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zjp8PjXiAnLAmgWmDr7CM8wc83Z7ba0mT6o7NJd+Dv0=; b=g/xpKYEgVTl9Y+YC+g6ZryBRi3HeskV5U7z+Gd/XqOsv7ra6nbKEcSo46YPzNvvgT+drJC G/59HHj8u+mo9NcxDx/DDWi4xhQVTwORLcATwuoVXv6Z1J2knt53jea7od54PNLwsOH5bb QYIGiTT0s0HJu3NkeKzB/MzG4/LNGFpiNi56NAZejgJoJrix40m/clbZfx1y/8PA2ANYM2 t4WjDGZZY3D3EcjZk/qLqwg8iWck/nvZUpRNKkv4C66kv0lo2pzKWRQMuaJNpex74ITpv0 zDsSroFjeTxOKph+W+xKJIwIj4BUhRdvakhqmKlAuv30MQa2U8eYS7C5Bif0rQ== From: Arthur Crepin Leblond Date: Tue, 15 Sep 2026 10:06:03 +0200 Subject: [PATCH net-next v8 2/3] dt-bindings: net: wiznet,w5100: add link status interrupt Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-wiznet-link-gpio-v8-2-d173622474cc@marmottus.net> References: <20260915-wiznet-link-gpio-v8-0-d173622474cc@marmottus.net> In-Reply-To: <20260915-wiznet-link-gpio-v8-0-d173622474cc@marmottus.net> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Arnd Bergmann , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Crepin Leblond X-Mailer: b4 0.15.2 X-GND-Sasl: arthur@marmottus.net X-GND-State: clean X-GND-Score: -100 X-GND-Cause: dmFkZTFAFqprjYmMpGKftCTkYlbk5kdK4l8Fitu7zs4+KBA0m8t3VRCs8xUf9+CZ5U3qNYjJxsUJwkHFm6CTcIxkrUixEh9MRSgg+b+3GEgRVe5rGxdkPxTUXurRaic+wE2+hLOnmGcr/adm+W6FlAeH+y8E/wnjtu9WluIC4LFUQWUCjN5rGuBUOIxMySz0myLCeSuyrzkg/LXvW4ECcruBfdzuWPCZwp6ZINeRnspLS9TpE5Yd/tynzLutmhfM0brccBXPAVxNesNx0XZY7/j/f+G1m4k5L9tNogzM4K5fCyjvtneZA9frkKyXLiznFGo2i+z3w4FUXo7q2gbFgrem5XnCi+9CkF8DkIA3TwdKC259mZjyvgtUJ8nlXrwETJlI4ErBnq3K503rAcYSfd4ldDha0bktGAjExBWdkB+tjVaVSbNm24ehAZiradpdQE8nR3kmMz76V9gmQLN+aolve/tzCDiklA1mTDt4XbJvPcNuXft6eN+FyHaiPVjuA0HoNp65evUFEBNiPv20q9jBKhGDA92aMTNwK0GdZC2zMBaigiWmR4YToMeUPx1P1QkCAia/IffwYK5C5idA5WwpmrNriQzavRlVxhnhWehWP3GkVxf40BS359FjgYUef6QO9js8ogeYuPb9ZZA6H4Z1FZD0h97q6a/iHukMEsAaXQF+aw Add an optional link status interrupt which can be connected to the LINKLED pin on the device to detect link status changes. This second interrupt is only supported on wiznet,w5500. Signed-off-by: Arthur Crepin Leblond --- v8: - Remove Krzysztof Kozlowski reviewed-by tag after Sashiko review changes - Make the interrupts property conditional v7: - No changes v6: - Fix DT error: use minItems - Remove conditional properties v5: - Make the DT interrupts property dynamic from the compatible one - Fix DT bindings errors v4: - Update interrupts in DT bindings v3: - Fix DT binding errors v2: - Convert device tree binding to YAML --- .../devicetree/bindings/net/wiznet,w5100.yaml | 38 ++++++++++++++++++= ---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml b/Docu= mentation/devicetree/bindings/net/wiznet,w5100.yaml index 25098308eb6e..da03f4e07f29 100644 --- a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -12,10 +12,6 @@ maintainers: description: | This is a standalone 10/100 MBit Ethernet controller with SPI interface. =20 -allOf: - - $ref: /schemas/net/ethernet-controller.yaml# - - $ref: /schemas/spi/spi-peripheral-props.yaml# - properties: compatible: enum: @@ -24,8 +20,11 @@ properties: - wiznet,w5500 =20 interrupts: - maxItems: 1 - description: Main interrupt (INT pin on the device). + description: + The main interrupt (INT pin) is mandatory on all devices. The w5500 + additionally supports an optional second interrupt for link status c= hanges + (LINKLED pin). If it is not specified, link state changes will not be + reported. =20 reg: maxItems: 1 @@ -42,6 +41,30 @@ required: - reg - interrupts =20 +allOf: + - $ref: /schemas/net/ethernet-controller.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + - if: + properties: + compatible: + contains: + enum: + - wiznet,w5500 + then: + properties: + interrupts: + minItems: 1 + items: + - description: Main interrupt (INT pin on the device). + - description: + Optional interrupt for link status changes (LINKLED pin on + w5500). + else: + properties: + interrupts: + maxItems: 1 + description: Main interrupt (INT pin on the device). + unevaluatedProperties: false =20 examples: @@ -60,7 +83,8 @@ examples: pinctrl-names =3D "default"; pinctrl-0 =3D <ð1_pins>; interrupt-parent =3D <&gpio>; - interrupts =3D <25 IRQ_TYPE_LEVEL_LOW>; + interrupts =3D <25 IRQ_TYPE_LEVEL_LOW>, + <24 IRQ_TYPE_EDGE_BOTH>; spi-max-frequency =3D <30000000>; local-mac-address =3D [ a0 b0 c0 d0 e0 f0 ]; }; --=20 2.55.0 From nobody Fri Sep 25 12:06:09 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABB7C346ACE; Tue, 15 Sep 2026 08:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789459586; cv=none; b=Q1Pkv5H2POW/MPWQuQ/jVAP2sI6pDrxskgimPq29rO5bWY1y0EGbit3UUYY+lSSWBhl1SOIY/2rvp0tdKKLOlD0qsh9GDEUbCasIUMYi/i4KxQpL+O07NjvZTLizT1GERbAg5vYAh4OkBSyRcCdrqXS+i147NsYEd/oVOsMVNw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789459586; c=relaxed/simple; bh=ml2g+ppJkaDHul0KvlUDW7KKQjh5kOEaqIj8U0oGT5M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JGyu6GKk4UzX8jGWiFZv59HeaZ1uvhitgA5+7MDOSbk4gMS8+UCBpKG3REBjM1G9Ucrs6PIuK04FMsB1kb2GjgfNYGpHjL82pJ+zVo1g9oIRhksSF8anjQIejPBmoNy6MPOWmeTJy8sbGcJEe5tHR4DLTU0Xa2yy0FU42dUmBos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marmottus.net; spf=pass smtp.mailfrom=marmottus.net; dkim=pass (2048-bit key) header.d=marmottus.net header.i=@marmottus.net header.b=nOLyo5h4; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marmottus.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marmottus.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marmottus.net header.i=@marmottus.net header.b="nOLyo5h4" Received: by mail.gandi.net (Postfix) with ESMTPSA id 30FD63EDBD; Tue, 15 Sep 2026 08:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1789459581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tz1aT6Hss6CL1K9BopTDMRxfiQGjjDNLEgSy6K3YP/w=; b=nOLyo5h4BK4+YqDjDVzcx7ADbTIXwCfWwzAz+loaMr0OgbEpE6UQJDdbQEFuR9GDdgaN+o SWeAWwayfjW/8R3bBytfwZV/iQ+D7EpH4sWZODutUR87zBLWUEIqEyFC0tZ17aTw9tCZft S4nbdEoav4KDa7lSUus0p1XKRPwFD0N9CCLIfmS3HliiB79wxEF63cRPmn27JcCZlC0y4n gIyOFAnvvsfj1sR58jKSyB61uiEGdC5Pq0/MQxWgfgzzg6fiLN9UY2qdfG6up+9EeQuyJt tnvu0EXrIUB4fG031AX39GlhSC05QoKcyCFeqEy2LmeNja63TRduyvCV4A7euA== From: Arthur Crepin Leblond Date: Tue, 15 Sep 2026 10:06:04 +0200 Subject: [PATCH net-next v8 3/3] w5100: detect carrier state using link status bit and optional interrupt Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-wiznet-link-gpio-v8-3-d173622474cc@marmottus.net> References: <20260915-wiznet-link-gpio-v8-0-d173622474cc@marmottus.net> In-Reply-To: <20260915-wiznet-link-gpio-v8-0-d173622474cc@marmottus.net> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Arnd Bergmann , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Crepin Leblond X-Mailer: b4 0.15.2 X-GND-Sasl: arthur@marmottus.net X-GND-State: clean X-GND-Score: -100 X-GND-Cause: dmFkZTFAFqprjYmMpGKftCTkYlbk5kdK4l8Fitu7zs4+KBA0m8t3VRCs8xUf9+CZ5U3qNYjJxsUJwkHFm6CTcIxkrUixEh9MRSgg+b+3GEgRVe5rGxdkPxTUXurRaic+wE2+hLOnmGcr/adm+W6FlAeH+y8E/wnjtu9WluIC4LFUQWUCjN5rGuBUOIxMySz0myLCeSuyrzkg/LXvW4ECcruBfdzuWPCZwp6ZINeRnspLS9TpE5Yd/tynzLutmhfM0brccBXPAVxNesNx0XZY7/j/f+G1m4k5L9tNogzM4K5fCyjvtneZA9frkKyXLiznFGo2i+z3w4FUXo7q2gbFgrem5XnCFwVZgkYB8NiUwuZZ84sMkJUAgS5gH8ppxE3zjjbggcvu8DsRiyxG6ww4okFYRd50hSx07VCP4xSXc0Y6gtBsn6+0Ov4jaRW6Ee/XlV+I0ZvFklVZW6+Erh6ScsKpHrmmrusA2h4JXGHkpw5qr3ILi+oPIHE72A86iyzQiuODWQk6nKY1+7sAMpn1IT2mJDs69Myl4BvoyrQwN2NpVpFqDvpIem3bbM0aB+qrPpm2Ymcg3Q4dOaPVASzVFL5J1QghzAMLWkhwonWCGz6QMQK9HjkuuoyDkKUdopFD+TssObs/64BRB3dek3PyEpkZ8JYDm34sqzQ8gnoM5Ac8defs6A Detect the link status on the w5500 using the Link Status bit from the PHY Configuration register (PHYCFGR). On w5100/w5200, which lack this register, .get_link is not implemented and the carrier state is not reported. Add an optional interrupt, wired to the LINKLED pin of the w5500, to detect link status changes with a read of the PHYCFGR register and update of the carrier state with netif_carrier_on|off. If this interrupt is not set in the DT binding, only .get_link can be used to get the carrier state. The interrupt handler and the PHYCFGR register read are synchronized using a mutex. The carrier state (netif_carrier_on|off) is not called anymore on w5100/w5200 or w5500 without the link irq. Make sure that the netdev is registered last in the probe function so no operation can be performed before the probing is finished. dev_name is now used instead of netdev_name. Commit dacf281771a9 ("w5100: remove unused gpio link detection") dropped the link_gpio/link_irq handling on the grounds that no devicetree user passed a "link" gpio at the time and that it used the old gpio interface. This isn't a plain revert of that removal: link detection is now done using a second interrupt rather than a gpio with a documented DT binding. Signed-off-by: Arthur Crepin Leblond --- v8: - Add myself in the MAINTAINERS file - Address Sashiko reviews from online bot and locally run - Add a mutex to synchronize the link state read and interrupt - Return last known carrier state (netif_carrier_ok) in w5500_get_link on SPI error or if the device is not present - Only set ops .get_link on w5500 - Check the netif state, disable/enable the irq and re-check the carrier state in w5100_restart - Cancel the restart work on stop/suspend - Only set carrier state to off in w5100_stop/suspend when a link irq is present - Warn on fwnode_irq_get errors for the link irq - Free the main irq and flush queues before resetting the hardware in w5100_remove v7: - Address Sashiko reviews - Propagate spi read error to the caller - Do not change the state of the carrier on SPI read error - Enable the link IRQ before reading the PHYCFGR bit - Call unregister_netdev before reset - Update commit message v6: - Revert to the reviewed v4 version by Arnd Bergmann with a few changes based on Sashiko's review - Address Sashiko reviews - call netif_carrier_off in open if there is no link_irq or get_link returns false - call register_netdev at the very end of probe - call unregister_netdev before destroying work queue - handle link irq probe defer error - call netif_device_attach in resume before re enabling the link irq - disable the link irq first in suspend - log netif_err when PHYCFGR cannot be read - enable link irq in open - disable link irq in stop - free irq and invalidate it in remove v5: - Address Sashiko review - Read the link status register only on w5500 instead of checking link_irq - call netif_carrier_off on w5500 link status off in open - enable/disable the link irq in open/stop - enable/disable the link irq in resume/suspend - handle link irq probe defer error - register the netdev last v4: - Use directly an interrupt line instead of gpio -> irq - Address Sashiko reviews - drop devm_ on request_threaded_irq to avoid use after free - disable/enable the link_irq in the suspend/resume - only call netif_carrier_on|off if the link interrupt is present v3: - Use the Link Status bit of the PHY Configuration Register - Use the LINKLED gpio binding for change detection only v2: - Use devm_request_threaded_irq instead of request_any_context_irq - Use devm_gpiod_get_optional instead of gpiod_get_optional - Call dev_err_probe on gpiod_to_irq failure - Remove link_irq from priv - Use a fixed string for the IRQ name - Remove empty new lines --- MAINTAINERS | 1 + drivers/net/ethernet/wiznet/w5100.c | 192 ++++++++++++++++++++++++++++++++= ---- 2 files changed, 174 insertions(+), 19 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 624beed96f32..2a52f5cbe218 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -29445,6 +29445,7 @@ M: Arthur Crepin Leblond L: netdev@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/net/wiznet,w5100.yaml +F: drivers/net/ethernet/wiznet/ =20 WMI BINARY MOF DRIVER M: Armin Wolf diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiz= net/w5100.c index 53d8dc642fbd..335bafbc9fa4 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -18,9 +18,11 @@ #include #include #include +#include #include #include #include +#include #include =20 #include "w5100.h" @@ -124,6 +126,8 @@ MODULE_LICENSE("GPL"); */ #define W5500_SIMR 0x0018 /* Socket Interrupt Mask Register */ #define W5500_RTR 0x0019 /* Retry Time-value Register */ +#define W5500_PHYCFGR 0x002e /* PHY Configuration Register */ +#define PHYCFGR_LNK 0x01 /* Link status */ =20 #define W5500_S0_REGS 0x10000 =20 @@ -154,6 +158,9 @@ struct w5100_priv { u16 s0_rx_buf_size; =20 int irq; + int link_irq; + /* Protects link state and carrier updates */ + struct mutex link_lock; =20 struct napi_struct napi; struct net_device *ndev; @@ -345,6 +352,67 @@ static void w5500_memory_configure(struct w5100_priv *= priv) } } =20 +static int w5500_get_phycfgr_lnk(struct net_device *ndev) +{ + struct w5100_priv *priv =3D netdev_priv(ndev); + int ret =3D w5100_read(priv, W5500_PHYCFGR); + + if (ret < 0) { + netif_err(priv, link, ndev, + "failed to read link status: %d\n", ret); + return ret; + } + + return ret & PHYCFGR_LNK; +} + +static void w5500_report_carrier_state(struct net_device *ndev) +{ + struct w5100_priv *priv =3D netdev_priv(ndev); + int state; + + mutex_lock(&priv->link_lock); + + state =3D w5500_get_phycfgr_lnk(ndev); + if (state > 0) { + netif_info(priv, link, ndev, "link is up\n"); + netif_carrier_on(ndev); + } else if (state =3D=3D 0) { + netif_info(priv, link, ndev, "link is down\n"); + netif_carrier_off(ndev); + } + + mutex_unlock(&priv->link_lock); +} + +static irqreturn_t w5500_detect_link_interrupt(int irq, void *ndev_instanc= e) +{ + struct net_device *ndev =3D ndev_instance; + + if (netif_running(ndev)) + w5500_report_carrier_state(ndev); + + return IRQ_HANDLED; +} + +static u32 w5500_get_link(struct net_device *ndev) +{ + struct w5100_priv *priv =3D netdev_priv(ndev); + int state; + + if (!netif_device_present(ndev)) + return netif_carrier_ok(ndev); + + mutex_lock(&priv->link_lock); + state =3D w5500_get_phycfgr_lnk(ndev); + mutex_unlock(&priv->link_lock); + + if (state < 0) + return netif_carrier_ok(ndev); + + return state > 0; +} + static int w5100_hw_reset(struct w5100_priv *priv) { u32 rtr; @@ -448,12 +516,23 @@ static void w5100_restart(struct net_device *ndev) { struct w5100_priv *priv =3D netdev_priv(ndev); =20 + if (!netif_running(ndev)) + return; + + if (priv->link_irq > 0) + disable_irq(priv->link_irq); + netif_stop_queue(ndev); w5100_hw_reset(priv); w5100_hw_start(priv); ndev->stats.tx_errors++; netif_trans_update(ndev); netif_wake_queue(ndev); + + if (priv->link_irq > 0) { + w5500_report_carrier_state(ndev); + enable_irq(priv->link_irq); + } } =20 static void w5100_restart_work(struct work_struct *work) @@ -659,6 +738,12 @@ static int w5100_open(struct net_device *ndev) w5100_hw_start(priv); napi_enable(&priv->napi); netif_start_queue(ndev); + + if (priv->link_irq > 0) { + w5500_report_carrier_state(ndev); + enable_irq(priv->link_irq); + } + return 0; } =20 @@ -667,13 +752,31 @@ static int w5100_stop(struct net_device *ndev) struct w5100_priv *priv =3D netdev_priv(ndev); =20 netif_info(priv, ifdown, ndev, "shutting down\n"); + + cancel_work_sync(&priv->restart_work); + + if (priv->link_irq > 0) { + disable_irq(priv->link_irq); + mutex_lock(&priv->link_lock); + netif_carrier_off(ndev); + mutex_unlock(&priv->link_lock); + } + w5100_hw_close(priv); - netif_carrier_off(ndev); netif_stop_queue(ndev); napi_disable(&priv->napi); return 0; } =20 +static const struct ethtool_ops w5500_ethtool_ops =3D { + .get_drvinfo =3D w5100_get_drvinfo, + .get_msglevel =3D w5100_get_msglevel, + .set_msglevel =3D w5100_set_msglevel, + .get_link =3D w5500_get_link, + .get_regs_len =3D w5100_get_regs_len, + .get_regs =3D w5100_get_regs, +}; + static const struct ethtool_ops w5100_ethtool_ops =3D { .get_drvinfo =3D w5100_get_drvinfo, .get_msglevel =3D w5100_get_msglevel, @@ -721,6 +824,8 @@ int w5100_probe(struct device *dev, const struct w5100_= ops *ops, dev_set_drvdata(dev, ndev); priv =3D netdev_priv(ndev); =20 + mutex_init(&priv->link_lock); + switch (ops->chip_id) { case W5100: priv->s0_regs =3D W5100_S0_REGS; @@ -745,15 +850,26 @@ int w5100_probe(struct device *dev, const struct w510= 0_ops *ops, break; default: err =3D -EINVAL; - goto err_register; + goto err_mutex; } =20 priv->ndev =3D ndev; priv->ops =3D ops; priv->irq =3D irq; =20 + priv->link_irq =3D ops->chip_id =3D=3D W5500 ? + fwnode_irq_get(dev_fwnode(dev), 1) : -EINVAL; + if (priv->link_irq =3D=3D -EPROBE_DEFER) { + err =3D dev_err_probe(dev, priv->link_irq, + "failed to get link irq\n"); + goto err_mutex; + } else if (priv->link_irq < 0 && priv->link_irq !=3D -EINVAL) { + dev_warn(dev, "invalid link irq: %d\n", priv->link_irq); + } + ndev->netdev_ops =3D &w5100_netdev_ops; - ndev->ethtool_ops =3D &w5100_ethtool_ops; + ndev->ethtool_ops =3D ops->chip_id =3D=3D W5500 ? &w5500_ethtool_ops : + &w5100_ethtool_ops; netif_napi_add_weight(ndev, &priv->napi, w5100_napi_poll, 16); =20 /* This chip doesn't support VLAN packets with normal MTU, @@ -761,15 +877,11 @@ int w5100_probe(struct device *dev, const struct w510= 0_ops *ops, */ ndev->features |=3D NETIF_F_VLAN_CHALLENGED; =20 - err =3D register_netdev(ndev); - if (err < 0) - goto err_register; - priv->xfer_wq =3D alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_PERCPU, 0, - netdev_name(ndev)); + dev_name(dev)); if (!priv->xfer_wq) { err =3D -ENOMEM; - goto err_wq; + goto err_mutex; } =20 INIT_WORK(&priv->rx_work, w5100_rx_work); @@ -795,21 +907,42 @@ int w5100_probe(struct device *dev, const struct w510= 0_ops *ops, if (ops->may_sleep) { err =3D request_threaded_irq(priv->irq, NULL, w5100_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, - netdev_name(ndev), ndev); + dev_name(dev), ndev); } else { err =3D request_irq(priv->irq, w5100_interrupt, - IRQF_TRIGGER_LOW, netdev_name(ndev), ndev); + IRQF_TRIGGER_LOW, dev_name(dev), ndev); } if (err) goto err_hw; =20 + if (priv->link_irq > 0) { + err =3D request_threaded_irq(priv->link_irq, NULL, + w5500_detect_link_interrupt, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT | IRQF_NO_AUTOEN, + "w5100-link", ndev); + if (err < 0) + goto err_irq; + + netif_carrier_off(ndev); + } + + err =3D register_netdev(ndev); + if (err < 0) + goto err_link_irq; + return 0; =20 +err_link_irq: + if (priv->link_irq > 0) + free_irq(priv->link_irq, ndev); +err_irq: + free_irq(priv->irq, ndev); err_hw: destroy_workqueue(priv->xfer_wq); -err_wq: - unregister_netdev(ndev); -err_register: +err_mutex: + mutex_destroy(&priv->link_lock); free_netdev(ndev); return err; } @@ -820,14 +953,22 @@ void w5100_remove(struct device *dev) struct net_device *ndev =3D dev_get_drvdata(dev); struct w5100_priv *priv =3D netdev_priv(ndev); =20 - w5100_hw_reset(priv); + unregister_netdev(ndev); + + cancel_work_sync(&priv->rx_work); + cancel_work_sync(&priv->tx_work); + cancel_work_sync(&priv->setrx_work); + cancel_work_sync(&priv->restart_work); + + if (priv->link_irq > 0) + free_irq(priv->link_irq, ndev); + free_irq(priv->irq, ndev); + w5100_hw_reset(priv); =20 - flush_work(&priv->setrx_work); - flush_work(&priv->restart_work); destroy_workqueue(priv->xfer_wq); + mutex_destroy(&priv->link_lock); =20 - unregister_netdev(ndev); free_netdev(ndev); } EXPORT_SYMBOL_GPL(w5100_remove); @@ -839,9 +980,17 @@ static int w5100_suspend(struct device *dev) struct w5100_priv *priv =3D netdev_priv(ndev); =20 if (netif_running(ndev)) { - netif_carrier_off(ndev); + if (priv->link_irq > 0) { + disable_irq(priv->link_irq); + mutex_lock(&priv->link_lock); + netif_carrier_off(ndev); + mutex_unlock(&priv->link_lock); + } + netif_device_detach(ndev); =20 + cancel_work_sync(&priv->restart_work); + w5100_hw_close(priv); } return 0; @@ -857,6 +1006,11 @@ static int w5100_resume(struct device *dev) w5100_hw_start(priv); =20 netif_device_attach(ndev); + + if (priv->link_irq > 0) { + w5500_report_carrier_state(ndev); + enable_irq(priv->link_irq); + } } return 0; } --=20 2.55.0