blob: ee2e3d6b9aac83a4a2cca0b55b56b22bb0146db0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Valentin Longchampc98bf292013-10-18 11:47:24 +02002/*
3 * (C) Copyright 2013 Keymile AG
4 * Valentin Longchamp <valentin.longchamp@keymile.com>
5 *
6 * Copyright 2009-2011 Freescale Semiconductor, Inc.
Tom Rini10e47792018-05-06 17:58:06 -04007 */
Valentin Longchampc98bf292013-10-18 11:47:24 +02008
9#include <common.h>
10#include <i2c.h>
11#include <hwconfig.h>
12#include <asm/mmu.h>
York Sunf0626592013-09-30 09:22:09 -070013#include <fsl_ddr_sdram.h>
14#include <fsl_ddr_dimm_params.h>
Valentin Longchampc98bf292013-10-18 11:47:24 +020015
Simon Glass39f90ba2017-03-31 08:40:25 -060016DECLARE_GLOBAL_DATA_PTR;
17
Valentin Longchampc98bf292013-10-18 11:47:24 +020018void fsl_ddr_board_options(memctl_options_t *popts,
19 dimm_params_t *pdimm,
20 unsigned int ctrl_num)
21{
22 if (ctrl_num) {
23 printf("Wrong parameter for controller number %d", ctrl_num);
24 return;
25 }
26
27 /* automatic calibration for nb of cycles between read and DQS pre */
28 popts->cpo_override = 0xFF;
29
30 /* 1/2 clk delay between wr command and data strobe */
31 popts->write_data_delay = 4;
32 /* clk lauched 1/2 applied cylcle after address command */
33 popts->clk_adjust = 4;
34 /* 1T timing: command/address held for only 1 cycle */
35 popts->twot_en = 0;
36
37 /* we have only one module, half str should be OK */
38 popts->half_strength_driver_enable = 1;
39
Robert P. J. Day8d56db92016-07-15 13:44:45 -040040 /* wrlvl values overridden as recommended by ddr init func */
Valentin Longchampc98bf292013-10-18 11:47:24 +020041 popts->wrlvl_override = 1;
42 popts->wrlvl_sample = 0xf;
43 popts->wrlvl_start = 0x6;
44
45 /* Enable ZQ calibration */
46 popts->zq_en = 1;
47
48 /* DHC_EN =1, ODT = 75 Ohm */
49 popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR_ODT_75ohm;
50}
51
Simon Glassd35f3382017-04-06 12:47:05 -060052int dram_init(void)
Valentin Longchampc98bf292013-10-18 11:47:24 +020053{
54 phys_size_t dram_size = 0;
55
56 puts("Initializing with SPD\n");
57
58 dram_size = fsl_ddr_sdram();
59
60 dram_size = setup_ddr_tlbs(dram_size / 0x100000);
61 dram_size *= 0x100000;
62
63 debug(" DDR: ");
Simon Glass39f90ba2017-03-31 08:40:25 -060064 gd->ram_size = dram_size;
65
66 return 0;
Valentin Longchampc98bf292013-10-18 11:47:24 +020067}