2020-01-06 12:05:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright 2019-2020 NXP
|
|
|
|
*
|
|
|
|
* PCIe DT fixup for NXP Layerscape SoCs
|
|
|
|
* Author: Wasim Khan <wasim.khan@nxp.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-01-06 12:05:57 +00:00
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/soc.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <linux/libfdt.h>
|
2020-01-06 12:05:57 +00:00
|
|
|
#include "pcie_layerscape_fixup_common.h"
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
void ft_pci_setup(void *blob, struct bd_info *bd)
|
2020-01-06 12:05:57 +00:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_PCIE_LAYERSCAPE_GEN4)
|
|
|
|
uint svr;
|
|
|
|
|
|
|
|
svr = SVR_SOC_VER(get_svr());
|
|
|
|
|
|
|
|
if (svr == SVR_LX2160A && IS_SVR_REV(get_svr(), 1, 0))
|
|
|
|
ft_pci_setup_ls_gen4(blob, bd);
|
|
|
|
else
|
|
|
|
#endif /* CONFIG_PCIE_LAYERSCAPE_GEN4 */
|
|
|
|
ft_pci_setup_ls(blob, bd);
|
|
|
|
}
|
2020-01-06 12:05:59 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_FSL_LAYERSCAPE)
|
2020-01-06 12:06:00 +00:00
|
|
|
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;
|
2020-09-13 15:12:50 +00:00
|
|
|
const fdt32_t *prop;
|
|
|
|
u32 ob_wins, ib_wins;
|
2020-01-06 12:06:00 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
off = fdt_node_offset_by_compatible(fdt, off,
|
|
|
|
"fsl,lx2160a-pcie");
|
|
|
|
}
|
2020-09-13 15:12:50 +00:00
|
|
|
|
|
|
|
/* Fixup PCIe EP nodes */
|
|
|
|
off = -1;
|
|
|
|
off = fdt_node_offset_by_compatible(fdt, off, "fsl,lx2160a-pcie-ep");
|
|
|
|
while (off != -FDT_ERR_NOTFOUND) {
|
|
|
|
fdt_setprop_string(fdt, off, "compatible",
|
|
|
|
"fsl,lx2160ar2-pcie-ep");
|
|
|
|
prop = fdt_getprop(fdt, off, "apio-wins", NULL);
|
|
|
|
if (!prop) {
|
|
|
|
printf("%s: Failed to fixup PCIe EP node @0x%x\n",
|
|
|
|
__func__, off);
|
2020-10-26 03:57:42 +00:00
|
|
|
off = fdt_node_offset_by_compatible(fdt, off,
|
|
|
|
"fsl,lx2160a-pcie-ep");
|
2020-09-13 15:12:50 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ob_wins = fdt32_to_cpu(*prop);
|
|
|
|
ib_wins = (ob_wins == 256) ? 24 : 8;
|
|
|
|
fdt_setprop_u32(fdt, off, "num-ib-windows", ib_wins);
|
|
|
|
fdt_setprop_u32(fdt, off, "num-ob-windows", ob_wins);
|
|
|
|
fdt_delprop(fdt, off, "apio-wins");
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_compatible(fdt, off,
|
|
|
|
"fsl,lx2160a-pcie-ep");
|
|
|
|
}
|
|
|
|
|
2020-01-06 12:06:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pcie_board_fix_fdt(void *fdt)
|
|
|
|
{
|
|
|
|
uint svr;
|
|
|
|
|
|
|
|
svr = SVR_SOC_VER(get_svr());
|
|
|
|
|
armv8: lx2162a: Add Soc changes to support LX2162A
LX2162 is LX2160 based SoC, it has same die as of LX2160
with different packaging.
LX2162A support 64-bit 2.9GT/s DDR4 memory, i2c, micro-click module,
microSD card, eMMC support, serial console, qspi nor flash, qsgmii,
sgmii, 25g, 40g, 50g network interface, one usb 3.0 and serdes
interface to support three PCIe gen3 interface.
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
[Fixed whitespace errors]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2020-10-29 13:46:16 +00:00
|
|
|
if ((svr == SVR_LX2160A || svr == SVR_LX2162A ||
|
|
|
|
svr == SVR_LX2120A || svr == SVR_LX2080A ||
|
|
|
|
svr == SVR_LX2122A || svr == SVR_LX2082A) &&
|
|
|
|
IS_SVR_REV(get_svr(), 2, 0))
|
2020-01-06 12:06:00 +00:00
|
|
|
return lx2_board_fix_fdt(fdt);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
armv8: lx2162a: Add Soc changes to support LX2162A
LX2162 is LX2160 based SoC, it has same die as of LX2160
with different packaging.
LX2162A support 64-bit 2.9GT/s DDR4 memory, i2c, micro-click module,
microSD card, eMMC support, serial console, qspi nor flash, qsgmii,
sgmii, 25g, 40g, 50g network interface, one usb 3.0 and serdes
interface to support three PCIe gen3 interface.
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
[Fixed whitespace errors]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2020-10-29 13:46:16 +00:00
|
|
|
#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
|
2020-01-06 12:05:59 +00:00
|
|
|
/* returns the next available streamid for pcie, -errno if failed */
|
|
|
|
int pcie_next_streamid(int currentid, int idx)
|
|
|
|
{
|
|
|
|
if (currentid > FSL_PEX_STREAM_ID_END)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return currentid | ((idx + 1) << 11);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* returns the next available streamid for pcie, -errno if failed */
|
|
|
|
int pcie_next_streamid(int currentid, int idx)
|
|
|
|
{
|
|
|
|
static int next_stream_id = FSL_PEX_STREAM_ID_START;
|
|
|
|
|
|
|
|
if (next_stream_id > FSL_PEX_STREAM_ID_END)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return next_stream_id++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* CONFIG_FSL_LAYERSCAPE */
|