[U-Boot] [PATCH V4 5/6] net: fec_mxc: support i.MX8M with CLK_CCF

Peng Fan peng.fan at nxp.com
Mon Nov 4 00:58:54 UTC 2019


> Subject: RE: [PATCH V4 5/6] net: fec_mxc: support i.MX8M with CLK_CCF
> 
> Hi Stefano,
> 
> 
> > -----Original Message-----
> > From: Stefano Babic <sbabic at denx.de>
> > Sent: 2019年11月3日 23:20
> > To: Peng Fan <peng.fan at nxp.com>; sbabic at denx.de;
> festevam at gmail.com;
> > lukma at denx.de; joe.hershberger at ni.com
> > Cc: dl-uboot-imx <uboot-imx at nxp.com>; u-boot at lists.denx.de;
> > frieder.schrempf at kontron.de
> > Subject: Re: [PATCH V4 5/6] net: fec_mxc: support i.MX8M with CLK_CCF
> >
> > Hi Peng,
> >
> > On 25/10/19 11:48, Peng Fan wrote:
> > > 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 at kontron.de>
> > > Signed-off-by: Peng Fan <peng.fan at nxp.com>
> > > ---
> > >
> >
> > This seems to break most of i.MX8 boards - does it build o your side ?
> 
> I rebased imx/next to Tom's tree and apply some of my patches,
> https://github.com/MrVan/u-boot/commits/imx-next-11-1
> 
> The build pass:
> https://travis-ci.org/MrVan/u-boot/builds/605898636

Forget the mention, I add a patch to fix build CI. Will send it out soon.

Thanks,
Peng.

> 
> Thanks,
> Peng.
> 
> >
> > Regards,
> > Stefano
> >
> > > V4:
> > >  Fix build warning
> > >  Add R-b
> > >
> > > V3:
> > >  Drop unneeded else
> > >  correct ipg->ahb
> > >  Other patches keep V1
> > >
> > > V2:
> > >  Use CONFIG_IS_ENABLED
> > >
> > >
> > >  drivers/net/fec_mxc.c | 79
> > > +++++++++++++++++++++++++++++++++++++++++----------
> > >  drivers/net/fec_mxc.h |  4 +++
> > >  2 files changed, 68 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index
> > > 080dbcf7db..131d1998a7 100644
> > > --- a/drivers/net/fec_mxc.c
> > > +++ b/drivers/net/fec_mxc.c
> > > @@ -123,30 +123,38 @@ static int fec_mdio_read(struct ethernet_regs
> > *eth, uint8_t phyaddr,
> > >  	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)  { -#if
> > > IS_ENABLED(CONFIG_IMX8)
> > >  	struct fec_priv *fec;
> > >  	struct udevice *dev;
> > >  	int ret;
> > >
> > > -	dev = udev;
> > > -	if (!dev) {
> > > -		ret = uclass_get_device(UCLASS_ETH, idx, &dev);
> > > -		if (ret < 0) {
> > > -			debug("Can't get FEC udev: %d\n", ret);
> > > -			return ret;
> > > +	if (IS_ENABLED(CONFIG_IMX8) ||
> > > +	    CONFIG_IS_ENABLED(CLK_CCF)) {
> > > +		dev = udev;
> > > +		if (!dev) {
> > > +			ret = uclass_get_device(UCLASS_ETH, idx, &dev);
> > > +			if (ret < 0) {
> > > +				debug("Can't get FEC udev: %d\n", ret);
> > > +				return ret;
> > > +			}
> > >  		}
> > > -	}
> > >
> > > -	fec = dev_get_priv(dev);
> > > -	if (fec)
> > > -		return fec->clk_rate;
> > > +		fec = dev_get_priv(dev);
> > > +		if (fec)
> > > +			return fec->clk_rate;
> > >
> > > -	return -EINVAL;
> > > -#else
> > > -	return imx_get_fecclk();
> > > -#endif
> > > +		return -EINVAL;
> > > +	} else {
> > > +		return imx_get_fecclk();
> > > +	}
> > >  }
> > >
> > >  static void fec_mii_setspeed(struct ethernet_regs *eth) @@ -1335,6
> > > +1343,47 @@ static int fecmxc_probe(struct udevice *dev)
> > >  			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);
> > >  	}
> > >
> > > diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h index
> > > e5f2dd75c5..723b06a651 100644
> > > --- a/drivers/net/fec_mxc.h
> > > +++ b/drivers/net/fec_mxc.h
> > > @@ -264,6 +264,10 @@ struct fec_priv {
> > >  	u32 interface;
> > >  #endif
> > >  	struct clk ipg_clk;
> > > +	struct clk ahb_clk;
> > > +	struct clk clk_enet_out;
> > > +	struct clk clk_ref;
> > > +	struct clk clk_ptp;
> > >  	u32 clk_rate;
> > >  };
> > >
> > >
> >
> >
> > --
> >
> ==============================================================
> > =======
> > DENX Software Engineering GmbH,      Managing Director: Wolfgang
> Denk
> > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> > Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email:
> sbabic at denx.de
> >
> ==============================================================
> > =======


More information about the U-Boot mailing list