2 * Keystone2: DDR3 configuration
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/ddr3.h>
14 #include <asm/arch/hardware.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 /* DDR3 PHY configuration data with 1600M rate, 8GB size */
19 struct ddr3_phy_config ddr3phy_1600_8g = {
20 .pllcr = 0x0001C000ul,
21 .pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
22 .pgcr1_val = ((1 << 2) | (1 << 7) | (1 << 23)),
25 .ptr2 = 0, /* not set in gel */
28 .dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
29 .dcr_val = ((1 << 10)),
30 .dtpr0 = 0xA19DBB66ul,
31 .dtpr1 = 0x32868300ul,
32 .dtpr2 = 0x50035200ul,
37 .pgcr2 = 0x00F07A12ul,
38 .zq0cr1 = 0x0000005Dul,
39 .zq1cr1 = 0x0000005Bul,
40 .zq2cr1 = 0x0000005Bul,
41 .pir_v1 = 0x00000033ul,
42 .pir_v2 = 0x0000FF81ul,
45 /* DDR3 EMIF configuration data with 1600M rate, 8GB size */
46 struct ddr3_emif_config ddr3_1600_8g = {
47 .sdcfg = 0x6200CE6Aul,
48 .sdtim1 = 0x16709C55ul,
49 .sdtim2 = 0x00001D4Aul,
50 .sdtim3 = 0x435DFF54ul,
51 .sdtim4 = 0x553F0CFFul,
52 .zqcfg = 0xF0073200ul,
53 .sdrfc = 0x00001869ul,
56 #ifdef CONFIG_K2HK_EVM
57 /* DDR3 PHY configuration data with 1333M rate, and 2GB size */
58 struct ddr3_phy_config ddr3phy_1333_2g = {
59 .pllcr = 0x0005C000ul,
60 .pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
61 .pgcr1_val = ((1 << 2) | (1 << 7) | (1 << 23)),
64 .ptr2 = 0, /* not set in gel */
67 .dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
68 .dcr_val = ((1 << 10)),
69 .dtpr0 = 0x8558AA55ul,
70 .dtpr1 = 0x32857280ul,
71 .dtpr2 = 0x5002C200ul,
76 .pgcr2 = 0x00F065B8ul,
77 .zq0cr1 = 0x0000005Dul,
78 .zq1cr1 = 0x0000005Bul,
79 .zq2cr1 = 0x0000005Bul,
80 .pir_v1 = 0x00000033ul,
81 .pir_v2 = 0x0000FF81ul,
84 /* DDR3 EMIF configuration data with 1333M rate, and 2GB size */
85 struct ddr3_emif_config ddr3_1333_2g = {
86 .sdcfg = 0x62008C62ul,
87 .sdtim1 = 0x125C8044ul,
88 .sdtim2 = 0x00001D29ul,
89 .sdtim3 = 0x32CDFF43ul,
90 .sdtim4 = 0x543F0ADFul,
91 .zqcfg = 0x70073200ul,
92 .sdrfc = 0x00001457ul,
97 /* DDR3 PHY configuration data with 1600M rate, and 4GB size */
98 struct ddr3_phy_config ddr3phy_1600_4g = {
99 .pllcr = 0x0001C000ul,
100 .pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
101 .pgcr1_val = ((1 << 2) | (1 << 7) | (1 << 23)),
102 .ptr0 = 0x42C21590ul,
103 .ptr1 = 0xD05612C0ul,
104 .ptr2 = 0, /* not set in gel */
105 .ptr3 = 0x08861A80ul,
106 .ptr4 = 0x0C827100ul,
107 .dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
108 .dcr_val = ((1 << 10)),
109 .dtpr0 = 0x9D9CBB66ul,
110 .dtpr1 = 0x12840300ul,
111 .dtpr2 = 0x5002D200ul,
115 .dtcr = 0x710035C7ul,
116 .pgcr2 = 0x00F07A12ul,
117 .zq0cr1 = 0x0001005Dul,
118 .zq1cr1 = 0x0001005Bul,
119 .zq2cr1 = 0x0001005Bul,
120 .pir_v1 = 0x00000033ul,
121 .pir_v2 = 0x0000FF81ul,
124 /* DDR3 EMIF configuration data with 1600M rate, and 4GB size */
125 struct ddr3_emif_config ddr3_1600_4g = {
126 .sdcfg = 0x6200CE62ul,
127 .sdtim1 = 0x166C9855ul,
128 .sdtim2 = 0x00001D4Aul,
129 .sdtim3 = 0x421DFF53ul,
130 .sdtim4 = 0x543F07FFul,
131 .zqcfg = 0x70073200ul,
132 .sdrfc = 0x00001869ul,
136 struct ddr3_phy_config ddr3phy_1600_2g = {
137 .pllcr = 0x0001C000ul,
138 .pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
139 .pgcr1_val = ((1 << 2) | (1 << 7) | (1 << 23)),
140 .ptr0 = 0x42C21590ul,
141 .ptr1 = 0xD05612C0ul,
142 .ptr2 = 0, /* not set in gel */
143 .ptr3 = 0x0D861A80ul,
144 .ptr4 = 0x0C827100ul,
145 .dcr_mask = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
146 .dcr_val = ((1 << 10)),
147 .dtpr0 = 0x9D5CBB66ul,
148 .dtpr1 = 0x12868300ul,
149 .dtpr2 = 0x5002D200ul,
153 .dtcr = 0x710035C7ul,
154 .pgcr2 = 0x00F07A12ul,
155 .zq0cr1 = 0x0001005Dul,
156 .zq1cr1 = 0x0001005Bul,
157 .zq2cr1 = 0x0001005Bul,
158 .pir_v1 = 0x00000033ul,
159 .pir_v2 = 0x0000FF81ul,
162 struct ddr3_emif_config ddr3_1600_2g = {
163 .sdcfg = 0x6200CE62ul,
164 .sdtim1 = 0x166C9855ul,
165 .sdtim2 = 0x00001D4Aul,
166 .sdtim3 = 0x435DFF53ul,
167 .sdtim4 = 0x543F0CFFul,
168 .zqcfg = 0x70073200ul,
169 .sdrfc = 0x00001869ul,
172 int ddr3_get_dimm_params(char *dimm_name)
178 i2c_init(CONFIG_SYS_DAVINCI_I2C_SPEED, CONFIG_SYS_DAVINCI_I2C_SLAVE);
180 old_bus = i2c_get_bus_num();
183 ret = i2c_read(0x53, 0, 1, spd_params, 256);
185 i2c_set_bus_num(old_bus);
190 puts("Cannot read DIMM params\n");
195 * We need to convert spd data to dimm parameters
196 * and to DDR3 EMIF and PHY regirsters values.
197 * For now we just return DIMM type string value.
198 * Caller may use this value to choose appropriate
199 * a pre-set DDR3 configuration
202 strncpy(dimm_name, (char *)&spd_params[0x80], 18);
203 dimm_name[18] = '\0';