blob: d9c9ddf2bac5ed3a6891e45e33ada709c61163e0 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Valentin Longchamp877bfe32013-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 Rini83d290c2018-05-06 17:58:06 -04007 */
Valentin Longchamp877bfe32013-10-18 11:47:24 +02008
9#include <common.h>
10#include <i2c.h>
11#include <hwconfig.h>
Simon Glass691d7192020-05-10 11:40:02 -060012#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060013#include <log.h>
Valentin Longchamp877bfe32013-10-18 11:47:24 +020014#include <asm/mmu.h>
York Sun5614e712013-09-30 09:22:09 -070015#include <fsl_ddr_sdram.h>
16#include <fsl_ddr_dimm_params.h>
Valentin Longchamp877bfe32013-10-18 11:47:24 +020017
Simon Glass088454c2017-03-31 08:40:25 -060018DECLARE_GLOBAL_DATA_PTR;
19
Valentin Longchamp877bfe32013-10-18 11:47:24 +020020void fsl_ddr_board_options(memctl_options_t *popts,
21 dimm_params_t *pdimm,
22 unsigned int ctrl_num)
23{
24 if (ctrl_num) {
25 printf("Wrong parameter for controller number %d", ctrl_num);
26 return;
27 }
28
29 /* automatic calibration for nb of cycles between read and DQS pre */
30 popts->cpo_override = 0xFF;
31
32 /* 1/2 clk delay between wr command and data strobe */
33 popts->write_data_delay = 4;
34 /* clk lauched 1/2 applied cylcle after address command */
35 popts->clk_adjust = 4;
36 /* 1T timing: command/address held for only 1 cycle */
37 popts->twot_en = 0;
38
39 /* we have only one module, half str should be OK */
40 popts->half_strength_driver_enable = 1;
41
Robert P. J. Day62a3b7d2016-07-15 13:44:45 -040042 /* wrlvl values overridden as recommended by ddr init func */
Valentin Longchamp877bfe32013-10-18 11:47:24 +020043 popts->wrlvl_override = 1;
44 popts->wrlvl_sample = 0xf;
45 popts->wrlvl_start = 0x6;
46
47 /* Enable ZQ calibration */
48 popts->zq_en = 1;
49
50 /* DHC_EN =1, ODT = 75 Ohm */
51 popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR_ODT_75ohm;
52}
53
Simon Glassf1683aa2017-04-06 12:47:05 -060054int dram_init(void)
Valentin Longchamp877bfe32013-10-18 11:47:24 +020055{
56 phys_size_t dram_size = 0;
57
58 puts("Initializing with SPD\n");
59
60 dram_size = fsl_ddr_sdram();
61
62 dram_size = setup_ddr_tlbs(dram_size / 0x100000);
63 dram_size *= 0x100000;
64
65 debug(" DDR: ");
Simon Glass088454c2017-03-31 08:40:25 -060066 gd->ram_size = dram_size;
67
68 return 0;
Valentin Longchamp877bfe32013-10-18 11:47:24 +020069}