All of lore.kernel.org
 help / color / mirror / Atom feed
From: Padmarao Begari <padmarao.begari@microchip.com>
To: u-boot@lists.denx.de
Subject: [PATCH v8 3/7] net: macb: Add phy address to read it from device tree
Date: Tue, 12 Jan 2021 13:22:31 +0530	[thread overview]
Message-ID: <20210112075235.7692-4-padmarao.begari@microchip.com> (raw)
In-Reply-To: <20210112075235.7692-1-padmarao.begari@microchip.com>

Read phy address from device tree and use it to find the phy device
if not found then search in the range of 0 to 31.

Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Tested-by: Bin Meng <bin.meng@windriver.com>
---
 drivers/net/macb.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0c2ac811fb..2225b33ff6 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -531,6 +531,12 @@ static int macb_phy_find(struct macb_device *macb, const char *name)
 	int i;
 	u16 phy_id;
 
+	phy_id = macb_mdio_read(macb, macb->phy_addr, MII_PHYSID1);
+	if (phy_id != 0xffff) {
+		printf("%s: PHY present at %d\n", name, macb->phy_addr);
+		return 0;
+	}
+
 	/* Search for PHY... */
 	for (i = 0; i < 32; i++) {
 		macb->phy_addr = i;
@@ -1311,6 +1317,7 @@ static int macb_eth_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct macb_device *macb = dev_get_priv(dev);
+	struct ofnode_phandle_args phandle_args;
 	const char *phy_mode;
 	int ret;
 
@@ -1323,6 +1330,12 @@ static int macb_eth_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
+	/* Read phyaddr from DT */
+	if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+					&phandle_args))
+		macb->phy_addr = ofnode_read_u32_default(phandle_args.node,
+							 "reg", -1);
+
 	macb->regs = (void *)pdata->iobase;
 
 	macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678);
-- 
2.17.1

  parent reply	other threads:[~2021-01-12  7:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  7:52 [PATCH v8 0/7] Microchip PolarFire SoC support Padmarao Begari
2021-01-12  7:52 ` [PATCH v8 1/7] riscv: Add DMA 64-bit address support Padmarao Begari
2021-01-12  7:52 ` [PATCH v8 2/7] net: macb: Add DMA 64-bit address support for macb Padmarao Begari
2021-01-12  7:52 ` Padmarao Begari [this message]
2021-01-12  7:52 ` [PATCH v8 4/7] clk: Add Microchip PolarFire SoC clock driver Padmarao Begari
2021-01-12  7:52 ` [PATCH v8 5/7] riscv: dts: Add device tree for Microchip Icicle Kit Padmarao Begari
2021-01-12  7:52 ` [PATCH v8 6/7] riscv: Add Microchip MPFS Icicle Kit support Padmarao Begari
2021-01-12  7:52 ` [PATCH v8 7/7] doc: board: Add Microchip MPFS Icicle Kit doc Padmarao Begari

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=20210112075235.7692-4-padmarao.begari@microchip.com \
    --to=padmarao.begari@microchip.com \
    --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.