Commit 89b5bd54c1a425e416d67ce21b0fd5fd7da6a1d4

Authored by Fabio Estevam
Committed by Stefano Babic
1 parent 338d9b032a
Exists in emb_lf_v2022.04

net: fec: Allow the PHY node to be retrieved

As we move towards driver model, it is required to let the FEC driver
know how to properly deal with an Ethernet PHY subnode in the device tree.

For example:

 &fec {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_microsom_enet_ar8035>;
	phy-handle = <&phy>;
 	phy-mode = "rgmii-id";
 	phy-reset-duration = <2>;
 	phy-reset-gpios = <&gpio4 15 GPIO_ACTIVE_LOW>;
 	status = "okay";

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

		phy: ethernet-phy@0 {
			reg = <0>;
			qca,clk-out-frequency = <125000000>;
		};
	};
 };

Currently the PHY node pointer is incorrectly associated with the
Ethernel controller instead of the PHY node itself.

This causes the PHY properties, such as "qca,clk-out-frequency" in
the example above to not get parsed.

Fix this problem by populating the phy_of_node node.

Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Tom Rini <trini@konsulko.com>

Showing 2 changed files with 6 additions and 2 deletions Side-by-side Diff

drivers/net/fec_mxc.c
... ... @@ -1294,7 +1294,7 @@
1294 1294 .read_rom_hwaddr = fecmxc_read_rom_hwaddr,
1295 1295 };
1296 1296  
1297   -static int device_get_phy_addr(struct udevice *dev)
  1297 +static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
1298 1298 {
1299 1299 struct ofnode_phandle_args phandle_args;
1300 1300 int reg;
... ... @@ -1305,6 +1305,8 @@
1305 1305 return -ENODEV;
1306 1306 }
1307 1307  
  1308 + priv->phy_of_node = phandle_args.node;
  1309 +
1308 1310 reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
1309 1311  
1310 1312 return reg;
... ... @@ -1315,7 +1317,7 @@
1315 1317 struct phy_device *phydev;
1316 1318 int addr;
1317 1319  
1318   - addr = device_get_phy_addr(dev);
  1320 + addr = device_get_phy_addr(priv, dev);
1319 1321 #ifdef CONFIG_FEC_MXC_PHYADDR
1320 1322 addr = CONFIG_FEC_MXC_PHYADDR;
1321 1323 #endif
... ... @@ -1325,6 +1327,7 @@
1325 1327 return -ENODEV;
1326 1328  
1327 1329 priv->phydev = phydev;
  1330 + priv->phydev->node = priv->phy_of_node;
1328 1331 phy_config(phydev);
1329 1332  
1330 1333 return 0;
drivers/net/fec_mxc.h
... ... @@ -250,6 +250,7 @@
250 250 struct mii_dev *bus;
251 251 #ifdef CONFIG_PHYLIB
252 252 struct phy_device *phydev;
  253 + ofnode phy_of_node;
253 254 #else
254 255 int phy_id;
255 256 int (*mii_postcall)(int);