From nobody Sat Sep 26 05:29:05 2026 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 9D7BD476CC0; Fri, 4 Sep 2026 12:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788525386; cv=none; b=LKrEFR7+qDM7w6BUYsHpdpiP+btxqkTKerRIQ0DnP9PkexwzX9JMM6oooM0Ku4kPvYSyzc3ODb9fEZxI8tynqy51/gTo96/tOyq20VRSifS4wmv0FBda5m8dVRRaYV6pFJlpOUPB6V48t7uuB6BNpuYCBG5W8+PLPIPP1dl8RIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788525386; c=relaxed/simple; bh=jWa62zLpy08rskinsZHo7z2D8S8QE5BuplaCNauhzgY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GmOWF4arsczULvGyMBUn6BWFxWIcr88H1h9ji/G5JWU3SdZPrVtK8pm71UpcpLhURvWxd0gQA8pxhXLEGvtNYMsq+C3pSrtePp4Vdzmj036co3bOelyyNHFclRxSE94Wxy52kNnyhMYZxQz0wXHjmEGQBwtOLAWNbTOA0E7kFCo= 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=RExf1SzG; arc=none smtp.client-ip=217.70.183.200 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="RExf1SzG" Received: by mail.gandi.net (Postfix) with ESMTPSA id 741283EC79; Fri, 4 Sep 2026 12:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1788525376; 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=TYMSUckHhLQjqV8pm5rCkhEzTT9IEGOLgIijWF1A7cQ=; b=RExf1SzGF862ygKTfd4XAQ8S0RYLwTwKQghm7g91KQJGkXeX+NY4wQB/hnia+LO6q54B/z G9BSi4UVB80b+e4cdWjhnOZUb5Rl5Tgiq9RtyMepXu99kp2wZu7grjeHDtpkE85jEIlayf nfkwkxXCQh5iXrdx7W1uGdLomNyEy3EUej1J6kUgtd+dTP1nn8u6HTppOXfppOu+u6GUjq AV3piIAIUtgxxHYKeOlavuF8fA1PGwrfVDn8ckAeGVpGBaMBVB84PVX4W5TbdrQG+xtQTl VzXKVqGlII+2KAQSE+FDrD2TfdjNNB9GpW7lJkWsTj9zKb2IoDFr2uLdww3mVQ== From: Arthur Crepin Leblond Date: Fri, 04 Sep 2026 14:35:58 +0200 Subject: [PATCH net-next v7 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: <20260904-wiznet-link-gpio-v7-1-69f01b70c96f@marmottus.net> References: <20260904-wiznet-link-gpio-v7-0-69f01b70c96f@marmottus.net> In-Reply-To: <20260904-wiznet-link-gpio-v7-0-69f01b70c96f@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: dmFkZTFXVvGsnHbtESJ25bhQLeddbeFrEjKvb8Y7CeBBI8UT0YnNCcpPrNaLHGo7shEmYyZxlUNU3O99ue0pnk1eH2vGswuaWmMqCzRaZgo1jrs6W/c3dNJcHZt0Qvk+q23zr4Ei4CTpk+CTPnLD5gW3svufOWFVAfz18VyXl4fhplXg+1IncgaSrBY2PEcu19HW5LoIDfhzVBTOL2NP8DKNOtijqXiWe51clFtvdtdvsHvWkvWIcUonpvg+3Do64SWuWfJ9vmEQ4U36Ttcnf8zpwYYOFmdhhjASGjDFTLgAEQKxt4vK6gsrTwLX4XiBT64UxRgHGybX9C+YrUDilcRWS7uQPrKgl2gXclGHc76PNKX5jvnHQiwcziLqLmckehR+XYUsttBMQElkKh1reIO2jrpfdpEML4pKgHBSJH75L69+zemeaLeZn+/oH75CcsdfiUhQTWjFjer42miFecEMaY5xxiDFVUyVZF90wQ8yDqJv2lPXKzS7Nl7COht/gwZDwmXY7fj41TDEioMkyN/u4LnNVdxlN2s/UrG6DS9hRSvnjuER1glsVH4WnsJjh04o+hsWfd9YGmY9d9/epjfC11cVV+o56uSNry9kc//qx6u4vXScb8soY/7XKXzFft6nw9iWBhDVf2PHnsV0tJRBRr/EBFoLROFUANWgfIaXuw+emA 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 05:29:06 2026 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 81683481672; Fri, 4 Sep 2026 12:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788525387; cv=none; b=M6I0Ecy0Tcsq5LFy71CdGk3f90n9lSbod0EpPlPBnJwQrO0nsBfc2UjU+LuVx3tnTDMZsYqIlSiBNs06tvrlsTyALIJrqQcS88bw4ocmjKP1OEgtm4qGWp3tHonVpGsKCeO5B6ArtrKDalP+z1BgoTIVasvigrWMH2VJ/Rn+2cw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788525387; c=relaxed/simple; bh=2ragPpDgcBdUVTJPPum1+45KXksv2e/PXK3BlyWZkyg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=msccIoLMN+Eu7iaV03DLNfpkwXd1Yy0Dr3AZBTUpe9wyOXp0XsFAwa1tOKpL0b1+aTD28P14Kbk9VA1fuL+yXLS055f15kUKkek/h1xZd+COuExGMuD7YjU96n9brAPjhJqmsuJaJIyMqkAYwT9hb3O/HSg+mO6cbqMKbPW4Ios= 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=kQ6Nya2n; arc=none smtp.client-ip=217.70.183.200 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="kQ6Nya2n" Received: by mail.gandi.net (Postfix) with ESMTPSA id 880283EC63; Fri, 4 Sep 2026 12:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1788525378; 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=ZLyDBMoWcyb1HCkLCE1M8X2dUTVn7IvwOhHT2osi3e4=; b=kQ6Nya2nx28TbkPzEEQdSpdfg111LnYuhvo8IcxIbSFgpYRD3F0SSf9qKnpDUk8w0vZDTb gMJMzinEsMPKcd0hP4vZBimtCGtwIUDEfPAtJKqdUGJHRgtLU/Y6kesANL1ezSbi1XUb3d Q75RU8NK8fh12R/16FMysx5ASnIBX9FJuFXsc/KApcM4nJ0/8ZRCKP5yHYMlljWckygxS7 Oh14UkLyN5JazY6cbkVIQgByLkhpK+vsbs2aTWCNcTd1ojeuuo1F+VXf8QMJsXXQpVo6VU co9JByoE+/Ai4zvXvAlEuCgsPMfl4nMH/W3y1P9Ylj1/q7kG9x51M1yiAJyXSQ== From: Arthur Crepin Leblond Date: Fri, 04 Sep 2026 14:35:59 +0200 Subject: [PATCH net-next v7 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: <20260904-wiznet-link-gpio-v7-2-69f01b70c96f@marmottus.net> References: <20260904-wiznet-link-gpio-v7-0-69f01b70c96f@marmottus.net> In-Reply-To: <20260904-wiznet-link-gpio-v7-0-69f01b70c96f@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: dmFkZTG3cKQSdAPBXGVh6GOikZLK4Aas1ywOC0YbiXbtGhbq4f87oWC4nqjUGhyvbQYzqbjm9NzFQSKPLR9o/p9FzXrd53UGWxYyKiguWZrVRn6ttK9GibpIh/93LXTJC5xkVeV+MNEQ3etcQs1RonpGp/xrDk9O8z8UHJNWh/Yuf0QUlQQSq64ZWaaNL4njzkyxlgcgLJEpN6b/tB+3zBZ7HcJR/7dMJutbyDwfCxTry1ilSupgb4VJL79nMYQ04syN2C/i3SssZqwv2ymns8c6V+NPeNIOMpv8jXwN1C28pOdPT0XbMshdPSV+oOQzWsPYqNc8wAHroBhPrFAk8P1xnhArP0FpuvoAfwfjo9VWnfCAYHxE3G2HX7YKOInrFPmqkgHZGhbZKGP+eHf0w9P9abv/rOsS7aNthw1J3QL0raE3uq3hNgHCCEEWhygL8abOzPChgKFThI6po2KShrpC/mKhxcD/V/Ma9QGzfU6wqOvGYFJ21iEuhmA8+JHEh7+m4C5EPFTmYVEN07zeuGZKptPsmRU4V6ktbgMR+OHqzh2qLawuizLGoDyuTXMTplNZ1bBkjf8ZJHzUwjEsloDCF1c8hIYGcM4GWjINHChrEFMw6Laxa0d1MffxNkk1zxZeLk3gmUWRhL65ofZ9ulDEIDv8uIbkMb0c5qE57OMf/0eqVg 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 05:29:06 2026 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 E6BF94746C1; Fri, 4 Sep 2026 12:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788525385; cv=none; b=UsBhtgN7hopKxtJiUydLgIWI4WZvJEawyYk4Bob+78i+Lmm0GzE/RSSEiFvLlrhXuwR1VHG1dTseyu60YFp1yRGsoT0cw55fKY/sTpEx+Q5T1czuBr6ZPgM4WMOPo0xIp8VRLoJiN0uxAF2DFBCJ2jF6jed1DjtFoeY+1tmoWsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788525385; c=relaxed/simple; bh=wkD9qgpUwvA7a2CzDHOQ9mwyy5QbT0SqBmqmXQwNObg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NUZcszHvisDJboGusNv+Hv7Y1/MUh3G4S320w+l0U2B0JSFDlpNpArk/dMcnsTp0ommyVWB+roAlOGcqQlGcv2K8OpR6DnfLUhjkTtsGwYhI/Jwyv4jFBBe94Wp8/debip6x0n3NQxc2rL5FSmqw6bVHekcg1UIcwQ97KKV8qRA= 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=AD8BbN10; arc=none smtp.client-ip=217.70.183.200 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="AD8BbN10" Received: by mail.gandi.net (Postfix) with ESMTPSA id 802123EC45; Fri, 4 Sep 2026 12:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1788525380; 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=sqg4kz9gu5UYEDh9qK2Iw1PpJBYcKjXWKjKpK/DqoKw=; b=AD8BbN10Xq8zXZh5rmoLPlurCGMvuJgl28hWi8uaixvS3kesgcQZdDMG11oEbNHqshtanM K7Zq5EBXNhyL7VuEDbtl43lrJrKXcpeOZXi7fsHH4QsAGULoTEn/W4xxD+Z/ryJl/Bi52V P3+T7Tsl+B0U7zcbnW9G47IXwdwNMsCssijRCwXHAxgsqj+TK1YjJMKw1QzoxU7c4+0wWh h8z9POL6BkQ2Fttv38nNVlZmClD4y3IpyaPhw8RubzKHQu6S8C5GzEBbfxP1D/PTNSnFxI AQKxfM3nIxLm+KGC4JC94Yb0vH3PVlYyHpP+uYtfpVaSjQG5upiRUgkhu1awjA== From: Arthur Crepin Leblond Date: Fri, 04 Sep 2026 14:36:00 +0200 Subject: [PATCH net-next v7 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: <20260904-wiznet-link-gpio-v7-3-69f01b70c96f@marmottus.net> References: <20260904-wiznet-link-gpio-v7-0-69f01b70c96f@marmottus.net> In-Reply-To: <20260904-wiznet-link-gpio-v7-0-69f01b70c96f@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: dmFkZTEoOYE3Xl6y4pTm5T+4LfZ+vI1me5AQIa/0kee7YJbhaP2OOwvVGFmP50XqXW5VBYfYrYRYpePdOPaLJahVt9qVXaRAzsYF9UrEOayBgoU229nqEAV2ugUFtmvABk7auKo40dVBv0HI9vTPPT+eBalFuH3vAbOKW8GcB2Usj80XuCX3U/nuYOckWFNnfSLRzmz4D4OXU5X8yfJMT678pk5YH7+8dK+SbrXOKVPlo0eMLURjl/yK10y7d0BhqXc60++ve9AjUxTSehclyyf+aeAlszTfDZlxJLa90OGGzjy15COvSYEqoqFGtUK0ulfdifIE7iQKnZ1h1AQPTvrbG05sp6OYZZaYH9KFOvfkDihm3fzow4XTpiQM08tZT7k3rv6I9KXVrSpSTmgY/G1E4hG2c2cGhQPRQrTVlrEAZejsBht/1VIIqhklm8PJfHQWwJ6vLnsV3Ot5BCtaJNRYLSYqFD2OUC03Rdl8Z67fg3T3QpTe2GG0Svwn0Y1Jis8lVl/80igUeXH2wAZpvVzVRAQ1uBVY5jqPTWkUILOwCS9zN2JCiU3rIDpONp0txR4UDBdxJ46ebrPkmftdLX/rkAIXDWi+2vpTdiH4CIGnBv3f8MuafS6tyHNGU/Sn44SMa8VD9qqVNcy8cBBh3aCc1vp8wHDu3ub7EMUexE12OlJNnA 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. The initial link state is always probed from PHYCFGR regardless of whether the link interrupt is available. The interrupt is only needed to detect subsequent link changes. 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 --- 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: - 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 | 123 ++++++++++++++++++++++++++++++++= ---- 1 file changed, 112 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiz= net/w5100.c index 53d8dc642fbd..ecb99621d0a1 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,44 @@ 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 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); + int state; + + if (!netif_running(ndev)) + return IRQ_HANDLED; + + state =3D w5500_get_phycfgr_lnk(ndev); + if (state < 0) + return IRQ_HANDLED; + + if (state) { + 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 +456,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) > 0; + + return 1; +} + static u32 w5100_get_msglevel(struct net_device *ndev) { struct w5100_priv *priv =3D netdev_priv(ndev); @@ -659,6 +711,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 >=3D 0) + enable_irq(priv->link_irq); + + if (w5100_get_link(ndev)) + netif_carrier_on(ndev); + else + netif_carrier_off(ndev); + return 0; } =20 @@ -667,6 +728,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 +743,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 +811,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 +835,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 +865,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,6 +908,11 @@ void w5100_remove(struct device *dev) struct net_device *ndev =3D dev_get_drvdata(dev); struct w5100_priv *priv =3D netdev_priv(ndev); =20 + unregister_netdev(ndev); + + if (priv->link_irq >=3D 0) + free_irq(priv->link_irq, ndev); + w5100_hw_reset(priv); free_irq(priv->irq, ndev); =20 @@ -827,7 +920,6 @@ void w5100_remove(struct device *dev) flush_work(&priv->restart_work); destroy_workqueue(priv->xfer_wq); =20 - unregister_netdev(ndev); free_netdev(ndev); } EXPORT_SYMBOL_GPL(w5100_remove); @@ -839,6 +931,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 +952,12 @@ static int w5100_resume(struct device *dev) w5100_hw_start(priv); =20 netif_device_attach(ndev); + + if (priv->link_irq >=3D 0) + enable_irq(priv->link_irq); + + if (w5100_get_link(ndev)) + netif_carrier_on(ndev); } return 0; } --=20 2.55.0