2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-06-17 12:37:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 - 2013 Michal Simek <monstr@monstr.eu>
|
2018-01-17 06:37:47 +00:00
|
|
|
* Copyright (C) 2012 - 2017 Xilinx, Inc. All rights reserved.
|
2013-06-17 12:37:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
|
2017-05-12 09:34:11 +00:00
|
|
|
#ifndef CONFIG_ZYNQ_DDRC_INIT
|
|
|
|
void zynq_ddrc_init(void) {}
|
|
|
|
#else
|
2013-06-17 12:37:01 +00:00
|
|
|
/* Control regsiter bitfield definitions */
|
|
|
|
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_MASK 0xC
|
|
|
|
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_SHIFT 2
|
|
|
|
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT 1
|
|
|
|
|
|
|
|
/* ECC scrub regsiter definitions */
|
|
|
|
#define ZYNQ_DDRC_ECC_SCRUBREG_ECC_MODE_MASK 0x7
|
|
|
|
#define ZYNQ_DDRC_ECC_SCRUBREG_ECCMODE_SECDED 0x4
|
|
|
|
|
|
|
|
void zynq_ddrc_init(void)
|
|
|
|
{
|
|
|
|
u32 width, ecctype;
|
|
|
|
|
|
|
|
width = readl(&ddrc_base->ddrc_ctrl);
|
|
|
|
width = (width & ZYNQ_DDRC_CTRLREG_BUSWIDTH_MASK) >>
|
|
|
|
ZYNQ_DDRC_CTRLREG_BUSWIDTH_SHIFT;
|
|
|
|
ecctype = (readl(&ddrc_base->ecc_scrub) &
|
|
|
|
ZYNQ_DDRC_ECC_SCRUBREG_ECC_MODE_MASK);
|
|
|
|
|
|
|
|
/* ECC is enabled when memory is in 16bit mode and it is enabled */
|
|
|
|
if ((ecctype == ZYNQ_DDRC_ECC_SCRUBREG_ECCMODE_SECDED) &&
|
|
|
|
(width == ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT)) {
|
2014-05-15 07:40:14 +00:00
|
|
|
puts("ECC enabled ");
|
2013-06-17 12:37:01 +00:00
|
|
|
/*
|
|
|
|
* Clear the first 1MB because it is not initialized from
|
|
|
|
* first stage bootloader. To get ECC to work all memory has
|
|
|
|
* been initialized by writing any value.
|
|
|
|
*/
|
2014-11-06 13:02:57 +00:00
|
|
|
/* cppcheck-suppress nullPointer */
|
2014-04-25 12:19:00 +00:00
|
|
|
memset((void *)0, 0, 1 * 1024 * 1024);
|
2013-06-17 12:37:01 +00:00
|
|
|
} else {
|
2014-05-15 07:40:14 +00:00
|
|
|
puts("ECC disabled ");
|
2013-06-17 12:37:01 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-12 09:34:11 +00:00
|
|
|
#endif
|