From nobody Sat Sep 26 18:55:39 2026 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 761613EB0EF; Mon, 31 Aug 2026 12:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788180865; cv=none; b=Ux2v9PemKCapLmOghUzWptrXQGY3/gh4Zdx52G0jtZNanWUEB/QSpXhUWvGdYvemIqgkXhUxVzI9NlGMa1Vj9iNTOdGS5QRbQJCPK8Aus35Legycsjs/QQqhRNM4Na0+BlM/G79tHnFlQqr8v38UV8kveCP+wAv16wmUbNwides= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788180865; c=relaxed/simple; bh=0El5XylhT0A8Zgb3BngoVFSvYJ3S9pojFoc/NSo7D10=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BQXeYCJJPwf19VwbXBFHOoZSwoPgthBpZm4nQjPwkrg+Ub3/rucBrc+e4Z+cPgC0GKvv1QYwKCGRbQcp6GNIqOZ6/NK3hDVYe1QZGJgdEzR4aEmeC1gGgoboOth/5IjqxXKZU994g7MxbY5QHPkOhckxezIC6agifywHxwZta5o= 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=JdHP7R3v; arc=none smtp.client-ip=217.70.183.194 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="JdHP7R3v" Received: by mail.gandi.net (Postfix) with ESMTPSA id 60D033EE29; Mon, 31 Aug 2026 12:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1788180855; 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=BliuPYaZRf54U29M6fMfqX3GleAX8i4yO741/uY2E44=; b=JdHP7R3vBJ0agD1zD1iGNjAzdRYxICieCBR0JlyFLIMibN7V8bsWKfRRmf602vD7Cln8E/ B1+6nC3fzzQ1gewAX/5lywpDb5kLNUcQQqz72HmzyzePC5dmfv0m3FzDwPBZ7CvfGMDOx3 iBTWBE2g6gb7xZARlrx2u6kOoHFCW8B1P96dywMFiuJvWv6UQN0Gk9fEYfgdDdTQR5xtWs ze39JO5EviIbDn0v5n++YkKIUUPRaEbJz1/LYP8Z2AGa0UgrMZor2gE34/ALunEMXTRQif JnGOy9O3WP+akWsXPmuH99+4LfKl93MEbYqG4TsY1GVKgdG3Qj7UJ6hozUV2Jw== From: Arthur Crepin Leblond Date: Mon, 31 Aug 2026 14:53:34 +0200 Subject: [PATCH net-next v6 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: <20260831-wiznet-link-gpio-v6-1-abee6c5c966e@marmottus.net> References: <20260831-wiznet-link-gpio-v6-0-abee6c5c966e@marmottus.net> In-Reply-To: <20260831-wiznet-link-gpio-v6-0-abee6c5c966e@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-Score: -100 X-GND-Cause: dmFkZTGHg4yYEBQC3aqwwM9nF14K19hKJoQkcZn5/uSKILhdj5Z0nU/TEjxCeRxnx2TxxAMbRXw1k/ZOgKdLh2fY5EOXrESFRJZWX/Zs11Xhup2i06e8UFIH4S1o4ter4xXtTPS+L2TzrH1bunsSHdFkNQjqwbp3mYOHSEpvATAu3vQsxxYzPlJ6kWus+83MV6HmkryAc+aaQbRph6ocB659cH/voKG9TdVuMRSEoIWUNz+BEgqa3L36rltYjX/Do2Q9ryMY/kMXxXP/nWQM6L63W8DbvWMRQ8UGRtm2B9ccIsE0T0BnF83dE1v3/Shz0vclSiA/MjHNP5A7humrTtcfWLrrkZeuEv9oNiFK2eTq9mNKgyiFxypbCSlFg74uNOHKfY9hyfeVo6jRdobVrmCNPXqnIyWLG5Vu4b6TyGppFc6+vQOHY8HN3lXppDIKHc+nPyEjW//YELgRxyaj9Htq+/GTmbO4CwT9q2cYcePOuKRRXHrt5LBRxnBKgtmQsK7VJPUD1cBXtjK364DEWcDgMb6k5/zhBbrHBnUaQ/7cU2SvCwwFdMVz3Clu82/YPddVGPPf9EhYp6Hs28dMdYzThLhMCGrpAlVU2bhyQ11r7nlcLbQLhckt0u/80C+uLlgYG6DDSKsi6wRlvluekIgu9AJFTeDS9TlSx4aVjdhsRr9OGA X-GND-State: clean Convert the Wiznet w5x00 SPI Ethernet controller binding from plain text to DT schema. Signed-off-by: Arthur Crepin Leblond Reviewed-by: Krzysztof Kozlowski --- v6: - Put back the reviewed by tag from Krzysztof Kozlowski from v4 v5: - Remove gpio/gpio.h include from DT example - 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 | 66 ++++++++++++++++++= ++++ .../devicetree/bindings/net/wiznet,w5x00.txt | 50 ---------------- 2 files changed, 66 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..601d828bae92 --- /dev/null +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -0,0 +1,66 @@ +# 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 + + reg: + maxItems: 1 + + spi-max-frequency: + description: + According to the w5500 datasheet, the chip allows a maximum of 80 MH= z, + however, 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_EDGE_FALLING>; + 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 */ - }; -}; --=20 2.55.0 From nobody Sat Sep 26 18:55:39 2026 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 8BC6940BCD2; Mon, 31 Aug 2026 12:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788180866; cv=none; b=GiaLBWQBlL6rqEiTSKN8JHjn2v+e+MTVoZ9LlM0e+DBaoGRjymGHHSX6ZYeXNOiGgn5lOYQSrRqZa0LeRuyFWiWX5IHl/jPiSPIZa7g6X76k59xIhxnVwCK13HSkt5vcioOSw0It8HX/1JMiqB1g83gWw6oTwZx3Ea+alsf5jVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788180866; c=relaxed/simple; bh=KRwObc38dCsL+DMjX+ACtzzAkYCQQKuVBqUWh2pJ4J4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gLFx9tZsjO+/YESRaVLZYFAt8ex8dL7DJKAaF6BzgZujjbPiw2qaNPttET5aX/ASknODjXl1MPR9hzYiAgVJHarh4BNfQ0ImqkiDdjpg7RMUoxuVxFMqN6XPYkeYUvzbVRUKWLUgl9DQd7hJ6KadgmLKz+beu2e0lB6I9bOh0+I= 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=Fr5MeDL3; arc=none smtp.client-ip=217.70.183.194 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="Fr5MeDL3" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7978B3EE25; Mon, 31 Aug 2026 12:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1788180857; 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=x9XpjJvgDZb76wpKWcPbjb14vGucnYqZwnzLbwbLtnE=; b=Fr5MeDL35t8J+SZpmUgygaQfLyjPfVVTGjMx59abeuta1U+pjjjMCTgyqfCG44ia1ru8/s ukwrVUrkG5XsX6ucVTEtPm258pQcprCyWvKgoP64jET+mukTgs9ql6pbLftJO0DZAP9Yao zUswqg9SXr0wXHiITQPYFXqdTcx3q2T2qZsTXFREClDN4JsTcMGOBjFqLYb1Fc5B1bsZRH FuDSzliasfkJoMqvfvI4TFft1j9q9gTWdWHBhVrnTFDgMYjJA4pIta2H+eAgURjvkz+q2z dhdBrsLgbtywwxSVwRmgB4dP00yy06ZQ45EDxByyzy86BkCICQ1+Q62anJueKw== From: Arthur Crepin Leblond Date: Mon, 31 Aug 2026 14:53:35 +0200 Subject: [PATCH net-next v6 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: <20260831-wiznet-link-gpio-v6-2-abee6c5c966e@marmottus.net> References: <20260831-wiznet-link-gpio-v6-0-abee6c5c966e@marmottus.net> In-Reply-To: <20260831-wiznet-link-gpio-v6-0-abee6c5c966e@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-Score: -100 X-GND-Cause: dmFkZTFnAYAbPsQmdBbSjjcIcCyVvtkyvcgvrXKYgeL3G39/dtl9jIE01puh6LxyPBp3VxJ/IAZv/5LqgNcKN8gQC+IIMVX3Jx2hVd076mC8HvsfENZKpY02epCMBDk1TI3O835BtM/38lsgtyFEnfDFIHqAAoobwiH3gA3uyLT01Y0eXgq01XLUURWMTPCqZMGDaOoiM1jVFIpUbExF7A1xzqnmsoxIWykHUG+pj7aap/+a6spNV3uR1lLMo6YX9bnrgOWWyiQs+vG6vOv8o8W0yaHlgOszd6qPQ5GMk0pcinjVyF/g0p9X0fQ/12gWOzayfW2E3ATH7aZ6S+ojMKMVS6L5BxGxT1Tr8zBZqx+kZW1/+5bJ0yVL/ONjrNcg3XkzHtTZCR4an5xA5zwxZkb38W2L8CiF3RYboPaMLQ38dg1aPUqU9yyGABPD68S9AnwZS4xbepkq5TbwZpq28FF6W35Nq4lU6AJ9/16wCMj4rvzTPYfFDkzaK3DJstp9JpSbk+oBDb/tcjpNh0EUDPJm+2f0CI6b0dIo9KOS+FnCKNPbLk/HWM581KdsouVEW+1bdCg1oYmr9E3LVQ11wbxH3vQGZyuYVpwT3Wl62SqRDn7rdbWjKKqecHjRq8TBfUql/QltKT+FWvUi6nc/n5DEheYdBwfWdzPBko9jHvM7QN5bWQ X-GND-State: clean Add an optional link status interrupt which can be connected to the LINKLED pin on the device to detect link status changes. Signed-off-by: Arthur Crepin Leblond Reviewed-by: Krzysztof Kozlowski --- 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 --- Documentation/devicetree/bindings/net/wiznet,w5100.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml b/Docu= mentation/devicetree/bindings/net/wiznet,w5100.yaml index 601d828bae92..d0717ab45de6 100644 --- a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -24,7 +24,11 @@ properties: - wiznet,w5500 =20 interrupts: - maxItems: 1 + minItems: 1 + items: + - description: Main interrupt (INT pin on the device). + - description: + Optional interrupt for link status changes (LINKLED pin on w5500= ). =20 reg: maxItems: 1 @@ -58,7 +62,8 @@ examples: pinctrl-names =3D "default"; pinctrl-0 =3D <ð1_pins>; interrupt-parent =3D <&gpio>; - interrupts =3D <25 IRQ_TYPE_EDGE_FALLING>; + interrupts =3D <25 IRQ_TYPE_EDGE_FALLING>, + <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 Sat Sep 26 18:55:39 2026 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 3EC1B3FA5F5; Mon, 31 Aug 2026 12:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788180863; cv=none; b=Bwutm+Xwt37dbodcg3pcJwWQMbvva2pqQWqR/zLL4i0qIaMlQgWNDUk8CCcVccrIFDsckF3rN0xg3EzEQNCU5ONyGtpzXLpXzOCVFGPOCSPnps1lQNn30I/q40tXn+175NR5Y6XGyW94TbZFk+iWycpuFOzWKr9o+25xwE/Rw8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788180863; c=relaxed/simple; bh=sXNEBb+yJ53vai99Pxz6U6T+XyboTH1UH+wxB62LRjA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IEWTMszKvPQz/XZkCBJwCvKFIDp5vMryLaxGh/waIhMSD4XjRmKhbqc7Fo2fQS5xt+WBuzu0XFHDLIlqXewHH2A1aX60P4PkzL8dkFHG3iS4wxMzUO2qsyMzkVvmQ3YpfSIAQHQnyZVLWRVun3sspbR7vzRQvyTjeHvfDe1PHJQ= 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=oDrjGLHD; arc=none smtp.client-ip=217.70.183.194 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="oDrjGLHD" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7AA9D3EE10; Mon, 31 Aug 2026 12:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1788180859; 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=jUUG4YtFhFsn9pSHKodz3f/jjCry6l4JnmCFBIcD+kw=; b=oDrjGLHD6BcFQrfowwcLCGsV8La7UvKp2E1eoGsS7GPXgcQ1Fdzurv3+ENiAl3VrHJyNmt b9hqKHsK4doYa7xxYrCkvDWOuzEHCfefW4inZncc3YiPDVP8kWq7u66cnPBBdc26vyKIty HGc+YgpmOStL6DOjOqNazsuzn864QbrZ2t056pOtAiJCXm5mJMcl8rz5MMROUiC5DQT2P3 j0wMT0jgUobEcLDingDeZh5JF2awye6MYWYaYcFoUtcgqKi83tZY3goWwRv25AA0Y0EXsR OPgyeLtXEYG7a4StcIwoCfy18r9A6/v2mIRI6oPPtVKwC+/0UAhee/gllbLNrQ== From: Arthur Crepin Leblond Date: Mon, 31 Aug 2026 14:53:36 +0200 Subject: [PATCH net-next v6 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: <20260831-wiznet-link-gpio-v6-3-abee6c5c966e@marmottus.net> References: <20260831-wiznet-link-gpio-v6-0-abee6c5c966e@marmottus.net> In-Reply-To: <20260831-wiznet-link-gpio-v6-0-abee6c5c966e@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-Score: -100 X-GND-Cause: dmFkZTEdZ3j52SRC0X9wcnaeo51hks17Hu7a++uhvG4c2nj4O/x6sPaGyXS39raY0QZTaMbDInPDMpS9sDt9tChXsU3YB07OWArfXdhpNx1/lVEGH+1fDk2YvcBgFT/hcDu30w9TYi6AhvDi511RmlZcG2Zl50a+aqK8lJDxUuaTmQ7wQ455Q1VReknGN0eZ98UTdnysMJJZc6DrhUv41kXjwgaIkpc5M3uAYTMMkG1k8WDK1RjUzJv6pMEnA56uwCQPRVxZltZhmFxDr6JqNcpdg7k4GffjkiWkl4erDbBBZuKYBJRIP0F0dXP+Rw6/YQ8dNkoCSgqGk2WuIqQnKdlmjybKXeLB+hkBZTl1L0r02A3JHIxNbv3aAs89NUshnlRXN5J6n/Q5WJ5HLr2aiJ4aqLHAI9CZyvzP3b0pkyVZLWlsDPSIy1xGA+dXA9goG3iKB98L/nteIQLqdSgGhqej9N4cm2H0otn0KGjz1JTmsmDrQjfInCJaZiuf2yO2J1/W+g3gBAX9s1+kkvUzx7cP6OrTV001VpDpdulSSfkmKBCrWbuc3YDq0gAqiYrMnViHo2c9CkqItxYe3rN2uaifQSBmL5k08ytNiigSxmgxpgnVBxstUMSVzY3aFrI5ziRTfibWb0g13bX14+1gcE8XcVU5JknCBscbjWDCCEYuIhoplQ X-GND-State: clean 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, the link is always reported as up. Also add an optional interrupt, wired to the LINKLED pin of the w5500, to detect link status changes and read the PHYCFGR register. Make sure that the netdev is registered last in the probe function so no operation can be performed before the probing is finished. The w5500 interrupt is only enabled when the netdev is opened and disabled on stop. Same behavior for suspend/resume. 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 --- v6: - Revert to the reviewed v4 version by Arnd Bergmann with a few changes based on Sashiko's review: - 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 reenabling 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: - Read the link status register only on w5500 instead of checking link_irq - Address sashiko review - 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 --- drivers/net/ethernet/wiznet/w5100.c | 119 ++++++++++++++++++++++++++++++++= ---- 1 file changed, 108 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiz= net/w5100.c index 53d8dc642fbd..d91881ecd797 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -21,6 +21,7 @@ #include #include #include +#include #include =20 #include "w5100.h" @@ -124,6 +125,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 +157,7 @@ struct w5100_priv { u16 s0_rx_buf_size; =20 int irq; + int link_irq; =20 struct napi_struct napi; struct net_device *ndev; @@ -345,6 +349,38 @@ 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 0; + } + + return ret & PHYCFGR_LNK; +} + +static irqreturn_t w5500_detect_link(int irq, void *ndev_instance) +{ + struct net_device *ndev =3D ndev_instance; + struct w5100_priv *priv =3D netdev_priv(ndev); + + if (netif_running(ndev)) { + if (w5500_get_phycfgr_lnk(ndev)) { + netif_info(priv, link, ndev, "link is up\n"); + netif_carrier_on(ndev); + } else { + netif_info(priv, link, ndev, "link is down\n"); + netif_carrier_off(ndev); + } + } + + return IRQ_HANDLED; +} + static int w5100_hw_reset(struct w5100_priv *priv) { u32 rtr; @@ -414,6 +450,16 @@ static void w5100_get_drvinfo(struct net_device *ndev, sizeof(info->bus_info)); } =20 +static u32 w5100_get_link(struct net_device *ndev) +{ + struct w5100_priv *priv =3D netdev_priv(ndev); + + if (priv->ops->chip_id =3D=3D W5500) + return w5500_get_phycfgr_lnk(ndev); + + return 1; +} + static u32 w5100_get_msglevel(struct net_device *ndev) { struct w5100_priv *priv =3D netdev_priv(ndev); @@ -659,6 +705,15 @@ 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 || w5100_get_link(ndev)) + netif_carrier_on(ndev); + else + netif_carrier_off(ndev); + + if (priv->link_irq >=3D 0) + enable_irq(priv->link_irq); + return 0; } =20 @@ -667,6 +722,10 @@ 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"); + + if (priv->link_irq >=3D 0) + disable_irq(priv->link_irq); + w5100_hw_close(priv); netif_carrier_off(ndev); netif_stop_queue(ndev); @@ -678,6 +737,7 @@ static const struct ethtool_ops w5100_ethtool_ops =3D { .get_drvinfo =3D w5100_get_drvinfo, .get_msglevel =3D w5100_get_msglevel, .set_msglevel =3D w5100_set_msglevel, + .get_link =3D w5100_get_link, .get_regs_len =3D w5100_get_regs_len, .get_regs =3D w5100_get_regs, }; @@ -745,13 +805,21 @@ int w5100_probe(struct device *dev, const struct w510= 0_ops *ops, break; default: err =3D -EINVAL; - goto err_register; + goto err_wq; } =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) : -ENODEV; + 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_wq; + } + ndev->netdev_ops =3D &w5100_netdev_ops; ndev->ethtool_ops =3D &w5100_ethtool_ops; netif_napi_add_weight(ndev, &priv->napi, w5100_napi_poll, 16); @@ -761,12 +829,8 @@ int w5100_probe(struct device *dev, const struct w5100= _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; @@ -795,21 +859,39 @@ 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 >=3D 0) { + err =3D request_threaded_irq(priv->link_irq, NULL, + w5500_detect_link, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT | IRQF_NO_AUTOEN, + "w5100-link", priv->ndev); + if (err < 0) + goto err_link_irq; + } + + err =3D register_netdev(ndev); + if (err < 0) + goto err_register; + return 0; =20 +err_register: + if (priv->link_irq >=3D 0) + free_irq(priv->link_irq, ndev); +err_link_irq: + free_irq(priv->irq, ndev); err_hw: destroy_workqueue(priv->xfer_wq); err_wq: - unregister_netdev(ndev); -err_register: free_netdev(ndev); return err; } @@ -820,14 +902,20 @@ void w5100_remove(struct device *dev) struct net_device *ndev =3D dev_get_drvdata(dev); struct w5100_priv *priv =3D netdev_priv(ndev); =20 + if (priv->link_irq >=3D 0) { + free_irq(priv->link_irq, ndev); + priv->link_irq =3D -ENODEV; + } + w5100_hw_reset(priv); free_irq(priv->irq, ndev); =20 + unregister_netdev(ndev); + flush_work(&priv->setrx_work); flush_work(&priv->restart_work); destroy_workqueue(priv->xfer_wq); =20 - unregister_netdev(ndev); free_netdev(ndev); } EXPORT_SYMBOL_GPL(w5100_remove); @@ -839,6 +927,9 @@ static int w5100_suspend(struct device *dev) struct w5100_priv *priv =3D netdev_priv(ndev); =20 if (netif_running(ndev)) { + if (priv->link_irq >=3D 0) + disable_irq(priv->link_irq); + netif_carrier_off(ndev); netif_device_detach(ndev); =20 @@ -857,6 +948,12 @@ static int w5100_resume(struct device *dev) w5100_hw_start(priv); =20 netif_device_attach(ndev); + + if (priv->link_irq < 0 || w5100_get_link(ndev)) + netif_carrier_on(ndev); + + if (priv->link_irq >=3D 0) + enable_irq(priv->link_irq); } return 0; } --=20 2.55.0