From nobody Fri Oct 2 01:15:10 2026 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 78646448B8D; Thu, 6 Aug 2026 15:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786028429; cv=none; b=Biew9inmkjpknWudef8Xpc6VFeDcU9eRtmlfr2zcIKH756tYCgpUtimGm8+7BO7Mt61Bc4+4a9PA+wLt9gY1oQXmJ+hVDbe/LbcAAOADQMjsGLlxDglKeHt3Ibd3A+NnYywldsUjtYzir27staNXVbESySqEFRpfSHQMzU2A2kc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786028429; c=relaxed/simple; bh=IXst3cKVKDLmRagRovNr0FfjZ5GeFMvyoHKbudg/r+w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XULmNuOnmjcHwFQKFYQ8RbosXLIaKl+lfuYC2hAvsDa7YZq+W9Fv9iWwnt8ShxHV85HW9kcyL97xmTR33fc/YSCmwPk5D0936iOCgoHPMjPg/CHFXo2fxUIyX50MYlL/4k01htNVFKEDbQzUjGa5EowkKJ7I/LrV7rEtko9JYak= 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=G3faqlTw; arc=none smtp.client-ip=217.70.183.197 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="G3faqlTw" Received: by mail.gandi.net (Postfix) with ESMTPSA id 23EEE3ECEF; Thu, 6 Aug 2026 15:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1786028419; 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=90d8dWirxmfwgGLydAAfx1QUlMewXIwlua8Bh1xHfUQ=; b=G3faqlTw60IROFngy8xL1NKoSXxRn5d5KMhArqf0YlMDgAs1ZpyCj4kLVxNKujTP1CKAU/ bK3f1QyBTenk8A+RNCjgHb5C6WqFSzqZBxOUhW+xhv/jogj51BVZgOUE+CjBYPmYJdlz7i AARyGyj6RQ5jzFnh0ZriDhtvtTJK20FWPw+ON4gTlUKfcbz0l/pewuIFN4jCVobcHm8zSK rs3rVlzdo4yBWd5cM3sLX0LarnpwKEnIIxojjbGZf1+kgTcVYEblbuOb86ZfYYlKZkPMwd LMOPMTJj4EZiONblDDv9scqALQ2MX5wtQfa3ungO+aIuczs/Vgm39mVno8Vg+w== From: =?utf-8?q?Arthur_Cr=C3=A9pin_Leblond?= Date: Thu, 06 Aug 2026 17:00:00 +0200 Subject: [PATCH net-next v3 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: <20260806-wiznet-link-gpio-v3-1-532d4a143805@marmottus.net> References: <20260806-wiznet-link-gpio-v3-0-532d4a143805@marmottus.net> In-Reply-To: <20260806-wiznet-link-gpio-v3-0-532d4a143805@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, =?utf-8?q?Arthur_Cr=C3=A9pin_Leblond?= X-Mailer: b4 0.15.2 X-GND-Sasl: arthur@marmottus.net X-GND-Score: -100 X-GND-Cause: dmFkZTFXr9okfw4jPp/xxHAYs0x2o65yfSeJ6OzsqMvfrcKdZlYJHhikgqkTHnpp9BuF6PyeukxCAV7NH6qy8B9s4O/nQ7yV//yxCRVt6v6NGYnE2P+4xp8KWCEuMeI9DxVEvkF+X9KHK5ZpKzL9Z5hvsh3taI30YBjeQFUg39YH8Az6mcm23c2w/2F5PGzSq1S4l8TrXYA9k9EVVMBf9heLWuaw8GVelVwN6sjsMP7z+Md5EHmE5sh40R2H4iN+R0jcCPz5uYVZ89LnY6VFF3Hkt4Vabr0qrWdhS6H0l0EPSyCdC6d+Gu1DRy1Ju4nPcMGtVFDK57bOFPybzv/U2hZoEW88HwM++OwpHuQpatp/aVPXHyfPaI0sS9OR8eNrLPvatYtwxaghoBU5RTDl8SvvIDYVa4NL6yu//xXiLg0rmwFUFCvHZkStYELVAMMkDzYM0gaFM0aSsF4g5meLzrYCso3it4od2HrlOUowbdeIEWr50bI40c/RMtODowBnzeHYgqfvoK5qvywsi74NKPb4e/yxCLhjBfyy4TstcR+h/lOIGK4L62/J/DxcdZdKItT0HesxhE6o9WEHE2eiVJlgHrOI7Z0QbtZ8Cl3TKQv+B8UEbwrd29Hm2WN1J54ELGWuB3AkpCiV6pyZcJNZe4p+8isGza2wrqUIwRgIfGg67zO9ww X-GND-State: clean Convert the Wiznet w5x00 SPI Ethernet controller binding from plain text to DT schema. Signed-off-by: Arthur Cr=C3=A9pin Leblond Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/net/wiznet,w5100.yaml | 67 ++++++++++++++++++= ++++ .../devicetree/bindings/net/wiznet,w5x00.txt | 50 ---------------- 2 files changed, 67 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..641c9ddbde9e --- /dev/null +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -0,0 +1,67 @@ +# 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 Cr=C3=A9pin 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 + #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 Fri Oct 2 01:15:10 2026 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 63FEC47ACFD; Thu, 6 Aug 2026 15:00:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786028437; cv=none; b=nZ7/045hwKYTzSHWVmbNob0JG5T0RAOmmu4VfNXrrEXwhfUj9GXPEdZ7HDDyfGKu02j2T2lMn5qs+JaYTAZGY3iS1A78eyxylYhMx9W0eTFFR0HYZLjHtzROSfXEOo/O3GswSS3bKLeZ5obDU2MCrHbXQrTmS5DK4gQpI+fVmG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786028437; c=relaxed/simple; bh=uBBYMoJ4BxsVlp5cY1rbRF0sQIE12on96iPK64kgI78=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FCmQ/VjsC1soqmNJ4k8ZXvSep+fkaiNmnCHJlroIqOPtXcroB2P3xsg2F4sfeC4+3bRdQ1Djz/2nlb1mHL8/P8+cAUeQwruECRL0NF8XRptP/+L4QDJsGt/gH1pRBKPkkvbSoY04DeDUgj6DRHnyke792j2UdxP//k2Rg+SEIUY= 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=Laso9TJn; arc=none smtp.client-ip=217.70.183.197 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="Laso9TJn" Received: by mail.gandi.net (Postfix) with ESMTPSA id 0A9A53ECF7; Thu, 6 Aug 2026 15:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1786028421; 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=ndgS6gnOTOGCHQ4/bgAHvlK16ze3UjOG4fDbcLDpDNc=; b=Laso9TJnBZEN+5uRemAac9bCAh4OB9VK3bxp7e8eGn3leA+ODMorUwcictsHgRlfApNxTa feXbskhqr7IRPcsx552Ppp81v4DQq4kUKYu8GGi5VSge1pc3Hzwh+eWZe44eCMetoeRS+l 4zqUxCbe/mq2TMuJOT5CfyGfbEmu/g9kJmpHbirLtPBMQZD0sDTk6x5EF22O3NVNVSbpHG NPyHzQMJlLNtvGcqwiKHDTvT65luCrXeVRm8X6RCbXfhbjlRHQaFQM6oWgwAWBFKbHHFIs wuD8693ZgOngfL7jRJ1yni8rEwpJgoJZ0mMVzoxhcVV20Xo1vvHBdKngjwatYw== From: =?utf-8?q?Arthur_Cr=C3=A9pin_Leblond?= Date: Thu, 06 Aug 2026 17:00:01 +0200 Subject: [PATCH net-next v3 2/3] dt-bindings: net: wiznet,w5100: add link-gpios 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: <20260806-wiznet-link-gpio-v3-2-532d4a143805@marmottus.net> References: <20260806-wiznet-link-gpio-v3-0-532d4a143805@marmottus.net> In-Reply-To: <20260806-wiznet-link-gpio-v3-0-532d4a143805@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, =?utf-8?q?Arthur_Cr=C3=A9pin_Leblond?= X-Mailer: b4 0.15.2 X-GND-Sasl: arthur@marmottus.net X-GND-Score: -100 X-GND-Cause: dmFkZTE+WcSggV5zCp8g8eT5E/JolsF24Rl9OX9pXx8yvsvxSceOKMXWcUHCvd4FGfevv8symVzCRbUUPKuWQJrU0JMpZ4BXbtbyj1f/j+clyQ1HGu2c46H5js9LJVJE8KA3BBxdUe9a053FvnuCrnM8aIzoCoaPGF6fkS7JkXplNhcPhSwG3KxHsexsKkHwH9U2A2bYSfs14ahqkakWTVvmMuOCCFFLlhTynsi9SmUPAc4HsxDK8ORsAeHen5Pzi8iDuFMwsE40c16a2c+1FGEvCTezP8A4oNhT1kFysW4RXvpJKfxZdizPrIkk3wC80Bsw8Yr7m4qqwKsIByUhvFuQ1N9PMepZo0ov+3CmmlaEWj9dk/ITyzJZC+3R+fcjN1d/du4fCf+OR1wt6fJceVh3gcJlSumxPz70683FSkrMZ4BeVnAp6RTQoC1URC0MJqPCWfRAsysMqpsz5ds6U/clO9fn7QZIB6z2YpX9MiAFDOAbVJTVPveGbbcbwqDN7F11N5K0DPS34i4oUfgGDeIBOqDa7GxAdf92EBa5u0YnQ4nLOn0BAZkZYMDUlzkDfxGQlUItibMQreQ3I4LzUtBLrmYiAUlYtSlVBIKM+aITVOkCxMbOea9iLxO5It0foVrTqFW8AWju4Rlbx4Hw3WXQ6SLBm9mD2j8EWh7OShdUxdJA6w X-GND-State: clean Add the link-gpios property which describes an optional GPIO line that can be wired to the LINKLED pin of the w5500 as an interrupt to detect link status changes. Signed-off-by: Arthur Cr=C3=A9pin Leblond --- Documentation/devicetree/bindings/net/wiznet,w5100.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml b/Docu= mentation/devicetree/bindings/net/wiznet,w5100.yaml index 641c9ddbde9e..cebf437ad3c4 100644 --- a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -35,6 +35,12 @@ properties: however, board designs may need to limit this value. maximum: 80000000 =20 + link-gpios: + description: + An optional GPIO line that can be wired to the LINKLED pin of the w5= 500 + as an interrupt to detect link status changes. + maxItems: 1 + required: - compatible - reg @@ -60,6 +66,7 @@ examples: pinctrl-0 =3D <ð1_pins>; interrupt-parent =3D <&gpio>; interrupts =3D <25 IRQ_TYPE_EDGE_FALLING>; + link-gpios =3D <&gpio 24 GPIO_ACTIVE_LOW>; spi-max-frequency =3D <30000000>; local-mac-address =3D [ a0 b0 c0 d0 e0 f0 ]; }; --=20 2.55.0 From nobody Fri Oct 2 01:15:10 2026 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 7DC233AEB5F; Thu, 6 Aug 2026 15:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786028427; cv=none; b=WUpCm8tPFr1dK5GuQn+8iefkHrM+0H7Jx9GH3H61DW+oEJTUqkQiy/xzVMljWwVqjUmpBTWkfx5d0TkRnYAYNa9yDy6IIVRtj/cHELcwUzKtEPjSPEFF3GyA8i+QG4Ytmsn4manN6ePBfS65xHlKm0TByhaG5OcQ0ynbfyMD7c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786028427; c=relaxed/simple; bh=lp8eITXUCfgHmVikAplRm1gVPpLc2Ql2JMBCRKbqS7k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p+C2k4pWrVhQ+bVpXUZJsvGg2LARiFkBKJMp/k8tWk+mr1O0/VtkoOfj8PYJjsb6FkHTVunFB36CwzfBeHGK0cWa18b/SK66CZUtne5lBaZNwXQTpv5zk1Lqt5VH0kjcxFc/OsW6AtTbcBig/rzyM92BQaRZ6s/Fqo628IqrrgY= 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=amn9WweM; arc=none smtp.client-ip=217.70.183.197 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="amn9WweM" Received: by mail.gandi.net (Postfix) with ESMTPSA id F39E73ECEA; Thu, 6 Aug 2026 15:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1786028423; 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=BHZA1FNeXrM1A3izwrYic9PHMjd1HkNfriy7KZM7waY=; b=amn9WweMSeGH3qH7vBjnBb6IbW1lqfjStoC2+I9PIVdkGWMSd67h5DC9lPRnFSBNKka6/c Hxw9yMOgFtxXcBIXLWIS7XfT/Brzds2pcoCHe5bmvTdlHqN6s/THOgIRlD3evlERe7xgkU 0EVq2RpJKCL/3nhIjEVygajbong8Zpp14i3FR+m9e9S95OX1rGqUNunGddLAT4aCiLozSk eQVSD4COJ/D5d73k8Ixd5j1PEu3xBRpO9xpzk1L8gHu3RQaDj4xjh9aFBenP/zVHrcs8bn oCamU5iA6UEmKCgS5D+MQAuy+X/eS8g9ErdwSTYcZ/OfGAcVjI6xkB5ZknSybg== From: =?utf-8?q?Arthur_Cr=C3=A9pin_Leblond?= Date: Thu, 06 Aug 2026 17:00:02 +0200 Subject: [PATCH net-next v3 3/3] w5100: detect carrier state using link status bit 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: <20260806-wiznet-link-gpio-v3-3-532d4a143805@marmottus.net> References: <20260806-wiznet-link-gpio-v3-0-532d4a143805@marmottus.net> In-Reply-To: <20260806-wiznet-link-gpio-v3-0-532d4a143805@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, =?utf-8?q?Arthur_Cr=C3=A9pin_Leblond?= X-Mailer: b4 0.15.2 X-GND-Sasl: arthur@marmottus.net X-GND-Score: -100 X-GND-Cause: dmFkZTE+WcSggV5zCp8g8eT5E/JolsF24Rl9OX9pXx8yvsvxSceOKMXWcUHCvd4FGfevv8symVzCRbUUPKuWQJrU0JMpZ4BXbtbyj1f/j+clyQ1HGu2c46H5js9LJVJE8KA3BBxdUe9a053FvnuCrnM8aIzoCoaPGF6fkS7JkXplNhcPhSwG3KxHsexsKkHwH9U2A2bYSfs14ahqkakWTVvmMuOCCFFLlhTynsi9SmUPAc4HsxDK8ORsAeHen5Pzi8iDuFMwsE40c16a2c+1FGEvCTezP8A4oNhT1kFysW4RXvpJKfxZdizPrIkk3wC80Bsw8Yr7m4qqwKsIByUhvFuQ1N9PnjHMD/Jj/1h+SNNzwidmUtJLgUfOEcevqw1wVBIOoIVLzofQjejtXyeCRtyxk263AvczqRCqUJMy99Y+g/+5+nt8850KrZ2vwsFk9J/r+gIgyH+xMlDJw1HFZ3dXIzqlqw58TVqd8m8vDjzWvQnpDE6Usv0OkoBADQ3J41NL4Y/0BWPo1WahBkNE0udwb/ybNRGLMdvn3rM5SdCQf/AmtH3SxJDn3wqaS0CGXkVXQ8FD3kKs3XpEqAAWwyXUurhviyBn5aoNgG98iL+I39wfSrdPgwmjkcPf3+MWFSOxU6UalmJSTh5jcgxtjUhQHZfMUFH/dWLZzu2Mdb0gVlxDUQ X-GND-State: clean Detect the link status on the w5500 using the Link Status bit from the PHY Configuration register. Also add an optional GPIO line that can be wired to the LINKLED pin of the w5500 as an interrupt to detect link status changes and read the register. On chip variants other than the w5500, which lack this register, the link is always reported as up. 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. It uses the new managed GPIO descriptors so that the resources are released automatically on driver removal or probe failure. Signed-off-by: Arthur Cr=C3=A9pin Leblond --- drivers/net/ethernet/wiznet/w5100.c | 70 +++++++++++++++++++++++++++++++++= ++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiz= net/w5100.c index 53d8dc642fbd..6707a6f27395 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 #include "w5100.h" =20 @@ -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; + struct gpio_desc *link_gpio; =20 struct napi_struct napi; struct net_device *ndev; @@ -414,6 +418,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 w5100_read(priv, W5500_PHYCFGR) & PHYCFGR_LNK; + + return 1; +} + static u32 w5100_get_msglevel(struct net_device *ndev) { struct w5100_priv *priv =3D netdev_priv(ndev); @@ -616,6 +630,24 @@ static irqreturn_t w5100_interrupt(int irq, void *ndev= _instance) return IRQ_HANDLED; } =20 +static irqreturn_t w5100_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 (w5100_get_link(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 void w5100_setrx_work(struct work_struct *work) { struct w5100_priv *priv =3D container_of(work, struct w5100_priv, @@ -659,6 +691,12 @@ static int w5100_open(struct net_device *ndev) w5100_hw_start(priv); napi_enable(&priv->napi); netif_start_queue(ndev); + + if (w5100_get_link(ndev)) + netif_carrier_on(ndev); + else + netif_carrier_off(ndev); + return 0; } =20 @@ -678,6 +716,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, }; @@ -751,6 +790,13 @@ int w5100_probe(struct device *dev, const struct w5100= _ops *ops, priv->ndev =3D ndev; priv->ops =3D ops; priv->irq =3D irq; + priv->link_gpio =3D devm_gpiod_get_optional(dev, "link", GPIOD_IN); + if (IS_ERR(priv->link_gpio)) { + err =3D dev_err_probe(dev, PTR_ERR(priv->link_gpio), + "failed to get link GPIO\n"); + priv->link_gpio =3D NULL; + goto err_register; + } =20 ndev->netdev_ops =3D &w5100_netdev_ops; ndev->ethtool_ops =3D &w5100_ethtool_ops; @@ -803,8 +849,29 @@ int w5100_probe(struct device *dev, const struct w5100= _ops *ops, if (err) goto err_hw; =20 + if (priv->link_gpio) { + int link_irq =3D gpiod_to_irq(priv->link_gpio); + + if (link_irq < 0) { + err =3D dev_err_probe(dev, link_irq, + "No corresponding irq for link gpio\n"); + goto err_gpio; + } + + err =3D devm_request_threaded_irq(dev, link_irq, NULL, + w5100_detect_link, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "w5100-link", priv->ndev); + if (err < 0) + goto err_gpio; + } + return 0; =20 +err_gpio: + free_irq(priv->irq, ndev); err_hw: destroy_workqueue(priv->xfer_wq); err_wq: @@ -857,6 +924,9 @@ static int w5100_resume(struct device *dev) w5100_hw_start(priv); =20 netif_device_attach(ndev); + + if (w5100_get_link(ndev)) + netif_carrier_on(ndev); } return 0; } --=20 2.55.0