From: Wasim Khan <wasim.khan@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 8/9] pci: layerscape: device tree fixup based on SoC and Version
Date: Fri, 15 Nov 2019 09:23:44 +0000 [thread overview]
Message-ID: <1573809796-1196-9-git-send-email-wasim.khan@nxp.com> (raw)
In-Reply-To: <1573809796-1196-1-git-send-email-wasim.khan@nxp.com>
lx2160a rev1 requires layerscape_gen4 device tree fixup and
lx2160a rev2 requires layerscape device tree fixup.
Add device tree fixup for lx2160a based on SoC and Version.
Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
---
Changes in v3:
Updated patch subject and description based on Priyanka Jain
review comments
Changes in v2:
Updated patch description based on Priyanka Jain
review comments
drivers/pci/pcie_layerscape_fixup.c | 1 +
drivers/pci/pcie_layerscape_fixup_common.c | 76 ++++++++++++++++++++++++++++++
drivers/pci/pcie_layerscape_fixup_common.h | 1 +
3 files changed, 78 insertions(+)
diff --git a/drivers/pci/pcie_layerscape_fixup.c b/drivers/pci/pcie_layerscape_fixup.c
index b1d2470..df76048 100644
--- a/drivers/pci/pcie_layerscape_fixup.c
+++ b/drivers/pci/pcie_layerscape_fixup.c
@@ -208,6 +208,7 @@ static void fdt_fixup_pcie_ls(void *blob)
fdt_pcie_set_iommu_map_entry_ls(blob, pcie, bdf >> 8,
streamid);
}
+ pcie_board_fix_fdt(blob);
}
#endif
diff --git a/drivers/pci/pcie_layerscape_fixup_common.c b/drivers/pci/pcie_layerscape_fixup_common.c
index 3458ae8..ff8cd1f 100644
--- a/drivers/pci/pcie_layerscape_fixup_common.c
+++ b/drivers/pci/pcie_layerscape_fixup_common.c
@@ -29,6 +29,82 @@ void ft_pci_setup(void *blob, bd_t *bd)
}
#if defined(CONFIG_FSL_LAYERSCAPE)
+int lx2_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[] = {
+ { "csr_axi_slave", "regs" },
+ { "config_axi_slave", "config" }
+ };
+ int off = -1, i;
+ u32 val;
+
+ off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie");
+ while (off != -FDT_ERR_NOTFOUND) {
+ fdt_setprop(fdt, off, "compatible", "fsl,ls2088a-pcie",
+ strlen("fsl,ls2088a-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);
+ fdt_delprop(fdt, off, "apio-wins");
+ fdt_delprop(fdt, off, "ppio-wins");
+ val = cpu_to_fdt32(0x4);
+ fdt_setprop(fdt, off, "num-lanes", &val, sizeof(val));
+ off = fdt_node_offset_by_compatible(fdt, off,
+ "fsl,lx2160a-pcie");
+ }
+ return 0;
+}
+
+int pcie_board_fix_fdt(void *fdt)
+{
+ uint svr;
+
+ svr = SVR_SOC_VER(get_svr());
+
+ if (svr == SVR_LX2160A && IS_SVR_REV(get_svr(), 2, 0))
+ return lx2_board_fix_fdt(fdt);
+
+ return 0;
+}
+
#ifdef CONFIG_ARCH_LX2160A
/* returns the next available streamid for pcie, -errno if failed */
int pcie_next_streamid(int currentid, int idx)
diff --git a/drivers/pci/pcie_layerscape_fixup_common.h b/drivers/pci/pcie_layerscape_fixup_common.h
index e747396..8d95690 100644
--- a/drivers/pci/pcie_layerscape_fixup_common.h
+++ b/drivers/pci/pcie_layerscape_fixup_common.h
@@ -23,5 +23,6 @@ static void ft_pci_setup_ls_gen4(void *blob, bd_t *bd)
#endif
#endif /* CONFIG_FSL_LAYERSCAPE */
int pcie_next_streamid(int currentid, int id);
+int pcie_board_fix_fdt(void *fdt);
#endif //_PCIE_LAYERSCAPE_FIXUP_COMMON_H_
--
2.7.4
next prev parent reply other threads:[~2019-11-15 9:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 9:23 [U-Boot] [PATCH v3 0/9] Enablement of PCIe controller for lx2160a rev2 Wasim Khan
2019-11-15 9:23 ` [U-Boot] [PATCH v3 1/9] drivers/pci : enable pcie_layerscape code " Wasim Khan
2019-11-15 9:23 ` [U-Boot] [PATCH v3 2/9] pci: layerscape: Add stream_id_cur field to ls_pcie structure Wasim Khan
2019-11-15 9:23 ` [U-Boot] [PATCH v3 3/9] pci: layerscape: Suffix API names with _ls Wasim Khan
2019-11-15 9:23 ` [U-Boot] [PATCH v3 4/9] pci: layerscape_gen4: Suffix API names with _ls_gen4 Wasim Khan
2019-11-15 9:23 ` [U-Boot] [PATCH v3 5/9] armv8: lx2160a: Add FSL_PEX_STREAM_ID_END for LX2160A Wasim Khan
2019-11-15 9:23 ` [U-Boot] [PATCH v3 6/9] pci: layerscape: Common device tree fixup for NXP SoCs Wasim Khan
2019-12-26 10:54 ` Priyanka Jain
2019-11-15 9:23 ` [U-Boot] [PATCH v3 7/9] pci: layerscape: Move streamId allocation to common device tree fixup Wasim Khan
2019-11-15 9:23 ` Wasim Khan [this message]
2019-11-15 9:23 ` [U-Boot] [PATCH v3 9/9] configs: lx2160a: enable CONFIG_OF_BOARD_FIXUP for SECURE_BOOT defconfig Wasim Khan
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=1573809796-1196-9-git-send-email-wasim.khan@nxp.com \
--to=wasim.khan@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.