[U-Boot] [PATCH 05/10] net: designware: Add a post-started hook
Bin Meng
bmeng.cn at gmail.com
Thu Oct 1 13:27:01 CEST 2015
Hi Sjoerd,
On Thu, Oct 1, 2015 at 5:48 PM, Sjoerd Simons
<sjoerd.simons at collabora.co.uk> wrote:
> Add the ability for e.g. drivers subclassing to register a function to
> be called after ethernet initialisation. This is useful if e.g. the
> driver needs to change configuration based on the negotiated speed.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons at collabora.co.uk>
> ---
>
> drivers/net/designware.c | 11 ++++++++++-
> drivers/net/designware.h | 4 ++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/designware.c b/drivers/net/designware.c
> index 0b7adc9..da27041 100644
> --- a/drivers/net/designware.c
> +++ b/drivers/net/designware.c
> @@ -564,8 +564,17 @@ int designware_initialize(ulong base_addr, u32 interface)
> static int designware_eth_start(struct udevice *dev)
> {
> struct eth_pdata *pdata = dev_get_platdata(dev);
> + struct dw_eth_dev *priv = dev_get_priv(dev);
> + int ret;
>
> - return _dw_eth_init(dev->priv, pdata->enetaddr);
> + ret = _dw_eth_init(priv, pdata->enetaddr);
> + if (ret)
> + return ret;
> +
> + if (priv->started)
> + ret = priv->started(dev);
It looks to me a better approach to set up the MAC clock is to insert
the hook in dw_adjust_link(). And see below ..
> +
> + return ret;
> }
>
> static int designware_eth_send(struct udevice *dev, void *packet, int length)
> diff --git a/drivers/net/designware.h b/drivers/net/designware.h
> index 47e727b..b45599b 100644
> --- a/drivers/net/designware.h
> +++ b/drivers/net/designware.h
> @@ -236,6 +236,10 @@ struct dw_eth_dev {
> #endif
> struct phy_device *phydev;
> struct mii_dev *bus;
> +
> +#ifdef CONFIG_DM_ETH
> + int (*started)(struct udevice *dev);
> +#endif
We can name this as something like (*clk_set) to be clearer.
(*started) is not that intuitive.
> };
>
> #ifdef CONFIG_DM_ETH
> --
Regards,
Bin
More information about the U-Boot
mailing list