All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martyn Welch <martyn@welchs.me.uk>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/3] Enable FEC driver to retrieve PHY address from device tree
Date: Fri, 23 Nov 2018 16:47:30 +0000	[thread overview]
Message-ID: <20181123164732.14161-1-martyn.welch@collabora.com> (raw)

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@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
-- 
2.19.1

             reply	other threads:[~2018-11-23 16:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23 16:47 Martyn Welch [this message]
2018-11-23 16:47 ` [U-Boot] [PATCH v2 2/3] Only attempt to build USB driver model in SPL when required Martyn Welch
2018-11-24 18:25   ` Marek Vasut
2018-11-26 10:20     ` Martyn Welch
2018-11-26 10:22       ` Marek Vasut
2018-11-26 15:23         ` Simon Goldschmidt
2018-11-26 15:27           ` Marek Vasut
2018-11-26 16:16         ` Martyn Welch
2018-11-26 18:21           ` Marek Vasut
2018-11-23 16:47 ` [U-Boot] [PATCH v2 3/3] imx: Add PHYTEC phyBOARD-i.MX6UL-Segin Martyn Welch
2018-11-27 14:15   ` Wadim Egorov
2018-12-03 16:34     ` Martyn Welch
2018-11-27 17:34   ` Marek Vasut
2018-12-03 16:35     ` Martyn Welch
2018-11-24 12:25 ` [U-Boot] [PATCH v2 1/3] Enable FEC driver to retrieve PHY address from device tree Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181123164732.14161-1-martyn.welch@collabora.com \
    --to=martyn@welchs.me.uk \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.