From nobody Tue Sep 29 02:35:27 2026 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 7BDF3443E44; Thu, 13 Aug 2026 08:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786611517; cv=none; b=ELdMRWEkLK1fJb+WAV72zTqbliOnmqwQ2gA/yqhii23Tn9vmvxSYwfwtTyzmCsi8TVz7GPmhtm7PMAnnxNOnOdHOAgC402Y6QXNrx0VbBB4qHERH0VZ80WhLt67ffFqOByUJaggohr3pRw4D8FFuKGjjOJEkQNl8hmPb1r+55n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786611517; c=relaxed/simple; bh=Mq7IuXzUETIgFtlTdiW2LMSeidORN8jn24X7MCilsWA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bd45CAvW6XlPvqYC8Yino89+9pScBtp7DAM+h5wTRThhtF0Ovn/8Q6jqf8feNkvRjG6gOfx2HBhQtX1PCnH9j8EfNnHalsAHlakABawqznFaMgu+7iOlnlgYZK1RqDtgi4YojbTkEykv5VCgIb6ZGwiYmwaFiqVgFuLosObYhO4= 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=lgE9JhYf; arc=none smtp.client-ip=217.70.183.195 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="lgE9JhYf" Received: by mail.gandi.net (Postfix) with ESMTPSA id 2B3D01F416; Thu, 13 Aug 2026 08:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1786611506; 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=4dsJLxD6ymGjk//iy+rCgruznZq24h6b7dxmWfHzV7U=; b=lgE9JhYffV24LnzDPHJedt4wIWPBxjA+GjOtKji/YGeT2LrfilLCaYXkupM0vMXIFfqj70 wU6jer2Fr0XzryYMGasjEGwhUtMFsek34N3ThNBg7mibwLmeqyII0HXpDcTHskJUp42U3O 0vYI92czYmVI5nAIF4Vm+GsH22gAuaxonG7qasdsiefyiQoyFoDhH3lOJaZqPWL98Yomnd IZd4BfeFfb/ay9M0ogoeYqePvbVyxVDGNv7/FKE0IZFqzMHFJiGpNdwHq5D/9JYwCfm9Ox vIWgcpUj2OsMjO2++uBe1WZWD9DSf8ol2x8bhJucLLp1iw2rN6ZQ1eCO7y4JWQ== From: Arthur Crepin Leblond Date: Thu, 13 Aug 2026 10:58:14 +0200 Subject: [PATCH net-next v5 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: <20260813-wiznet-link-gpio-v5-1-ac8046f24413@marmottus.net> References: <20260813-wiznet-link-gpio-v5-0-ac8046f24413@marmottus.net> In-Reply-To: <20260813-wiznet-link-gpio-v5-0-ac8046f24413@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: dmFkZTGOKF1OE0DoXxrQQYUcRrf3MbbM9Qm2ZcibCBH7iOVlqO0bFpnBa9RZm6cKwJOQOT8ztxpEkrS0IZ/oNS09zl+Aj+saIP+obNoL1OV5xbq3rN6NLfv0wo1JVbkzV5HCBZU/7UTmOoi/JKGgKhDk8CNOxlAyETAMiXYE5fKvme77hHGhJ6M3GjCn2zo7wdiB13qZB+0Dsy1zw0VRcsnD7lGhKv3sEToDIzzwmI/ut9wjTWTC5oRbOI3gURMCqKDtcBExkQ9FfQC5zuZMGrqBBuFv41h5EKNP/9hlVfATi/35VIFS1Cj1lAHRb3n3mveS3oJ4kaSYILVekivu/CYUR1OFnYSKAfWcktTMSfKm1jrLgpmlPJL5udYNTbzM95xsx4rKpJTHd7mipbVyijy4LeOTU7zCQDBzYO3plsqWjag2y/FDB/0Fm7EokxzxbxY4ILPQgXnLeIHMBbXis8Yi5d/9K8BxiwO/ywgZEA30o+dzGlCTYVdKX8rBoaPEk2aaT+qdr5opxoSwTjE40t0COji7lGHiYuz1fQOgDQpO7Lc97u8Hdh/lwHThrisfIj68x7e/GI21pmv3mylA3PBTAPAab2ODAdZTd+O+knXTUWdLzaNx6qk60f1bOcXr2qCR5FPiHnTc10mB8MBN3s69wq9tHktwd7kN89TjN9zxBlXSvw X-GND-State: clean Convert the Wiznet w5x00 SPI Ethernet controller binding from plain text to DT schema. Signed-off-by: Arthur Crepin Leblond --- .../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..217f301db182 --- /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: + items: + - description: Main interrupt (INT pin on the device). + + 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 Tue Sep 29 02:35:27 2026 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 F14D636D9F9; Thu, 13 Aug 2026 08:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786611529; cv=none; b=VShYWFBswJSnhmvHyiCIkXyMteh+b+2fmivwad/KDsQvnwrOu9iWNqf6KSOeKPpB6/thfovR/roye9qpeQg8N3rD56ZaKGhX9WVXU7AXk6VnuT5uiexKZMG2Bjvwlm7wGwPODeZywhhosgjEtFEU4KdNoX0F9L6JpKZHrCyn5jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786611529; c=relaxed/simple; bh=2izXu46JTqwc7ECMQLwEx3srH/UtXbyYI47w0RvLocQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MQYNwIg08sFuli9yd9rwDYawF+1qi2i03LPkHAHy9FhYePzFHmAtUELnTWP5sGvrwltorJDWL72uRfoIcrhYJJ8gQ/kzQFnIEfmKX9a1xBGTyQQnAbemMYELl8GTAlin6qZIhLAEwzm09NOSUhPTWdZEkhheLvGuihlY30ssKoU= 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=R3v6p5uO; arc=none smtp.client-ip=217.70.183.195 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="R3v6p5uO" Received: by mail.gandi.net (Postfix) with ESMTPSA id 236231F4F6; Thu, 13 Aug 2026 08:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1786611508; 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=bFGT+wlZ8v/tMI9vsoS1Vyx4Ec5r+ju/y8tc/RnmVTU=; b=R3v6p5uOGDKa/2V9kVMHOIybOPa4/b6HIUgsq0Dj6yowTkJYpDnWPY7aeTYrQVuB+wz+e2 idtRkE2/9VaeRMHgVVq3FIXyPi3ilQ1alHOzmi6MpZtXRaR8ci57b8WRa0biOxDVq9PgPV UiHT8gKecsr7sXxXESkezKo8EvVfd1Kv/pyDUFG2AaUCk46+nYo0cH1Yyj+2M+ydxpV14f q8qn7ERctw5W7nZI4JGGyyOwRnhysQXdkuQrL2x+34ekMva+Vp9H/r+iNXQ7VdBlQpEypz CMk1N/n7fsQqN8KT4Rm8zFnM6MCiECNg4K/5nz5Pl2xUtuK9q0deGmtrDKRMvA== From: Arthur Crepin Leblond Date: Thu, 13 Aug 2026 10:58:15 +0200 Subject: [PATCH net-next v5 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: <20260813-wiznet-link-gpio-v5-2-ac8046f24413@marmottus.net> References: <20260813-wiznet-link-gpio-v5-0-ac8046f24413@marmottus.net> In-Reply-To: <20260813-wiznet-link-gpio-v5-0-ac8046f24413@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: dmFkZTEefOc/klXO7/5PUwgpO9aRGI+MvHJFAt8DwIne0cCoUt3ECEsrJA+BLmH72mDq1CsFMbtDh1wiK9YProHM+4AJcNpDI1DxoHXxzBomKdJoAhzFio4WIF4skfNRCv0QnBTlMatn8lL+un+8XKtAU3pRmsF62Sf7cD6o4B4k9QACUP6Zj9C2LGJv2CCBSayjtsku/gq66ggcCYTKGgAb4gqE282IS+8zKcU/KIAE/6oNSGQxh35K2ERw38WUWtQi99oRjhphiwk7WD6fjDSl/Ta4BKlnEeIExNOZGRKqLT51RhryA/YkA0PNXUuQVWLo5tZJyCoNoc10x1+deWdLRTuSKy0wQW9JNgpydofqzOlIvD+WOyGdBN1AUWUlGQyfF2GKPTMFJ+edCUBnGIZcswCr6l85drmwJS7mbJ2RiucIs1zsIpSUS9Jk4qhb2AKS2Bwwo6sdbNpdsCScjMBd9i3pZ4jrA91Wmrla3Eo3tuuzJD9y4+C8Zw0FGQF6pXD0oGkgPAYQz6L3IFO2+0rNKGxcjakB7NtoXfW7XNUHLO4oYC7XT+vmEwhCMClMjJJUtaFveiCGfH/+Ltc8nm9nr+Z0yhhtf6a5ycPY8cwpRil7iF96WrVeKuZjtDz+PjZGy75WeHtmAaO+z0uWM7keI3QqcY1iHj1FCEYisWipUMSgMQ 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 --- .../devicetree/bindings/net/wiznet,w5100.yaml | 34 ++++++++++++++++++= ---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml b/Docu= mentation/devicetree/bindings/net/wiznet,w5100.yaml index 217f301db182..81f4382eb96c 100644 --- a/Documentation/devicetree/bindings/net/wiznet,w5100.yaml +++ b/Documentation/devicetree/bindings/net/wiznet,w5100.yaml @@ -15,6 +15,33 @@ description: | 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). + - if: + properties: + compatible: + contains: + enum: + - wiznet,w5100 + - wiznet,w5200 + then: + properties: + interrupts: + items: + - description: Main interrupt (INT pin on the device). =20 properties: compatible: @@ -23,10 +50,6 @@ properties: - wiznet,w5200 - wiznet,w5500 =20 - interrupts: - items: - - description: Main interrupt (INT pin on the device). - reg: maxItems: 1 =20 @@ -59,7 +82,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 Tue Sep 29 02:35:27 2026 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 BF05843F8AC; Thu, 13 Aug 2026 08:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786611515; cv=none; b=IBgwdaXsQ2S8ErqzQbb2WLTXpVuduIjQEINVsFLE54xLZFjmXjPEUw29+Az7G5+dChRsTOT8+/0zoX4fZ15d5WujVyf4ROPM1qraym34dUGQEBHS7PVkdLgW9vO7SURrdG5y83i3pCGaRCceO0U1FHwtHYIf5JOrZHuMJqSC+WU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786611515; c=relaxed/simple; bh=eMGzuFewfGtIYN0C0eJpqu97B6dAblhN1cMCUugLcKo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d7Cmg4akNnOtM9g6fFW6M2iDOLSzH/1LerNEN4JdR+oOiqSiUP9jFNpelw+hf7WlraV6MKvOWcs2PDQisMQSDJZl+VgrCtCDwWXLwCLOfIAbiF/aq6Ulrle019Y435q3Tn0SGPrrl7oS6wmTD3AmrB+SU3J2e1xyXynIrVA4ouI= 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=OPk0TrTV; arc=none smtp.client-ip=217.70.183.195 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="OPk0TrTV" Received: by mail.gandi.net (Postfix) with ESMTPSA id 2356D1F6A9; Thu, 13 Aug 2026 08:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marmottus.net; s=gm1; t=1786611510; 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=GOPI8QRTJRKE7q8uv8QbuoU2yJuWRYbi5nzp3r7Xbf0=; b=OPk0TrTV0J5MWtCFld4ATX8O/6Ok4ciCHZ9ogoVIqaxCTC0i9Dek9qWJTqnpjKfOmOowvy Xbq+Zdfmg5rdwyfQpFqsZ3GVJYnxy7U7ua+Qc9yAve0QmhLQftScffZjuzBuvf2/TrcIut coU1d1c5e8zeMmYdlQ/gVLgQE6jmpgrdKMpP9G55FrnUIg7NIPTMfFnBH7nGMS3R5z2Gpe FlKNZzvDq/ZvSFn8BLTpp31LVzI7KDrBT9+iWn1xIemaIQND1jxylMWewwGd+xlfNiO1Yc EBQ9VmAAsk1fqWKdFP4EympRARRDqzDx/kvuU6vCRIKeYSUCe12TYF3PHAy4mw== From: Arthur Crepin Leblond Date: Thu, 13 Aug 2026 10:58:16 +0200 Subject: [PATCH net-next v5 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: <20260813-wiznet-link-gpio-v5-3-ac8046f24413@marmottus.net> References: <20260813-wiznet-link-gpio-v5-0-ac8046f24413@marmottus.net> In-Reply-To: <20260813-wiznet-link-gpio-v5-0-ac8046f24413@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: dmFkZTFlHy9UV5KrcAc65cAqSIoL1v8G+Pp1OCsnNJtOtAHdcMzzR7eNxtFYxzCTgczprVKvWZcsfmFtYApGFrC7wMNZV0nbm+v/IXyxRNx39HGsW0l37FM8MVgcZ+v8fiEJy4Nb8hSr44Vet+Wb0ajorM36iW5plKoRZUQy7UTfDzIHeUjtmK3krVOg1kTHGAhIsKKsEH6oynLL/lj5iatNmm5CzeJLAr0rn2+VWg91cEL3qtI0vxVSvZjXvl6AE/4pOHDvoElCyg7FwhEg6RUWwZ7FlVx2Ijm5zDKevXgnPLvZggswCMez381ko/6lwMLAvynCJFA/mDREZ2egYgpoQKjGO21K047Xx6/u4kYBdm/+wrssRj0iiF3pIbH7hHrofYLU9PCLfa2pbdRUM0CiRKOb+MQQd/VIydVydg3GeLpjvhTxohf1b1K2G/kqSXJThxDpAVbwwkdKKlP4AsBrigHruQCKlhRat6NbKkBJH97oWmVWl/KtnCGSFW8/L76qRdgWCR4mrJoKRYUCHL/rMnh/CxLm0zTIgA3GkVPwbtSPHyU5nUetL8jNf/hDTEu3I6oPlaGukUwSrLkQQeA4ymz2mlHlRt95r70KjzoLqK32t/7k6AqsqL9GvMFVwHyYqJAjgRedgBWZY2/5iOw1b4JXfQ9aJv6VvqLeqDb2MChTcw 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 --- 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..b5976d5e6c60 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,20 @@ 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 int w5100_hw_reset(struct w5100_priv *priv) { u32 rtr; @@ -414,6 +432,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); @@ -616,6 +644,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 +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 >=3D 0) + enable_irq(priv->link_irq); + + if (priv->ops->chip_id !=3D W5500 || w5500_get_phycfgr_lnk(ndev)) + netif_carrier_on(ndev); + else + netif_carrier_off(ndev); + 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, + w5100_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 +902,13 @@ 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); + priv->link_irq =3D -ENODEV; + } + w5100_hw_reset(priv); free_irq(priv->irq, ndev); =20 @@ -827,7 +916,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 +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 >=3D 0) + enable_irq(priv->link_irq); + + if (priv->ops->chip_id !=3D W5500 || w5500_get_phycfgr_lnk(ndev)) + netif_carrier_on(ndev); } return 0; } --=20 2.55.0