
Some rockchio Socs have integrated phy inside, to support it, add the integrated phy ops.
Signed-off-by: David Wu david.wu@rock-chips.com ---
drivers/net/gmac_rockchip.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c index 5afc415..bca0a2a 100644 --- a/drivers/net/gmac_rockchip.c +++ b/drivers/net/gmac_rockchip.c @@ -10,6 +10,7 @@ #include <dm.h> #include <clk.h> #include <phy.h> +#include <reset.h> #include <syscon.h> #include <asm/io.h> #include <asm/arch/periph.h> @@ -22,6 +23,7 @@ #include <asm/arch/grf_rk3399.h> #include <asm/arch/grf_rv1108.h> #include <dm/pinctrl.h> +#include <dm/of_access.h> #include <dt-bindings/clock/rk3288-cru.h> #include "designware.h"
@@ -35,6 +37,8 @@ DECLARE_GLOBAL_DATA_PTR; struct gmac_rockchip_platdata { struct dw_eth_pdata dw_eth_pdata; bool clock_input; + bool integrated_phy; + struct reset_ctl phy_reset; int tx_delay; int rx_delay; }; @@ -46,13 +50,16 @@ struct rk_gmac_ops { struct dw_eth_dev *priv); void (*set_to_rmii)(struct gmac_rockchip_platdata *pdata); void (*set_to_rgmii)(struct gmac_rockchip_platdata *pdata); + void (*integrated_phy_powerup)(struct gmac_rockchip_platdata *pdata); };
static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) { struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev); + struct ofnode_phandle_args args; const char *string; + int ret;
string = dev_read_string(dev, "clock_in_out"); if (!strcmp(string, "input")) @@ -60,6 +67,25 @@ static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) else pdata->clock_input = false;
+ /* If phy-handle property is passed from DT, use it as the PHY */ + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, &args); + if (ret) { + debug("Cannot get phy phandle: ret=%d\n", ret); + pdata->integrated_phy = dev_read_bool(dev, "phy-is-integrated"); + } else { + debug("Found phy-handle subnode\n"); + pdata->integrated_phy = ofnode_read_bool(args.node, + "phy-is-integrated"); + } + + if (pdata->integrated_phy) { + ret = reset_get_by_name(dev, "mac-phy", &pdata->phy_reset); + if (ret) { + debug("No PHY reset control found: ret=%d\n", ret); + return ret; + } + } + /* Check the new naming-style first... */ pdata->tx_delay = dev_read_u32_default(dev, "tx_delay", -ENOENT); pdata->rx_delay = dev_read_u32_default(dev, "rx_delay", -ENOENT); @@ -572,6 +598,9 @@ static int gmac_rockchip_probe(struct udevice *dev) if (ret) return ret;
+ if (pdata->integrated_phy && ops->integrated_phy_powerup) + ops->integrated_phy_powerup(pdata); + switch (eth_pdata->phy_interface) { case PHY_INTERFACE_MODE_RGMII: /*