devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dt-bindings: net: dsa: microchip: add bit-banged SMI example
@ 2025-06-02 17:04 Corentin Guillevic
  2025-06-02 19:53 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Corentin Guillevic @ 2025-06-02 17:04 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: Corentin Guillevic, Woojung Huh, netdev, devicetree, linux-kernel

KSZ8863 can be configured using I2C, SPI or Microchip SMI. The latter is
similar to MDIO, but uses a different protocol. If the hardware doesn't
support this, SMI bit banging can help. This commit adds an device tree
example that uses the CONFIG_MDIO_GPIO driver for SMI bit banging.

Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr>
---
Changes in v2:
- Fix dt_binding_check errors

 .../bindings/net/dsa/microchip,ksz.yaml       | 59 ++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
index 62ca63e8a26f..33a067809ebe 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
@@ -241,4 +241,61 @@ examples:
             };
         };
     };
-...
+
+  # KSZ8863 with bit-banged SMI
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    // Ethernet switch connected via SMI to the host, CPU port wired to eth0:
+    ethernet0 {
+        phy-mode = "rmii";
+
+        fixed-link {
+            speed = <100>;
+            full-duplex;
+            pause;
+        };
+    };
+
+    mdio: mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        compatible = "microchip,mdio-smi0";
+        gpios = <&gpioc 1 GPIO_ACTIVE_HIGH>,
+            <&gpioa 2 GPIO_ACTIVE_HIGH>;
+        status = "okay";
+
+        switch@0 {
+            compatible = "microchip,ksz8863";
+            reg = <0>;
+            reset-gpios = <&gpioa 4 GPIO_ACTIVE_LOW>;
+            status = "okay";
+
+            ethernet-ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                lan1: port@0 {
+                    reg = <0>;
+                    label = "lan1";
+                    phy-mode = "internal";
+                };
+                lan2: port@1 {
+                    reg = <1>;
+                    label = "lan2";
+                    phy-mode = "internal";
+                };
+                port@2 {
+                    reg = <2>;
+                    label = "cpu";
+                    ethernet = <&ethernet0>;
+                    phy-mode = "rmii";
+                    microchip,rmii-clk-internal;
+
+                    fixed-link {
+                        speed = <100>;
+                        full-duplex;
+                    };
+                };
+            };
+        };
+    };
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] dt-bindings: net: dsa: microchip: add bit-banged SMI example
  2025-06-02 17:04 [PATCH v2] dt-bindings: net: dsa: microchip: add bit-banged SMI example Corentin Guillevic
@ 2025-06-02 19:53 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-02 19:53 UTC (permalink / raw)
  To: Corentin Guillevic, 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: netdev, devicetree, linux-kernel

On 02/06/2025 19:04, Corentin Guillevic wrote:
> KSZ8863 can be configured using I2C, SPI or Microchip SMI. The latter is
> similar to MDIO, but uses a different protocol. If the hardware doesn't
> support this, SMI bit banging can help. This commit adds an device tree
> example that uses the CONFIG_MDIO_GPIO driver for SMI bit banging.

So the difference is in one property? Or no difference at all...

> 
> Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr>
> ---
> Changes in v2:
> - Fix dt_binding_check errors
> 
>  .../bindings/net/dsa/microchip,ksz.yaml       | 59 ++++++++++++++++++-
>  1 file changed, 58 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
> index 62ca63e8a26f..33a067809ebe 100644
> --- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
> @@ -241,4 +241,61 @@ examples:
>              };
>          };
>      };
> -...
> +
> +  # KSZ8863 with bit-banged SMI
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    // Ethernet switch connected via SMI to the host, CPU port wired to eth0:
> +    ethernet0 {


Drop node, not really used.

> +        phy-mode = "rmii";
> +
> +        fixed-link {
> +            speed = <100>;
> +            full-duplex;
> +            pause;
> +        };
> +    };
> +
> +    mdio: mdio {
> +        #address-cells = <1>;
> +        #size-cells = <0>;

Order properties according to DTS coding style.

> +        compatible = "microchip,mdio-smi0";

Not relevant. This binding describes device, not bus.

> +        gpios = <&gpioc 1 GPIO_ACTIVE_HIGH>,
> +            <&gpioa 2 GPIO_ACTIVE_HIGH>;

Messed indentation

> +        status = "okay";

Drop status

but anyway all above is not really relevant, drop.

> +
> +        switch@0 {
> +            compatible = "microchip,ksz8863";
> +            reg = <0>;
> +            reset-gpios = <&gpioa 4 GPIO_ACTIVE_LOW>;
> +            status = "okay";

Drop.

After cleanup from redundant pieces there is basically no difference.
Don't add examples which differ by compatible (or even by one property).



Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-02 19:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-02 17:04 [PATCH v2] dt-bindings: net: dsa: microchip: add bit-banged SMI example Corentin Guillevic
2025-06-02 19:53 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).