[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190727183836.Horde.B4Y-dcWu5sojGbybcU-O1Qc@www.vdorst.com>
Date: Sat, 27 Jul 2019 18:38:36 +0000
From: René van Dorst <opensource@...rst.com>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: netdev@...r.kernel.org, frank-w@...lic-files.de,
sean.wang@...iatek.com, linux@...linux.org.uk, davem@...emloft.net,
matthias.bgg@...il.com, andrew@...n.ch, vivien.didelot@...il.com,
john@...ozen.org, linux-mediatek@...ts.infradead.org,
linux-mips@...r.kernel.org, robh+dt@...nel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH net-next 3/3] net: dsa: mt7530: Add support for port 5
Quoting Florian Fainelli <f.fainelli@...il.com>:
> On 7/24/2019 9:25 PM, René van Dorst wrote:
>> Adding support for port 5.
>>
>> Port 5 can muxed/interface to:
>> - internal 5th GMAC of the switch; can be used as 2nd CPU port or as
>> extra port with an external phy for a 6th ethernet port.
>> - internal PHY of port 0 or 4; Used in most applications so that port 0
>> or 4 is the WAN port and interfaces with the 2nd GMAC of the SOC.
>>
>> Signed-off-by: René van Dorst <opensource@...rst.com>
>
> [snip]
>
>> + /* Setup port 5 */
>> + priv->p5_intf_sel = P5_DISABLED;
>> + interface = PHY_INTERFACE_MODE_NA;
>> +
>> + if (!dsa_is_unused_port(ds, 5)) {
>> + priv->p5_intf_sel = P5_INTF_SEL_GMAC5;
>> + interface = of_get_phy_mode(ds->ports[5].dn);
>> + } else {
>> + /* Scan the ethernet nodes. Look for GMAC1, Lookup used phy */
>> + for_each_child_of_node(dn, mac_np) {
>> + if (!of_device_is_compatible(mac_np,
>> + "mediatek,eth-mac"))
>> + continue;
>> + _id = of_get_property(mac_np, "reg", NULL);
>> + if (be32_to_cpup(_id) != 1)
>> + continue;
>> +
>> + interface = of_get_phy_mode(mac_np);
>> + phy_node = of_parse_phandle(mac_np, "phy-handle", 0);
>> +
>> + if (phy_node->parent == priv->dev->of_node->parent) {
>> + _id = of_get_property(phy_node, "reg", NULL);
>> + id = be32_to_cpup(_id);
>> + if (id == 0)
>> + priv->p5_intf_sel = P5_INTF_SEL_PHY_P0;
>> + if (id == 4)
>> + priv->p5_intf_sel = P5_INTF_SEL_PHY_P4;
>
Hi Florian,
> Can you use of_mdio_parse_addr() here?
Yes that function be used.
Thanks for mention this function.
I see that I can refactor this scan routine a bit more.
Also I missing a of_node_put(phy_node) at the end.
> --
> Florian
Greats,
René
Powered by blists - more mailing lists