diff mbox series

[U-Boot,28/41] net: fec_mxc: Add the init_clk_fec function

Message ID 20180528122526.20597-29-peng.fan@nxp.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series imx: add i.MX8QXP support | expand

Commit Message

Peng Fan May 28, 2018, 12:25 p.m. UTC
From: Ye Li <ye.li@nxp.com>

When the power domain driver is enabled, we need to enable clocks after power
domain on. So the clock settings can't set in board_init, needs to set them
when the device is probed. Add this weak function in driver, that SoC codes
can implement the clock settings.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/net/fec_mxc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Joe Hershberger June 12, 2018, 6:27 p.m. UTC | #1
Hi Peng,

On Mon, May 28, 2018 at 7:25 AM, Peng Fan <peng.fan@nxp.com> wrote:
> From: Ye Li <ye.li@nxp.com>
>
> When the power domain driver is enabled, we need to enable clocks after power
> domain on. So the clock settings can't set in board_init, needs to set them
> when the device is probed. Add this weak function in driver, that SoC codes
> can implement the clock settings.

Can you not use clock infrastructure in DM to handle this. We don't
really want these direct calls out of drivers like this. Simon?

Thanks,
-Joe

> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> ---
>  drivers/net/fec_mxc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index b512a71c0c..d4e5a2a776 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1037,6 +1037,10 @@ struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
>         return bus;
>  }
>
> +__weak void init_clk_fec(int index)
> +{
> +}
> +
>  #ifndef CONFIG_DM_ETH
>  #ifdef CONFIG_PHYLIB
>  int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
> @@ -1154,6 +1158,7 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
>  #else
>         base_mii = addr;
>  #endif
> +       init_clk_fec(dev_id);
>         debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
>         bus = fec_get_miibus(base_mii, dev_id);
>         if (!bus)
> @@ -1253,6 +1258,8 @@ static int fecmxc_probe(struct udevice *dev)
>         uint32_t start;
>         int ret;
>
> +       init_clk_fec(dev->seq);
> +
>         ret = fec_alloc_descs(priv);
>         if (ret)
>                 return ret;
> --
> 2.14.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Simon Glass June 13, 2018, 1:26 a.m. UTC | #2
Hi,

On 12 June 2018 at 12:27, Joe Hershberger <joe.hershberger@ni.com> wrote:
>
> Hi Peng,
>
> On Mon, May 28, 2018 at 7:25 AM, Peng Fan <peng.fan@nxp.com> wrote:
> > From: Ye Li <ye.li@nxp.com>
> >
> > When the power domain driver is enabled, we need to enable clocks after power
> > domain on. So the clock settings can't set in board_init, needs to set them
> > when the device is probed. Add this weak function in driver, that SoC codes
> > can implement the clock settings.
>
> Can you not use clock infrastructure in DM to handle this. We don't
> really want these direct calls out of drivers like this. Simon?
>

Yes that is definitely bad.

Probably the easiest option is to add a clock driver.

Regards,
Simon
Peng Fan June 15, 2018, 6:46 a.m. UTC | #3
Hi Joe, Simon,

> -----Original Message-----
> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
> Sent: 2018年6月13日 9:26
> To: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Peng Fan <peng.fan@nxp.com>; Stefano Babic <sbabic@denx.de>; Fabio
> Estevam <fabio.estevam@nxp.com>; u-boot <u-boot@lists.denx.de>
> Subject: Re: [U-Boot] [PATCH 28/41] net: fec_mxc: Add the init_clk_fec function
> 
> Hi,
> 
> On 12 June 2018 at 12:27, Joe Hershberger <joe.hershberger@ni.com> wrote:
> >
> > Hi Peng,
> >
> > On Mon, May 28, 2018 at 7:25 AM, Peng Fan <peng.fan@nxp.com> wrote:
> > > From: Ye Li <ye.li@nxp.com>
> > >
> > > When the power domain driver is enabled, we need to enable clocks
> > > after power domain on. So the clock settings can't set in
> > > board_init, needs to set them when the device is probed. Add this
> > > weak function in driver, that SoC codes can implement the clock settings.
> >
> > Can you not use clock infrastructure in DM to handle this. We don't
> > really want these direct calls out of drivers like this. Simon?
> >
> 
> Yes that is definitely bad.
> 
> Probably the easiest option is to add a clock driver.

I'll give a try to add a clock DM driver.

Thanks,
Peng.

> 
> Regards,
> Simon
diff mbox series

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index b512a71c0c..d4e5a2a776 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1037,6 +1037,10 @@  struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
 	return bus;
 }
 
+__weak void init_clk_fec(int index)
+{
+}
+
 #ifndef CONFIG_DM_ETH
 #ifdef CONFIG_PHYLIB
 int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
@@ -1154,6 +1158,7 @@  int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
 #else
 	base_mii = addr;
 #endif
+	init_clk_fec(dev_id);
 	debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
 	bus = fec_get_miibus(base_mii, dev_id);
 	if (!bus)
@@ -1253,6 +1258,8 @@  static int fecmxc_probe(struct udevice *dev)
 	uint32_t start;
 	int ret;
 
+	init_clk_fec(dev->seq);
+
 	ret = fec_alloc_descs(priv);
 	if (ret)
 		return ret;