Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 Keymile AG |
| 4 | * Valentin Longchamp <valentin.longchamp@keymile.com> |
| 5 | * |
| 6 | * Copyright 2009-2011 Freescale Semiconductor, Inc. |
Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 7 | */ |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 8 | |
| 9 | #include <common.h> |
| 10 | #include <i2c.h> |
| 11 | #include <hwconfig.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 13 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 15 | #include <asm/mmu.h> |
York Sun | f062659 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 16 | #include <fsl_ddr_sdram.h> |
| 17 | #include <fsl_ddr_dimm_params.h> |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 18 | |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 21 | void fsl_ddr_board_options(memctl_options_t *popts, |
| 22 | dimm_params_t *pdimm, |
| 23 | unsigned int ctrl_num) |
| 24 | { |
| 25 | if (ctrl_num) { |
| 26 | printf("Wrong parameter for controller number %d", ctrl_num); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | /* automatic calibration for nb of cycles between read and DQS pre */ |
| 31 | popts->cpo_override = 0xFF; |
| 32 | |
| 33 | /* 1/2 clk delay between wr command and data strobe */ |
| 34 | popts->write_data_delay = 4; |
| 35 | /* clk lauched 1/2 applied cylcle after address command */ |
| 36 | popts->clk_adjust = 4; |
| 37 | /* 1T timing: command/address held for only 1 cycle */ |
| 38 | popts->twot_en = 0; |
| 39 | |
| 40 | /* we have only one module, half str should be OK */ |
| 41 | popts->half_strength_driver_enable = 1; |
| 42 | |
Robert P. J. Day | 8d56db9 | 2016-07-15 13:44:45 -0400 | [diff] [blame] | 43 | /* wrlvl values overridden as recommended by ddr init func */ |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 44 | popts->wrlvl_override = 1; |
| 45 | popts->wrlvl_sample = 0xf; |
| 46 | popts->wrlvl_start = 0x6; |
| 47 | |
| 48 | /* Enable ZQ calibration */ |
| 49 | popts->zq_en = 1; |
| 50 | |
| 51 | /* DHC_EN =1, ODT = 75 Ohm */ |
| 52 | popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR_ODT_75ohm; |
| 53 | } |
| 54 | |
Simon Glass | d35f338 | 2017-04-06 12:47:05 -0600 | [diff] [blame] | 55 | int dram_init(void) |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 56 | { |
| 57 | phys_size_t dram_size = 0; |
| 58 | |
| 59 | puts("Initializing with SPD\n"); |
| 60 | |
| 61 | dram_size = fsl_ddr_sdram(); |
| 62 | |
| 63 | dram_size = setup_ddr_tlbs(dram_size / 0x100000); |
| 64 | dram_size *= 0x100000; |
| 65 | |
| 66 | debug(" DDR: "); |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 67 | gd->ram_size = dram_size; |
| 68 | |
| 69 | return 0; |
Valentin Longchamp | c98bf29 | 2013-10-18 11:47:24 +0200 | [diff] [blame] | 70 | } |