Re: [PATCH net-next 3/3] net: dsa: mt7530: Add support for port 5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>

[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;

Can you use of_mdio_parse_addr() here?
-- 
Florian



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux