[PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC

Priyanka Jain priyanka.jain at nxp.com
Thu Jun 17 08:39:51 CEST 2021



>-----Original Message-----
>From: Ioana Ciornei <ioana.ciornei at nxp.com>
>Sent: Monday, April 26, 2021 6:31 PM
>To: Priyanka Jain <priyanka.jain at nxp.com>
>Cc: u-boot at lists.denx.de; Florin Laurentiu Chiculita
><florinlaurentiu.chiculita at nxp.com>; Wasim Khan (OSS)
><wasim.khan at oss.nxp.com>; Ioana Ciornei <ioana.ciornei at nxp.com>
>Subject: [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC
>
>From: Florin Chiculita <florinlaurentiu.chiculita at 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 at nxp.com>
>Signed-off-by: Ioana Ciornei <ioana.ciornei at 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;
>+
>+	/* DPMACs 3,4 have their Aquantia PHYs at new addresses */
>+	ret = fdt_update_phy_addr(fdt, 3, AQR113C_PHY_ADDR1);
>+	if (ret)
>+		return ret;
>+
>+	ret = fdt_update_phy_addr(fdt, 4, AQR113C_PHY_ADDR2);
>+	if (ret)
>+		return ret;
>+
>+	/* There is no PHY for the DPMAC2, so remove the phy-handle */
>+	return fdt_delete_phy_handle(fdt, 2);
>+}
>+
> int fdt_fixup_board_phy(void *fdt)
> {
> 	int mdio_offset;
>diff --git a/board/freescale/lx2160a/lx2160a.h
>b/board/freescale/lx2160a/lx2160a.h
>index cf56cefb45a3..e9b318339af3 100644
>--- a/board/freescale/lx2160a/lx2160a.h
>+++ b/board/freescale/lx2160a/lx2160a.h
>@@ -60,6 +60,7 @@
>
> #if CONFIG_IS_ENABLED(TARGET_LX2160ARDB)
> u8 get_board_rev(void);
>+int fdt_fixup_board_phy_revc(void *fdt);
> #endif
>
> #endif /* __LX2160_H */
>--
>2.17.1


Kindly ensure build for all lx2160a platforms, fix build issues like below  
2021-06-16T15:10:30.1450001Z    aarch64:  +   lx2162aqds_tfa
2021-06-16T15:10:30.1450811Z +board/freescale/lx2160a/lx2160a.c: In function 'board_fix_fdt':
2021-06-16T15:10:30.1451830Z +board/freescale/lx2160a/lx2160a.c:196:3: error: implicit declaration of function 'fdt_fixup_board_phy_revc'; did you mean 'fdt_fixup_board_enet'? [-Werror=implicit-function-declaration]
2021-06-16T15:10:30.1452462Z +  196 |   fdt_fixup_board_phy_revc(fdt);
2021-06-16T15:10:30.1452800Z +      |   ^~~~~~~~~~~~~~~~~~~~~~~~
2021-06-16T15:10:30.1453131Z +      |   fdt_fixup_board_enet
2021-06-16T15:10:30.1453705Z +board/freescale/lx2160a/lx2160a.c: In function 'ft_board_setup':
2021-06-16T15:10:30.1454548Z +board/freescale/lx2160a/lx2160a.c:922:6: error: implicit declaration of function 'get_board_rev' [-Werror=implicit-function-declaration]
2021-06-16T15:10:30.1455235Z +  922 |  if (get_board_rev() >= 'C')
2021-06-16T15:10:30.1455569Z +      |      ^~~~~~~~~~~~~
2021-06-16T15:10:30.1456345Z +board/freescale/lx2160a/lx2160a.c:923:3: error: implicit declaration of function 'fdt_fixup_i2c_thermal_node' [-Werror=implicit-function-declaration]
2021-06-16T15:10:30.1456912Z +  923 |   fdt_fixup_i2c_thermal_node(blob);
2021-06-16T15:10:30.1457254Z +      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
2021-06-16T15:10:30.1457608Z +cc1: all warnings being treated as errors
2021-06-16T15:10:30.1457987Z +make[2]: *** [board/freescale/lx2160a/lx2160a.o] Error 1
2021-06-16T15:10:30.1458374Z +make[1]: *** [board/freescale/lx2160a] Error 2
2021-06-16T15:10:30.1458878Z +make: *** [sub-make] Error 2
2021-06-16T15:10:30.1459042Z 
2021-06-16T15:10:49.8594009Z     2    0    3 /8       -3      0:01:07  : lx2162aqds_tfa
2021-06-16T15:10:49.8606363Z                                                            

https://dev.azure.com/u-boot/a1096300-2999-4ec4-a21a-4c22075e3771/_apis/build/builds/2383/logs/415


Regards
Priyanka




More information about the U-Boot mailing list