ddr: Rework errata A008109, A008378, 009942 workaround

Move errata A008109, A008378, 009942 workaround implementation from
compute_fsl_memctl_config_regs() to  fsl_ddr_set_memctl_regs()
and add register write after each workaround implementation.

Signed-off-by: Jaiprakash Singh <Jaiprakash.singh@nxp.com>
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
This commit is contained in:
Jaiprakash Singh 2020-06-02 12:44:02 +05:30 committed by Priyanka Jain
parent 73af094c84
commit 164a5af436
4 changed files with 111 additions and 65 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2014-2015 Freescale Semiconductor, Inc.
* Copyright 2014-2020 Freescale Semiconductor, Inc.
*/
#include <common.h>
@ -72,6 +72,15 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
#endif
#ifdef CONFIG_FSL_DDR_BIST
char buffer[CONFIG_SYS_CBSIZE];
#endif
#if defined(CONFIG_SYS_FSL_ERRATUM_A009942) || \
(defined(CONFIG_SYS_FSL_ERRATUM_A008378) && \
defined(CONFIG_SYS_FSL_DDRC_GEN4)) || \
defined(CONFIG_SYS_FSL_ERRATUM_A008109)
u32 val32;
#endif
#ifdef CONFIG_SYS_FSL_ERRATUM_A009942
unsigned int ddr_freq;
#endif
switch (ctrl_num) {
case 0:
@ -437,6 +446,49 @@ step2:
ddr_out32(&ddr->sdram_cfg_2, regs->ddr_sdram_cfg_2);
#endif
#if defined(CONFIG_SYS_FSL_ERRATUM_A008378) && defined(CONFIG_SYS_FSL_DDRC_GEN4)
/* Erratum applies when accumulated ECC is used, or DBI is enabled */
#define IS_ACC_ECC_EN(v) ((v) & 0x4)
#define IS_DBI(v) ((((v) >> 12) & 0x3) == 0x2)
if (has_erratum_a008378()) {
if (IS_ACC_ECC_EN(regs->ddr_sdram_cfg) ||
IS_DBI(regs->ddr_sdram_cfg_3)) {
val32 = ddr_in32(&ddr->debug[28]);
val32 |= (0x9 << 20);
ddr_out32(&ddr->debug[28], val32);
}
debug("Applied errata CONFIG_SYS_FSL_ERRATUM_A008378\n");
}
#endif
#if defined(CONFIG_SYS_FSL_ERRATUM_A008109)
val32 = ddr_in32(&ddr->sdram_cfg_2) | 0x800; /* DDR_SLOW */
ddr_out32(&ddr->sdram_cfg_2, val32);
val32 = ddr_in32(&ddr->debug[18]) | 0x2;
ddr_out32(&ddr->debug[18], val32);
ddr_out32(&ddr->debug[28], 0x30000000);
debug("Applied errta CONFIG_SYS_FSL_ERRATUM_A008109\n");
#endif
#ifdef CONFIG_SYS_FSL_ERRATUM_A009942
ddr_freq = get_ddr_freq(ctrl_num) / 1000000;
val32 = ddr_in32(&ddr->debug[28]);
val32 &= 0xff0fff00;
if (ddr_freq <= 1333)
val32 |= 0x0080006a;
else if (ddr_freq <= 1600)
val32 |= 0x0070006f;
else if (ddr_freq <= 1867)
val32 |= 0x00700076;
else if (ddr_freq <= 2133)
val32 |= 0x0060007b;
ddr_out32(&ddr->debug[28], val32);
debug("Applied errata CONFIG_SYS_FSL_ERRATUM_A009942\n");
#endif
total_gb_size_per_controller = 0;
for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
if (!(regs->cs[i].config & 0x80000000))