[U-Boot] [PATCH v2 1/3] Enable FEC driver to retrieve PHY address from device tree

Lukasz Majewski lukma at denx.de
Sat Nov 24 12:25:38 UTC 2018


On Fri, 23 Nov 2018 16:47:30 +0000
Martyn Welch <martyn at welchs.me.uk> wrote:

> Currently if we have more than one phy on the MDIO bus, we do not
> have a good mechanism for determining which should be used at
> runtime. Enable the FEC driver to determine the address for the PHY
> from the device tree.
> 
> Signed-off-by: Martyn Welch <martyn.welch at collabora.com>
> 
> ---
> 
> Changes in v2:
> - New in v2
> 
>  drivers/net/fec_mxc.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 99c5c649a0..425f6197cb 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1264,11 +1264,32 @@ static const struct eth_ops fecmxc_ops = {
>  	.read_rom_hwaddr	= fecmxc_read_rom_hwaddr,
>  };
>  
> +static int device_get_phy_addr(struct udevice *dev)
> +{
> +	struct ofnode_phandle_args phandle_args;
> +	int reg;
> +
> +	if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> +				       &phandle_args)) {
> +		debug("Failed to find phy-handle");
> +		return -ENODEV;
> +	}
> +
> +	reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
> +
> +	return reg;
> +}
> +
>  static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
>  {
>  	struct phy_device *phydev;
> +	int addr;
>  	int mask = 0xffffffff;
>  
> +	addr = device_get_phy_addr(dev);
> +	if (addr >= 0)
> +		mask = 1 << addr;
> +
>  #ifdef CONFIG_FEC_MXC_PHYADDR
>  	mask = 1 << CONFIG_FEC_MXC_PHYADDR;
>  #endif

I suppose that the above code is to move the CONFIG_FEC_MXC_PHYADDR to
DTS.

I do agree for this,

Reviewed-by: Lukasz Majewski <lukma at denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181124/864121e0/attachment.sig>


More information about the U-Boot mailing list