Subject: DSA: external phy address and port number of switch conflicts

From: John Rama <[email-masked]>
Date: Thu, 13 Dec 2018 18:51:16 -0500

Dear DSA experts

My name is John.

I'm working for our custom board which has the Marvel 88e5050 ethernet switch
as shown below, and trying to make the system works using DSA subsystem.
I havea problem and a question.

- System
    - i.MX6 and Marvel 88e5050 Switch(PHY addr is 0x10)
    - port1-5 has integrated PHY
     - port7 is connected to Marvel 88e1510 PHY(PHY addr is 0x1)

                           0x10
    +------------+         +-----------------+
    |            |         | Marvel 88e5050  |
    |            | RGMII   |           port1 |
    |   IMX6     +---------+ port6           |
    |            |         |           port2 |
    |            | MDIO    |                 |
    |            +-+-------+           port3 |
    |            | |       |                 |
    +------------+ |       |           port4 |
                   |       |                 |
                 +-+-+     |           port5 |
                 |   |SGMII|                 |
                 |PHY|-----| port7           |
                 |   |     |                 |
                 +---+     +-----------------+
              Marvel 88e1510
                   0x1                        

- Device Tree setting
    In this configuration, our dts is as followings.

    dsa@0 {
      compatible = "marvell,dsa";
        #address-cells = <2>;
        #size-cells = <0>;

        dsa,ethernet = <&fec>;
        dsa,mii-bus = <&mdio>;

        switch@0 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <0x10 0>;    /* MDIO address 16, switch 0 in tree */

            port@1 {
                reg = <1>;
                label = "port1";
            };

            port@2 {
                reg = <2>;
                label = "port2";
            };

            port@3 {
                reg = <3>;
                label = "port3";
            };

            port@4 {
                reg = <4>;
                label = "port4";
            };

            port@5 {
                reg = <5>;
                label = "port5";
            };

            port@6 {
                reg = <6>;
                label = "cpu";
            };

            port@7 {
                reg = <7>;
                label = "port7";
                phy-handle = <&ethphy1>;
                phy-mode = "sgmii";
            };                                       
        };
     };

    mdio: mdio {
        #address-cells = <1>;
        #size-cells = <0>;

        ethphy1: 88e1510{
            reg = <1>;
            phy-mode = "sgmii";
        };

    };
                                
- Problem
    dsa_slave_phy_connect() for port 7 results in attaching Generic PHY,
    as shown in the following log, which is unexpected result.
    dsa dsa@0 port7 (uninitialized): attached PHY at address 1 [Generic PHY]

    This is because port7 PHY addr (reg=<1>) and the port1 port number (reg=<1)> is conflicting.
    If I comment out the port1 setting from DTS, I can get following log,
    everything working fine and

    dsa dsa@0 port7 (uninitialized): attached PHY at address 1 [Marvel 88E1510]

    I'm using a little bit old kernel,4.1.15.
    So I checked the latest code of linux-next, but it seems there is similar problem.

- Question
    Is this system configuration is not supported by DSA ?
    Or am I misunderstand something ?
    Any insights are really appreciated.

John