2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-08-26 20:01:29 +00:00
|
|
|
/*
|
2014-03-28 00:54:47 +00:00
|
|
|
* Copyright 2008-2014 Freescale Semiconductor, Inc.
|
2008-08-26 20:01:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2013-09-30 21:20:51 +00:00
|
|
|
#ifdef CONFIG_PPC
|
2008-08-26 20:01:29 +00:00
|
|
|
#include <asm/fsl_law.h>
|
2013-09-30 21:20:51 +00:00
|
|
|
#endif
|
2011-03-15 15:23:47 +00:00
|
|
|
#include <div64.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2013-09-30 16:22:09 +00:00
|
|
|
#include <fsl_ddr.h>
|
2013-11-18 18:29:32 +00:00
|
|
|
#include <fsl_immap.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2013-09-30 16:22:09 +00:00
|
|
|
#include <asm/io.h>
|
2017-05-17 14:23:10 +00:00
|
|
|
#if defined(CONFIG_FSL_LSCH2) || defined(CONFIG_FSL_LSCH3) || \
|
|
|
|
defined(CONFIG_ARM)
|
2017-05-17 14:23:06 +00:00
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#endif
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2011-03-15 15:23:47 +00:00
|
|
|
/* To avoid 64-bit full-divides, we factor this here */
|
2011-04-14 17:39:30 +00:00
|
|
|
#define ULL_2E12 2000000000000ULL
|
|
|
|
#define UL_5POW12 244140625UL
|
|
|
|
#define UL_2POW13 (1UL << 13)
|
2011-03-15 15:23:47 +00:00
|
|
|
|
2011-04-14 17:39:30 +00:00
|
|
|
#define ULL_8FS 0xFFFFFFFFULL
|
2011-03-15 15:23:47 +00:00
|
|
|
|
2015-03-19 16:30:26 +00:00
|
|
|
u32 fsl_ddr_get_version(unsigned int ctrl_num)
|
2014-03-28 00:54:47 +00:00
|
|
|
{
|
|
|
|
struct ccsr_ddr __iomem *ddr;
|
|
|
|
u32 ver_major_minor_errata;
|
|
|
|
|
2015-03-19 16:30:26 +00:00
|
|
|
switch (ctrl_num) {
|
|
|
|
case 0:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
|
|
|
|
break;
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_DDR2_ADDR) && (CONFIG_SYS_NUM_DDR_CTLRS > 1)
|
2015-03-19 16:30:26 +00:00
|
|
|
case 1:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR2_ADDR;
|
|
|
|
break;
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_DDR3_ADDR) && (CONFIG_SYS_NUM_DDR_CTLRS > 2)
|
2015-03-19 16:30:26 +00:00
|
|
|
case 2:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR3_ADDR;
|
|
|
|
break;
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_DDR4_ADDR) && (CONFIG_SYS_NUM_DDR_CTLRS > 3)
|
2015-03-19 16:30:26 +00:00
|
|
|
case 3:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR4_ADDR;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
printf("%s unexpected ctrl_num = %u\n", __func__, ctrl_num);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-28 00:54:47 +00:00
|
|
|
ver_major_minor_errata = (ddr_in32(&ddr->ip_rev1) & 0xFFFF) << 8;
|
|
|
|
ver_major_minor_errata |= (ddr_in32(&ddr->ip_rev2) & 0xFF00) >> 8;
|
|
|
|
|
|
|
|
return ver_major_minor_errata;
|
|
|
|
}
|
|
|
|
|
2008-08-26 20:01:29 +00:00
|
|
|
/*
|
2011-08-26 18:32:42 +00:00
|
|
|
* Round up mclk_ps to nearest 1 ps in memory controller code
|
|
|
|
* if the error is 0.5ps or more.
|
2008-08-26 20:01:29 +00:00
|
|
|
*
|
|
|
|
* If an imprecise data rate is too high due to rounding error
|
|
|
|
* propagation, compute a suitably rounded mclk_ps to compute
|
|
|
|
* a working memory controller configuration.
|
|
|
|
*/
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned int get_memory_clk_period_ps(const unsigned int ctrl_num)
|
2008-08-26 20:01:29 +00:00
|
|
|
{
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned int data_rate = get_ddr_freq(ctrl_num);
|
2011-03-15 15:23:47 +00:00
|
|
|
unsigned int result;
|
|
|
|
|
|
|
|
/* Round to nearest 10ps, being careful about 64-bit multiply/divide */
|
2011-08-26 18:32:42 +00:00
|
|
|
unsigned long long rem, mclk_ps = ULL_2E12;
|
2011-03-15 15:23:47 +00:00
|
|
|
|
|
|
|
/* Now perform the big divide, the result fits in 32-bits */
|
2011-08-26 18:32:42 +00:00
|
|
|
rem = do_div(mclk_ps, data_rate);
|
|
|
|
result = (rem >= (data_rate >> 1)) ? mclk_ps + 1 : mclk_ps;
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2011-08-26 18:32:42 +00:00
|
|
|
return result;
|
2008-08-26 20:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert picoseconds into DRAM clock cycles (rounding up if needed). */
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned int picos_to_mclk(const unsigned int ctrl_num, unsigned int picos)
|
2008-08-26 20:01:29 +00:00
|
|
|
{
|
2011-03-15 15:23:47 +00:00
|
|
|
unsigned long long clks, clks_rem;
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned long data_rate = get_ddr_freq(ctrl_num);
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2011-03-15 15:23:47 +00:00
|
|
|
/* Short circuit for zero picos */
|
2008-08-26 20:01:29 +00:00
|
|
|
if (!picos)
|
|
|
|
return 0;
|
|
|
|
|
2011-03-15 15:23:47 +00:00
|
|
|
/* First multiply the time by the data rate (32x32 => 64) */
|
2011-08-26 18:32:42 +00:00
|
|
|
clks = picos * (unsigned long long)data_rate;
|
2011-03-15 15:23:47 +00:00
|
|
|
/*
|
|
|
|
* Now divide by 5^12 and track the 32-bit remainder, then divide
|
|
|
|
* by 2*(2^12) using shifts (and updating the remainder).
|
|
|
|
*/
|
2011-04-14 17:39:30 +00:00
|
|
|
clks_rem = do_div(clks, UL_5POW12);
|
2011-08-26 18:32:42 +00:00
|
|
|
clks_rem += (clks & (UL_2POW13-1)) * UL_5POW12;
|
2011-03-15 15:23:47 +00:00
|
|
|
clks >>= 13;
|
|
|
|
|
2011-08-26 18:32:42 +00:00
|
|
|
/* If we had a remainder greater than the 1ps error, then round up */
|
|
|
|
if (clks_rem > data_rate)
|
2008-08-26 20:01:29 +00:00
|
|
|
clks++;
|
|
|
|
|
2011-03-15 15:23:47 +00:00
|
|
|
/* Clamp to the maximum representable value */
|
2011-04-14 17:39:30 +00:00
|
|
|
if (clks > ULL_8FS)
|
|
|
|
clks = ULL_8FS;
|
2008-08-26 20:01:29 +00:00
|
|
|
return (unsigned int) clks;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned int mclk_to_picos(const unsigned int ctrl_num, unsigned int mclk)
|
2008-08-26 20:01:29 +00:00
|
|
|
{
|
2015-01-06 21:18:50 +00:00
|
|
|
return get_memory_clk_period_ps(ctrl_num) * mclk;
|
2008-08-26 20:01:29 +00:00
|
|
|
}
|
|
|
|
|
2013-09-30 21:20:51 +00:00
|
|
|
#ifdef CONFIG_PPC
|
2008-08-26 20:01:29 +00:00
|
|
|
void
|
|
|
|
__fsl_ddr_set_lawbar(const common_timing_params_t *memctl_common_params,
|
2012-08-17 08:22:39 +00:00
|
|
|
unsigned int law_memctl,
|
2008-08-26 20:01:29 +00:00
|
|
|
unsigned int ctrl_num)
|
|
|
|
{
|
2009-06-12 04:42:35 +00:00
|
|
|
unsigned long long base = memctl_common_params->base_address;
|
|
|
|
unsigned long long size = memctl_common_params->total_mem;
|
|
|
|
|
2008-08-26 20:01:29 +00:00
|
|
|
/*
|
|
|
|
* If no DIMMs on this controller, do not proceed any further.
|
|
|
|
*/
|
|
|
|
if (!memctl_common_params->ndimms_present) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-12 04:42:35 +00:00
|
|
|
#if !defined(CONFIG_PHYS_64BIT)
|
|
|
|
if (base >= CONFIG_MAX_MEM_MAPPED)
|
|
|
|
return;
|
|
|
|
if ((base + size) >= CONFIG_MAX_MEM_MAPPED)
|
|
|
|
size = CONFIG_MAX_MEM_MAPPED - base;
|
|
|
|
#endif
|
2012-08-17 08:22:39 +00:00
|
|
|
if (set_ddr_laws(base, size, law_memctl) < 0) {
|
|
|
|
printf("%s: ERROR (ctrl #%d, TRGT ID=%x)\n", __func__, ctrl_num,
|
|
|
|
law_memctl);
|
|
|
|
return ;
|
2008-08-26 20:01:29 +00:00
|
|
|
}
|
2012-08-17 08:22:39 +00:00
|
|
|
debug("setup ddr law base = 0x%llx, size 0x%llx, TRGT_ID 0x%x\n",
|
|
|
|
base, size, law_memctl);
|
2008-08-26 20:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((weak, alias("__fsl_ddr_set_lawbar"))) void
|
|
|
|
fsl_ddr_set_lawbar(const common_timing_params_t *memctl_common_params,
|
|
|
|
unsigned int memctl_interleaved,
|
|
|
|
unsigned int ctrl_num);
|
2013-09-30 21:20:51 +00:00
|
|
|
#endif
|
2009-07-17 15:14:48 +00:00
|
|
|
|
2012-08-17 08:22:39 +00:00
|
|
|
void fsl_ddr_set_intl3r(const unsigned int granule_size)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_E6500
|
|
|
|
u32 *mcintl3r = (void *) (CONFIG_SYS_IMMR + 0x18004);
|
|
|
|
*mcintl3r = 0x80000000 | (granule_size & 0x1f);
|
|
|
|
debug("Enable MCINTL3R with granule size 0x%x\n", granule_size);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-10-08 07:44:25 +00:00
|
|
|
u32 fsl_ddr_get_intl3r(void)
|
|
|
|
{
|
|
|
|
u32 val = 0;
|
|
|
|
#ifdef CONFIG_E6500
|
|
|
|
u32 *mcintl3r = (void *) (CONFIG_SYS_IMMR + 0x18004);
|
|
|
|
val = *mcintl3r;
|
|
|
|
#endif
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2014-08-01 22:51:00 +00:00
|
|
|
void print_ddr_info(unsigned int start_ctrl)
|
2009-07-17 15:14:48 +00:00
|
|
|
{
|
2013-11-18 18:29:32 +00:00
|
|
|
struct ccsr_ddr __iomem *ddr =
|
|
|
|
(struct ccsr_ddr __iomem *)(CONFIG_SYS_FSL_DDR_ADDR);
|
2012-10-24 00:03:46 +00:00
|
|
|
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_E6500) && (CONFIG_SYS_NUM_DDR_CTLRS == 3)
|
2012-08-17 08:22:39 +00:00
|
|
|
u32 *mcintl3r = (void *) (CONFIG_SYS_IMMR + 0x18004);
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if (CONFIG_SYS_NUM_DDR_CTLRS > 1)
|
2014-02-10 21:59:42 +00:00
|
|
|
uint32_t cs0_config = ddr_in32(&ddr->cs0_config);
|
2009-07-17 15:14:48 +00:00
|
|
|
#endif
|
2014-02-10 21:59:42 +00:00
|
|
|
uint32_t sdram_cfg = ddr_in32(&ddr->sdram_cfg);
|
2009-07-17 15:14:48 +00:00
|
|
|
int cas_lat;
|
|
|
|
|
2016-12-28 16:43:45 +00:00
|
|
|
#if CONFIG_SYS_NUM_DDR_CTLRS >= 2
|
2014-08-01 22:51:00 +00:00
|
|
|
if ((!(sdram_cfg & SDRAM_CFG_MEM_EN)) ||
|
|
|
|
(start_ctrl == 1)) {
|
2013-09-30 16:22:09 +00:00
|
|
|
ddr = (void __iomem *)CONFIG_SYS_FSL_DDR2_ADDR;
|
2014-02-10 21:59:42 +00:00
|
|
|
sdram_cfg = ddr_in32(&ddr->sdram_cfg);
|
2012-10-08 07:44:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if CONFIG_SYS_NUM_DDR_CTLRS >= 3
|
2014-08-01 22:51:00 +00:00
|
|
|
if ((!(sdram_cfg & SDRAM_CFG_MEM_EN)) ||
|
|
|
|
(start_ctrl == 2)) {
|
2013-09-30 16:22:09 +00:00
|
|
|
ddr = (void __iomem *)CONFIG_SYS_FSL_DDR3_ADDR;
|
2014-02-10 21:59:42 +00:00
|
|
|
sdram_cfg = ddr_in32(&ddr->sdram_cfg);
|
2012-10-08 07:44:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
2014-08-01 22:51:00 +00:00
|
|
|
|
|
|
|
if (!(sdram_cfg & SDRAM_CFG_MEM_EN)) {
|
|
|
|
puts(" (DDR not enabled)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-17 15:14:48 +00:00
|
|
|
puts(" (DDR");
|
|
|
|
switch ((sdram_cfg & SDRAM_CFG_SDRAM_TYPE_MASK) >>
|
|
|
|
SDRAM_CFG_SDRAM_TYPE_SHIFT) {
|
|
|
|
case SDRAM_TYPE_DDR1:
|
|
|
|
puts("1");
|
|
|
|
break;
|
|
|
|
case SDRAM_TYPE_DDR2:
|
|
|
|
puts("2");
|
|
|
|
break;
|
|
|
|
case SDRAM_TYPE_DDR3:
|
|
|
|
puts("3");
|
|
|
|
break;
|
2014-03-28 00:54:47 +00:00
|
|
|
case SDRAM_TYPE_DDR4:
|
|
|
|
puts("4");
|
|
|
|
break;
|
2009-07-17 15:14:48 +00:00
|
|
|
default:
|
|
|
|
puts("?");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sdram_cfg & SDRAM_CFG_32_BE)
|
|
|
|
puts(", 32-bit");
|
2011-02-07 09:39:51 +00:00
|
|
|
else if (sdram_cfg & SDRAM_CFG_16_BE)
|
|
|
|
puts(", 16-bit");
|
2009-07-17 15:14:48 +00:00
|
|
|
else
|
|
|
|
puts(", 64-bit");
|
|
|
|
|
|
|
|
/* Calculate CAS latency based on timing cfg values */
|
2014-03-28 00:54:47 +00:00
|
|
|
cas_lat = ((ddr_in32(&ddr->timing_cfg_1) >> 16) & 0xf);
|
2015-03-19 16:30:26 +00:00
|
|
|
if (fsl_ddr_get_version(0) <= 0x40400)
|
2014-03-28 00:54:47 +00:00
|
|
|
cas_lat += 1;
|
|
|
|
else
|
|
|
|
cas_lat += 2;
|
|
|
|
cas_lat += ((ddr_in32(&ddr->timing_cfg_3) >> 12) & 3) << 4;
|
2009-07-17 15:14:48 +00:00
|
|
|
printf(", CL=%d", cas_lat >> 1);
|
|
|
|
if (cas_lat & 0x1)
|
|
|
|
puts(".5");
|
|
|
|
|
|
|
|
if (sdram_cfg & SDRAM_CFG_ECC_EN)
|
|
|
|
puts(", ECC on)");
|
|
|
|
else
|
|
|
|
puts(", ECC off)");
|
|
|
|
|
2016-12-28 16:43:45 +00:00
|
|
|
#if (CONFIG_SYS_NUM_DDR_CTLRS == 3)
|
2012-08-17 08:22:39 +00:00
|
|
|
#ifdef CONFIG_E6500
|
|
|
|
if (*mcintl3r & 0x80000000) {
|
|
|
|
puts("\n");
|
|
|
|
puts(" DDR Controller Interleaving Mode: ");
|
|
|
|
switch (*mcintl3r & 0x1f) {
|
|
|
|
case FSL_DDR_3WAY_1KB_INTERLEAVING:
|
|
|
|
puts("3-way 1KB");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_3WAY_4KB_INTERLEAVING:
|
|
|
|
puts("3-way 4KB");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_3WAY_8KB_INTERLEAVING:
|
|
|
|
puts("3-way 8KB");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
puts("3-way UNKNOWN");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if (CONFIG_SYS_NUM_DDR_CTLRS >= 2)
|
2014-08-01 22:51:00 +00:00
|
|
|
if ((cs0_config & 0x20000000) && (start_ctrl == 0)) {
|
2009-07-17 15:14:48 +00:00
|
|
|
puts("\n");
|
|
|
|
puts(" DDR Controller Interleaving Mode: ");
|
|
|
|
|
|
|
|
switch ((cs0_config >> 24) & 0xf) {
|
2014-02-10 21:59:44 +00:00
|
|
|
case FSL_DDR_256B_INTERLEAVING:
|
|
|
|
puts("256B");
|
|
|
|
break;
|
2009-07-17 15:14:48 +00:00
|
|
|
case FSL_DDR_CACHE_LINE_INTERLEAVING:
|
|
|
|
puts("cache line");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_PAGE_INTERLEAVING:
|
|
|
|
puts("page");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_BANK_INTERLEAVING:
|
|
|
|
puts("bank");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_SUPERBANK_INTERLEAVING:
|
|
|
|
puts("super-bank");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
puts("invalid");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((sdram_cfg >> 8) & 0x7f) {
|
|
|
|
puts("\n");
|
|
|
|
puts(" DDR Chip-Select Interleaving Mode: ");
|
|
|
|
switch(sdram_cfg >> 8 & 0x7f) {
|
|
|
|
case FSL_DDR_CS0_CS1_CS2_CS3:
|
|
|
|
puts("CS0+CS1+CS2+CS3");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_CS0_CS1:
|
|
|
|
puts("CS0+CS1");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_CS2_CS3:
|
|
|
|
puts("CS2+CS3");
|
|
|
|
break;
|
|
|
|
case FSL_DDR_CS0_CS1_AND_CS2_CS3:
|
|
|
|
puts("CS0+CS1 and CS2+CS3");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
puts("invalid");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-01 22:51:00 +00:00
|
|
|
|
|
|
|
void __weak detail_board_ddr_info(void)
|
|
|
|
{
|
|
|
|
print_ddr_info(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void board_add_ram_info(int use_default)
|
|
|
|
{
|
|
|
|
detail_board_ddr_info();
|
|
|
|
}
|
2015-01-06 21:18:55 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_FSL_DDR_SYNC_REFRESH
|
|
|
|
#define DDRC_DEBUG20_INIT_DONE 0x80000000
|
|
|
|
#define DDRC_DEBUG2_RF 0x00000040
|
|
|
|
void fsl_ddr_sync_memctl_refresh(unsigned int first_ctrl,
|
|
|
|
unsigned int last_ctrl)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
u32 ddrc_debug20;
|
2016-12-28 16:43:45 +00:00
|
|
|
u32 ddrc_debug2[CONFIG_SYS_NUM_DDR_CTLRS] = {};
|
|
|
|
u32 *ddrc_debug2_p[CONFIG_SYS_NUM_DDR_CTLRS] = {};
|
2015-01-06 21:18:55 +00:00
|
|
|
struct ccsr_ddr __iomem *ddr;
|
|
|
|
|
|
|
|
for (i = first_ctrl; i <= last_ctrl; i++) {
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
|
|
|
|
break;
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_DDR2_ADDR) && (CONFIG_SYS_NUM_DDR_CTLRS > 1)
|
2015-01-06 21:18:55 +00:00
|
|
|
case 1:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR2_ADDR;
|
|
|
|
break;
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_DDR3_ADDR) && (CONFIG_SYS_NUM_DDR_CTLRS > 2)
|
2015-01-06 21:18:55 +00:00
|
|
|
case 2:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR3_ADDR;
|
|
|
|
break;
|
|
|
|
#endif
|
2016-12-28 16:43:45 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_DDR4_ADDR) && (CONFIG_SYS_NUM_DDR_CTLRS > 3)
|
2015-01-06 21:18:55 +00:00
|
|
|
case 3:
|
|
|
|
ddr = (void *)CONFIG_SYS_FSL_DDR4_ADDR;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
printf("%s unexpected ctrl = %u\n", __func__, i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ddrc_debug20 = ddr_in32(&ddr->debug[19]);
|
|
|
|
ddrc_debug2_p[i] = &ddr->debug[1];
|
|
|
|
while (!(ddrc_debug20 & DDRC_DEBUG20_INIT_DONE)) {
|
|
|
|
/* keep polling until DDRC init is done */
|
|
|
|
udelay(100);
|
|
|
|
ddrc_debug20 = ddr_in32(&ddr->debug[19]);
|
|
|
|
}
|
|
|
|
ddrc_debug2[i] = ddr_in32(&ddr->debug[1]) | DDRC_DEBUG2_RF;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Sync refresh
|
|
|
|
* This is put together to make sure the refresh reqeusts are sent
|
|
|
|
* closely to each other.
|
|
|
|
*/
|
|
|
|
for (i = first_ctrl; i <= last_ctrl; i++)
|
|
|
|
ddr_out32(ddrc_debug2_p[i], ddrc_debug2[i]);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_FSL_DDR_SYNC_REFRESH */
|
2015-11-04 17:53:10 +00:00
|
|
|
|
|
|
|
void remove_unused_controllers(fsl_ddr_info_t *info)
|
|
|
|
{
|
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
|
|
|
#ifdef CONFIG_SYS_FSL_HAS_CCN504
|
2015-11-04 17:53:10 +00:00
|
|
|
int i;
|
|
|
|
u64 nodeid;
|
|
|
|
void *hnf_sam_ctrl = (void *)(CCI_HN_F_0_BASE + CCN_HN_F_SAM_CTL);
|
|
|
|
bool ddr0_used = false;
|
|
|
|
bool ddr1_used = false;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
nodeid = in_le64(hnf_sam_ctrl) & CCN_HN_F_SAM_NODEID_MASK;
|
|
|
|
if (nodeid == CCN_HN_F_SAM_NODEID_DDR0) {
|
|
|
|
ddr0_used = true;
|
|
|
|
} else if (nodeid == CCN_HN_F_SAM_NODEID_DDR1) {
|
|
|
|
ddr1_used = true;
|
|
|
|
} else {
|
|
|
|
printf("Unknown nodeid in HN-F SAM control: 0x%llx\n",
|
|
|
|
nodeid);
|
|
|
|
}
|
|
|
|
hnf_sam_ctrl += (CCI_HN_F_1_BASE - CCI_HN_F_0_BASE);
|
|
|
|
}
|
|
|
|
if (!ddr0_used && !ddr1_used) {
|
|
|
|
printf("Invalid configuration in HN-F SAM control\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ddr0_used && info->first_ctrl == 0) {
|
|
|
|
info->first_ctrl = 1;
|
|
|
|
info->num_ctrls = 1;
|
|
|
|
debug("First DDR controller disabled\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ddr1_used && info->first_ctrl + info->num_ctrls > 1) {
|
|
|
|
info->num_ctrls = 1;
|
|
|
|
debug("Second DDR controller disabled\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|