net: fec: Allow the PHY node to be retrieved
authorFabio Estevam <festevam@gmail.com>
Thu, 18 Jun 2020 23:21:18 +0000 (20:21 -0300)
committerStefano Babic <sbabic@denx.de>
Mon, 22 Jun 2020 15:40:49 +0000 (17:40 +0200)
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>
drivers/net/fec_mxc.c
drivers/net/fec_mxc.h

index 9ae2db033e66b253b1526b38d1128d013ff25cd9..992180df869bc163bed99eb371b7ef4688e74ab3 100644 (file)
@@ -1294,7 +1294,7 @@ static const struct eth_ops fecmxc_ops = {
        .read_rom_hwaddr        = fecmxc_read_rom_hwaddr,
 };
 
-static int device_get_phy_addr(struct udevice *dev)
+static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
 {
        struct ofnode_phandle_args phandle_args;
        int reg;
@@ -1305,6 +1305,8 @@ static int device_get_phy_addr(struct udevice *dev)
                return -ENODEV;
        }
 
+       priv->phy_of_node = phandle_args.node;
+
        reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
 
        return reg;
@@ -1315,7 +1317,7 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
        struct phy_device *phydev;
        int addr;
 
-       addr = device_get_phy_addr(dev);
+       addr = device_get_phy_addr(priv, dev);
 #ifdef CONFIG_FEC_MXC_PHYADDR
        addr = CONFIG_FEC_MXC_PHYADDR;
 #endif
@@ -1325,6 +1327,7 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
                return -ENODEV;
 
        priv->phydev = phydev;
+       priv->phydev->node = priv->phy_of_node;
        phy_config(phydev);
 
        return 0;
index 0e8f08a51a18d816c7199522ed8a715e0b38201a..659d62646f8b4398c5d68b69c7ddb35d0caa7e65 100644 (file)
@@ -250,6 +250,7 @@ struct fec_priv {
        struct mii_dev *bus;
 #ifdef CONFIG_PHYLIB
        struct phy_device *phydev;
+       ofnode phy_of_node;
 #else
        int phy_id;
        int (*mii_postcall)(int);