From nobody Wed Sep 10 23:29:29 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 DAC2832A81F; Wed, 10 Sep 2025 14:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757516156; cv=none; b=gulENoGaiyvseQbabPmO361PsQRHb2MPnnQUzinqnmhFYAnbT7LBhmIru7koOOrUZavGqZI7/Mxp4Hf0VX9uZ1N+mbcN3zwhErXR6o8VCxTSWNu3uKaBPBgmNbcPwomD+p8QojAufkRwpjUym6ReOfeXKIeKT2AuzqXrztXI+pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757516156; c=relaxed/simple; bh=Bc3e3/0ahFi9v5qz8AZyosX6PMtW/7OQTL8jvV0sdXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AcdiLF7j6DQ+tcrxAjuZxAFmRVE5Dn/pf7xee80LgwqJQivRMu0lIzM4+pO1D22mCWSBma/Bejhe4FufXJ5/mERQ/qm6fttkl5GewnYWiwuyy0TpBUn7JbAnTF8CMU6CNx/puuHVw0QXwyPy5oPhd05e57491R87E7DCrk9tvUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=0jjTLQlu; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="0jjTLQlu" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 0DC264E40BDD; Wed, 10 Sep 2025 14:55:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id F24D2606D4; Wed, 10 Sep 2025 14:55:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D261C102F1CED; Wed, 10 Sep 2025 16:55:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757516151; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Z56JzDWKmQD/kK3e7696NE0uPkdwabDSZWVgzG00JDo=; b=0jjTLQluKeDkY5SA+dZQ5tGXUCW+EiG/eIerCtRfUrNfbAeHDjmqczQJIkBU5Cc2JqRC07 YNknpkI+S+gFWIceaOkZuz8bbGMRCFoGpuPeJvF2ZemDL7RvsZAUTQOAHpBPrcnsMFZfmw JtIQac1SpjbVgInMug7DYhkoI4FiwY5/d2/CffCkGh7OSUCsVM9oSTImHbnFguAj4q5Liw kxpOCygeVJX8k/QCJH4AQtdCpaMdXD3x79rKtz0RnSGMRZOfqGMaydbZrskndXS1B4brNQ zDeKmWZ/G/KY/YYinjoUR/YqIJE3/hgqq/SDTYCxYX46AoelBhu46scKGUvr2g== From: Bastien Curutchet Date: Wed, 10 Sep 2025 16:55:24 +0200 Subject: [PATCH net-next 1/2] dt-bindings: net: dsa: microchip: Add strap description 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: <20250910-ksz-strap-pins-v1-1-6308bb2e139e@bootlin.com> References: <20250910-ksz-strap-pins-v1-0-6308bb2e139e@bootlin.com> In-Reply-To: <20250910-ksz-strap-pins-v1-0-6308bb2e139e@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marek Vasut Cc: Thomas Petazzoni , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Pascal Eberhard , Woojung Huh , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 At reset, some KSZ switches use strap-based configuration. If the required pull-ups/pull-downs are missing (by mistake or by design to save power) the pins may float and the configuration can go wrong. Add a strap description that can be used by the driver to drive the strap pins during reset. It consists of a 'reset' pinmux configuration and a set of strap GPIOs. Since the pins used and the nature of the configuration differ from one KSZ switch to another, GPIO names aren't used. Signed-off-by: Bastien Curutchet (Schneider Electric) --- Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 12 ++++++++= ++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b= /Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml index eb4607460db7f32a4dffd416e44b61c2674f731e..f40a5e3cd0e4d39c809a1fb6697= bc3bc64f35fec 100644 --- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml @@ -37,6 +37,13 @@ properties: - microchip,ksz8567 - microchip,lan9646 =20 + pinctrl-names: + items: + - const: default + - const: reset + description: + Used during reset for strap configuration. + reset-gpios: description: Should be a gpio specifier for a reset line. @@ -80,6 +87,11 @@ properties: enum: [2000, 4000, 8000, 12000, 16000, 20000, 24000, 28000] default: 8000 =20 + strap-gpios: + description: + Strap pins to drive during reset. For KSZ8463, the first GPIO drives= the + RXDO line, the second one drives the RXD1 line. + interrupts: maxItems: 1 =20 --=20 2.51.0 From nobody Wed Sep 10 23:29:29 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 AC643245005 for ; Wed, 10 Sep 2025 14:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757516158; cv=none; b=pDkF0g6CAlwayFhqWR+5bRi5naZ5qrG962OJMVqf0yZPqNstMms1glBh/XP6/452ODBiKk/UDzda2tfh3YA7Ff9tX5na+RY0IhUISYQSw+egOU5BJ18MePxMG0I0zcybXac7v+OukXZ0HqFi63NvLPVXMciXbNorcqm1yl2w4zE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757516158; c=relaxed/simple; bh=NRsUrwsfDBVIR7zlW4wHZ1hxvm6bFw8otTg0Io2tZxY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KfkT6np7oqx8ocFuUVJc7BK6S/0SjBNEuCWgmbsRQ0zOv4vJtiPEOHHtkkkdIp7KlEU1tpeq1ntIenrvspNnb8XIFbIjPf0oAWgygPX6I9uJeyOt8uBhjp/UwGovsSYK2/pOO2D8ZIpSGkc6KMtLijaL23YxzlgxCobFjhvz8O8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SR17GPLm; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SR17GPLm" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 018DA4E40BDB; Wed, 10 Sep 2025 14:55:55 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E687D606D4; Wed, 10 Sep 2025 14:55:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 538D3102F2982; Wed, 10 Sep 2025 16:55:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757516154; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XoKGOrO1Ey6obEn8h5SKfYR6XgUo5CImp+vP8RhoOl8=; b=SR17GPLmDx/c2f6RuJqn2RxWzsFXKEER0zSR2+bmcdGZ+UhJ1QrmQYZHs2WSlr5ahyrtyy 3GJN92WhvJsJOTNPXZgd1g6H2DpiDnrAKlAgkyUI7QiNSu+rMxcxcAwlAr48Nvj1paHPH9 2fXlio33TrE0+47FH2SmCJ+sDMn8Lz42oNIhUVd2wU1N0c9QHfuO45szMDJNR0mPuh6a9v ey1dNrnC7HqAjiqED3LcdFYwNU4NsdcRtqPe3t5O9WMtcbnL1Sd+6O/UjCisPzgCT7q5jl ndbghqSiW+PFpghc/iXaLxSgwbMjBJ7sVrbjsaq2qAVkz0wm19Ue2OFN8bpynA== From: Bastien Curutchet Date: Wed, 10 Sep 2025 16:55:25 +0200 Subject: [PATCH net-next 2/2] net: dsa: microchip: configure strap pins during reset 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: <20250910-ksz-strap-pins-v1-2-6308bb2e139e@bootlin.com> References: <20250910-ksz-strap-pins-v1-0-6308bb2e139e@bootlin.com> In-Reply-To: <20250910-ksz-strap-pins-v1-0-6308bb2e139e@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marek Vasut Cc: Thomas Petazzoni , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Pascal Eberhard , Woojung Huh , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 At reset, some KSZ switches use strap based configuration. If the required pull-ups/pull-downs are missing (by mistake or by design to save power) the pins may float and the configuration can go wrong. Introduce a configure_strap() function, called during the device reset. It relies on the 'strap-gpios' OF property and the 'reset' pinmux configuration to drive the configuration pins to the proper state. Support the KSZ8463's strap configuration that enforces SPI as communication bus, since it is the only bus supported by the driver. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 47 ++++++++++++++++++++++++++++++= ++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 7292bfe2f7cac3a0d88bb51339cc287f56ca1d1f..0ab201a3c336b99ba92d87c003b= a48f7f82a098a 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -5338,6 +5339,44 @@ static int ksz_parse_drive_strength(struct ksz_devic= e *dev) return 0; } =20 +static int ksz_configure_strap(struct ksz_device *dev) +{ + struct pinctrl_state *state =3D NULL; + struct pinctrl *pinctrl; + int ret; + + if (of_device_is_compatible(dev->dev->of_node, "microchip,ksz8463")) { + struct gpio_desc *rxd0; + struct gpio_desc *rxd1; + + rxd0 =3D devm_gpiod_get_index_optional(dev->dev, "strap", 0, GPIOD_OUT_L= OW); + if (IS_ERR(rxd0)) + return PTR_ERR(rxd0); + + rxd1 =3D devm_gpiod_get_index_optional(dev->dev, "strap", 1, GPIOD_OUT_H= IGH); + if (IS_ERR(rxd1)) + return PTR_ERR(rxd1); + + /* If at least one strap definition is missing we don't do anything */ + if (!rxd0 || !rxd1) + return 0; + + pinctrl =3D devm_pinctrl_get(dev->dev); + if (IS_ERR(pinctrl)) + return PTR_ERR(pinctrl); + + state =3D pinctrl_lookup_state(pinctrl, "reset"); + if (IS_ERR(state)) + return PTR_ERR(state); + + ret =3D pinctrl_select_state(pinctrl, state); + if (ret) + return ret; + } + + return 0; +} + int ksz_switch_register(struct ksz_device *dev) { const struct ksz_chip_data *info; @@ -5353,10 +5392,18 @@ int ksz_switch_register(struct ksz_device *dev) return PTR_ERR(dev->reset_gpio); =20 if (dev->reset_gpio) { + ret =3D ksz_configure_strap(dev); + if (ret) + return ret; + gpiod_set_value_cansleep(dev->reset_gpio, 1); usleep_range(10000, 12000); gpiod_set_value_cansleep(dev->reset_gpio, 0); msleep(100); + + ret =3D pinctrl_select_default_state(dev->dev); + if (ret) + return ret; } =20 mutex_init(&dev->dev_mutex); --=20 2.51.0