Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 Gateworks Corporation |
| 3 | * Author: Tim Harvey <tharvey@gateworks.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <linux/types.h> |
Peng Fan | da7ada0 | 2015-08-17 16:11:04 +0800 | [diff] [blame] | 10 | #include <asm/arch/clock.h> |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 11 | #include <asm/arch/mx6-ddr.h> |
| 12 | #include <asm/arch/sys_proto.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/types.h> |
| 15 | |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 16 | #if defined(CONFIG_MX6SX) |
| 17 | /* Configure MX6SX mmdc iomux */ |
| 18 | void mx6sx_dram_iocfg(unsigned width, |
| 19 | const struct mx6sx_iomux_ddr_regs *ddr, |
| 20 | const struct mx6sx_iomux_grp_regs *grp) |
| 21 | { |
| 22 | struct mx6sx_iomux_ddr_regs *mx6_ddr_iomux; |
| 23 | struct mx6sx_iomux_grp_regs *mx6_grp_iomux; |
| 24 | |
| 25 | mx6_ddr_iomux = (struct mx6sx_iomux_ddr_regs *)MX6SX_IOM_DDR_BASE; |
| 26 | mx6_grp_iomux = (struct mx6sx_iomux_grp_regs *)MX6SX_IOM_GRP_BASE; |
| 27 | |
| 28 | /* DDR IO TYPE */ |
| 29 | writel(grp->grp_ddr_type, &mx6_grp_iomux->grp_ddr_type); |
| 30 | writel(grp->grp_ddrpke, &mx6_grp_iomux->grp_ddrpke); |
| 31 | |
| 32 | /* CLOCK */ |
| 33 | writel(ddr->dram_sdclk_0, &mx6_ddr_iomux->dram_sdclk_0); |
| 34 | |
| 35 | /* ADDRESS */ |
| 36 | writel(ddr->dram_cas, &mx6_ddr_iomux->dram_cas); |
| 37 | writel(ddr->dram_ras, &mx6_ddr_iomux->dram_ras); |
| 38 | writel(grp->grp_addds, &mx6_grp_iomux->grp_addds); |
| 39 | |
| 40 | /* Control */ |
| 41 | writel(ddr->dram_reset, &mx6_ddr_iomux->dram_reset); |
| 42 | writel(ddr->dram_sdba2, &mx6_ddr_iomux->dram_sdba2); |
| 43 | writel(ddr->dram_sdcke0, &mx6_ddr_iomux->dram_sdcke0); |
| 44 | writel(ddr->dram_sdcke1, &mx6_ddr_iomux->dram_sdcke1); |
| 45 | writel(ddr->dram_odt0, &mx6_ddr_iomux->dram_odt0); |
| 46 | writel(ddr->dram_odt1, &mx6_ddr_iomux->dram_odt1); |
| 47 | writel(grp->grp_ctlds, &mx6_grp_iomux->grp_ctlds); |
| 48 | |
| 49 | /* Data Strobes */ |
| 50 | writel(grp->grp_ddrmode_ctl, &mx6_grp_iomux->grp_ddrmode_ctl); |
| 51 | writel(ddr->dram_sdqs0, &mx6_ddr_iomux->dram_sdqs0); |
| 52 | writel(ddr->dram_sdqs1, &mx6_ddr_iomux->dram_sdqs1); |
| 53 | if (width >= 32) { |
| 54 | writel(ddr->dram_sdqs2, &mx6_ddr_iomux->dram_sdqs2); |
| 55 | writel(ddr->dram_sdqs3, &mx6_ddr_iomux->dram_sdqs3); |
| 56 | } |
| 57 | |
| 58 | /* Data */ |
| 59 | writel(grp->grp_ddrmode, &mx6_grp_iomux->grp_ddrmode); |
| 60 | writel(grp->grp_b0ds, &mx6_grp_iomux->grp_b0ds); |
| 61 | writel(grp->grp_b1ds, &mx6_grp_iomux->grp_b1ds); |
| 62 | if (width >= 32) { |
| 63 | writel(grp->grp_b2ds, &mx6_grp_iomux->grp_b2ds); |
| 64 | writel(grp->grp_b3ds, &mx6_grp_iomux->grp_b3ds); |
| 65 | } |
| 66 | writel(ddr->dram_dqm0, &mx6_ddr_iomux->dram_dqm0); |
| 67 | writel(ddr->dram_dqm1, &mx6_ddr_iomux->dram_dqm1); |
| 68 | if (width >= 32) { |
| 69 | writel(ddr->dram_dqm2, &mx6_ddr_iomux->dram_dqm2); |
| 70 | writel(ddr->dram_dqm3, &mx6_ddr_iomux->dram_dqm3); |
| 71 | } |
| 72 | } |
| 73 | #endif |
| 74 | |
Peng Fan | 98f11a1 | 2015-07-20 19:28:33 +0800 | [diff] [blame] | 75 | #ifdef CONFIG_MX6UL |
| 76 | void mx6ul_dram_iocfg(unsigned width, |
| 77 | const struct mx6ul_iomux_ddr_regs *ddr, |
| 78 | const struct mx6ul_iomux_grp_regs *grp) |
| 79 | { |
| 80 | struct mx6ul_iomux_ddr_regs *mx6_ddr_iomux; |
| 81 | struct mx6ul_iomux_grp_regs *mx6_grp_iomux; |
| 82 | |
| 83 | mx6_ddr_iomux = (struct mx6ul_iomux_ddr_regs *)MX6UL_IOM_DDR_BASE; |
| 84 | mx6_grp_iomux = (struct mx6ul_iomux_grp_regs *)MX6UL_IOM_GRP_BASE; |
| 85 | |
| 86 | /* DDR IO TYPE */ |
| 87 | writel(grp->grp_ddr_type, &mx6_grp_iomux->grp_ddr_type); |
| 88 | writel(grp->grp_ddrpke, &mx6_grp_iomux->grp_ddrpke); |
| 89 | |
| 90 | /* CLOCK */ |
| 91 | writel(ddr->dram_sdclk_0, &mx6_ddr_iomux->dram_sdclk_0); |
| 92 | |
| 93 | /* ADDRESS */ |
| 94 | writel(ddr->dram_cas, &mx6_ddr_iomux->dram_cas); |
| 95 | writel(ddr->dram_ras, &mx6_ddr_iomux->dram_ras); |
| 96 | writel(grp->grp_addds, &mx6_grp_iomux->grp_addds); |
| 97 | |
| 98 | /* Control */ |
| 99 | writel(ddr->dram_reset, &mx6_ddr_iomux->dram_reset); |
| 100 | writel(ddr->dram_sdba2, &mx6_ddr_iomux->dram_sdba2); |
| 101 | writel(ddr->dram_odt0, &mx6_ddr_iomux->dram_odt0); |
| 102 | writel(ddr->dram_odt1, &mx6_ddr_iomux->dram_odt1); |
| 103 | writel(grp->grp_ctlds, &mx6_grp_iomux->grp_ctlds); |
| 104 | |
| 105 | /* Data Strobes */ |
| 106 | writel(grp->grp_ddrmode_ctl, &mx6_grp_iomux->grp_ddrmode_ctl); |
| 107 | writel(ddr->dram_sdqs0, &mx6_ddr_iomux->dram_sdqs0); |
| 108 | writel(ddr->dram_sdqs1, &mx6_ddr_iomux->dram_sdqs1); |
| 109 | |
| 110 | /* Data */ |
| 111 | writel(grp->grp_ddrmode, &mx6_grp_iomux->grp_ddrmode); |
| 112 | writel(grp->grp_b0ds, &mx6_grp_iomux->grp_b0ds); |
| 113 | writel(grp->grp_b1ds, &mx6_grp_iomux->grp_b1ds); |
| 114 | writel(ddr->dram_dqm0, &mx6_ddr_iomux->dram_dqm0); |
| 115 | writel(ddr->dram_dqm1, &mx6_ddr_iomux->dram_dqm1); |
| 116 | } |
| 117 | #endif |
| 118 | |
Peng Fan | d226fac | 2015-08-17 16:11:00 +0800 | [diff] [blame] | 119 | #if defined(CONFIG_MX6SL) |
| 120 | void mx6sl_dram_iocfg(unsigned width, |
| 121 | const struct mx6sl_iomux_ddr_regs *ddr, |
| 122 | const struct mx6sl_iomux_grp_regs *grp) |
| 123 | { |
| 124 | struct mx6sl_iomux_ddr_regs *mx6_ddr_iomux; |
| 125 | struct mx6sl_iomux_grp_regs *mx6_grp_iomux; |
| 126 | |
| 127 | mx6_ddr_iomux = (struct mx6sl_iomux_ddr_regs *)MX6SL_IOM_DDR_BASE; |
| 128 | mx6_grp_iomux = (struct mx6sl_iomux_grp_regs *)MX6SL_IOM_GRP_BASE; |
| 129 | |
| 130 | /* DDR IO TYPE */ |
| 131 | mx6_grp_iomux->grp_ddr_type = grp->grp_ddr_type; |
| 132 | mx6_grp_iomux->grp_ddrpke = grp->grp_ddrpke; |
| 133 | |
| 134 | /* CLOCK */ |
| 135 | mx6_ddr_iomux->dram_sdclk_0 = ddr->dram_sdclk_0; |
| 136 | |
| 137 | /* ADDRESS */ |
| 138 | mx6_ddr_iomux->dram_cas = ddr->dram_cas; |
| 139 | mx6_ddr_iomux->dram_ras = ddr->dram_ras; |
| 140 | mx6_grp_iomux->grp_addds = grp->grp_addds; |
| 141 | |
| 142 | /* Control */ |
| 143 | mx6_ddr_iomux->dram_reset = ddr->dram_reset; |
| 144 | mx6_ddr_iomux->dram_sdba2 = ddr->dram_sdba2; |
| 145 | mx6_grp_iomux->grp_ctlds = grp->grp_ctlds; |
| 146 | |
| 147 | /* Data Strobes */ |
| 148 | mx6_grp_iomux->grp_ddrmode_ctl = grp->grp_ddrmode_ctl; |
| 149 | mx6_ddr_iomux->dram_sdqs0 = ddr->dram_sdqs0; |
| 150 | mx6_ddr_iomux->dram_sdqs1 = ddr->dram_sdqs1; |
| 151 | if (width >= 32) { |
| 152 | mx6_ddr_iomux->dram_sdqs2 = ddr->dram_sdqs2; |
| 153 | mx6_ddr_iomux->dram_sdqs3 = ddr->dram_sdqs3; |
| 154 | } |
| 155 | |
| 156 | /* Data */ |
| 157 | mx6_grp_iomux->grp_ddrmode = grp->grp_ddrmode; |
| 158 | mx6_grp_iomux->grp_b0ds = grp->grp_b0ds; |
| 159 | mx6_grp_iomux->grp_b1ds = grp->grp_b1ds; |
| 160 | if (width >= 32) { |
| 161 | mx6_grp_iomux->grp_b2ds = grp->grp_b2ds; |
| 162 | mx6_grp_iomux->grp_b3ds = grp->grp_b3ds; |
| 163 | } |
| 164 | |
| 165 | mx6_ddr_iomux->dram_dqm0 = ddr->dram_dqm0; |
| 166 | mx6_ddr_iomux->dram_dqm1 = ddr->dram_dqm1; |
| 167 | if (width >= 32) { |
| 168 | mx6_ddr_iomux->dram_dqm2 = ddr->dram_dqm2; |
| 169 | mx6_ddr_iomux->dram_dqm3 = ddr->dram_dqm3; |
| 170 | } |
| 171 | } |
| 172 | #endif |
| 173 | |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 174 | #if defined(CONFIG_MX6QDL) || defined(CONFIG_MX6Q) || defined(CONFIG_MX6D) |
| 175 | /* Configure MX6DQ mmdc iomux */ |
| 176 | void mx6dq_dram_iocfg(unsigned width, |
| 177 | const struct mx6dq_iomux_ddr_regs *ddr, |
| 178 | const struct mx6dq_iomux_grp_regs *grp) |
| 179 | { |
| 180 | volatile struct mx6dq_iomux_ddr_regs *mx6_ddr_iomux; |
| 181 | volatile struct mx6dq_iomux_grp_regs *mx6_grp_iomux; |
| 182 | |
| 183 | mx6_ddr_iomux = (struct mx6dq_iomux_ddr_regs *)MX6DQ_IOM_DDR_BASE; |
| 184 | mx6_grp_iomux = (struct mx6dq_iomux_grp_regs *)MX6DQ_IOM_GRP_BASE; |
| 185 | |
| 186 | /* DDR IO Type */ |
| 187 | mx6_grp_iomux->grp_ddr_type = grp->grp_ddr_type; |
| 188 | mx6_grp_iomux->grp_ddrpke = grp->grp_ddrpke; |
| 189 | |
| 190 | /* Clock */ |
| 191 | mx6_ddr_iomux->dram_sdclk_0 = ddr->dram_sdclk_0; |
| 192 | mx6_ddr_iomux->dram_sdclk_1 = ddr->dram_sdclk_1; |
| 193 | |
| 194 | /* Address */ |
| 195 | mx6_ddr_iomux->dram_cas = ddr->dram_cas; |
| 196 | mx6_ddr_iomux->dram_ras = ddr->dram_ras; |
| 197 | mx6_grp_iomux->grp_addds = grp->grp_addds; |
| 198 | |
| 199 | /* Control */ |
| 200 | mx6_ddr_iomux->dram_reset = ddr->dram_reset; |
| 201 | mx6_ddr_iomux->dram_sdcke0 = ddr->dram_sdcke0; |
| 202 | mx6_ddr_iomux->dram_sdcke1 = ddr->dram_sdcke1; |
| 203 | mx6_ddr_iomux->dram_sdba2 = ddr->dram_sdba2; |
| 204 | mx6_ddr_iomux->dram_sdodt0 = ddr->dram_sdodt0; |
| 205 | mx6_ddr_iomux->dram_sdodt1 = ddr->dram_sdodt1; |
| 206 | mx6_grp_iomux->grp_ctlds = grp->grp_ctlds; |
| 207 | |
| 208 | /* Data Strobes */ |
| 209 | mx6_grp_iomux->grp_ddrmode_ctl = grp->grp_ddrmode_ctl; |
| 210 | mx6_ddr_iomux->dram_sdqs0 = ddr->dram_sdqs0; |
| 211 | mx6_ddr_iomux->dram_sdqs1 = ddr->dram_sdqs1; |
| 212 | if (width >= 32) { |
| 213 | mx6_ddr_iomux->dram_sdqs2 = ddr->dram_sdqs2; |
| 214 | mx6_ddr_iomux->dram_sdqs3 = ddr->dram_sdqs3; |
| 215 | } |
| 216 | if (width >= 64) { |
| 217 | mx6_ddr_iomux->dram_sdqs4 = ddr->dram_sdqs4; |
| 218 | mx6_ddr_iomux->dram_sdqs5 = ddr->dram_sdqs5; |
| 219 | mx6_ddr_iomux->dram_sdqs6 = ddr->dram_sdqs6; |
| 220 | mx6_ddr_iomux->dram_sdqs7 = ddr->dram_sdqs7; |
| 221 | } |
| 222 | |
| 223 | /* Data */ |
| 224 | mx6_grp_iomux->grp_ddrmode = grp->grp_ddrmode; |
| 225 | mx6_grp_iomux->grp_b0ds = grp->grp_b0ds; |
| 226 | mx6_grp_iomux->grp_b1ds = grp->grp_b1ds; |
| 227 | if (width >= 32) { |
| 228 | mx6_grp_iomux->grp_b2ds = grp->grp_b2ds; |
| 229 | mx6_grp_iomux->grp_b3ds = grp->grp_b3ds; |
| 230 | } |
| 231 | if (width >= 64) { |
| 232 | mx6_grp_iomux->grp_b4ds = grp->grp_b4ds; |
| 233 | mx6_grp_iomux->grp_b5ds = grp->grp_b5ds; |
| 234 | mx6_grp_iomux->grp_b6ds = grp->grp_b6ds; |
| 235 | mx6_grp_iomux->grp_b7ds = grp->grp_b7ds; |
| 236 | } |
| 237 | mx6_ddr_iomux->dram_dqm0 = ddr->dram_dqm0; |
| 238 | mx6_ddr_iomux->dram_dqm1 = ddr->dram_dqm1; |
| 239 | if (width >= 32) { |
| 240 | mx6_ddr_iomux->dram_dqm2 = ddr->dram_dqm2; |
| 241 | mx6_ddr_iomux->dram_dqm3 = ddr->dram_dqm3; |
| 242 | } |
| 243 | if (width >= 64) { |
| 244 | mx6_ddr_iomux->dram_dqm4 = ddr->dram_dqm4; |
| 245 | mx6_ddr_iomux->dram_dqm5 = ddr->dram_dqm5; |
| 246 | mx6_ddr_iomux->dram_dqm6 = ddr->dram_dqm6; |
| 247 | mx6_ddr_iomux->dram_dqm7 = ddr->dram_dqm7; |
| 248 | } |
| 249 | } |
| 250 | #endif |
| 251 | |
| 252 | #if defined(CONFIG_MX6QDL) || defined(CONFIG_MX6DL) || defined(CONFIG_MX6S) |
| 253 | /* Configure MX6SDL mmdc iomux */ |
| 254 | void mx6sdl_dram_iocfg(unsigned width, |
| 255 | const struct mx6sdl_iomux_ddr_regs *ddr, |
| 256 | const struct mx6sdl_iomux_grp_regs *grp) |
| 257 | { |
| 258 | volatile struct mx6sdl_iomux_ddr_regs *mx6_ddr_iomux; |
| 259 | volatile struct mx6sdl_iomux_grp_regs *mx6_grp_iomux; |
| 260 | |
| 261 | mx6_ddr_iomux = (struct mx6sdl_iomux_ddr_regs *)MX6SDL_IOM_DDR_BASE; |
| 262 | mx6_grp_iomux = (struct mx6sdl_iomux_grp_regs *)MX6SDL_IOM_GRP_BASE; |
| 263 | |
| 264 | /* DDR IO Type */ |
| 265 | mx6_grp_iomux->grp_ddr_type = grp->grp_ddr_type; |
| 266 | mx6_grp_iomux->grp_ddrpke = grp->grp_ddrpke; |
| 267 | |
| 268 | /* Clock */ |
| 269 | mx6_ddr_iomux->dram_sdclk_0 = ddr->dram_sdclk_0; |
| 270 | mx6_ddr_iomux->dram_sdclk_1 = ddr->dram_sdclk_1; |
| 271 | |
| 272 | /* Address */ |
| 273 | mx6_ddr_iomux->dram_cas = ddr->dram_cas; |
| 274 | mx6_ddr_iomux->dram_ras = ddr->dram_ras; |
| 275 | mx6_grp_iomux->grp_addds = grp->grp_addds; |
| 276 | |
| 277 | /* Control */ |
| 278 | mx6_ddr_iomux->dram_reset = ddr->dram_reset; |
| 279 | mx6_ddr_iomux->dram_sdcke0 = ddr->dram_sdcke0; |
| 280 | mx6_ddr_iomux->dram_sdcke1 = ddr->dram_sdcke1; |
| 281 | mx6_ddr_iomux->dram_sdba2 = ddr->dram_sdba2; |
| 282 | mx6_ddr_iomux->dram_sdodt0 = ddr->dram_sdodt0; |
| 283 | mx6_ddr_iomux->dram_sdodt1 = ddr->dram_sdodt1; |
| 284 | mx6_grp_iomux->grp_ctlds = grp->grp_ctlds; |
| 285 | |
| 286 | /* Data Strobes */ |
| 287 | mx6_grp_iomux->grp_ddrmode_ctl = grp->grp_ddrmode_ctl; |
| 288 | mx6_ddr_iomux->dram_sdqs0 = ddr->dram_sdqs0; |
| 289 | mx6_ddr_iomux->dram_sdqs1 = ddr->dram_sdqs1; |
| 290 | if (width >= 32) { |
| 291 | mx6_ddr_iomux->dram_sdqs2 = ddr->dram_sdqs2; |
| 292 | mx6_ddr_iomux->dram_sdqs3 = ddr->dram_sdqs3; |
| 293 | } |
| 294 | if (width >= 64) { |
| 295 | mx6_ddr_iomux->dram_sdqs4 = ddr->dram_sdqs4; |
| 296 | mx6_ddr_iomux->dram_sdqs5 = ddr->dram_sdqs5; |
| 297 | mx6_ddr_iomux->dram_sdqs6 = ddr->dram_sdqs6; |
| 298 | mx6_ddr_iomux->dram_sdqs7 = ddr->dram_sdqs7; |
| 299 | } |
| 300 | |
| 301 | /* Data */ |
| 302 | mx6_grp_iomux->grp_ddrmode = grp->grp_ddrmode; |
| 303 | mx6_grp_iomux->grp_b0ds = grp->grp_b0ds; |
| 304 | mx6_grp_iomux->grp_b1ds = grp->grp_b1ds; |
| 305 | if (width >= 32) { |
| 306 | mx6_grp_iomux->grp_b2ds = grp->grp_b2ds; |
| 307 | mx6_grp_iomux->grp_b3ds = grp->grp_b3ds; |
| 308 | } |
| 309 | if (width >= 64) { |
| 310 | mx6_grp_iomux->grp_b4ds = grp->grp_b4ds; |
| 311 | mx6_grp_iomux->grp_b5ds = grp->grp_b5ds; |
| 312 | mx6_grp_iomux->grp_b6ds = grp->grp_b6ds; |
| 313 | mx6_grp_iomux->grp_b7ds = grp->grp_b7ds; |
| 314 | } |
| 315 | mx6_ddr_iomux->dram_dqm0 = ddr->dram_dqm0; |
| 316 | mx6_ddr_iomux->dram_dqm1 = ddr->dram_dqm1; |
| 317 | if (width >= 32) { |
| 318 | mx6_ddr_iomux->dram_dqm2 = ddr->dram_dqm2; |
| 319 | mx6_ddr_iomux->dram_dqm3 = ddr->dram_dqm3; |
| 320 | } |
| 321 | if (width >= 64) { |
| 322 | mx6_ddr_iomux->dram_dqm4 = ddr->dram_dqm4; |
| 323 | mx6_ddr_iomux->dram_dqm5 = ddr->dram_dqm5; |
| 324 | mx6_ddr_iomux->dram_dqm6 = ddr->dram_dqm6; |
| 325 | mx6_ddr_iomux->dram_dqm7 = ddr->dram_dqm7; |
| 326 | } |
| 327 | } |
| 328 | #endif |
| 329 | |
| 330 | /* |
| 331 | * Configure mx6 mmdc registers based on: |
| 332 | * - board-specific memory configuration |
| 333 | * - board-specific calibration data |
Peng Fan | da7ada0 | 2015-08-17 16:11:04 +0800 | [diff] [blame] | 334 | * - ddr3/lpddr2 chip details |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 335 | * |
| 336 | * The various calculations here are derived from the Freescale |
Peng Fan | da7ada0 | 2015-08-17 16:11:04 +0800 | [diff] [blame] | 337 | * 1. i.Mx6DQSDL DDR3 Script Aid spreadsheet (DOC-94917) designed to generate |
| 338 | * MMDC configuration registers based on memory system and memory chip |
| 339 | * parameters. |
| 340 | * |
| 341 | * 2. i.Mx6SL LPDDR2 Script Aid spreadsheet V0.04 designed to generate MMDC |
| 342 | * configuration registers based on memory system and memory chip |
| 343 | * parameters. |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 344 | * |
| 345 | * The defaults here are those which were specified in the spreadsheet. |
| 346 | * For details on each register, refer to the IMX6DQRM and/or IMX6SDLRM |
Peng Fan | da7ada0 | 2015-08-17 16:11:04 +0800 | [diff] [blame] | 347 | * and/or IMX6SLRM section titled MMDC initialization. |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 348 | */ |
| 349 | #define MR(val, ba, cmd, cs1) \ |
| 350 | ((val << 16) | (1 << 15) | (cmd << 4) | (cs1 << 3) | ba) |
Peng Fan | 98f11a1 | 2015-07-20 19:28:33 +0800 | [diff] [blame] | 351 | #define MMDC1(entry, value) do { \ |
Peng Fan | 1b81b06 | 2015-08-17 16:10:58 +0800 | [diff] [blame] | 352 | if (!is_cpu_type(MXC_CPU_MX6SX) && !is_cpu_type(MXC_CPU_MX6UL) && \ |
| 353 | !is_cpu_type(MXC_CPU_MX6SL)) \ |
Peng Fan | 98f11a1 | 2015-07-20 19:28:33 +0800 | [diff] [blame] | 354 | mmdc1->entry = value; \ |
| 355 | } while (0) |
| 356 | |
Peng Fan | da7ada0 | 2015-08-17 16:11:04 +0800 | [diff] [blame] | 357 | /* |
| 358 | * According JESD209-2B-LPDDR2: Table 103 |
| 359 | * WL: write latency |
| 360 | */ |
| 361 | static int lpddr2_wl(uint32_t mem_speed) |
| 362 | { |
| 363 | switch (mem_speed) { |
| 364 | case 1066: |
| 365 | case 933: |
| 366 | return 4; |
| 367 | case 800: |
| 368 | return 3; |
| 369 | case 677: |
| 370 | case 533: |
| 371 | return 2; |
| 372 | case 400: |
| 373 | case 333: |
| 374 | return 1; |
| 375 | default: |
| 376 | puts("invalid memory speed\n"); |
| 377 | hang(); |
| 378 | } |
| 379 | |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | /* |
| 384 | * According JESD209-2B-LPDDR2: Table 103 |
| 385 | * RL: read latency |
| 386 | */ |
| 387 | static int lpddr2_rl(uint32_t mem_speed) |
| 388 | { |
| 389 | switch (mem_speed) { |
| 390 | case 1066: |
| 391 | return 8; |
| 392 | case 933: |
| 393 | return 7; |
| 394 | case 800: |
| 395 | return 6; |
| 396 | case 677: |
| 397 | return 5; |
| 398 | case 533: |
| 399 | return 4; |
| 400 | case 400: |
| 401 | case 333: |
| 402 | return 3; |
| 403 | default: |
| 404 | puts("invalid memory speed\n"); |
| 405 | hang(); |
| 406 | } |
| 407 | |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | void mx6_lpddr2_cfg(const struct mx6_ddr_sysinfo *sysinfo, |
| 412 | const struct mx6_mmdc_calibration *calib, |
| 413 | const struct mx6_lpddr2_cfg *lpddr2_cfg) |
| 414 | { |
| 415 | volatile struct mmdc_p_regs *mmdc0; |
| 416 | u32 val; |
| 417 | u8 tcke, tcksrx, tcksre, trrd; |
| 418 | u8 twl, txp, tfaw, tcl; |
| 419 | u16 tras, twr, tmrd, trtp, twtr, trfc, txsr; |
| 420 | u16 trcd_lp, trppb_lp, trpab_lp, trc_lp; |
| 421 | u16 cs0_end; |
| 422 | u8 coladdr; |
| 423 | int clkper; /* clock period in picoseconds */ |
| 424 | int clock; /* clock freq in mHz */ |
| 425 | int cs; |
| 426 | |
| 427 | /* only support 16/32 bits */ |
| 428 | if (sysinfo->dsize > 1) |
| 429 | hang(); |
| 430 | |
| 431 | mmdc0 = (struct mmdc_p_regs *)MMDC_P0_BASE_ADDR; |
| 432 | |
| 433 | clock = mxc_get_clock(MXC_DDR_CLK) / 1000000U; |
| 434 | clkper = (1000 * 1000) / clock; /* pico seconds */ |
| 435 | |
| 436 | twl = lpddr2_wl(lpddr2_cfg->mem_speed) - 1; |
| 437 | |
| 438 | /* LPDDR2-S2 and LPDDR2-S4 have the same tRFC value. */ |
| 439 | switch (lpddr2_cfg->density) { |
| 440 | case 1: |
| 441 | case 2: |
| 442 | case 4: |
| 443 | trfc = DIV_ROUND_UP(130000, clkper) - 1; |
| 444 | txsr = DIV_ROUND_UP(140000, clkper) - 1; |
| 445 | break; |
| 446 | case 8: |
| 447 | trfc = DIV_ROUND_UP(210000, clkper) - 1; |
| 448 | txsr = DIV_ROUND_UP(220000, clkper) - 1; |
| 449 | break; |
| 450 | default: |
| 451 | /* |
| 452 | * 64Mb, 128Mb, 256Mb, 512Mb are not supported currently. |
| 453 | */ |
| 454 | hang(); |
| 455 | break; |
| 456 | } |
| 457 | /* |
| 458 | * txpdll, txpr, taonpd and taofpd are not relevant in LPDDR2 mode, |
| 459 | * set them to 0. */ |
| 460 | txp = DIV_ROUND_UP(7500, clkper) - 1; |
| 461 | tcke = 3; |
| 462 | if (lpddr2_cfg->mem_speed == 333) |
| 463 | tfaw = DIV_ROUND_UP(60000, clkper) - 1; |
| 464 | else |
| 465 | tfaw = DIV_ROUND_UP(50000, clkper) - 1; |
| 466 | trrd = DIV_ROUND_UP(10000, clkper) - 1; |
| 467 | |
| 468 | /* tckesr for LPDDR2 */ |
| 469 | tcksre = DIV_ROUND_UP(15000, clkper); |
| 470 | tcksrx = tcksre; |
| 471 | twr = DIV_ROUND_UP(15000, clkper) - 1; |
| 472 | /* |
| 473 | * tMRR: 2, tMRW: 5 |
| 474 | * tMRD should be set to max(tMRR, tMRW) |
| 475 | */ |
| 476 | tmrd = 5; |
| 477 | tras = DIV_ROUND_UP(lpddr2_cfg->trasmin, clkper / 10) - 1; |
| 478 | /* LPDDR2 mode use tRCD_LP filed in MDCFG3. */ |
| 479 | trcd_lp = DIV_ROUND_UP(lpddr2_cfg->trcd_lp, clkper / 10) - 1; |
| 480 | trc_lp = DIV_ROUND_UP(lpddr2_cfg->trasmin + lpddr2_cfg->trppb_lp, |
| 481 | clkper / 10) - 1; |
| 482 | trppb_lp = DIV_ROUND_UP(lpddr2_cfg->trppb_lp, clkper / 10) - 1; |
| 483 | trpab_lp = DIV_ROUND_UP(lpddr2_cfg->trpab_lp, clkper / 10) - 1; |
| 484 | /* To LPDDR2, CL in MDCFG0 refers to RL */ |
| 485 | tcl = lpddr2_rl(lpddr2_cfg->mem_speed) - 3; |
| 486 | twtr = DIV_ROUND_UP(7500, clkper) - 1; |
| 487 | trtp = DIV_ROUND_UP(7500, clkper) - 1; |
| 488 | |
| 489 | cs0_end = 4 * sysinfo->cs_density - 1; |
| 490 | |
| 491 | debug("density:%d Gb (%d Gb per chip)\n", |
| 492 | sysinfo->cs_density, lpddr2_cfg->density); |
| 493 | debug("clock: %dMHz (%d ps)\n", clock, clkper); |
| 494 | debug("memspd:%d\n", lpddr2_cfg->mem_speed); |
| 495 | debug("trcd_lp=%d\n", trcd_lp); |
| 496 | debug("trppb_lp=%d\n", trppb_lp); |
| 497 | debug("trpab_lp=%d\n", trpab_lp); |
| 498 | debug("trc_lp=%d\n", trc_lp); |
| 499 | debug("tcke=%d\n", tcke); |
| 500 | debug("tcksrx=%d\n", tcksrx); |
| 501 | debug("tcksre=%d\n", tcksre); |
| 502 | debug("trfc=%d\n", trfc); |
| 503 | debug("txsr=%d\n", txsr); |
| 504 | debug("txp=%d\n", txp); |
| 505 | debug("tfaw=%d\n", tfaw); |
| 506 | debug("tcl=%d\n", tcl); |
| 507 | debug("tras=%d\n", tras); |
| 508 | debug("twr=%d\n", twr); |
| 509 | debug("tmrd=%d\n", tmrd); |
| 510 | debug("twl=%d\n", twl); |
| 511 | debug("trtp=%d\n", trtp); |
| 512 | debug("twtr=%d\n", twtr); |
| 513 | debug("trrd=%d\n", trrd); |
| 514 | debug("cs0_end=%d\n", cs0_end); |
| 515 | debug("ncs=%d\n", sysinfo->ncs); |
| 516 | |
| 517 | /* |
| 518 | * board-specific configuration: |
| 519 | * These values are determined empirically and vary per board layout |
| 520 | */ |
| 521 | mmdc0->mpwldectrl0 = calib->p0_mpwldectrl0; |
| 522 | mmdc0->mpwldectrl1 = calib->p0_mpwldectrl1; |
| 523 | mmdc0->mpdgctrl0 = calib->p0_mpdgctrl0; |
| 524 | mmdc0->mpdgctrl1 = calib->p0_mpdgctrl1; |
| 525 | mmdc0->mprddlctl = calib->p0_mprddlctl; |
| 526 | mmdc0->mpwrdlctl = calib->p0_mpwrdlctl; |
| 527 | mmdc0->mpzqlp2ctl = calib->mpzqlp2ctl; |
| 528 | |
| 529 | /* Read data DQ Byte0-3 delay */ |
| 530 | mmdc0->mprddqby0dl = 0x33333333; |
| 531 | mmdc0->mprddqby1dl = 0x33333333; |
| 532 | if (sysinfo->dsize > 0) { |
| 533 | mmdc0->mprddqby2dl = 0x33333333; |
| 534 | mmdc0->mprddqby3dl = 0x33333333; |
| 535 | } |
| 536 | |
| 537 | /* Write data DQ Byte0-3 delay */ |
| 538 | mmdc0->mpwrdqby0dl = 0xf3333333; |
| 539 | mmdc0->mpwrdqby1dl = 0xf3333333; |
| 540 | if (sysinfo->dsize > 0) { |
| 541 | mmdc0->mpwrdqby2dl = 0xf3333333; |
| 542 | mmdc0->mpwrdqby3dl = 0xf3333333; |
| 543 | } |
| 544 | |
| 545 | /* |
| 546 | * In LPDDR2 mode this register should be cleared, |
| 547 | * so no termination will be activated. |
| 548 | */ |
| 549 | mmdc0->mpodtctrl = 0; |
| 550 | |
| 551 | /* complete calibration */ |
| 552 | val = (1 << 11); /* Force measurement on delay-lines */ |
| 553 | mmdc0->mpmur0 = val; |
| 554 | |
| 555 | /* Step 1: configuration request */ |
| 556 | mmdc0->mdscr = (u32)(1 << 15); /* config request */ |
| 557 | |
| 558 | /* Step 2: Timing configuration */ |
| 559 | mmdc0->mdcfg0 = (trfc << 24) | (txsr << 16) | (txp << 13) | |
| 560 | (tfaw << 4) | tcl; |
| 561 | mmdc0->mdcfg1 = (tras << 16) | (twr << 9) | (tmrd << 5) | twl; |
| 562 | mmdc0->mdcfg2 = (trtp << 6) | (twtr << 3) | trrd; |
| 563 | mmdc0->mdcfg3lp = (trc_lp << 16) | (trcd_lp << 8) | |
| 564 | (trppb_lp << 4) | trpab_lp; |
| 565 | mmdc0->mdotc = 0; |
| 566 | |
| 567 | mmdc0->mdasp = cs0_end; /* CS addressing */ |
| 568 | |
| 569 | /* Step 3: Configure DDR type */ |
| 570 | mmdc0->mdmisc = (sysinfo->cs1_mirror << 19) | (sysinfo->walat << 16) | |
| 571 | (sysinfo->bi_on << 12) | (sysinfo->mif3_mode << 9) | |
| 572 | (sysinfo->ralat << 6) | (1 << 3); |
| 573 | |
| 574 | /* Step 4: Configure delay while leaving reset */ |
| 575 | mmdc0->mdor = (sysinfo->sde_to_rst << 8) | |
| 576 | (sysinfo->rst_to_cke << 0); |
| 577 | |
| 578 | /* Step 5: Configure DDR physical parameters (density and burst len) */ |
| 579 | coladdr = lpddr2_cfg->coladdr; |
| 580 | if (lpddr2_cfg->coladdr == 8) /* 8-bit COL is 0x3 */ |
| 581 | coladdr += 4; |
| 582 | else if (lpddr2_cfg->coladdr == 12) /* 12-bit COL is 0x4 */ |
| 583 | coladdr += 1; |
| 584 | mmdc0->mdctl = (lpddr2_cfg->rowaddr - 11) << 24 | /* ROW */ |
| 585 | (coladdr - 9) << 20 | /* COL */ |
| 586 | (0 << 19) | /* Burst Length = 4 for LPDDR2 */ |
| 587 | (sysinfo->dsize << 16); /* DDR data bus size */ |
| 588 | |
| 589 | /* Step 6: Perform ZQ calibration */ |
| 590 | val = 0xa1390003; /* one-time HW ZQ calib */ |
| 591 | mmdc0->mpzqhwctrl = val; |
| 592 | |
| 593 | /* Step 7: Enable MMDC with desired chip select */ |
| 594 | mmdc0->mdctl |= (1 << 31) | /* SDE_0 for CS0 */ |
| 595 | ((sysinfo->ncs == 2) ? 1 : 0) << 30; /* SDE_1 for CS1 */ |
| 596 | |
| 597 | /* Step 8: Write Mode Registers to Init LPDDR2 devices */ |
| 598 | for (cs = 0; cs < sysinfo->ncs; cs++) { |
| 599 | /* MR63: reset */ |
| 600 | mmdc0->mdscr = MR(63, 0, 3, cs); |
| 601 | /* MR10: calibration, |
| 602 | * 0xff is calibration command after intilization. |
| 603 | */ |
| 604 | val = 0xA | (0xff << 8); |
| 605 | mmdc0->mdscr = MR(val, 0, 3, cs); |
| 606 | /* MR1 */ |
| 607 | val = 0x1 | (0x82 << 8); |
| 608 | mmdc0->mdscr = MR(val, 0, 3, cs); |
| 609 | /* MR2 */ |
| 610 | val = 0x2 | (0x04 << 8); |
| 611 | mmdc0->mdscr = MR(val, 0, 3, cs); |
| 612 | /* MR3 */ |
| 613 | val = 0x3 | (0x02 << 8); |
| 614 | mmdc0->mdscr = MR(val, 0, 3, cs); |
| 615 | } |
| 616 | |
| 617 | /* Step 10: Power down control and self-refresh */ |
| 618 | mmdc0->mdpdc = (tcke & 0x7) << 16 | |
| 619 | 5 << 12 | /* PWDT_1: 256 cycles */ |
| 620 | 5 << 8 | /* PWDT_0: 256 cycles */ |
| 621 | 1 << 6 | /* BOTH_CS_PD */ |
| 622 | (tcksrx & 0x7) << 3 | |
| 623 | (tcksre & 0x7); |
| 624 | mmdc0->mapsr = 0x00001006; /* ADOPT power down enabled */ |
| 625 | |
| 626 | /* Step 11: Configure ZQ calibration: one-time and periodic 1ms */ |
| 627 | val = 0xa1310003; |
| 628 | mmdc0->mpzqhwctrl = val; |
| 629 | |
| 630 | /* Step 12: Configure and activate periodic refresh */ |
| 631 | mmdc0->mdref = (0 << 14) | /* REF_SEL: Periodic refresh cycle: 64kHz */ |
| 632 | (3 << 11); /* REFR: Refresh Rate - 4 refreshes */ |
| 633 | |
| 634 | /* Step 13: Deassert config request - init complete */ |
| 635 | mmdc0->mdscr = 0x00000000; |
| 636 | |
| 637 | /* wait for auto-ZQ calibration to complete */ |
| 638 | mdelay(1); |
| 639 | } |
| 640 | |
Peng Fan | 77e8695 | 2015-08-17 16:11:03 +0800 | [diff] [blame] | 641 | void mx6_ddr3_cfg(const struct mx6_ddr_sysinfo *sysinfo, |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 642 | const struct mx6_mmdc_calibration *calib, |
| 643 | const struct mx6_ddr3_cfg *ddr3_cfg) |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 644 | { |
| 645 | volatile struct mmdc_p_regs *mmdc0; |
| 646 | volatile struct mmdc_p_regs *mmdc1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 647 | u32 val; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 648 | u8 tcke, tcksrx, tcksre, txpdll, taofpd, taonpd, trrd; |
| 649 | u8 todtlon, taxpd, tanpd, tcwl, txp, tfaw, tcl; |
| 650 | u8 todt_idle_off = 0x4; /* from DDR3 Script Aid spreadsheet */ |
| 651 | u16 trcd, trc, tras, twr, tmrd, trtp, trp, twtr, trfc, txs, txpr; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 652 | u16 cs0_end; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 653 | u16 tdllk = 0x1ff; /* DLL locking time: 512 cycles (JEDEC DDR3) */ |
Marek Vasut | 4a46360 | 2014-08-04 01:47:10 +0200 | [diff] [blame] | 654 | u8 coladdr; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 655 | int clkper; /* clock period in picoseconds */ |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 656 | int clock; /* clock freq in MHz */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 657 | int cs; |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 658 | u16 mem_speed = ddr3_cfg->mem_speed; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 659 | |
| 660 | mmdc0 = (struct mmdc_p_regs *)MMDC_P0_BASE_ADDR; |
Peng Fan | 1b81b06 | 2015-08-17 16:10:58 +0800 | [diff] [blame] | 661 | if (!is_cpu_type(MXC_CPU_MX6SX) && !is_cpu_type(MXC_CPU_MX6UL) && |
| 662 | !is_cpu_type(MXC_CPU_MX6SL)) |
Peng Fan | 98f11a1 | 2015-07-20 19:28:33 +0800 | [diff] [blame] | 663 | mmdc1 = (struct mmdc_p_regs *)MMDC_P1_BASE_ADDR; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 664 | |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 665 | /* Limit mem_speed for MX6D/MX6Q */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 666 | if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) { |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 667 | if (mem_speed > 1066) |
| 668 | mem_speed = 1066; /* 1066 MT/s */ |
| 669 | |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 670 | tcwl = 4; |
| 671 | } |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 672 | /* Limit mem_speed for MX6S/MX6DL */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 673 | else { |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 674 | if (mem_speed > 800) |
| 675 | mem_speed = 800; /* 800 MT/s */ |
| 676 | |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 677 | tcwl = 3; |
| 678 | } |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 679 | |
| 680 | clock = mem_speed / 2; |
| 681 | /* |
| 682 | * Data rate of 1066 MT/s requires 533 MHz DDR3 clock, but MX6D/Q supports |
| 683 | * up to 528 MHz, so reduce the clock to fit chip specs |
| 684 | */ |
| 685 | if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) { |
| 686 | if (clock > 528) |
| 687 | clock = 528; /* 528 MHz */ |
| 688 | } |
| 689 | |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 690 | clkper = (1000 * 1000) / clock; /* pico seconds */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 691 | todtlon = tcwl; |
| 692 | taxpd = tcwl; |
| 693 | tanpd = tcwl; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 694 | |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 695 | switch (ddr3_cfg->density) { |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 696 | case 1: /* 1Gb per chip */ |
| 697 | trfc = DIV_ROUND_UP(110000, clkper) - 1; |
| 698 | txs = DIV_ROUND_UP(120000, clkper) - 1; |
| 699 | break; |
| 700 | case 2: /* 2Gb per chip */ |
| 701 | trfc = DIV_ROUND_UP(160000, clkper) - 1; |
| 702 | txs = DIV_ROUND_UP(170000, clkper) - 1; |
| 703 | break; |
| 704 | case 4: /* 4Gb per chip */ |
Peng Fan | b96b74c | 2015-09-01 11:03:14 +0800 | [diff] [blame] | 705 | trfc = DIV_ROUND_UP(260000, clkper) - 1; |
| 706 | txs = DIV_ROUND_UP(270000, clkper) - 1; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 707 | break; |
| 708 | case 8: /* 8Gb per chip */ |
| 709 | trfc = DIV_ROUND_UP(350000, clkper) - 1; |
| 710 | txs = DIV_ROUND_UP(360000, clkper) - 1; |
| 711 | break; |
| 712 | default: |
| 713 | /* invalid density */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 714 | puts("invalid chip density\n"); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 715 | hang(); |
| 716 | break; |
| 717 | } |
| 718 | txpr = txs; |
| 719 | |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 720 | switch (mem_speed) { |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 721 | case 800: |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 722 | txp = DIV_ROUND_UP(max(3 * clkper, 7500), clkper) - 1; |
| 723 | tcke = DIV_ROUND_UP(max(3 * clkper, 7500), clkper) - 1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 724 | if (ddr3_cfg->pagesz == 1) { |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 725 | tfaw = DIV_ROUND_UP(40000, clkper) - 1; |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 726 | trrd = DIV_ROUND_UP(max(4 * clkper, 10000), clkper) - 1; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 727 | } else { |
| 728 | tfaw = DIV_ROUND_UP(50000, clkper) - 1; |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 729 | trrd = DIV_ROUND_UP(max(4 * clkper, 10000), clkper) - 1; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 730 | } |
| 731 | break; |
| 732 | case 1066: |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 733 | txp = DIV_ROUND_UP(max(3 * clkper, 7500), clkper) - 1; |
| 734 | tcke = DIV_ROUND_UP(max(3 * clkper, 5625), clkper) - 1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 735 | if (ddr3_cfg->pagesz == 1) { |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 736 | tfaw = DIV_ROUND_UP(37500, clkper) - 1; |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 737 | trrd = DIV_ROUND_UP(max(4 * clkper, 7500), clkper) - 1; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 738 | } else { |
| 739 | tfaw = DIV_ROUND_UP(50000, clkper) - 1; |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 740 | trrd = DIV_ROUND_UP(max(4 * clkper, 10000), clkper) - 1; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 741 | } |
| 742 | break; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 743 | default: |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 744 | puts("invalid memory speed\n"); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 745 | hang(); |
| 746 | break; |
| 747 | } |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 748 | txpdll = DIV_ROUND_UP(max(10 * clkper, 24000), clkper) - 1; |
| 749 | tcksre = DIV_ROUND_UP(max(5 * clkper, 10000), clkper); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 750 | taonpd = DIV_ROUND_UP(2000, clkper) - 1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 751 | tcksrx = tcksre; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 752 | taofpd = taonpd; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 753 | twr = DIV_ROUND_UP(15000, clkper) - 1; |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 754 | tmrd = DIV_ROUND_UP(max(12 * clkper, 15000), clkper) - 1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 755 | trc = DIV_ROUND_UP(ddr3_cfg->trcmin, clkper / 10) - 1; |
| 756 | tras = DIV_ROUND_UP(ddr3_cfg->trasmin, clkper / 10) - 1; |
| 757 | tcl = DIV_ROUND_UP(ddr3_cfg->trcd, clkper / 10) - 3; |
| 758 | trp = DIV_ROUND_UP(ddr3_cfg->trcd, clkper / 10) - 1; |
Masahiro Yamada | b62b39b | 2014-09-18 13:28:06 +0900 | [diff] [blame] | 759 | twtr = ROUND(max(4 * clkper, 7500) / clkper, 1) - 1; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 760 | trcd = trp; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 761 | trtp = twtr; |
Nikita Kiryanov | 4a50ec2 | 2014-08-20 15:08:58 +0300 | [diff] [blame] | 762 | cs0_end = 4 * sysinfo->cs_density - 1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 763 | |
| 764 | debug("density:%d Gb (%d Gb per chip)\n", |
| 765 | sysinfo->cs_density, ddr3_cfg->density); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 766 | debug("clock: %dMHz (%d ps)\n", clock, clkper); |
Nikolay Dimitrov | 99c25ff | 2015-04-22 18:37:31 +0300 | [diff] [blame] | 767 | debug("memspd:%d\n", mem_speed); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 768 | debug("tcke=%d\n", tcke); |
| 769 | debug("tcksrx=%d\n", tcksrx); |
| 770 | debug("tcksre=%d\n", tcksre); |
| 771 | debug("taofpd=%d\n", taofpd); |
| 772 | debug("taonpd=%d\n", taonpd); |
| 773 | debug("todtlon=%d\n", todtlon); |
| 774 | debug("tanpd=%d\n", tanpd); |
| 775 | debug("taxpd=%d\n", taxpd); |
| 776 | debug("trfc=%d\n", trfc); |
| 777 | debug("txs=%d\n", txs); |
| 778 | debug("txp=%d\n", txp); |
| 779 | debug("txpdll=%d\n", txpdll); |
| 780 | debug("tfaw=%d\n", tfaw); |
| 781 | debug("tcl=%d\n", tcl); |
| 782 | debug("trcd=%d\n", trcd); |
| 783 | debug("trp=%d\n", trp); |
| 784 | debug("trc=%d\n", trc); |
| 785 | debug("tras=%d\n", tras); |
| 786 | debug("twr=%d\n", twr); |
| 787 | debug("tmrd=%d\n", tmrd); |
| 788 | debug("tcwl=%d\n", tcwl); |
| 789 | debug("tdllk=%d\n", tdllk); |
| 790 | debug("trtp=%d\n", trtp); |
| 791 | debug("twtr=%d\n", twtr); |
| 792 | debug("trrd=%d\n", trrd); |
| 793 | debug("txpr=%d\n", txpr); |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 794 | debug("cs0_end=%d\n", cs0_end); |
| 795 | debug("ncs=%d\n", sysinfo->ncs); |
| 796 | debug("Rtt_wr=%d\n", sysinfo->rtt_wr); |
| 797 | debug("Rtt_nom=%d\n", sysinfo->rtt_nom); |
| 798 | debug("SRT=%d\n", ddr3_cfg->SRT); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 799 | debug("twr=%d\n", twr); |
| 800 | |
| 801 | /* |
| 802 | * board-specific configuration: |
| 803 | * These values are determined empirically and vary per board layout |
| 804 | * see: |
| 805 | * appnote, ddr3 spreadsheet |
| 806 | */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 807 | mmdc0->mpwldectrl0 = calib->p0_mpwldectrl0; |
| 808 | mmdc0->mpwldectrl1 = calib->p0_mpwldectrl1; |
| 809 | mmdc0->mpdgctrl0 = calib->p0_mpdgctrl0; |
| 810 | mmdc0->mpdgctrl1 = calib->p0_mpdgctrl1; |
| 811 | mmdc0->mprddlctl = calib->p0_mprddlctl; |
| 812 | mmdc0->mpwrdlctl = calib->p0_mpwrdlctl; |
| 813 | if (sysinfo->dsize > 1) { |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 814 | MMDC1(mpwldectrl0, calib->p1_mpwldectrl0); |
| 815 | MMDC1(mpwldectrl1, calib->p1_mpwldectrl1); |
| 816 | MMDC1(mpdgctrl0, calib->p1_mpdgctrl0); |
| 817 | MMDC1(mpdgctrl1, calib->p1_mpdgctrl1); |
| 818 | MMDC1(mprddlctl, calib->p1_mprddlctl); |
| 819 | MMDC1(mpwrdlctl, calib->p1_mpwrdlctl); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 820 | } |
| 821 | |
| 822 | /* Read data DQ Byte0-3 delay */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 823 | mmdc0->mprddqby0dl = 0x33333333; |
| 824 | mmdc0->mprddqby1dl = 0x33333333; |
| 825 | if (sysinfo->dsize > 0) { |
| 826 | mmdc0->mprddqby2dl = 0x33333333; |
| 827 | mmdc0->mprddqby3dl = 0x33333333; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 828 | } |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 829 | |
| 830 | if (sysinfo->dsize > 1) { |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 831 | MMDC1(mprddqby0dl, 0x33333333); |
| 832 | MMDC1(mprddqby1dl, 0x33333333); |
| 833 | MMDC1(mprddqby2dl, 0x33333333); |
| 834 | MMDC1(mprddqby3dl, 0x33333333); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | /* MMDC Termination: rtt_nom:2 RZQ/2(120ohm), rtt_nom:1 RZQ/4(60ohm) */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 838 | val = (sysinfo->rtt_nom == 2) ? 0x00011117 : 0x00022227; |
| 839 | mmdc0->mpodtctrl = val; |
| 840 | if (sysinfo->dsize > 1) |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 841 | MMDC1(mpodtctrl, val); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 842 | |
| 843 | /* complete calibration */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 844 | val = (1 << 11); /* Force measurement on delay-lines */ |
| 845 | mmdc0->mpmur0 = val; |
| 846 | if (sysinfo->dsize > 1) |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 847 | MMDC1(mpmur0, val); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 848 | |
| 849 | /* Step 1: configuration request */ |
| 850 | mmdc0->mdscr = (u32)(1 << 15); /* config request */ |
| 851 | |
| 852 | /* Step 2: Timing configuration */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 853 | mmdc0->mdcfg0 = (trfc << 24) | (txs << 16) | (txp << 13) | |
| 854 | (txpdll << 9) | (tfaw << 4) | tcl; |
| 855 | mmdc0->mdcfg1 = (trcd << 29) | (trp << 26) | (trc << 21) | |
| 856 | (tras << 16) | (1 << 15) /* trpa */ | |
| 857 | (twr << 9) | (tmrd << 5) | tcwl; |
| 858 | mmdc0->mdcfg2 = (tdllk << 16) | (trtp << 6) | (twtr << 3) | trrd; |
| 859 | mmdc0->mdotc = (taofpd << 27) | (taonpd << 24) | (tanpd << 20) | |
| 860 | (taxpd << 16) | (todtlon << 12) | (todt_idle_off << 4); |
| 861 | mmdc0->mdasp = cs0_end; /* CS addressing */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 862 | |
| 863 | /* Step 3: Configure DDR type */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 864 | mmdc0->mdmisc = (sysinfo->cs1_mirror << 19) | (sysinfo->walat << 16) | |
| 865 | (sysinfo->bi_on << 12) | (sysinfo->mif3_mode << 9) | |
| 866 | (sysinfo->ralat << 6); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 867 | |
| 868 | /* Step 4: Configure delay while leaving reset */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 869 | mmdc0->mdor = (txpr << 16) | (sysinfo->sde_to_rst << 8) | |
| 870 | (sysinfo->rst_to_cke << 0); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 871 | |
| 872 | /* Step 5: Configure DDR physical parameters (density and burst len) */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 873 | coladdr = ddr3_cfg->coladdr; |
| 874 | if (ddr3_cfg->coladdr == 8) /* 8-bit COL is 0x3 */ |
Marek Vasut | 4a46360 | 2014-08-04 01:47:10 +0200 | [diff] [blame] | 875 | coladdr += 4; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 876 | else if (ddr3_cfg->coladdr == 12) /* 12-bit COL is 0x4 */ |
Marek Vasut | 4a46360 | 2014-08-04 01:47:10 +0200 | [diff] [blame] | 877 | coladdr += 1; |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 878 | mmdc0->mdctl = (ddr3_cfg->rowaddr - 11) << 24 | /* ROW */ |
| 879 | (coladdr - 9) << 20 | /* COL */ |
| 880 | (1 << 19) | /* Burst Length = 8 for DDR3 */ |
| 881 | (sysinfo->dsize << 16); /* DDR data bus size */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 882 | |
| 883 | /* Step 6: Perform ZQ calibration */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 884 | val = 0xa1390001; /* one-time HW ZQ calib */ |
| 885 | mmdc0->mpzqhwctrl = val; |
| 886 | if (sysinfo->dsize > 1) |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 887 | MMDC1(mpzqhwctrl, val); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 888 | |
| 889 | /* Step 7: Enable MMDC with desired chip select */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 890 | mmdc0->mdctl |= (1 << 31) | /* SDE_0 for CS0 */ |
| 891 | ((sysinfo->ncs == 2) ? 1 : 0) << 30; /* SDE_1 for CS1 */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 892 | |
| 893 | /* Step 8: Write Mode Registers to Init DDR3 devices */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 894 | for (cs = 0; cs < sysinfo->ncs; cs++) { |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 895 | /* MR2 */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 896 | val = (sysinfo->rtt_wr & 3) << 9 | (ddr3_cfg->SRT & 1) << 7 | |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 897 | ((tcwl - 3) & 3) << 3; |
Tim Harvey | fe1723f | 2015-04-03 16:52:52 -0700 | [diff] [blame] | 898 | debug("MR2 CS%d: 0x%08x\n", cs, (u32)MR(val, 2, 3, cs)); |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 899 | mmdc0->mdscr = MR(val, 2, 3, cs); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 900 | /* MR3 */ |
Tim Harvey | fe1723f | 2015-04-03 16:52:52 -0700 | [diff] [blame] | 901 | debug("MR3 CS%d: 0x%08x\n", cs, (u32)MR(0, 3, 3, cs)); |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 902 | mmdc0->mdscr = MR(0, 3, 3, cs); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 903 | /* MR1 */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 904 | val = ((sysinfo->rtt_nom & 1) ? 1 : 0) << 2 | |
| 905 | ((sysinfo->rtt_nom & 2) ? 1 : 0) << 6; |
Tim Harvey | fe1723f | 2015-04-03 16:52:52 -0700 | [diff] [blame] | 906 | debug("MR1 CS%d: 0x%08x\n", cs, (u32)MR(val, 1, 3, cs)); |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 907 | mmdc0->mdscr = MR(val, 1, 3, cs); |
| 908 | /* MR0 */ |
| 909 | val = ((tcl - 1) << 4) | /* CAS */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 910 | (1 << 8) | /* DLL Reset */ |
Tim Harvey | 591fe97 | 2015-05-18 07:07:02 -0700 | [diff] [blame] | 911 | ((twr - 3) << 9) | /* Write Recovery */ |
| 912 | (sysinfo->pd_fast_exit << 12); /* Precharge PD PLL on */ |
Tim Harvey | fe1723f | 2015-04-03 16:52:52 -0700 | [diff] [blame] | 913 | debug("MR0 CS%d: 0x%08x\n", cs, (u32)MR(val, 0, 3, cs)); |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 914 | mmdc0->mdscr = MR(val, 0, 3, cs); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 915 | /* ZQ calibration */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 916 | val = (1 << 10); |
| 917 | mmdc0->mdscr = MR(val, 0, 4, cs); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | /* Step 10: Power down control and self-refresh */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 921 | mmdc0->mdpdc = (tcke & 0x7) << 16 | |
| 922 | 5 << 12 | /* PWDT_1: 256 cycles */ |
| 923 | 5 << 8 | /* PWDT_0: 256 cycles */ |
| 924 | 1 << 6 | /* BOTH_CS_PD */ |
| 925 | (tcksrx & 0x7) << 3 | |
| 926 | (tcksre & 0x7); |
Tim Harvey | fe1723f | 2015-04-03 16:52:52 -0700 | [diff] [blame] | 927 | if (!sysinfo->pd_fast_exit) |
| 928 | mmdc0->mdpdc |= (1 << 7); /* SLOW_PD */ |
Nikita Kiryanov | 6816f71 | 2014-08-20 15:08:56 +0300 | [diff] [blame] | 929 | mmdc0->mapsr = 0x00001006; /* ADOPT power down enabled */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 930 | |
| 931 | /* Step 11: Configure ZQ calibration: one-time and periodic 1ms */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 932 | val = 0xa1390003; |
| 933 | mmdc0->mpzqhwctrl = val; |
| 934 | if (sysinfo->dsize > 1) |
Peng Fan | 2ecdd02 | 2014-12-30 17:24:01 +0800 | [diff] [blame] | 935 | MMDC1(mpzqhwctrl, val); |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 936 | |
| 937 | /* Step 12: Configure and activate periodic refresh */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 938 | mmdc0->mdref = (1 << 14) | /* REF_SEL: Periodic refresh cycle: 32kHz */ |
| 939 | (7 << 11); /* REFR: Refresh Rate - 8 refreshes */ |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 940 | |
| 941 | /* Step 13: Deassert config request - init complete */ |
Nikita Kiryanov | c475346 | 2014-09-07 18:58:11 +0300 | [diff] [blame] | 942 | mmdc0->mdscr = 0x00000000; |
Tim Harvey | 8ab871b | 2014-06-02 16:13:23 -0700 | [diff] [blame] | 943 | |
| 944 | /* wait for auto-ZQ calibration to complete */ |
| 945 | mdelay(1); |
| 946 | } |
Peng Fan | 77e8695 | 2015-08-17 16:11:03 +0800 | [diff] [blame] | 947 | |
| 948 | void mx6_dram_cfg(const struct mx6_ddr_sysinfo *sysinfo, |
| 949 | const struct mx6_mmdc_calibration *calib, |
| 950 | const void *ddr_cfg) |
| 951 | { |
| 952 | if (sysinfo->ddr_type == DDR_TYPE_DDR3) { |
| 953 | mx6_ddr3_cfg(sysinfo, calib, ddr_cfg); |
Peng Fan | da7ada0 | 2015-08-17 16:11:04 +0800 | [diff] [blame] | 954 | } else if (sysinfo->ddr_type == DDR_TYPE_LPDDR2) { |
| 955 | mx6_lpddr2_cfg(sysinfo, calib, ddr_cfg); |
Peng Fan | 77e8695 | 2015-08-17 16:11:03 +0800 | [diff] [blame] | 956 | } else { |
| 957 | puts("Unsupported ddr type\n"); |
| 958 | hang(); |
| 959 | } |
| 960 | } |