* [PATCH v2 0/4] board: fsl: lx2160ardb: add networking support for RevC
@ 2021-04-26 13:01 Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 1/4] board: fsl: lx2160ardb: add api for obtaining board revision Ioana Ciornei
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Ioana Ciornei @ 2021-04-26 13:01 UTC (permalink / raw)
To: u-boot
This patch set adds networking support for the LX2160A-RDB revC board.
The main difference is that the 10G Aquantia PHYs are at different MDIO
bus addresses. To address this, the u-boot's DTS (in case of DM_ETH) and
the kernel's DTS need to undergo a fixup.
This patch set applies cleanly on top of the following, yet unnaccepted,
patch:
https://patchwork.ozlabs.org/project/uboot/patch/20210417180332.1164345-1-wasim.khan at oss.nxp.com/
Changes in v2:
- in 1/4: trigger the i2c node fixup if the board rev is 'C' or greater
Florin Chiculita (3):
board: fsl: lx2160ardb: add api for obtaining board revision
board: fsl: lx2160ardb: add support for lx2160ardb revC board
board: fsl: lx2160ardb: add dts fixup function for RevC
Ioana Ciornei (1):
board: fsl: lx2160ardb: add dts fixup for RevC
board/freescale/lx2160a/eth_lx2160ardb.c | 160 ++++++++++++++++++++++-
board/freescale/lx2160a/lx2160a.c | 21 ++-
board/freescale/lx2160a/lx2160a.h | 7 +-
include/configs/lx2160ardb.h | 5 +-
4 files changed, 186 insertions(+), 7 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/4] board: fsl: lx2160ardb: add api for obtaining board revision
2021-04-26 13:01 [PATCH v2 0/4] board: fsl: lx2160ardb: add networking support for RevC Ioana Ciornei
@ 2021-04-26 13:01 ` Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 2/4] board: fsl: lx2160ardb: add support for lx2160ardb revC board Ioana Ciornei
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Ioana Ciornei @ 2021-04-26 13:01 UTC (permalink / raw)
To: u-boot
From: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
Add new API for obtaining board revision and trigger the i2c node
fixup with this new API.
Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
board/freescale/lx2160a/lx2160a.c | 13 ++++++++++---
board/freescale/lx2160a/lx2160a.h | 6 +++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index 8f75b48f956b..9f1a6979258c 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -564,6 +564,15 @@ int config_board_mux(void)
}
#endif
+#if CONFIG_IS_ENABLED(TARGET_LX2160ARDB)
+u8 get_board_rev(void)
+{
+ u8 board_rev = (QIXIS_READ(arch) & 0xf) - 1 + 'A';
+
+ return board_rev;
+}
+#endif
+
unsigned long get_board_sys_clk(void)
{
#if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS)
@@ -847,7 +856,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
u64 mc_memory_base = 0;
u64 mc_memory_size = 0;
u16 total_memory_banks;
- u8 board_rev;
ft_cpu_setup(blob, bd);
@@ -903,8 +911,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
fdt_fixup_icid(blob);
if (IS_ENABLED(CONFIG_TARGET_LX2160ARDB)) {
- board_rev = (QIXIS_READ(arch) & 0xf) - 1 + 'A';
- if (board_rev == 'C')
+ if (get_board_rev() >= 'C')
fdt_fixup_i2c_thermal_node(blob);
}
diff --git a/board/freescale/lx2160a/lx2160a.h b/board/freescale/lx2160a/lx2160a.h
index 52b020765dc6..cf56cefb45a3 100644
--- a/board/freescale/lx2160a/lx2160a.h
+++ b/board/freescale/lx2160a/lx2160a.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
- * Copyright 2020 NXP
+ * Copyright 2020-2021 NXP
*/
#ifndef __LX2160_H
@@ -58,4 +58,8 @@
#endif
#endif
+#if CONFIG_IS_ENABLED(TARGET_LX2160ARDB)
+u8 get_board_rev(void);
+#endif
+
#endif /* __LX2160_H */
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] board: fsl: lx2160ardb: add support for lx2160ardb revC board
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 ` Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC Ioana Ciornei
2021-04-26 13:01 ` [PATCH v2 4/4] board: fsl: lx2160ardb: add dts fixup " Ioana Ciornei
3 siblings, 0 replies; 7+ messages in thread
From: Ioana Ciornei @ 2021-04-26 13:01 UTC (permalink / raw)
To: u-boot
From: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
New RevC LX2160A-RDB board doesn't have any 40G PHY and the 10G Aquantia
PHYs have different MDIO bus addresses, thus a different init is
required.
This patch adds support for the non-DM_ETH use of the LX2160ARDB RevC
board.
Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
board/freescale/lx2160a/eth_lx2160ardb.c | 52 +++++++++++++++++++++++-
include/configs/lx2160ardb.h | 5 ++-
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/board/freescale/lx2160a/eth_lx2160ardb.c b/board/freescale/lx2160a/eth_lx2160ardb.c
index 15cbc58d59a7..8fd2a501de16 100644
--- a/board/freescale/lx2160a/eth_lx2160ardb.c
+++ b/board/freescale/lx2160a/eth_lx2160ardb.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright 2018, 2020 NXP
+ * Copyright 2018-2021 NXP
*
*/
@@ -41,6 +41,49 @@ static bool get_inphi_phy_id(struct mii_dev *bus, int addr, int devad)
return false;
}
+int setup_eth_rev_c(u32 srds_p)
+{
+ struct mii_dev *bus;
+ int i;
+
+ /* difference between SerDes1 protocols 18/19 is 4x10G vs. 40G */
+ switch (srds_p) {
+ case 19:
+ wriop_init_dpmac_enet_if(WRIOP1_DPMAC2,
+ PHY_INTERFACE_MODE_XLAUI);
+ break;
+ case 18:
+ for (i = WRIOP1_DPMAC7; i <= WRIOP1_DPMAC10; i++)
+ wriop_init_dpmac_enet_if(i, PHY_INTERFACE_MODE_XFI);
+ break;
+ default:
+ printf("SerDes1 protocol 0x%x is not supported on LX2160ARDB\n",
+ srds_p);
+ return -1;
+ }
+
+ /* common interfaces for SerDes1 protocols 18 and 19 initialization */
+ wriop_set_phy_address(WRIOP1_DPMAC3, 0, AQR113C_PHY_ADDR1);
+ wriop_set_phy_address(WRIOP1_DPMAC4, 0, AQR113C_PHY_ADDR2);
+ wriop_set_phy_address(WRIOP1_DPMAC5, 0, INPHI_PHY_ADDR1);
+ wriop_set_phy_address(WRIOP1_DPMAC6, 0, INPHI_PHY_ADDR1);
+ wriop_set_phy_address(WRIOP1_DPMAC17, 0, RGMII_PHY_ADDR1);
+ wriop_set_phy_address(WRIOP1_DPMAC18, 0, RGMII_PHY_ADDR2);
+
+ /* assign DPMAC/PHY to MDIO bus */
+ bus = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO1_NAME);
+ wriop_set_mdio(WRIOP1_DPMAC3, bus);
+ wriop_set_mdio(WRIOP1_DPMAC4, bus);
+ wriop_set_mdio(WRIOP1_DPMAC17, bus);
+ wriop_set_mdio(WRIOP1_DPMAC18, bus);
+
+ bus = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO2_NAME);
+ wriop_set_mdio(WRIOP1_DPMAC5, bus);
+ wriop_set_mdio(WRIOP1_DPMAC6, bus);
+
+ return 0;
+}
+
int board_eth_init(struct bd_info *bis)
{
#if defined(CONFIG_FSL_MC_ENET)
@@ -70,6 +113,13 @@ int board_eth_init(struct bd_info *bis)
fm_memac_mdio_init(bis, &mdio_info);
dev = miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO2_NAME);
+
+ /* new LX2160A-RDB2 revC board uses phy-less 25G/40G interfaces */
+ if (get_board_rev() == 'C') {
+ setup_eth_rev_c(srds_s1);
+ goto next;
+ }
+
switch (srds_s1) {
case 19:
wriop_set_phy_address(WRIOP1_DPMAC2, 0,
diff --git a/include/configs/lx2160ardb.h b/include/configs/lx2160ardb.h
index 097f1224c90f..a7e9753dc174 100644
--- a/include/configs/lx2160ardb.h
+++ b/include/configs/lx2160ardb.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
- * Copyright 2018,2020 NXP
+ * Copyright 2018-2021 NXP
*/
#ifndef __LX2_RDB_H
@@ -21,6 +21,9 @@
#if defined(CONFIG_FSL_MC_ENET)
#define CONFIG_MII
#define CONFIG_ETHPRIME "DPMAC1@xgmii"
+
+#define AQR113C_PHY_ADDR1 0x0
+#define AQR113C_PHY_ADDR2 0x08
#endif
/* EMC2305 */
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC
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 ` Ioana Ciornei
2021-05-07 9:04 ` Priyanka Jain
2021-06-17 6:39 ` Priyanka Jain
2021-04-26 13:01 ` [PATCH v2 4/4] board: fsl: lx2160ardb: add dts fixup " Ioana Ciornei
3 siblings, 2 replies; 7+ messages in thread
From: Ioana Ciornei @ 2021-04-26 13:01 UTC (permalink / raw)
To: u-boot
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;
+
+ /* DPMACs 3,4 have their Aquantia PHYs@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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] board: fsl: lx2160ardb: add dts fixup for RevC
2021-04-26 13:01 [PATCH v2 0/4] board: fsl: lx2160ardb: add networking support for RevC Ioana Ciornei
` (2 preceding siblings ...)
2021-04-26 13:01 ` [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC Ioana Ciornei
@ 2021-04-26 13:01 ` Ioana Ciornei
3 siblings, 0 replies; 7+ messages in thread
From: Ioana Ciornei @ 2021-04-26 13:01 UTC (permalink / raw)
To: u-boot
Use the newly fdt_fixup_board_phy_revc() function introduced to updated
both kernel's DTS and u-boot's DTS in case we are running with DM_ETH.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
---
board/freescale/lx2160a/eth_lx2160ardb.c | 2 +-
board/freescale/lx2160a/lx2160a.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/board/freescale/lx2160a/eth_lx2160ardb.c b/board/freescale/lx2160a/eth_lx2160ardb.c
index c693ad9a0a4a..30a3af9f4737 100644
--- a/board/freescale/lx2160a/eth_lx2160ardb.c
+++ b/board/freescale/lx2160a/eth_lx2160ardb.c
@@ -366,5 +366,5 @@ int fdt_fixup_board_phy(void *fdt)
}
}
- return ret;
+ return fdt_fixup_board_phy_revc(fdt);
}
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index 9f1a6979258c..0736735e6f0d 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -189,6 +189,11 @@ int board_fix_fdt(void *fdt)
"fsl,lx2160a-pcie");
}
+ /* Fixup u-boot's DTS in case this is a revC board and
+ * we're using DM_ETH.
+ */
+ if (IS_ENABLED(CONFIG_TARGET_LX2160ARDB) && IS_ENABLED(CONFIG_DM_ETH))
+ fdt_fixup_board_phy_revc(fdt);
return 0;
}
#endif
@@ -723,6 +728,9 @@ void fdt_fixup_board_enet(void *fdt)
fdt_status_okay(fdt, offset);
#ifndef CONFIG_DM_ETH
fdt_fixup_board_phy(fdt);
+#else
+ if (IS_ENABLED(CONFIG_TARGET_LX2160ARDB))
+ fdt_fixup_board_phy_revc(fdt);
#endif
} else {
fdt_status_fail(fdt, offset);
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC
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
2021-06-17 6:39 ` Priyanka Jain
1 sibling, 0 replies; 7+ messages in thread
From: Priyanka Jain @ 2021-05-07 9:04 UTC (permalink / raw)
To: u-boot
>-----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
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v2 3/4] board: fsl: lx2160ardb: add dts fixup function for RevC
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
@ 2021-06-17 6:39 ` Priyanka Jain
1 sibling, 0 replies; 7+ messages in thread
From: Priyanka Jain @ 2021-06-17 6:39 UTC (permalink / raw)
To: Ioana Ciornei; +Cc: u-boot, Florin Laurentiu Chiculita, Wasim Khan (OSS)
>-----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@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@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@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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-06-17 6:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-06-17 6:39 ` Priyanka Jain
2021-04-26 13:01 ` [PATCH v2 4/4] board: fsl: lx2160ardb: add dts fixup " Ioana Ciornei
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.