[U-Boot] [PATCH] board: fsl: lx2160a: implement board_fix_fdt

lx2 rev2 requires some fixups to be applied to fdt before relocation. Implement the same.
Signed-off-by: Pankaj Bansal pankaj.bansal@nxp.com --- board/freescale/lx2160a/lx2160a.c | 69 +++++++++++++++++++++++++++++ configs/lx2160aqds_tfa_defconfig | 1 + configs/lx2160ardb_tfa_defconfig | 1 + 3 files changed, 71 insertions(+)
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index b763f6db0f..3661eba672 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -20,6 +20,8 @@ #include <efi_loader.h> #include <asm/arch/mmu.h> #include <hwconfig.h> +#include <asm/arch/clock.h> +#include <asm/arch/config.h> #include <asm/arch/fsl_serdes.h> #include <asm/arch/soc.h> #include "../common/qixis.h" @@ -120,6 +122,73 @@ int board_early_init_f(void) return 0; }
+#ifdef CONFIG_OF_BOARD_FIXUP +int board_fix_fdt(void *fdt) +{ + char *reg_name, *old_str, *new_str; + const char *reg_names; + int names_len, old_str_len, new_str_len, remaining_str_len; + struct str_map { + char *old_str; + char *new_str; + } reg_names_map[] = { + { "ccsr", "dbi" }, + { "pf_ctrl", "ctrl" } + }; + int off = -1, i; + + if (IS_SVR_REV(get_svr(), 1, 0)) + return 0; + + off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie"); + while (off != -FDT_ERR_NOTFOUND) { + fdt_setprop(fdt, off, "compatible", "fsl,ls-pcie", + strlen("fsl,ls-pcie") + 1); + + reg_names = fdt_getprop(fdt, off, "reg-names", &names_len); + if (!reg_names) + continue; + + reg_name = (char *)reg_names; + remaining_str_len = names_len - (reg_name - reg_names); + i = 0; + while ((i < ARRAY_SIZE(reg_names_map)) && remaining_str_len) { + old_str = reg_names_map[i].old_str; + new_str = reg_names_map[i].new_str; + old_str_len = strlen(old_str); + new_str_len = strlen(new_str); + if (memcmp(reg_name, old_str, old_str_len) == 0) { + /* first only leave required bytes for new_str + * and copy rest of the string after it + */ + memcpy(reg_name + new_str_len, + reg_name + old_str_len, + remaining_str_len - old_str_len); + /* Now copy new_str */ + memcpy(reg_name, new_str, new_str_len); + names_len -= old_str_len; + names_len += new_str_len; + i++; + } + + reg_name = memchr(reg_name, '\0', remaining_str_len); + if (!reg_name) + break; + + reg_name += 1; + + remaining_str_len = names_len - (reg_name - reg_names); + } + + fdt_setprop(fdt, off, "reg-names", reg_names, names_len); + off = fdt_node_offset_by_compatible(fdt, off, + "fsl,lx2160a-pcie"); + } + + return 0; +} +#endif + #if defined(CONFIG_TARGET_LX2160AQDS) void esdhc_dspi_status_fixup(void *blob) { diff --git a/configs/lx2160aqds_tfa_defconfig b/configs/lx2160aqds_tfa_defconfig index 0390bef203..3abe1ebf5b 100644 --- a/configs/lx2160aqds_tfa_defconfig +++ b/configs/lx2160aqds_tfa_defconfig @@ -8,6 +8,7 @@ CONFIG_NR_DRAM_BANKS=3 CONFIG_DM=y CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_TFABOOT=y CONFIG_BOOTDELAY=10 diff --git a/configs/lx2160ardb_tfa_defconfig b/configs/lx2160ardb_tfa_defconfig index f6b20eb27d..394108daf7 100644 --- a/configs/lx2160ardb_tfa_defconfig +++ b/configs/lx2160ardb_tfa_defconfig @@ -8,6 +8,7 @@ CONFIG_NR_DRAM_BANKS=3 CONFIG_DM=y CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_TFABOOT=y CONFIG_BOOTDELAY=10

Dear Pankaj,
-----Original Message----- From: Pankaj Bansal Sent: Friday, May 17, 2019 3:02 PM To: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Meenakshi Aggarwal meenakshi.aggarwal@nxp.com Cc: Varun Sethi V.Sethi@nxp.com; u-boot@lists.denx.de; Pankaj Bansal pankaj.bansal@nxp.com Subject: [PATCH] board: fsl: lx2160a: implement board_fix_fdt
lx2 rev2 requires some fixups to be applied to fdt before relocation. Implement the same.
Can you please be more elaborative. What your patch is doing. What kind of fix-up and why it is required?
Signed-off-by: Pankaj Bansal pankaj.bansal@nxp.com
Considering LX2 rev2 is not available
has these patches been thoroughly tested on function model.
--pk

-----Original Message----- From: Prabhakar Kushwaha Sent: Wednesday, 22 May, 2019 10:47 PM To: Pankaj Bansal pankaj.bansal@nxp.com; Meenakshi Aggarwal meenakshi.aggarwal@nxp.com Cc: Varun Sethi V.Sethi@nxp.com; u-boot@lists.denx.de Subject: RE: [PATCH] board: fsl: lx2160a: implement board_fix_fdt
Dear Pankaj,
-----Original Message----- From: Pankaj Bansal Sent: Friday, May 17, 2019 3:02 PM To: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Meenakshi Aggarwal meenakshi.aggarwal@nxp.com Cc: Varun Sethi V.Sethi@nxp.com; u-boot@lists.denx.de; Pankaj Bansal pankaj.bansal@nxp.com Subject: [PATCH] board: fsl: lx2160a: implement board_fix_fdt
lx2 rev2 requires some fixups to be applied to fdt before relocation. Implement the same.
Can you please be more elaborative. What your patch is doing. What kind of fix-up and why it is required?
Ok.
Signed-off-by: Pankaj Bansal pankaj.bansal@nxp.com
Considering LX2 rev2 is not available
has these patches been thoroughly tested on function model.
The correct driver is probed, this has been tested.
--pk
participants (2)
-
Pankaj Bansal
-
Prabhakar Kushwaha