* [PATCH net-next v3 1/3] dt-bindings: net: dsa: microchip: Group if clause under allOf tag
2025-09-18 8:33 [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus Bastien Curutchet (Schneider Electric)
@ 2025-09-18 8:33 ` Bastien Curutchet (Schneider Electric)
2025-09-18 8:33 ` [PATCH net-next v3 2/3] dt-bindings: net: dsa: microchip: Add strap description to set SPI mode Bastien Curutchet (Schneider Electric)
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2025-09-18 8:33 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marek Vasut
Cc: Thomas Petazzoni, Miquèl Raynal, Pascal Eberhard,
Woojung Huh, netdev, devicetree, linux-kernel,
Bastien Curutchet (Schneider Electric)
Upcoming patch adds a new if/then clause. It requires to be grouped with
the already existing if/then clause under an 'allOf:' tag.
Move the if/then clause under the already existing 'allOf:' tag to
prepare next patch.
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
.../devicetree/bindings/net/dsa/microchip,ksz.yaml | 68 +++++++++++-----------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
index eb4607460db7f32a4dffd416e44b61c2674f731e..db8175b4ced6d136ba97c371b68ba993637e444a 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
@@ -10,9 +10,6 @@ maintainers:
- Marek Vasut <marex@denx.de>
- Woojung Huh <Woojung.Huh@microchip.com>
-allOf:
- - $ref: /schemas/spi/spi-peripheral-props.yaml#
-
properties:
# See Documentation/devicetree/bindings/net/dsa/dsa.yaml for a list of additional
# required and optional properties.
@@ -107,38 +104,41 @@ required:
- compatible
- reg
-if:
- not:
- properties:
- compatible:
- enum:
- - microchip,ksz8863
- - microchip,ksz8873
-then:
- $ref: dsa.yaml#/$defs/ethernet-ports
-else:
- patternProperties:
- "^(ethernet-)?ports$":
+allOf:
+ - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+ - if:
+ not:
+ properties:
+ compatible:
+ enum:
+ - microchip,ksz8863
+ - microchip,ksz8873
+ then:
+ $ref: dsa.yaml#/$defs/ethernet-ports
+ else:
patternProperties:
- "^(ethernet-)?port@[0-2]$":
- $ref: dsa-port.yaml#
- unevaluatedProperties: false
- properties:
- microchip,rmii-clk-internal:
- $ref: /schemas/types.yaml#/definitions/flag
- description:
- When ksz88x3 is acting as clock provier (via REFCLKO) it
- can select between internal and external RMII reference
- clock. Internal reference clock means that the clock for
- the RMII of ksz88x3 is provided by the ksz88x3 internally
- and the REFCLKI pin is unconnected. For the external
- reference clock, the clock needs to be fed back to ksz88x3
- via REFCLKI.
- If microchip,rmii-clk-internal is set, ksz88x3 will provide
- rmii reference clock internally, otherwise reference clock
- should be provided externally.
- dependencies:
- microchip,rmii-clk-internal: [ethernet]
+ "^(ethernet-)?ports$":
+ patternProperties:
+ "^(ethernet-)?port@[0-2]$":
+ $ref: dsa-port.yaml#
+ unevaluatedProperties: false
+ properties:
+ microchip,rmii-clk-internal:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description:
+ When ksz88x3 is acting as clock provier (via REFCLKO) it
+ can select between internal and external RMII reference
+ clock. Internal reference clock means that the clock for
+ the RMII of ksz88x3 is provided by the ksz88x3 internally
+ and the REFCLKI pin is unconnected. For the external
+ reference clock, the clock needs to be fed back to ksz88x3
+ via REFCLKI.
+ If microchip,rmii-clk-internal is set, ksz88x3 will provide
+ rmii reference clock internally, otherwise reference clock
+ should be provided externally.
+ dependencies:
+ microchip,rmii-clk-internal: [ethernet]
unevaluatedProperties: false
--
2.51.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH net-next v3 2/3] dt-bindings: net: dsa: microchip: Add strap description to set SPI mode
2025-09-18 8:33 [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus Bastien Curutchet (Schneider Electric)
2025-09-18 8:33 ` [PATCH net-next v3 1/3] dt-bindings: net: dsa: microchip: Group if clause under allOf tag Bastien Curutchet (Schneider Electric)
@ 2025-09-18 8:33 ` Bastien Curutchet (Schneider Electric)
2025-09-22 17:22 ` Rob Herring (Arm)
2025-09-18 8:33 ` [PATCH net-next v3 3/3] net: dsa: microchip: Set SPI as bus interface during reset for KSZ8463 Bastien Curutchet
2025-09-22 23:40 ` [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus patchwork-bot+netdevbpf
3 siblings, 1 reply; 6+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2025-09-18 8:33 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marek Vasut
Cc: Thomas Petazzoni, Miquèl Raynal, Pascal Eberhard,
Woojung Huh, netdev, devicetree, linux-kernel,
Bastien Curutchet (Schneider Electric)
At reset, KSZ8463 uses a strap-based configuration to set SPI as
interface bus. 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 preventing any communication with the switch.
Add a 'reset' pinmux state
Add a KSZ8463 specific strap description that can be used by the driver
to drive the strap pins during reset. Two GPIOs are used. Users must
describe either both of them or none of them.
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
.../devicetree/bindings/net/dsa/microchip,ksz.yaml | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
index db8175b4ced6d136ba97c371b68ba993637e444a..a8c8009414ae00b1a60aad715e15c23343e241ff 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
@@ -34,6 +34,13 @@ properties:
- microchip,ksz8567
- microchip,lan9646
+ 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.
@@ -139,6 +146,18 @@ allOf:
should be provided externally.
dependencies:
microchip,rmii-clk-internal: [ethernet]
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: microchip,ksz8463
+ then:
+ properties:
+ straps-rxd-gpios:
+ description:
+ RXD0 and RXD1 pins, used to select SPI as bus interface.
+ minItems: 2
+ maxItems: 2
unevaluatedProperties: false
--
2.51.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net-next v3 2/3] dt-bindings: net: dsa: microchip: Add strap description to set SPI mode
2025-09-18 8:33 ` [PATCH net-next v3 2/3] dt-bindings: net: dsa: microchip: Add strap description to set SPI mode Bastien Curutchet (Schneider Electric)
@ 2025-09-22 17:22 ` Rob Herring (Arm)
0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring (Arm) @ 2025-09-22 17:22 UTC (permalink / raw)
To: Bastien Curutchet (Schneider Electric)
Cc: Paolo Abeni, Woojung Huh, netdev, Conor Dooley, devicetree,
David S. Miller, Krzysztof Kozlowski, Marek Vasut,
Vladimir Oltean, UNGLinuxDriver, Woojung Huh, Eric Dumazet,
Andrew Lunn, Miquèl Raynal, Pascal Eberhard, linux-kernel,
Thomas Petazzoni, Jakub Kicinski
On Thu, 18 Sep 2025 10:33:51 +0200, Bastien Curutchet (Schneider Electric) wrote:
> At reset, KSZ8463 uses a strap-based configuration to set SPI as
> interface bus. 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 preventing any communication with the switch.
>
> Add a 'reset' pinmux state
> Add a KSZ8463 specific strap description that can be used by the driver
> to drive the strap pins during reset. Two GPIOs are used. Users must
> describe either both of them or none of them.
>
> Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
> ---
> .../devicetree/bindings/net/dsa/microchip,ksz.yaml | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v3 3/3] net: dsa: microchip: Set SPI as bus interface during reset for KSZ8463
2025-09-18 8:33 [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus Bastien Curutchet (Schneider Electric)
2025-09-18 8:33 ` [PATCH net-next v3 1/3] dt-bindings: net: dsa: microchip: Group if clause under allOf tag Bastien Curutchet (Schneider Electric)
2025-09-18 8:33 ` [PATCH net-next v3 2/3] dt-bindings: net: dsa: microchip: Add strap description to set SPI mode Bastien Curutchet (Schneider Electric)
@ 2025-09-18 8:33 ` Bastien Curutchet
2025-09-22 23:40 ` [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Bastien Curutchet @ 2025-09-18 8:33 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marek Vasut
Cc: Thomas Petazzoni, Miquèl Raynal, Pascal Eberhard,
Woojung Huh, netdev, devicetree, linux-kernel,
Bastien Curutchet (Schneider Electric)
At reset, the KSZ8463 uses a strap-based configuration to set SPI as
bus interface. SPI is the only bus supported by the driver. 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
preventing any communication with the switch.
Introduce a ksz8463_configure_straps_spi() function called during the
device reset. It relies on the 'straps-rxd-gpios' OF property and the
'reset' pinmux configuration to enforce SPI as bus interface.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
drivers/net/dsa/microchip/ksz_common.c | 45 ++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 7292bfe2f7cac3a0d88bb51339cc287f56ca1d1f..3bfa894d62eecc08dc45b25225e1122fe30b8f99 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -23,6 +23,7 @@
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/micrel_phy.h>
+#include <linux/pinctrl/consumer.h>
#include <net/dsa.h>
#include <net/ieee8021q.h>
#include <net/pkt_cls.h>
@@ -5338,6 +5339,38 @@ static int ksz_parse_drive_strength(struct ksz_device *dev)
return 0;
}
+static int ksz8463_configure_straps_spi(struct ksz_device *dev)
+{
+ struct pinctrl *pinctrl;
+ struct gpio_desc *rxd0;
+ struct gpio_desc *rxd1;
+
+ rxd0 = devm_gpiod_get_index_optional(dev->dev, "straps-rxd", 0, GPIOD_OUT_LOW);
+ if (IS_ERR(rxd0))
+ return PTR_ERR(rxd0);
+
+ rxd1 = devm_gpiod_get_index_optional(dev->dev, "straps-rxd", 1, GPIOD_OUT_HIGH);
+ if (IS_ERR(rxd1))
+ return PTR_ERR(rxd1);
+
+ if (!rxd0 && !rxd1)
+ return 0;
+
+ if ((rxd0 && !rxd1) || (rxd1 && !rxd0))
+ return -EINVAL;
+
+ pinctrl = devm_pinctrl_get_select(dev->dev, "reset");
+ if (IS_ERR(pinctrl))
+ return PTR_ERR(pinctrl);
+
+ return 0;
+}
+
+static int ksz8463_release_straps_spi(struct ksz_device *dev)
+{
+ return pinctrl_select_default_state(dev->dev);
+}
+
int ksz_switch_register(struct ksz_device *dev)
{
const struct ksz_chip_data *info;
@@ -5353,10 +5386,22 @@ int ksz_switch_register(struct ksz_device *dev)
return PTR_ERR(dev->reset_gpio);
if (dev->reset_gpio) {
+ if (of_device_is_compatible(dev->dev->of_node, "microchip,ksz8463")) {
+ ret = ksz8463_configure_straps_spi(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);
+
+ if (of_device_is_compatible(dev->dev->of_node, "microchip,ksz8463")) {
+ ret = ksz8463_release_straps_spi(dev);
+ if (ret)
+ return ret;
+ }
}
mutex_init(&dev->dev_mutex);
--
2.51.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus
2025-09-18 8:33 [PATCH net-next v3 0/3] net: dsa: microchip: Add strap description to set SPI as interface bus Bastien Curutchet (Schneider Electric)
` (2 preceding siblings ...)
2025-09-18 8:33 ` [PATCH net-next v3 3/3] net: dsa: microchip: Set SPI as bus interface during reset for KSZ8463 Bastien Curutchet
@ 2025-09-22 23:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-22 23:40 UTC (permalink / raw)
To: Bastien Curutchet
Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
kuba, pabeni, robh, krzk+dt, conor+dt, marex, thomas.petazzoni,
miquel.raynal, pascal.eberhard, Woojung.Huh, netdev, devicetree,
linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 18 Sep 2025 10:33:49 +0200 you wrote:
> Hi all,
>
> At reset, the KSZ8463 uses a strap-based configuration to set SPI as
> interface bus. 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 preventing any communication with the switch.
>
> [...]
Here is the summary with links:
- [net-next,v3,1/3] dt-bindings: net: dsa: microchip: Group if clause under allOf tag
https://git.kernel.org/netdev/net-next/c/6bd5b7297c95
- [net-next,v3,2/3] dt-bindings: net: dsa: microchip: Add strap description to set SPI mode
https://git.kernel.org/netdev/net-next/c/e469b87e0fb0
- [net-next,v3,3/3] net: dsa: microchip: Set SPI as bus interface during reset for KSZ8463
https://git.kernel.org/netdev/net-next/c/a0b977a3d193
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread