All of lore.kernel.org
 help / color / mirror / Atom feed
From: Priyanka Jain <priyanka.jain@nxp.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC
Date: Fri, 7 May 2021 09:04:45 +0000	[thread overview]
Message-ID: <AM6PR04MB51446A8236A746A024E80121E6579@AM6PR04MB5144.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20210426130113.6514-4-ioana.ciornei@nxp.com>



>-----Original Message-----
>From: Ioana Ciornei <ioana.ciornei@nxp.com>
>Sent: Monday, April 26, 2021 6:31 PM
>To: Priyanka Jain <priyanka.jain@nxp.com>
>Cc: u-boot at lists.denx.de; Florin Laurentiu Chiculita
><florinlaurentiu.chiculita@nxp.com>; Wasim Khan (OSS)
><wasim.khan@oss.nxp.com>; Ioana Ciornei <ioana.ciornei@nxp.com>
>Subject: [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC
>
>From: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
>
>Since the new RevC LX2160A-RDB board has its 10G Aquantia PHYs at different
>MDIO bus addresses, we must update both the kernel DTS and u-boot's DTS (in
>case of DM_ETH) in case the board is indeed RevC.
>Use the newly introduced get_board_rev() function to trigger a fixup of the kernel
>DTS to properly match the actual PHY addresses.
>All this is encapsulated in the fdt_fixup_board_phy_revc() function which will be
>used in the next patch.
>
>Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
>Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
>---
> board/freescale/lx2160a/eth_lx2160ardb.c | 106 +++++++++++++++++++++++
> board/freescale/lx2160a/lx2160a.h        |   1 +
> 2 files changed, 107 insertions(+)
>
>diff --git a/board/freescale/lx2160a/eth_lx2160ardb.c
>b/board/freescale/lx2160a/eth_lx2160ardb.c
>index 8fd2a501de16..c693ad9a0a4a 100644
>--- a/board/freescale/lx2160a/eth_lx2160ardb.c
>+++ b/board/freescale/lx2160a/eth_lx2160ardb.c
>@@ -231,6 +231,112 @@ void reset_phy(void)  }  #endif /*
>CONFIG_RESET_PHY_R */
>
>+static int fdt_get_dpmac_node(void *fdt, int dpmac_id) {
>+	char dpmac_str[] = "dpmacs at 00";
>+	int offset, dpmacs_offset;
>+
>+	/* get the dpmac offset */
>+	dpmacs_offset = fdt_path_offset(fdt, "/soc/fsl-mc/dpmacs");
>+	if (dpmacs_offset < 0)
>+		dpmacs_offset = fdt_path_offset(fdt, "/fsl-mc/dpmacs");
>+
>+	if (dpmacs_offset < 0) {
>+		printf("dpmacs node not found in device tree\n");
>+		return dpmacs_offset;
>+	}
>+
>+	sprintf(dpmac_str, "dpmac@%x", dpmac_id);
>+	offset = fdt_subnode_offset(fdt, dpmacs_offset, dpmac_str);
>+	if (offset < 0) {
>+		sprintf(dpmac_str, "ethernet@%x", dpmac_id);
>+		offset = fdt_subnode_offset(fdt, dpmacs_offset, dpmac_str);
>+		if (offset < 0) {
>+			printf("dpmac@%x/ethernet@%x node not found in
>device tree\n",
>+			       dpmac_id, dpmac_id);
>+			return offset;
>+		}
>+	}
>+
>+	return offset;
>+}
>+
>+static int fdt_update_phy_addr(void *fdt, int dpmac_id, int phy_addr) {
>+	char dpmac_str[] = "dpmacs at 00";
>+	const u32 *phyhandle;
>+	int offset;
>+	int err;
>+
>+	/* get the dpmac offset */
>+	offset = fdt_get_dpmac_node(fdt, dpmac_id);
>+	if (offset < 0)
>+		return offset;
>+
>+	/* get dpmac phy-handle */
>+	sprintf(dpmac_str, "dpmac@%x", dpmac_id);
>+	phyhandle = (u32 *)fdt_getprop(fdt, offset, "phy-handle", NULL);
>+	if (!phyhandle) {
>+		printf("%s node not found in device tree\n", dpmac_str);
>+		return offset;
>+	}
>+
>+	offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*phyhandle));
>+	if (offset < 0) {
>+		printf("Could not get the ph node offset for dpmac %d\n",
>+		       dpmac_id);
>+		return offset;
>+	}
>+
>+	phy_addr = cpu_to_fdt32(phy_addr);
>+	err = fdt_setprop(fdt, offset, "reg", &phy_addr, sizeof(phy_addr));
>+	if (err < 0) {
>+		printf("Could not set phy node's reg for dpmac %d: %s.\n",
>+		       dpmac_id, fdt_strerror(err));
>+		return err;
>+	}
>+
>+	return 0;
>+}
>+
>+static int fdt_delete_phy_handle(void *fdt, int dpmac_id) {
>+	const u32 *phyhandle;
>+	int offset;
>+
>+	/* get the dpmac offset */
>+	offset = fdt_get_dpmac_node(fdt, dpmac_id);
>+	if (offset < 0)
>+		return offset;
>+
>+	/* verify if the node has a phy-handle */
>+	phyhandle = (u32 *)fdt_getprop(fdt, offset, "phy-handle", NULL);
>+	if (!phyhandle)
>+		return 0;
>+
>+	return fdt_delprop(fdt, offset, "phy-handle"); }
>+
>+int fdt_fixup_board_phy_revc(void *fdt) {
>+	int ret;
>+
>+	if (get_board_rev() != 'C')
>+		return 0;

Do we want to check for < 'C' version or != here?
Is fdt_fixup_board_phy_revc() rquired only for Rev C version or >= Rev C?

Regards
Priyanka

  reply	other threads:[~2021-05-07  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 13:01 [PATCH v2 0/4] board: fsl: lx2160ardb: add networking support for RevC Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 1/4] board: fsl: lx2160ardb: add api for obtaining board revision Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 2/4] board: fsl: lx2160ardb: add support for lx2160ardb revC board Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC Ioana Ciornei
2021-05-07  9:04   ` Priyanka Jain [this message]
2021-06-17  6:39   ` Priyanka Jain
2021-04-26 13:01 ` [PATCH v2 4/4] board: fsl: lx2160ardb: add dts fixup " Ioana Ciornei

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=AM6PR04MB51446A8236A746A024E80121E6579@AM6PR04MB5144.eurprd04.prod.outlook.com \
    --to=priyanka.jain@nxp.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.