OSDN Git Service

net: dsa: bcm_sf2: Ensure that MDIO diversion is used
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 4 Sep 2020 21:37:30 +0000 (14:37 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 5 Sep 2020 20:09:03 +0000 (13:09 -0700)
commit771089c2a485958e423f305e974303760167b45c
treee107272160bde0bd8c34720b1c5ce600243d1191
parent0f7c5317b89058e432d3e97efa19467ff4c3b86b
net: dsa: bcm_sf2: Ensure that MDIO diversion is used

Registering our slave MDIO bus outside of the OF infrastructure is
necessary in order to avoid creating double references of the same
Device Tree nodes, however it is not sufficient to guarantee that the
MDIO bus diversion is used because of_phy_connect() will still resolve
to a valid PHY phandle and it will connect to the PHY using its parent
MDIO bus which is still the SF2 master MDIO bus. The reason for that is
because BCM7445 systems were already shipped with a Device Tree blob
looking like this (irrelevant parts omitted for simplicity):

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

port@1 {
phy-mode = "rgmii-txid";
phy-handle = <&phy0>;
                        reg = <1>;
label = "rgmii_1";
};
...

mdio@403c0 {
...

phy0: ethernet-phy@0 {
broken-turn-around;
device_type = "ethernet-phy";
max-speed = <0x3e8>;
reg = <0>;
compatible = "brcm,bcm53125", "ethernet-phy-ieee802.3-c22";
};
};

There is a hardware issue with chip revisions (Dx) that lead to the
development of the following commits:

461cd1b03e32 ("net: dsa: bcm_sf2: Register our slave MDIO bus")
536fab5bf582 ("net: dsa: bcm_sf2: Do not register slave MDIO bus with OF")
b8c6cd1d316f ("net: dsa: bcm_sf2: do not use indirect reads and writes for 7445E0")

There should have been an internal MDIO bus node created for the chip
revision (Dx) that suffers from this problem, but it did not happen back
then.

Had that happen, that we should have correctly parented phy@0 (bcm53125
below) as child node of the internal MDIO bus, but the production Device
Tree blob that was shipped with the firmware targeted the fixed version
of the chip, despite both the affected and corrected chips being shipped
into production.

The problem is that of_phy_connect() for port@1 will happily resolve the
'phy-handle' from the mdio@403c0 node, which bypasses the diversion
completely. This results in this double programming that the diversion
refers to and aims to avoid. In order to force of_phy_connect() to fail,
and have DSA call to dsa_slave_phy_connect(), we must deactivate
ethernet-phy@0 from mdio@403c0, and the best way to do that is by
removing the phandle property completely.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/bcm_sf2.c