U-Boot DSA driver for microchip KSZ9477 suggestions needed

Tim Harvey tharvey at gateworks.com
Tue Jun 22 01:10:51 CEST 2021


Greetings,

I've written a U-Boot phy driver for a Microchip KSZ9477 ethernet
switch that I submitted some time ago as an RFC [1] which simply
enables the ports in the dt and puts them in forwarding mode with link
detect. However I think this would be much better suited as a DSA
driver now that UCLASS_DSA exists.

The KSZ9477 switch is used in the Gateworks GW7901 IMX8M Mini based
board and is hooked up via I2C (instead of MDIO) so the relevant dt
(already in Mainline Linux) looks like this:

/ {
        aliases {
                ethernet0 = &fec1;
                ethernet1 = &lan1;
                ethernet2 = &lan2;
                ethernet3 = &lan3;
                ethernet4 = &lan4;
                usb0 = &usbotg1;
                usb1 = &usbotg2;
        };
};

&fec1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_fec1>;
        phy-mode = "rgmii-id";
        local-mac-address = [00 00 00 00 00 00];
        status = "okay";

        fixed-link {
                speed = <1000>;
                full-duplex;
        };
};

&i2c3 {
        clock-frequency = <400000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c3>;
        status = "okay";

        switch: switch at 5f {
                compatible = "microchip,ksz9897";
                reg = <0x5f>;
                pinctrl-0 = <&pinctrl_ksz>;
                interrupt-parent = <&gpio4>;
                interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
                phy-mode = "rgmii-id";

                ports {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        lan1: port at 0 {
                                reg = <0>;
                                label = "lan1";
                                local-mac-address = [00 00 00 00 00 00];
                        };
                        lan2: port at 1 {
                                reg = <1>;
                                label = "lan2";
                                local-mac-address = [00 00 00 00 00 00];
                        };
                        lan3: port at 2 {
                                reg = <2>;
                                label = "lan3";
                                local-mac-address = [00 00 00 00 00 00];
                        };
                        lan4: port at 3 {
                                reg = <3>;
                                label = "lan4";
                                local-mac-address = [00 00 00 00 00 00];
                        };
                        port at 5 {
                                reg = <5>;
                                label = "cpu";
                                ethernet = <&fec1>;
                                phy-mode = "rgmii-id";

                                fixed-link {
                                        speed = <1000>;
                                        full-duplex;
                                };
                        };
                };
        };
};

I'm running into an issue trying to get a DSA driver working for this
switch on this board. My UCLASS_DSA driver is getting registered and
dsa_post_bind successfully sees the ports and the master_dev however
when eth_initialize() is called my dsa driver probes before the fec1
master because i2c comes before fec in the imx8mm.dtsi device-tree.
Any suggestions on how and where to properly resolve this (Likely
there is a way to force a probe)?

If I hack around that my moving i2c in imx8mm.dtsi after fec I see a
U-Boot net device for all the ports including the cpu port. I'm not
quite sure what the necessity of the cpu port is here because I assume
the idea is to set 'ethact' to one of the physical ports before
initiating a cmd that sends/receives traffic but I suppose the cpu
interface is there because that's what Linux dsa does.

Without adding any tagging and just doing a 'setenv ethact lan1; ping
<serverip>' I'm not seeing any response. I'm not exactly clear what to
be using here for tagging. The Linux ksz driver [3] appears to add a 2
byte tag on ingress packets but a 1 byte on egress packets.

I'm also not quite clear if I should be implementing link detect on the ports.

Any suggestions would be greatly appreciated. I would like to get this
dsa driver working and submitted and then perhaps move on to added a
DSA driver or DSA support to drivers/net/phy/mv88e61xx.c

Best regards,

Tim
[1] https://www.mail-archive.com/u-boot@lists.denx.de/msg389713.html
[2] https://elixir.bootlin.com/linux/latest/source/net/dsa/tag_ksz.c


More information about the U-Boot mailing list