2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-09-19 10:56:43 +00:00
|
|
|
/*
|
|
|
|
* K2G: DDR3 initialization
|
|
|
|
*
|
|
|
|
* (C) Copyright 2015
|
|
|
|
* Texas Instruments Incorporated, <www.ti.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include "ddr3_cfg.h"
|
|
|
|
#include <asm/arch/ddr3.h>
|
2017-12-28 15:09:59 +00:00
|
|
|
#include <asm/arch/hardware.h>
|
2017-06-16 22:25:24 +00:00
|
|
|
#include "board.h"
|
2015-09-19 10:56:43 +00:00
|
|
|
|
2017-06-16 22:25:24 +00:00
|
|
|
/* K2G GP EVM DDR3 Configuration */
|
2017-12-28 15:10:03 +00:00
|
|
|
static struct ddr3_phy_config ddr3phy_800_2g = {
|
2015-09-19 10:56:43 +00:00
|
|
|
.pllcr = 0x000DC000ul,
|
|
|
|
.pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
|
|
|
|
.pgcr1_val = ((1 << 2) | (1 << 7) | (1 << 23)),
|
|
|
|
.ptr0 = 0x42C21590ul,
|
|
|
|
.ptr1 = 0xD05612C0ul,
|
|
|
|
.ptr2 = 0,
|
|
|
|
.ptr3 = 0x06C30D40ul,
|
|
|
|
.ptr4 = 0x06413880ul,
|
|
|
|
.dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
|
|
|
|
.dcr_val = ((1 << 10)),
|
|
|
|
.dtpr0 = 0x550F6644ul,
|
|
|
|
.dtpr1 = 0x328341E0ul,
|
|
|
|
.dtpr2 = 0x50022A00ul,
|
|
|
|
.mr0 = 0x00001430ul,
|
|
|
|
.mr1 = 0x00000006ul,
|
2017-06-16 22:25:20 +00:00
|
|
|
.mr2 = 0x00000000ul,
|
2015-09-19 10:56:43 +00:00
|
|
|
.dtcr = 0x710035C7ul,
|
|
|
|
.pgcr2 = 0x00F03D09ul,
|
|
|
|
.zq0cr1 = 0x0001005Dul,
|
|
|
|
.zq1cr1 = 0x0001005Bul,
|
|
|
|
.zq2cr1 = 0x0001005Bul,
|
|
|
|
.pir_v1 = 0x00000033ul,
|
2017-06-16 22:25:21 +00:00
|
|
|
.datx8_2_mask = 0,
|
|
|
|
.datx8_2_val = 0,
|
|
|
|
.datx8_3_mask = 0,
|
|
|
|
.datx8_3_val = 0,
|
|
|
|
.datx8_4_mask = 0,
|
|
|
|
.datx8_4_val = ((1 << 0)),
|
|
|
|
.datx8_5_mask = DXEN_MASK,
|
|
|
|
.datx8_5_val = 0,
|
|
|
|
.datx8_6_mask = DXEN_MASK,
|
|
|
|
.datx8_6_val = 0,
|
|
|
|
.datx8_7_mask = DXEN_MASK,
|
|
|
|
.datx8_7_val = 0,
|
|
|
|
.datx8_8_mask = DXEN_MASK,
|
|
|
|
.datx8_8_val = 0,
|
2015-09-19 10:56:43 +00:00
|
|
|
.pir_v2 = 0x00000F81ul,
|
|
|
|
};
|
|
|
|
|
2017-12-28 15:09:59 +00:00
|
|
|
static struct ddr3_phy_config ddr3phy_1066_2g = {
|
|
|
|
.pllcr = 0x000DC000ul,
|
|
|
|
.pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
|
|
|
|
.pgcr1_val = ((1 << 2) | (2 << 7) | (1 << 23)),
|
|
|
|
.ptr0 = 0x42C21590ul,
|
|
|
|
.ptr1 = 0xD05612C0ul,
|
|
|
|
.ptr2 = 0,
|
|
|
|
.ptr3 = 0x0904111Dul,
|
|
|
|
.ptr4 = 0x0859A072ul,
|
|
|
|
.dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
|
|
|
|
.dcr_val = ((1 << 10)),
|
|
|
|
.dtpr0 = 0x6D147744ul,
|
|
|
|
.dtpr1 = 0x32845A80ul,
|
|
|
|
.dtpr2 = 0x50023600ul,
|
|
|
|
.mr0 = 0x00001830ul,
|
|
|
|
.mr1 = 0x00000006ul,
|
|
|
|
.mr2 = 0x00000000ul,
|
|
|
|
.dtcr = 0x710035C7ul,
|
|
|
|
.pgcr2 = 0x00F05159ul,
|
|
|
|
.zq0cr1 = 0x0001005Dul,
|
|
|
|
.zq1cr1 = 0x0001005Bul,
|
|
|
|
.zq2cr1 = 0x0001005Bul,
|
|
|
|
.pir_v1 = 0x00000033ul,
|
|
|
|
.datx8_2_mask = 0,
|
|
|
|
.datx8_2_val = 0,
|
|
|
|
.datx8_3_mask = 0,
|
|
|
|
.datx8_3_val = 0,
|
|
|
|
.datx8_4_mask = 0,
|
|
|
|
.datx8_4_val = ((1 << 0)),
|
|
|
|
.datx8_5_mask = DXEN_MASK,
|
|
|
|
.datx8_5_val = 0,
|
|
|
|
.datx8_6_mask = DXEN_MASK,
|
|
|
|
.datx8_6_val = 0,
|
|
|
|
.datx8_7_mask = DXEN_MASK,
|
|
|
|
.datx8_7_val = 0,
|
|
|
|
.datx8_8_mask = DXEN_MASK,
|
|
|
|
.datx8_8_val = 0,
|
|
|
|
.pir_v2 = 0x00000F81ul,
|
|
|
|
};
|
|
|
|
|
2017-12-28 15:10:03 +00:00
|
|
|
static struct ddr3_emif_config ddr3_800_2g = {
|
2015-09-19 10:56:43 +00:00
|
|
|
.sdcfg = 0x62005662ul,
|
|
|
|
.sdtim1 = 0x0A385033ul,
|
|
|
|
.sdtim2 = 0x00001CA5ul,
|
|
|
|
.sdtim3 = 0x21ADFF32ul,
|
|
|
|
.sdtim4 = 0x533F067Ful,
|
|
|
|
.zqcfg = 0x70073200ul,
|
|
|
|
.sdrfc = 0x00000C34ul,
|
|
|
|
};
|
|
|
|
|
2017-12-28 15:10:03 +00:00
|
|
|
static struct ddr3_emif_config ddr3_1066_2g = {
|
2017-12-28 15:09:59 +00:00
|
|
|
.sdcfg = 0x62005662ul,
|
|
|
|
.sdtim1 = 0x0E4C6843ul,
|
|
|
|
.sdtim2 = 0x00001CC6ul,
|
|
|
|
.sdtim3 = 0x323DFF32ul,
|
|
|
|
.sdtim4 = 0x533F08AFul,
|
|
|
|
.zqcfg = 0x70073200ul,
|
|
|
|
.sdrfc = 0x00001044ul,
|
|
|
|
};
|
|
|
|
|
2017-06-16 22:25:24 +00:00
|
|
|
/* K2G ICE evm DDR3 Configuration */
|
2017-12-28 15:10:03 +00:00
|
|
|
static struct ddr3_phy_config ddr3phy_800_512mb = {
|
2017-06-16 22:25:24 +00:00
|
|
|
.pllcr = 0x000DC000ul,
|
|
|
|
.pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
|
|
|
|
.pgcr1_val = ((1 << 2) | (2 << 7) | (1 << 23)),
|
|
|
|
.ptr0 = 0x42C21590ul,
|
|
|
|
.ptr1 = 0xD05612C0ul,
|
|
|
|
.ptr2 = 0,
|
|
|
|
.ptr3 = 0x06C30D40ul,
|
|
|
|
.ptr4 = 0x06413880ul,
|
|
|
|
.dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
|
|
|
|
.dcr_val = ((1 << 10)),
|
|
|
|
.dtpr0 = 0x550E6644ul,
|
|
|
|
.dtpr1 = 0x32834200ul,
|
|
|
|
.dtpr2 = 0x50022A00ul,
|
|
|
|
.mr0 = 0x00001430ul,
|
|
|
|
.mr1 = 0x00000006ul,
|
|
|
|
.mr2 = 0x00000008ul,
|
|
|
|
.dtcr = 0x710035C7ul,
|
|
|
|
.pgcr2 = 0x00F03D09ul,
|
|
|
|
.zq0cr1 = 0x0001005Dul,
|
|
|
|
.zq1cr1 = 0x0001005Bul,
|
|
|
|
.zq2cr1 = 0x0001005Bul,
|
|
|
|
.pir_v1 = 0x00000033ul,
|
|
|
|
.datx8_2_mask = DXEN_MASK,
|
|
|
|
.datx8_2_val = 0,
|
|
|
|
.datx8_3_mask = DXEN_MASK,
|
|
|
|
.datx8_3_val = 0,
|
|
|
|
.datx8_4_mask = DXEN_MASK,
|
|
|
|
.datx8_4_val = 0,
|
|
|
|
.datx8_5_mask = DXEN_MASK,
|
|
|
|
.datx8_5_val = 0,
|
|
|
|
.datx8_6_mask = DXEN_MASK,
|
|
|
|
.datx8_6_val = 0,
|
|
|
|
.datx8_7_mask = DXEN_MASK,
|
|
|
|
.datx8_7_val = 0,
|
|
|
|
.datx8_8_mask = DXEN_MASK,
|
|
|
|
.datx8_8_val = 0,
|
|
|
|
.pir_v2 = 0x00000F81ul,
|
|
|
|
};
|
|
|
|
|
2017-12-28 15:10:03 +00:00
|
|
|
static struct ddr3_emif_config ddr3_800_512mb = {
|
2017-06-16 22:25:24 +00:00
|
|
|
.sdcfg = 0x62006662ul,
|
|
|
|
.sdtim1 = 0x0A385033ul,
|
|
|
|
.sdtim2 = 0x00001CA5ul,
|
|
|
|
.sdtim3 = 0x21ADFF32ul,
|
|
|
|
.sdtim4 = 0x533F067Ful,
|
|
|
|
.zqcfg = 0x70073200ul,
|
|
|
|
.sdrfc = 0x00000C34ul,
|
|
|
|
};
|
|
|
|
|
2015-09-19 10:56:43 +00:00
|
|
|
u32 ddr3_init(void)
|
|
|
|
{
|
|
|
|
/* Reset DDR3 PHY after PLL enabled */
|
|
|
|
ddr3_reset_ddrphy();
|
2017-12-28 15:09:59 +00:00
|
|
|
if (board_is_k2g_g1()) {
|
|
|
|
ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1066_2g);
|
|
|
|
ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_1066_2g);
|
|
|
|
} else if (board_is_k2g_gp()) {
|
2017-06-16 22:25:24 +00:00
|
|
|
ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_2g);
|
|
|
|
ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_2g);
|
|
|
|
} else if (board_is_k2g_ice()) {
|
|
|
|
ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_512mb);
|
|
|
|
ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_512mb);
|
|
|
|
}
|
2015-09-19 10:56:43 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int ddr3_get_size(void)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|