diff mbox series

net: fsl-mc: fixup DPC: add /board/ports node if missing

Message ID 1588079399-17832-1-git-send-email-razvanionut.cirjan@nxp.com
State Accepted
Commit d5b0af047a942b21ea86476e3931df28445b1ca4
Headers show
Series net: fsl-mc: fixup DPC: add /board/ports node if missing | expand

Commit Message

Razvan Ionut Cirjan April 28, 2020, 1:09 p.m. UTC
The DPC fixup for MAC address and enet_if is not made if
/board/ports node is missing in DPC file.
Add /board/ports or /ports nodes if them are missing.

Signed-off-by: Razvan Ionut Cirjan <razvanionut.cirjan at nxp.com>
---
 drivers/net/fsl-mc/mc.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

Ioana Ciornei April 30, 2020, 12:46 p.m. UTC | #1
> Subject: [PATCH] net: fsl-mc: fixup DPC: add /board/ports node if missing
> 
> The DPC fixup for MAC address and enet_if is not made if /board/ports node is
> missing in DPC file.
> Add /board/ports or /ports nodes if them are missing.
> 
> Signed-off-by: Razvan Ionut Cirjan <razvanionut.cirjan at nxp.com>

Reviewed-by: Ioana Ciornei <Ioana.ciornei at nxp.com>

> ---
>  drivers/net/fsl-mc/mc.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index
> 07bbcc9b2311..a9bccdd1b04e 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -1,7 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
>   * Copyright 2014 Freescale Semiconductor, Inc.
> - * Copyright 2017-2018 NXP
> + * Copyright 2017-2018, 2020 NXP
>   */
>  #include <common.h>
>  #include <command.h>
> @@ -439,8 +439,19 @@ static int mc_fixup_dpc(u64 dpc_addr)
> 
>  	/* fixup MAC addresses for dpmac ports */
>  	nodeoffset = fdt_path_offset(blob, "/board_info/ports");
> -	if (nodeoffset < 0)
> -		goto out;
> +	if (nodeoffset < 0) {
> +		err = fdt_increase_size(blob, 512);
> +		if (err) {
> +			printf("fdt_increase_size: err=%s\n",
> +			       fdt_strerror(err));
> +			goto out;
> +		}
> +		nodeoffset = fdt_path_offset(blob, "/board_info");
> +		if (nodeoffset < 0)
> +			nodeoffset = fdt_add_subnode(blob, 0, "board_info");
> +
> +		nodeoffset = fdt_add_subnode(blob, nodeoffset, "ports");
> +	}
> 
>  	err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPC);
> 
> --
> 1.9.1
Priyanka Jain (OSS) May 20, 2020, 10:58 a.m. UTC | #2
>-----Original Message-----
>From: U-Boot <u-boot-bounces at lists.denx.de> On Behalf Of Razvan Ionut
>Cirjan
>Sent: Tuesday, April 28, 2020 6:40 PM
>To: Priyanka Jain <priyanka.jain at nxp.com>; joe.hershberger at ni.com; u-
>boot at lists.denx.de
>Cc: Ioana Ciornei <ioana.ciornei at nxp.com>; Florin Laurentiu Chiculita
><florinlaurentiu.chiculita at nxp.com>; Cristi Sovaiala
><cristian.sovaiala at nxp.com>; Razvan Ionut Cirjan
><razvanionut.cirjan at nxp.com>
>Subject: [PATCH] net: fsl-mc: fixup DPC: add /board/ports node if missing
>
>The DPC fixup for MAC address and enet_if is not made if /board/ports node
>is missing in DPC file.
>Add /board/ports or /ports nodes if them are missing.
>
>Signed-off-by: Razvan Ionut Cirjan <razvanionut.cirjan at nxp.com>
>---
Applied to u-boot-fsl-qoriq. Awaiting upstream.

Thanks
Priyanka
diff mbox series

Patch

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 07bbcc9b2311..a9bccdd1b04e 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -1,7 +1,7 @@ 
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
- * Copyright 2017-2018 NXP
+ * Copyright 2017-2018, 2020 NXP
  */
 #include <common.h>
 #include <command.h>
@@ -439,8 +439,19 @@  static int mc_fixup_dpc(u64 dpc_addr)
 
 	/* fixup MAC addresses for dpmac ports */
 	nodeoffset = fdt_path_offset(blob, "/board_info/ports");
-	if (nodeoffset < 0)
-		goto out;
+	if (nodeoffset < 0) {
+		err = fdt_increase_size(blob, 512);
+		if (err) {
+			printf("fdt_increase_size: err=%s\n",
+			       fdt_strerror(err));
+			goto out;
+		}
+		nodeoffset = fdt_path_offset(blob, "/board_info");
+		if (nodeoffset < 0)
+			nodeoffset = fdt_add_subnode(blob, 0, "board_info");
+
+		nodeoffset = fdt_add_subnode(blob, nodeoffset, "ports");
+	}
 
 	err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPC);