mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-21 12:25:27 +00:00
net: fec_mxc: support i.MX8M with CLK_CCF
Add more clks for fec_mxc according to Linux Kernel 5.4.0-rc1 drivers/net/ethernet/freescale/fec_main.c. Since i.MX8MQ not support CLK_CCF, so add a check to restrict the code only effect when CONFIG_IMX8M and CONFIG_CLK_CCF both defined. Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
81dc2ac557
commit
673f659732
2 changed files with 69 additions and 16 deletions
|
@ -123,13 +123,21 @@ static int fec_mdio_read(struct ethernet_regs *eth, uint8_t phyaddr,
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef imx_get_fecclk
|
||||||
|
u32 __weak imx_get_fecclk(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int fec_get_clk_rate(void *udev, int idx)
|
static int fec_get_clk_rate(void *udev, int idx)
|
||||||
{
|
{
|
||||||
#if IS_ENABLED(CONFIG_IMX8)
|
|
||||||
struct fec_priv *fec;
|
struct fec_priv *fec;
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_IMX8) ||
|
||||||
|
CONFIG_IS_ENABLED(CLK_CCF)) {
|
||||||
dev = udev;
|
dev = udev;
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
ret = uclass_get_device(UCLASS_ETH, idx, &dev);
|
ret = uclass_get_device(UCLASS_ETH, idx, &dev);
|
||||||
|
@ -144,9 +152,9 @@ static int fec_get_clk_rate(void *udev, int idx)
|
||||||
return fec->clk_rate;
|
return fec->clk_rate;
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
#else
|
} else {
|
||||||
return imx_get_fecclk();
|
return imx_get_fecclk();
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fec_mii_setspeed(struct ethernet_regs *eth)
|
static void fec_mii_setspeed(struct ethernet_regs *eth)
|
||||||
|
@ -1335,6 +1343,47 @@ static int fecmxc_probe(struct udevice *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->clk_rate = clk_get_rate(&priv->ipg_clk);
|
||||||
|
} else if (CONFIG_IS_ENABLED(CLK_CCF)) {
|
||||||
|
ret = clk_get_by_name(dev, "ipg", &priv->ipg_clk);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("Can't get FEC ipg clk: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = clk_enable(&priv->ipg_clk);
|
||||||
|
if(ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = clk_get_by_name(dev, "ahb", &priv->ahb_clk);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("Can't get FEC ahb clk: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = clk_enable(&priv->ahb_clk);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = clk_get_by_name(dev, "enet_out", &priv->clk_enet_out);
|
||||||
|
if (!ret) {
|
||||||
|
ret = clk_enable(&priv->clk_enet_out);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = clk_get_by_name(dev, "enet_clk_ref", &priv->clk_ref);
|
||||||
|
if (!ret) {
|
||||||
|
ret = clk_enable(&priv->clk_ref);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = clk_get_by_name(dev, "ptp", &priv->clk_ptp);
|
||||||
|
if (!ret) {
|
||||||
|
ret = clk_enable(&priv->clk_ptp);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
priv->clk_rate = clk_get_rate(&priv->ipg_clk);
|
priv->clk_rate = clk_get_rate(&priv->ipg_clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,10 @@ struct fec_priv {
|
||||||
u32 interface;
|
u32 interface;
|
||||||
#endif
|
#endif
|
||||||
struct clk ipg_clk;
|
struct clk ipg_clk;
|
||||||
|
struct clk ahb_clk;
|
||||||
|
struct clk clk_enet_out;
|
||||||
|
struct clk clk_ref;
|
||||||
|
struct clk clk_ptp;
|
||||||
u32 clk_rate;
|
u32 clk_rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue