2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-03-21 02:28:12 +00:00
|
|
|
/*
|
2015-10-26 11:47:50 +00:00
|
|
|
* Copyright 2014-2015 Freescale Semiconductor
|
2021-06-16 12:23:19 +00:00
|
|
|
* Copyright 2019-2021 NXP
|
2015-03-21 02:28:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-12-28 17:44:58 +00:00
|
|
|
#include <clock_legacy.h>
|
2020-04-28 02:19:32 +00:00
|
|
|
#include <cpu_func.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2017-08-11 05:39:14 +00:00
|
|
|
#include <fsl_immap.h>
|
2015-03-21 02:28:12 +00:00
|
|
|
#include <fsl_ifc.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2020-04-28 02:19:32 +00:00
|
|
|
#include <linux/sizes.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2016-08-02 11:03:27 +00:00
|
|
|
#include <asm/arch/fsl_serdes.h>
|
2015-10-26 11:47:50 +00:00
|
|
|
#include <asm/arch/soc.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <asm/cache.h>
|
2015-03-21 02:28:13 +00:00
|
|
|
#include <asm/io.h>
|
2015-03-24 20:25:02 +00:00
|
|
|
#include <asm/global_data.h>
|
2015-11-05 06:30:14 +00:00
|
|
|
#include <asm/arch-fsl-layerscape/config.h>
|
2018-08-10 07:00:00 +00:00
|
|
|
#include <asm/arch-fsl-layerscape/ns_access.h>
|
2018-08-09 12:19:46 +00:00
|
|
|
#include <asm/arch-fsl-layerscape/fsl_icid.h>
|
2020-04-28 02:19:32 +00:00
|
|
|
#include <asm/gic-v3.h>
|
2016-08-02 11:03:27 +00:00
|
|
|
#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
|
2016-08-02 11:03:23 +00:00
|
|
|
#include <fsl_csu.h>
|
2016-08-02 11:03:27 +00:00
|
|
|
#endif
|
2016-06-03 13:11:31 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_DDR
|
2016-04-07 08:22:21 +00:00
|
|
|
#include <fsl_ddr_sdram.h>
|
|
|
|
#include <fsl_ddr.h>
|
2016-06-03 13:11:31 +00:00
|
|
|
#endif
|
2016-01-22 11:07:26 +00:00
|
|
|
#ifdef CONFIG_CHAIN_OF_TRUST
|
|
|
|
#include <fsl_validate.h>
|
|
|
|
#endif
|
armv8: ls1088a: Add NXP LS1088A SoC support
LS1088A is compliant with the Layerscape Chassis Generation 3 with
eight ARM v8 Cortex-A53 cores in 2 cluster, CCI-400, one 64-bit DDR4
SDRAM memory controller with ECC, Data path acceleration architecture
2.0 (DPAA2), Ethernet interfaces (SGMIIs, RGMIIs, QSGMIIs, XFIs),
QSPI, IFC, PCIe, SATA, USB, SDXC, DUARTs etc.
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com>
Signed-off-by: Raghav Dogra <raghav.dogra@nxp.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
[YS: Revised commit message]
Reviewed-by: York Sun <york.sun@nxp.com>
2017-08-31 10:42:53 +00:00
|
|
|
#include <fsl_immap.h>
|
2020-08-05 07:07:27 +00:00
|
|
|
#include <dm.h>
|
2020-10-16 01:44:15 +00:00
|
|
|
#include <dm/device_compat.h>
|
2020-08-05 07:07:27 +00:00
|
|
|
#include <linux/err.h>
|
2020-11-17 15:20:04 +00:00
|
|
|
#ifdef CONFIG_GIC_V3_ITS
|
2018-11-05 18:01:52 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
#endif
|
2015-03-24 20:25:02 +00:00
|
|
|
|
2020-04-28 02:19:32 +00:00
|
|
|
#ifdef CONFIG_GIC_V3_ITS
|
2021-10-27 16:54:54 +00:00
|
|
|
#define PENDTABLE_MAX_SZ ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
|
|
|
|
#define PROPTABLE_MAX_SZ ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K)
|
|
|
|
#define GIC_LPI_SIZE ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
|
|
|
|
PROPTABLE_MAX_SZ, SZ_1M)
|
|
|
|
static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
struct fdt_memory gic_rd_tables;
|
|
|
|
|
|
|
|
gic_rd_tables.start = base;
|
|
|
|
gic_rd_tables.end = base + size - 1;
|
|
|
|
err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
|
|
|
|
NULL, 0, NULL, 0);
|
|
|
|
if (err < 0)
|
|
|
|
debug("%s: failed to add reserved memory: %d\n", __func__, err);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2020-04-28 02:19:32 +00:00
|
|
|
int ls_gic_rd_tables_init(void *blob)
|
|
|
|
{
|
2021-10-27 16:54:54 +00:00
|
|
|
u64 gic_lpi_base;
|
2021-10-27 16:54:53 +00:00
|
|
|
int ret;
|
2020-04-28 02:19:32 +00:00
|
|
|
|
2021-10-27 16:54:54 +00:00
|
|
|
gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
|
|
|
|
ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
|
2020-04-28 02:19:32 +00:00
|
|
|
if (ret)
|
|
|
|
debug("%s: failed to init gic-lpi-tables\n", __func__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-04-04 18:41:26 +00:00
|
|
|
bool soc_has_dp_ddr(void)
|
|
|
|
{
|
|
|
|
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
|
|
|
u32 svr = gur_in32(&gur->svr);
|
|
|
|
|
2016-11-17 06:59:55 +00:00
|
|
|
/* LS2085A, LS2088A, LS2048A has DP_DDR */
|
|
|
|
if ((SVR_SOC_VER(svr) == SVR_LS2085A) ||
|
|
|
|
(SVR_SOC_VER(svr) == SVR_LS2088A) ||
|
|
|
|
(SVR_SOC_VER(svr) == SVR_LS2048A))
|
2016-04-04 18:41:26 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool soc_has_aiop(void)
|
|
|
|
{
|
|
|
|
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
|
|
|
u32 svr = gur_in32(&gur->svr);
|
|
|
|
|
|
|
|
/* LS2085A has AIOP */
|
2016-06-24 08:18:13 +00:00
|
|
|
if (SVR_SOC_VER(svr) == SVR_LS2085A)
|
2016-04-04 18:41:26 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-04 10:46:48 +00:00
|
|
|
static inline void set_usb_txvreftune(u32 __iomem *scfg, u32 offset)
|
|
|
|
{
|
|
|
|
scfg_clrsetbits32(scfg + offset / 4,
|
|
|
|
0xF << 6,
|
|
|
|
SCFG_USB_TXVREFTUNE << 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void erratum_a009008(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A009008
|
|
|
|
u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
|
2017-09-04 10:46:49 +00:00
|
|
|
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1012A)
|
2017-09-04 10:46:48 +00:00
|
|
|
set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB1);
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
2017-09-04 10:46:48 +00:00
|
|
|
set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB2);
|
|
|
|
set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB3);
|
2017-11-13 08:14:48 +00:00
|
|
|
#endif
|
2017-09-04 10:46:48 +00:00
|
|
|
#elif defined(CONFIG_ARCH_LS2080A)
|
|
|
|
set_usb_txvreftune(scfg, SCFG_USB3PRM1CR);
|
|
|
|
#endif
|
|
|
|
#endif /* CONFIG_SYS_FSL_ERRATUM_A009008 */
|
|
|
|
}
|
|
|
|
|
2017-09-04 10:46:49 +00:00
|
|
|
static inline void set_usb_sqrxtune(u32 __iomem *scfg, u32 offset)
|
|
|
|
{
|
|
|
|
scfg_clrbits32(scfg + offset / 4,
|
|
|
|
SCFG_USB_SQRXTUNE_MASK << 23);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void erratum_a009798(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A009798
|
|
|
|
u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
|
|
|
|
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1012A)
|
2017-09-04 10:46:49 +00:00
|
|
|
set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB1);
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
2017-09-04 10:46:49 +00:00
|
|
|
set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB2);
|
|
|
|
set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB3);
|
2017-11-13 08:14:48 +00:00
|
|
|
#endif
|
2017-09-04 10:46:49 +00:00
|
|
|
#elif defined(CONFIG_ARCH_LS2080A)
|
|
|
|
set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR);
|
|
|
|
#endif
|
|
|
|
#endif /* CONFIG_SYS_FSL_ERRATUM_A009798 */
|
|
|
|
}
|
|
|
|
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1012A)
|
2017-09-04 10:46:50 +00:00
|
|
|
static inline void set_usb_pcstxswingfull(u32 __iomem *scfg, u32 offset)
|
|
|
|
{
|
|
|
|
scfg_clrsetbits32(scfg + offset / 4,
|
|
|
|
0x7F << 9,
|
|
|
|
SCFG_USB_PCSTXSWINGFULL << 9);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void erratum_a008997(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A008997
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1012A)
|
2017-09-04 10:46:50 +00:00
|
|
|
u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
|
|
|
|
|
|
|
|
set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB1);
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
2017-09-04 10:46:50 +00:00
|
|
|
set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB2);
|
|
|
|
set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB3);
|
|
|
|
#endif
|
2019-05-14 09:34:56 +00:00
|
|
|
#elif defined(CONFIG_ARCH_LS1028A)
|
|
|
|
clrsetbits_le32(DCSR_BASE + DCSR_USB_IOCR1,
|
|
|
|
0x7F << 11,
|
|
|
|
DCSR_USB_PCSTXSWINGFULL << 11);
|
2017-11-13 08:14:48 +00:00
|
|
|
#endif
|
2017-09-04 10:46:50 +00:00
|
|
|
#endif /* CONFIG_SYS_FSL_ERRATUM_A008997 */
|
|
|
|
}
|
|
|
|
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1012A)
|
2017-09-04 10:46:51 +00:00
|
|
|
|
|
|
|
#define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \
|
|
|
|
out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \
|
|
|
|
out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \
|
|
|
|
out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \
|
|
|
|
out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4)
|
|
|
|
|
2019-05-14 09:34:57 +00:00
|
|
|
#elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) || \
|
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
|
|
|
defined(CONFIG_ARCH_LS1028A) || defined(CONFIG_ARCH_LX2160A) || \
|
|
|
|
defined(CONFIG_ARCH_LX2162A)
|
2017-09-04 10:46:51 +00:00
|
|
|
|
|
|
|
#define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \
|
|
|
|
out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \
|
|
|
|
out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \
|
|
|
|
out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \
|
|
|
|
out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void erratum_a009007(void)
|
|
|
|
{
|
2022-02-22 18:38:39 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_SYS_FSL_ERRATUM_A009007))
|
|
|
|
return;
|
|
|
|
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1012A)
|
2017-09-04 10:46:51 +00:00
|
|
|
void __iomem *usb_phy = (void __iomem *)SCFG_USB_PHY1;
|
|
|
|
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
|
2017-11-13 08:14:48 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
2017-09-04 10:46:51 +00:00
|
|
|
usb_phy = (void __iomem *)SCFG_USB_PHY2;
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
|
|
|
|
|
|
|
|
usb_phy = (void __iomem *)SCFG_USB_PHY3;
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
|
2017-11-13 08:14:48 +00:00
|
|
|
#endif
|
2019-05-14 09:34:57 +00:00
|
|
|
#elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) || \
|
|
|
|
defined(CONFIG_ARCH_LS1028A)
|
2017-09-04 10:46:51 +00:00
|
|
|
void __iomem *dcsr = (void __iomem *)DCSR_BASE;
|
|
|
|
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY1);
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY2);
|
|
|
|
#endif /* CONFIG_SYS_FSL_ERRATUM_A009007 */
|
|
|
|
}
|
|
|
|
|
2016-11-11 10:11:05 +00:00
|
|
|
#if defined(CONFIG_FSL_LSCH3)
|
2021-06-16 12:23:19 +00:00
|
|
|
static void erratum_a050204(void)
|
2019-11-26 03:40:40 +00:00
|
|
|
{
|
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)
|
2019-11-26 03:40:40 +00:00
|
|
|
void __iomem *dcsr = (void __iomem *)DCSR_BASE;
|
|
|
|
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY1);
|
|
|
|
PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY2);
|
|
|
|
#endif
|
|
|
|
}
|
2015-12-05 06:59:14 +00:00
|
|
|
/*
|
|
|
|
* This erratum requires setting a value to eddrtqcr1 to
|
|
|
|
* optimal the DDR performance.
|
|
|
|
*/
|
|
|
|
static void erratum_a008336(void)
|
|
|
|
{
|
2016-11-11 10:11:05 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A008336
|
2015-12-05 06:59:14 +00:00
|
|
|
u32 *eddrtqcr1;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_DCSR_DDR_ADDR
|
|
|
|
eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR_ADDR + 0x800;
|
2016-08-26 10:30:38 +00:00
|
|
|
if (fsl_ddr_get_version(0) == 0x50200)
|
|
|
|
out_le32(eddrtqcr1, 0x63b30002);
|
2015-12-05 06:59:14 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SYS_FSL_DCSR_DDR2_ADDR
|
|
|
|
eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR2_ADDR + 0x800;
|
2016-08-26 10:30:38 +00:00
|
|
|
if (fsl_ddr_get_version(0) == 0x50200)
|
|
|
|
out_le32(eddrtqcr1, 0x63b30002);
|
2015-12-05 06:59:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This erratum requires a register write before being Memory
|
|
|
|
* controller 3 being enabled.
|
|
|
|
*/
|
|
|
|
static void erratum_a008514(void)
|
|
|
|
{
|
2016-11-11 10:11:05 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A008514
|
2015-12-05 06:59:14 +00:00
|
|
|
u32 *eddrtqcr1;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_DCSR_DDR3_ADDR
|
|
|
|
eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR3_ADDR + 0x800;
|
|
|
|
out_le32(eddrtqcr1, 0x63b20002);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
2015-11-05 06:30:14 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A009635
|
|
|
|
#define PLATFORM_CYCLE_ENV_VAR "a009635_interval_val"
|
|
|
|
|
|
|
|
static unsigned long get_internval_val_mhz(void)
|
|
|
|
{
|
2017-08-03 18:22:12 +00:00
|
|
|
char *interval = env_get(PLATFORM_CYCLE_ENV_VAR);
|
2015-11-05 06:30:14 +00:00
|
|
|
/*
|
|
|
|
* interval is the number of platform cycles(MHz) between
|
|
|
|
* wake up events generated by EPU.
|
|
|
|
*/
|
|
|
|
ulong interval_mhz = get_bus_freq(0) / (1000 * 1000);
|
|
|
|
|
|
|
|
if (interval)
|
2021-07-24 15:03:30 +00:00
|
|
|
interval_mhz = dectoul(interval, NULL);
|
2015-11-05 06:30:14 +00:00
|
|
|
|
|
|
|
return interval_mhz;
|
|
|
|
}
|
|
|
|
|
|
|
|
void erratum_a009635(void)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
unsigned long interval_mhz = get_internval_val_mhz();
|
|
|
|
|
|
|
|
if (!interval_mhz)
|
|
|
|
return;
|
|
|
|
|
|
|
|
val = in_le32(DCSR_CGACRE5);
|
|
|
|
writel(val | 0x00000200, DCSR_CGACRE5);
|
|
|
|
|
|
|
|
val = in_le32(EPU_EPCMPR5);
|
|
|
|
writel(interval_mhz, EPU_EPCMPR5);
|
|
|
|
val = in_le32(EPU_EPCCR5);
|
|
|
|
writel(val | 0x82820000, EPU_EPCCR5);
|
|
|
|
val = in_le32(EPU_EPSMCR5);
|
|
|
|
writel(val | 0x002f0000, EPU_EPSMCR5);
|
|
|
|
val = in_le32(EPU_EPECR5);
|
|
|
|
writel(val | 0x20000000, EPU_EPECR5);
|
|
|
|
val = in_le32(EPU_EPGCR);
|
|
|
|
writel(val | 0x80000000, EPU_EPGCR);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_SYS_FSL_ERRATUM_A009635 */
|
|
|
|
|
2015-03-24 20:25:02 +00:00
|
|
|
static void erratum_rcw_src(void)
|
|
|
|
{
|
2017-05-05 10:12:28 +00:00
|
|
|
#if defined(CONFIG_SPL) && defined(CONFIG_NAND_BOOT)
|
2015-03-24 20:25:02 +00:00
|
|
|
u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
|
|
|
|
u32 __iomem *dcfg_dcsr = (u32 __iomem *)DCFG_DCSR_BASE;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = in_le32(dcfg_ccsr + DCFG_PORSR1 / 4);
|
|
|
|
val &= ~DCFG_PORSR1_RCW_SRC;
|
|
|
|
val |= DCFG_PORSR1_RCW_SRC_NOR;
|
|
|
|
out_le32(dcfg_dcsr + DCFG_DCSR_PORCR1 / 4, val);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-03-23 17:41:35 +00:00
|
|
|
#define I2C_DEBUG_REG 0x6
|
|
|
|
#define I2C_GLITCH_EN 0x8
|
|
|
|
/*
|
|
|
|
* This erratum requires setting glitch_en bit to enable
|
|
|
|
* digital glitch filter to improve clock stability.
|
|
|
|
*/
|
2017-02-23 10:33:57 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A009203
|
2015-03-23 17:41:35 +00:00
|
|
|
static void erratum_a009203(void)
|
|
|
|
{
|
2021-08-19 03:12:24 +00:00
|
|
|
#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
|
2017-09-04 10:15:02 +00:00
|
|
|
u8 __iomem *ptr;
|
2015-03-23 17:41:35 +00:00
|
|
|
#ifdef I2C1_BASE_ADDR
|
|
|
|
ptr = (u8 __iomem *)(I2C1_BASE_ADDR + I2C_DEBUG_REG);
|
|
|
|
|
|
|
|
writeb(I2C_GLITCH_EN, ptr);
|
|
|
|
#endif
|
|
|
|
#ifdef I2C2_BASE_ADDR
|
|
|
|
ptr = (u8 __iomem *)(I2C2_BASE_ADDR + I2C_DEBUG_REG);
|
|
|
|
|
|
|
|
writeb(I2C_GLITCH_EN, ptr);
|
|
|
|
#endif
|
|
|
|
#ifdef I2C3_BASE_ADDR
|
|
|
|
ptr = (u8 __iomem *)(I2C3_BASE_ADDR + I2C_DEBUG_REG);
|
|
|
|
|
|
|
|
writeb(I2C_GLITCH_EN, ptr);
|
|
|
|
#endif
|
|
|
|
#ifdef I2C4_BASE_ADDR
|
|
|
|
ptr = (u8 __iomem *)(I2C4_BASE_ADDR + I2C_DEBUG_REG);
|
|
|
|
|
|
|
|
writeb(I2C_GLITCH_EN, ptr);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
2017-02-23 10:33:57 +00:00
|
|
|
#endif
|
2016-11-11 10:11:05 +00:00
|
|
|
|
2016-03-23 10:54:40 +00:00
|
|
|
void bypass_smmu(void)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
|
|
|
|
out_le32(SMMU_SCR0, val);
|
|
|
|
val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
|
|
|
|
out_le32(SMMU_NSCR0, val);
|
|
|
|
}
|
2015-03-21 02:28:12 +00:00
|
|
|
void fsl_lsch3_early_init_f(void)
|
|
|
|
{
|
2015-03-24 20:25:02 +00:00
|
|
|
erratum_rcw_src();
|
2017-09-04 10:14:05 +00:00
|
|
|
#ifdef CONFIG_FSL_IFC
|
2015-03-21 02:28:12 +00:00
|
|
|
init_early_memctl_regs(); /* tighten IFC timing */
|
2017-09-04 10:14:05 +00:00
|
|
|
#endif
|
2017-02-23 10:33:57 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A009203
|
2015-03-23 17:41:35 +00:00
|
|
|
erratum_a009203();
|
2017-02-23 10:33:57 +00:00
|
|
|
#endif
|
2015-12-05 06:59:14 +00:00
|
|
|
erratum_a008514();
|
|
|
|
erratum_a008336();
|
2017-09-04 10:46:48 +00:00
|
|
|
erratum_a009008();
|
2017-09-04 10:46:49 +00:00
|
|
|
erratum_a009798();
|
2017-09-04 10:46:50 +00:00
|
|
|
erratum_a008997();
|
2017-09-04 10:46:51 +00:00
|
|
|
erratum_a009007();
|
2021-06-16 12:23:19 +00:00
|
|
|
erratum_a050204();
|
2016-03-23 10:54:40 +00:00
|
|
|
#ifdef CONFIG_CHAIN_OF_TRUST
|
|
|
|
/* In case of Secure Boot, the IBR configures the SMMU
|
|
|
|
* to allow only Secure transactions.
|
|
|
|
* SMMU must be reset in bypass mode.
|
|
|
|
* Set the ClientPD bit and Clear the USFCFG Bit
|
|
|
|
*/
|
|
|
|
if (fsl_check_boot_mode_secure() == 1)
|
|
|
|
bypass_smmu();
|
|
|
|
#endif
|
2019-07-30 14:29:58 +00:00
|
|
|
|
2019-10-18 09:01:54 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS1028A) || \
|
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
|
|
|
defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LX2160A) || \
|
|
|
|
defined(CONFIG_ARCH_LX2162A)
|
2019-07-30 14:29:58 +00:00
|
|
|
set_icids();
|
|
|
|
#endif
|
2015-03-21 02:28:12 +00:00
|
|
|
}
|
2015-10-26 11:47:51 +00:00
|
|
|
|
2018-01-17 10:43:00 +00:00
|
|
|
/* Get VDD in the unit mV from voltage ID */
|
|
|
|
int get_core_volt_from_fuse(void)
|
|
|
|
{
|
|
|
|
struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
|
|
|
int vdd;
|
|
|
|
u32 fusesr;
|
|
|
|
u8 vid;
|
|
|
|
|
|
|
|
/* get the voltage ID from fuse status register */
|
|
|
|
fusesr = in_le32(&gur->dcfg_fusesr);
|
|
|
|
debug("%s: fusesr = 0x%x\n", __func__, fusesr);
|
|
|
|
vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT) &
|
|
|
|
FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK;
|
|
|
|
if ((vid == 0) || (vid == FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK)) {
|
|
|
|
vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT) &
|
|
|
|
FSL_CHASSIS3_DCFG_FUSESR_VID_MASK;
|
|
|
|
}
|
|
|
|
debug("%s: VID = 0x%x\n", __func__, vid);
|
|
|
|
switch (vid) {
|
|
|
|
case 0x00: /* VID isn't supported */
|
|
|
|
vdd = -EINVAL;
|
|
|
|
debug("%s: The VID feature is not supported\n", __func__);
|
|
|
|
break;
|
|
|
|
case 0x08: /* 0.9V silicon */
|
|
|
|
vdd = 900;
|
|
|
|
break;
|
|
|
|
case 0x10: /* 1.0V silicon */
|
|
|
|
vdd = 1000;
|
|
|
|
break;
|
|
|
|
default: /* Other core voltage */
|
|
|
|
vdd = -EINVAL;
|
|
|
|
debug("%s: The VID(%x) isn't supported\n", __func__, vid);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd);
|
|
|
|
|
|
|
|
return vdd;
|
|
|
|
}
|
|
|
|
|
2016-06-03 13:11:27 +00:00
|
|
|
#elif defined(CONFIG_FSL_LSCH2)
|
2016-02-02 03:28:03 +00:00
|
|
|
/*
|
|
|
|
* This erratum requires setting a value to eddrtqcr1 to optimal
|
|
|
|
* the DDR performance. The eddrtqcr1 register is in SCFG space
|
|
|
|
* of LS1043A and the offset is 0x157_020c.
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_SYS_FSL_ERRATUM_A009660) \
|
|
|
|
&& defined(CONFIG_SYS_FSL_ERRATUM_A008514)
|
|
|
|
#error A009660 and A008514 can not be both enabled.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void erratum_a009660(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A009660
|
|
|
|
u32 *eddrtqcr1 = (void *)CONFIG_SYS_FSL_SCFG_ADDR + 0x20c;
|
|
|
|
out_be32(eddrtqcr1, 0x63b20042);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-04-07 08:22:21 +00:00
|
|
|
static void erratum_a008850_early(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A008850
|
|
|
|
/* part 1 of 2 */
|
2017-08-11 05:39:14 +00:00
|
|
|
struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
|
|
|
|
CONFIG_SYS_CCI400_OFFSET);
|
2016-04-07 08:22:21 +00:00
|
|
|
struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
|
|
|
|
|
2017-05-15 15:51:59 +00:00
|
|
|
/* Skip if running at lower exception level */
|
|
|
|
if (current_el() < 3)
|
|
|
|
return;
|
|
|
|
|
2016-04-07 08:22:21 +00:00
|
|
|
/* disables propagation of barrier transactions to DDRC from CCI400 */
|
|
|
|
out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
|
|
|
|
|
|
|
|
/* disable the re-ordering in DDRC */
|
|
|
|
ddr_out32(&ddr->eor, DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void erratum_a008850_post(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A008850
|
|
|
|
/* part 2 of 2 */
|
2017-08-11 05:39:14 +00:00
|
|
|
struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
|
|
|
|
CONFIG_SYS_CCI400_OFFSET);
|
2016-04-07 08:22:21 +00:00
|
|
|
struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
|
|
|
|
u32 tmp;
|
|
|
|
|
2017-05-15 15:51:59 +00:00
|
|
|
/* Skip if running at lower exception level */
|
|
|
|
if (current_el() < 3)
|
|
|
|
return;
|
|
|
|
|
2016-04-07 08:22:21 +00:00
|
|
|
/* enable propagation of barrier transactions to DDRC from CCI400 */
|
|
|
|
out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
|
|
|
|
|
|
|
|
/* enable the re-ordering in DDRC */
|
|
|
|
tmp = ddr_in32(&ddr->eor);
|
|
|
|
tmp &= ~(DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS);
|
|
|
|
ddr_out32(&ddr->eor, tmp);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-08-02 11:03:27 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_ERRATUM_A010315
|
|
|
|
void erratum_a010315(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = PCIE1; i <= PCIE4; i++)
|
|
|
|
if (!is_serdes_configured(i)) {
|
|
|
|
debug("PCIe%d: disabled all R/W permission!\n", i);
|
|
|
|
set_pcie_ns_access(i, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-29 04:42:44 +00:00
|
|
|
static void erratum_a010539(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_SYS_FSL_ERRATUM_A010539) && defined(CONFIG_QSPI_BOOT)
|
|
|
|
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
|
|
|
u32 porsr1;
|
|
|
|
|
|
|
|
porsr1 = in_be32(&gur->porsr1);
|
|
|
|
porsr1 &= ~FSL_CHASSIS2_CCSR_PORSR1_RCW_MASK;
|
|
|
|
out_be32((void *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1),
|
|
|
|
porsr1);
|
2018-04-25 06:25:42 +00:00
|
|
|
out_be32((void *)(CONFIG_SYS_FSL_SCFG_ADDR + 0x1a8), 0xffffffff);
|
2016-09-29 04:42:44 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-09 08:09:00 +00:00
|
|
|
/* Get VDD in the unit mV from voltage ID */
|
|
|
|
int get_core_volt_from_fuse(void)
|
|
|
|
{
|
|
|
|
struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
|
|
|
|
int vdd;
|
|
|
|
u32 fusesr;
|
|
|
|
u8 vid;
|
|
|
|
|
|
|
|
fusesr = in_be32(&gur->dcfg_fusesr);
|
|
|
|
debug("%s: fusesr = 0x%x\n", __func__, fusesr);
|
|
|
|
vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_ALTVID_SHIFT) &
|
|
|
|
FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK;
|
|
|
|
if ((vid == 0) || (vid == FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK)) {
|
|
|
|
vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_VID_SHIFT) &
|
|
|
|
FSL_CHASSIS2_DCFG_FUSESR_VID_MASK;
|
|
|
|
}
|
|
|
|
debug("%s: VID = 0x%x\n", __func__, vid);
|
|
|
|
switch (vid) {
|
|
|
|
case 0x00: /* VID isn't supported */
|
|
|
|
vdd = -EINVAL;
|
|
|
|
debug("%s: The VID feature is not supported\n", __func__);
|
|
|
|
break;
|
|
|
|
case 0x08: /* 0.9V silicon */
|
|
|
|
vdd = 900;
|
|
|
|
break;
|
|
|
|
case 0x10: /* 1.0V silicon */
|
|
|
|
vdd = 1000;
|
|
|
|
break;
|
|
|
|
default: /* Other core voltage */
|
|
|
|
vdd = -EINVAL;
|
|
|
|
printf("%s: The VID(%x) isn't supported\n", __func__, vid);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd);
|
|
|
|
|
|
|
|
return vdd;
|
|
|
|
}
|
|
|
|
|
|
|
|
__weak int board_switch_core_volt(u32 vdd)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int setup_core_volt(u32 vdd)
|
|
|
|
{
|
|
|
|
return board_setup_core_volt(vdd);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_DDR
|
|
|
|
static void ddr_enable_0v9_volt(bool en)
|
|
|
|
{
|
|
|
|
struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = ddr_in32(&ddr->ddr_cdr1);
|
|
|
|
|
|
|
|
if (en)
|
|
|
|
tmp |= DDR_CDR1_V0PT9_EN;
|
|
|
|
else
|
|
|
|
tmp &= ~DDR_CDR1_V0PT9_EN;
|
|
|
|
|
|
|
|
ddr_out32(&ddr->ddr_cdr1, tmp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int setup_chip_volt(void)
|
|
|
|
{
|
|
|
|
int vdd;
|
|
|
|
|
|
|
|
vdd = get_core_volt_from_fuse();
|
|
|
|
/* Nothing to do for silicons doesn't support VID */
|
|
|
|
if (vdd < 0)
|
|
|
|
return vdd;
|
|
|
|
|
|
|
|
if (setup_core_volt(vdd))
|
|
|
|
printf("%s: Switch core VDD to %dmV failed\n", __func__, vdd);
|
|
|
|
#ifdef CONFIG_SYS_HAS_SERDES
|
|
|
|
if (setup_serdes_volt(vdd))
|
|
|
|
printf("%s: Switch SVDD to %dmV failed\n", __func__, vdd);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_DDR
|
|
|
|
if (vdd == 900)
|
|
|
|
ddr_enable_0v9_volt(true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-08 10:00:33 +00:00
|
|
|
#ifdef CONFIG_FSL_PFE
|
|
|
|
void init_pfe_scfg_dcfg_regs(void)
|
|
|
|
{
|
|
|
|
struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
|
|
|
|
u32 ecccr2;
|
|
|
|
|
|
|
|
out_be32(&scfg->pfeasbcr,
|
|
|
|
in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0);
|
|
|
|
out_be32(&scfg->pfebsbcr,
|
|
|
|
in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0);
|
|
|
|
|
|
|
|
/* CCI-400 QoS settings for PFE */
|
|
|
|
out_be32(&scfg->wr_qos1, (unsigned int)(SCFG_WR_QOS1_PFE1_QOS
|
|
|
|
| SCFG_WR_QOS1_PFE2_QOS));
|
|
|
|
out_be32(&scfg->rd_qos1, (unsigned int)(SCFG_RD_QOS1_PFE1_QOS
|
|
|
|
| SCFG_RD_QOS1_PFE2_QOS));
|
|
|
|
|
|
|
|
ecccr2 = in_be32(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2);
|
|
|
|
out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2,
|
|
|
|
ecccr2 | (unsigned int)DISABLE_PFE_ECC);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-26 11:47:51 +00:00
|
|
|
void fsl_lsch2_early_init_f(void)
|
|
|
|
{
|
2017-08-11 05:39:14 +00:00
|
|
|
struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
|
|
|
|
CONFIG_SYS_CCI400_OFFSET);
|
2015-12-08 08:24:27 +00:00
|
|
|
struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
|
2019-05-29 12:12:36 +00:00
|
|
|
#if defined(CONFIG_FSL_QSPI) && defined(CONFIG_TFABOOT)
|
|
|
|
enum boot_src src;
|
|
|
|
#endif
|
2015-10-26 11:47:51 +00:00
|
|
|
|
2016-08-02 11:03:23 +00:00
|
|
|
#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
|
|
|
|
enable_layerscape_ns_access();
|
|
|
|
#endif
|
|
|
|
|
2015-10-26 11:47:51 +00:00
|
|
|
#ifdef CONFIG_FSL_IFC
|
|
|
|
init_early_memctl_regs(); /* tighten IFC timing */
|
|
|
|
#endif
|
|
|
|
|
2019-05-29 12:12:36 +00:00
|
|
|
#if defined(CONFIG_FSL_QSPI) && defined(CONFIG_TFABOOT)
|
|
|
|
src = get_boot_src();
|
|
|
|
if (src != BOOT_SOURCE_QSPI_NOR)
|
|
|
|
out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
|
|
|
|
#else
|
2016-03-16 10:01:52 +00:00
|
|
|
#if defined(CONFIG_FSL_QSPI) && !defined(CONFIG_QSPI_BOOT)
|
2016-01-25 07:16:06 +00:00
|
|
|
out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
|
2019-05-29 12:12:36 +00:00
|
|
|
#endif
|
2016-01-25 07:16:06 +00:00
|
|
|
#endif
|
2015-12-08 08:24:27 +00:00
|
|
|
/* Make SEC reads and writes snoopable */
|
2019-09-20 09:34:29 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
|
|
|
setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
|
|
|
|
SCFG_SNPCNFGCR_SECWRSNP | SCFG_SNPCNFGCR_USB1RDSNP |
|
|
|
|
SCFG_SNPCNFGCR_USB1WRSNP | SCFG_SNPCNFGCR_USB2RDSNP |
|
|
|
|
SCFG_SNPCNFGCR_USB2WRSNP | SCFG_SNPCNFGCR_USB3RDSNP |
|
|
|
|
SCFG_SNPCNFGCR_USB3WRSNP | SCFG_SNPCNFGCR_SATARDSNP |
|
|
|
|
SCFG_SNPCNFGCR_SATAWRSNP);
|
2019-12-26 10:11:17 +00:00
|
|
|
#elif defined(CONFIG_ARCH_LS1012A)
|
|
|
|
setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
|
|
|
|
SCFG_SNPCNFGCR_SECWRSNP | SCFG_SNPCNFGCR_USB1RDSNP |
|
|
|
|
SCFG_SNPCNFGCR_USB1WRSNP | SCFG_SNPCNFGCR_SATARDSNP |
|
|
|
|
SCFG_SNPCNFGCR_SATAWRSNP);
|
2019-09-20 09:34:29 +00:00
|
|
|
#else
|
2015-12-08 08:24:27 +00:00
|
|
|
setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
|
2016-08-08 07:07:20 +00:00
|
|
|
SCFG_SNPCNFGCR_SECWRSNP |
|
|
|
|
SCFG_SNPCNFGCR_SATARDSNP |
|
|
|
|
SCFG_SNPCNFGCR_SATAWRSNP);
|
2019-09-20 09:34:29 +00:00
|
|
|
#endif
|
2015-12-08 08:24:27 +00:00
|
|
|
|
2015-10-26 11:47:51 +00:00
|
|
|
/*
|
|
|
|
* Enable snoop requests and DVM message requests for
|
|
|
|
* Slave insterface S4 (A53 core cluster)
|
|
|
|
*/
|
2017-05-15 15:51:59 +00:00
|
|
|
if (current_el() == 3) {
|
|
|
|
out_le32(&cci->slave[4].snoop_ctrl,
|
|
|
|
CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
|
|
|
|
}
|
2015-12-07 08:58:54 +00:00
|
|
|
|
2018-08-10 07:00:00 +00:00
|
|
|
/*
|
|
|
|
* Program Central Security Unit (CSU) to grant access
|
|
|
|
* permission for USB 2.0 controller
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
|
|
|
|
if (current_el() == 3)
|
|
|
|
set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW);
|
|
|
|
#endif
|
2015-12-07 08:58:54 +00:00
|
|
|
/* Erratum */
|
2016-04-07 08:22:21 +00:00
|
|
|
erratum_a008850_early(); /* part 1 of 2 */
|
2016-02-02 03:28:03 +00:00
|
|
|
erratum_a009660();
|
2016-09-29 04:42:44 +00:00
|
|
|
erratum_a010539();
|
2017-09-04 10:46:48 +00:00
|
|
|
erratum_a009008();
|
2017-09-04 10:46:49 +00:00
|
|
|
erratum_a009798();
|
2017-09-04 10:46:50 +00:00
|
|
|
erratum_a008997();
|
2017-09-04 10:46:51 +00:00
|
|
|
erratum_a009007();
|
2018-08-09 12:19:46 +00:00
|
|
|
|
2018-08-27 14:33:59 +00:00
|
|
|
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
2018-08-09 12:19:46 +00:00
|
|
|
set_icids();
|
|
|
|
#endif
|
2015-10-26 11:47:51 +00:00
|
|
|
}
|
2015-10-26 11:47:50 +00:00
|
|
|
#endif
|
2015-03-24 20:25:02 +00:00
|
|
|
|
2019-11-21 11:45:17 +00:00
|
|
|
#ifdef CONFIG_FSPI_AHB_EN_4BYTE
|
|
|
|
int fspi_ahb_init(void)
|
|
|
|
{
|
|
|
|
/* Enable 4bytes address support and fast read */
|
|
|
|
u32 *fspi_lut, lut_key, *fspi_key;
|
|
|
|
|
|
|
|
fspi_key = (void *)SYS_NXP_FSPI_ADDR + SYS_NXP_FSPI_LUTKEY_BASE_ADDR;
|
|
|
|
fspi_lut = (void *)SYS_NXP_FSPI_ADDR + SYS_NXP_FSPI_LUT_BASE_ADDR;
|
|
|
|
|
|
|
|
lut_key = in_be32(fspi_key);
|
|
|
|
|
|
|
|
if (lut_key == SYS_NXP_FSPI_LUTKEY) {
|
|
|
|
/* That means the register is BE */
|
|
|
|
out_be32(fspi_key, SYS_NXP_FSPI_LUTKEY);
|
|
|
|
/* Unlock the lut table */
|
|
|
|
out_be32(fspi_key + 1, SYS_NXP_FSPI_LUTCR_UNLOCK);
|
|
|
|
/* Create READ LUT */
|
|
|
|
out_be32(fspi_lut, 0x0820040c);
|
|
|
|
out_be32(fspi_lut + 1, 0x24003008);
|
|
|
|
out_be32(fspi_lut + 2, 0x00000000);
|
|
|
|
/* Lock the lut table */
|
|
|
|
out_be32(fspi_key, SYS_NXP_FSPI_LUTKEY);
|
|
|
|
out_be32(fspi_key + 1, SYS_NXP_FSPI_LUTCR_LOCK);
|
|
|
|
} else {
|
|
|
|
/* That means the register is LE */
|
|
|
|
out_le32(fspi_key, SYS_NXP_FSPI_LUTKEY);
|
|
|
|
/* Unlock the lut table */
|
|
|
|
out_le32(fspi_key + 1, SYS_NXP_FSPI_LUTCR_UNLOCK);
|
|
|
|
/* Create READ LUT */
|
|
|
|
out_le32(fspi_lut, 0x0820040c);
|
|
|
|
out_le32(fspi_lut + 1, 0x24003008);
|
|
|
|
out_le32(fspi_lut + 2, 0x00000000);
|
|
|
|
/* Lock the lut table */
|
|
|
|
out_le32(fspi_key, SYS_NXP_FSPI_LUTKEY);
|
|
|
|
out_le32(fspi_key + 1, SYS_NXP_FSPI_LUTCR_LOCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-12-01 02:13:52 +00:00
|
|
|
#ifdef CONFIG_QSPI_AHB_INIT
|
|
|
|
/* Enable 4bytes address support and fast read */
|
|
|
|
int qspi_ahb_init(void)
|
|
|
|
{
|
|
|
|
u32 *qspi_lut, lut_key, *qspi_key;
|
|
|
|
|
|
|
|
qspi_key = (void *)SYS_FSL_QSPI_ADDR + 0x300;
|
|
|
|
qspi_lut = (void *)SYS_FSL_QSPI_ADDR + 0x310;
|
|
|
|
|
|
|
|
lut_key = in_be32(qspi_key);
|
|
|
|
|
|
|
|
if (lut_key == 0x5af05af0) {
|
|
|
|
/* That means the register is BE */
|
|
|
|
out_be32(qspi_key, 0x5af05af0);
|
|
|
|
/* Unlock the lut table */
|
|
|
|
out_be32(qspi_key + 1, 0x00000002);
|
|
|
|
out_be32(qspi_lut, 0x0820040c);
|
|
|
|
out_be32(qspi_lut + 1, 0x1c080c08);
|
|
|
|
out_be32(qspi_lut + 2, 0x00002400);
|
|
|
|
/* Lock the lut table */
|
|
|
|
out_be32(qspi_key, 0x5af05af0);
|
|
|
|
out_be32(qspi_key + 1, 0x00000001);
|
|
|
|
} else {
|
|
|
|
/* That means the register is LE */
|
|
|
|
out_le32(qspi_key, 0x5af05af0);
|
|
|
|
/* Unlock the lut table */
|
|
|
|
out_le32(qspi_key + 1, 0x00000002);
|
|
|
|
out_le32(qspi_lut, 0x0820040c);
|
|
|
|
out_le32(qspi_lut + 1, 0x1c080c08);
|
|
|
|
out_le32(qspi_lut + 2, 0x00002400);
|
|
|
|
/* Lock the lut table */
|
|
|
|
out_le32(qspi_key, 0x5af05af0);
|
|
|
|
out_le32(qspi_key + 1, 0x00000001);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-11-05 18:01:52 +00:00
|
|
|
#ifdef CONFIG_TFABOOT
|
2018-12-27 04:37:49 +00:00
|
|
|
#define MAX_BOOTCMD_SIZE 512
|
2018-11-05 18:01:52 +00:00
|
|
|
|
|
|
|
int fsl_setenv_bootcmd(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
enum boot_src src = get_boot_src();
|
|
|
|
char bootcmd_str[MAX_BOOTCMD_SIZE];
|
|
|
|
|
|
|
|
switch (src) {
|
|
|
|
#ifdef IFC_NOR_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_IFC_NOR:
|
|
|
|
sprintf(bootcmd_str, IFC_NOR_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef QSPI_NOR_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_QSPI_NOR:
|
|
|
|
sprintf(bootcmd_str, QSPI_NOR_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef XSPI_NOR_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_XSPI_NOR:
|
|
|
|
sprintf(bootcmd_str, XSPI_NOR_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef IFC_NAND_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_IFC_NAND:
|
|
|
|
sprintf(bootcmd_str, IFC_NAND_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef QSPI_NAND_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_QSPI_NAND:
|
|
|
|
sprintf(bootcmd_str, QSPI_NAND_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef XSPI_NAND_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_XSPI_NAND:
|
|
|
|
sprintf(bootcmd_str, XSPI_NAND_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SD_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_SD_MMC:
|
|
|
|
sprintf(bootcmd_str, SD_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SD2_BOOTCOMMAND
|
|
|
|
case BOOT_SOURCE_SD_MMC2:
|
|
|
|
sprintf(bootcmd_str, SD2_BOOTCOMMAND);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
#ifdef QSPI_NOR_BOOTCOMMAND
|
|
|
|
sprintf(bootcmd_str, QSPI_NOR_BOOTCOMMAND);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = env_set("bootcmd", bootcmd_str);
|
|
|
|
if (ret) {
|
|
|
|
printf("Failed to set bootcmd: ret = %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-05 18:02:31 +00:00
|
|
|
|
|
|
|
int fsl_setenv_mcinitcmd(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
enum boot_src src = get_boot_src();
|
|
|
|
|
|
|
|
switch (src) {
|
|
|
|
#ifdef IFC_MC_INIT_CMD
|
|
|
|
case BOOT_SOURCE_IFC_NAND:
|
|
|
|
case BOOT_SOURCE_IFC_NOR:
|
|
|
|
ret = env_set("mcinitcmd", IFC_MC_INIT_CMD);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef QSPI_MC_INIT_CMD
|
|
|
|
case BOOT_SOURCE_QSPI_NAND:
|
|
|
|
case BOOT_SOURCE_QSPI_NOR:
|
|
|
|
ret = env_set("mcinitcmd", QSPI_MC_INIT_CMD);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef XSPI_MC_INIT_CMD
|
|
|
|
case BOOT_SOURCE_XSPI_NAND:
|
|
|
|
case BOOT_SOURCE_XSPI_NOR:
|
|
|
|
ret = env_set("mcinitcmd", XSPI_MC_INIT_CMD);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SD_MC_INIT_CMD
|
|
|
|
case BOOT_SOURCE_SD_MMC:
|
|
|
|
ret = env_set("mcinitcmd", SD_MC_INIT_CMD);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SD2_MC_INIT_CMD
|
|
|
|
case BOOT_SOURCE_SD_MMC2:
|
|
|
|
ret = env_set("mcinitcmd", SD2_MC_INIT_CMD);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
#ifdef QSPI_MC_INIT_CMD
|
|
|
|
ret = env_set("mcinitcmd", QSPI_MC_INIT_CMD);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
printf("Failed to set mcinitcmd: ret = %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-05 18:01:52 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-26 11:47:50 +00:00
|
|
|
#ifdef CONFIG_BOARD_LATE_INIT
|
2019-10-21 20:37:45 +00:00
|
|
|
__weak int fsl_board_late_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-08-05 07:07:27 +00:00
|
|
|
#define DWC3_GSBUSCFG0 0xc100
|
|
|
|
#define DWC3_GSBUSCFG0_CACHETYPE_SHIFT 16
|
|
|
|
#define DWC3_GSBUSCFG0_CACHETYPE(n) (((n) & 0xffff) \
|
|
|
|
<< DWC3_GSBUSCFG0_CACHETYPE_SHIFT)
|
|
|
|
|
2021-10-15 13:15:19 +00:00
|
|
|
static void enable_dwc3_snooping(void)
|
2020-08-05 07:07:27 +00:00
|
|
|
{
|
2021-10-15 13:15:19 +00:00
|
|
|
static const char * const compatibles[] = {
|
|
|
|
"fsl,layerscape-dwc3",
|
|
|
|
"fsl,ls1028a-dwc3",
|
|
|
|
};
|
2020-08-05 07:07:27 +00:00
|
|
|
fdt_addr_t dwc3_base;
|
2021-10-15 13:15:19 +00:00
|
|
|
ofnode node;
|
|
|
|
u32 val;
|
|
|
|
int i;
|
2020-08-05 07:07:27 +00:00
|
|
|
|
2021-10-15 13:15:19 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(compatibles); i++) {
|
|
|
|
ofnode_for_each_compatible_node(node, compatibles[i]) {
|
|
|
|
dwc3_base = ofnode_get_addr(node);
|
|
|
|
if (dwc3_base == FDT_ADDR_T_NONE)
|
2020-08-05 07:07:27 +00:00
|
|
|
continue;
|
2021-10-15 13:15:19 +00:00
|
|
|
|
2020-08-05 07:07:27 +00:00
|
|
|
val = in_le32(dwc3_base + DWC3_GSBUSCFG0);
|
|
|
|
val &= ~DWC3_GSBUSCFG0_CACHETYPE(~0);
|
|
|
|
val |= DWC3_GSBUSCFG0_CACHETYPE(0x2222);
|
|
|
|
writel(val, dwc3_base + DWC3_GSBUSCFG0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-26 11:47:50 +00:00
|
|
|
int board_late_init(void)
|
2015-03-24 20:25:02 +00:00
|
|
|
{
|
2016-01-22 11:07:26 +00:00
|
|
|
#ifdef CONFIG_CHAIN_OF_TRUST
|
|
|
|
fsl_setenv_chain_of_trust();
|
|
|
|
#endif
|
2018-11-05 18:01:52 +00:00
|
|
|
#ifdef CONFIG_TFABOOT
|
|
|
|
/*
|
2021-08-02 08:34:52 +00:00
|
|
|
* Set bootcmd and mcinitcmd if "fsl_bootcmd_mcinitcmd_set" does
|
|
|
|
* not exists in env
|
2018-12-27 04:37:49 +00:00
|
|
|
*/
|
2021-08-02 08:34:52 +00:00
|
|
|
if (env_get_yesno("fsl_bootcmd_mcinitcmd_set") <= 0) {
|
|
|
|
// Set bootcmd and mcinitcmd as per boot source
|
2018-12-27 04:37:49 +00:00
|
|
|
fsl_setenv_bootcmd();
|
|
|
|
fsl_setenv_mcinitcmd();
|
2021-08-02 08:34:52 +00:00
|
|
|
env_set("fsl_bootcmd_mcinitcmd_set", "y");
|
|
|
|
}
|
2018-11-05 18:01:52 +00:00
|
|
|
#endif
|
2016-12-01 02:13:52 +00:00
|
|
|
#ifdef CONFIG_QSPI_AHB_INIT
|
|
|
|
qspi_ahb_init();
|
|
|
|
#endif
|
2019-11-21 11:45:17 +00:00
|
|
|
#ifdef CONFIG_FSPI_AHB_EN_4BYTE
|
|
|
|
fspi_ahb_init();
|
|
|
|
#endif
|
2015-12-09 07:32:18 +00:00
|
|
|
|
2020-08-05 07:07:27 +00:00
|
|
|
if (IS_ENABLED(CONFIG_DM))
|
|
|
|
enable_dwc3_snooping();
|
|
|
|
|
2019-10-21 20:37:45 +00:00
|
|
|
return fsl_board_late_init();
|
2015-03-24 20:25:02 +00:00
|
|
|
}
|
|
|
|
#endif
|