Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | f5c208d | 2019-11-14 12:57:20 -0700 | [diff] [blame] | 6 | #include <vsprintf.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 7 | #include <asm/global_data.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 8 | #include <asm/mmu.h> |
| 9 | #include <asm/immap_85xx.h> |
| 10 | #include <asm/processor.h> |
York Sun | f062659 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 11 | #include <fsl_ddr_sdram.h> |
| 12 | #include <fsl_ddr_dimm_params.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | #include <asm/fsl_law.h> |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 18 | /* |
| 19 | * Samsung K4B2G0846C-HCF8 |
| 20 | * The following timing are for "downshift" |
| 21 | * i.e. to use CL9 part as CL7 |
| 22 | * otherwise, tAA, tRCD, tRP will be 13500ps |
| 23 | * and tRC will be 49500ps |
| 24 | */ |
| 25 | dimm_params_t ddr_raw_timing = { |
| 26 | .n_ranks = 1, |
| 27 | .rank_density = 1073741824u, |
| 28 | .capacity = 1073741824u, |
| 29 | .primary_sdram_width = 32, |
| 30 | .ec_sdram_width = 0, |
| 31 | .registered_dimm = 0, |
| 32 | .mirrored_dimm = 0, |
| 33 | .n_row_addr = 15, |
| 34 | .n_col_addr = 10, |
| 35 | .n_banks_per_sdram_device = 8, |
| 36 | .edc_config = 0, |
| 37 | .burst_lengths_bitmask = 0x0c, |
| 38 | |
Priyanka Jain | 4a71741 | 2013-09-25 10:41:19 +0530 | [diff] [blame] | 39 | .tckmin_x_ps = 1875, |
| 40 | .caslat_x = 0x1e << 4, /* 5,6,7,8 */ |
| 41 | .taa_ps = 13125, |
| 42 | .twr_ps = 15000, |
| 43 | .trcd_ps = 13125, |
| 44 | .trrd_ps = 7500, |
| 45 | .trp_ps = 13125, |
| 46 | .tras_ps = 37500, |
| 47 | .trc_ps = 50625, |
| 48 | .trfc_ps = 160000, |
| 49 | .twtr_ps = 7500, |
| 50 | .trtp_ps = 7500, |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 51 | .refresh_rate_ps = 7800000, |
Priyanka Jain | 4a71741 | 2013-09-25 10:41:19 +0530 | [diff] [blame] | 52 | .tfaw_ps = 37500, |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | int fsl_ddr_get_dimm_params(dimm_params_t *pdimm, |
| 56 | unsigned int controller_number, |
| 57 | unsigned int dimm_number) |
| 58 | { |
| 59 | const char dimm_model[] = "Fixed DDR on board"; |
| 60 | |
| 61 | if ((controller_number == 0) && (dimm_number == 0)) { |
| 62 | memcpy(pdimm, &ddr_raw_timing, sizeof(dimm_params_t)); |
| 63 | memset(pdimm->mpart, 0, sizeof(pdimm->mpart)); |
| 64 | memcpy(pdimm->mpart, dimm_model, sizeof(dimm_model) - 1); |
| 65 | } |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | void fsl_ddr_board_options(memctl_options_t *popts, |
| 71 | dimm_params_t *pdimm, |
| 72 | unsigned int ctrl_num) |
| 73 | { |
| 74 | struct cpu_type *cpu; |
| 75 | int i; |
| 76 | popts->clk_adjust = 6; |
| 77 | popts->cpo_override = 0x1f; |
| 78 | popts->write_data_delay = 2; |
| 79 | popts->half_strength_driver_enable = 1; |
| 80 | /* Write leveling override */ |
| 81 | popts->wrlvl_en = 1; |
| 82 | popts->wrlvl_override = 1; |
| 83 | popts->wrlvl_sample = 0xf; |
| 84 | popts->wrlvl_start = 0x8; |
| 85 | popts->trwt_override = 1; |
| 86 | popts->trwt = 0; |
| 87 | |
Simon Glass | a8b5739 | 2012-12-13 20:48:48 +0000 | [diff] [blame] | 88 | cpu = gd->arch.cpu; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 89 | /* P1014 and it's derivatives support max 16it DDR width */ |
York Sun | 8cb6548 | 2012-07-06 17:10:33 -0500 | [diff] [blame] | 90 | if (cpu->soc_ver == SVR_P1014) |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 91 | popts->data_bus_width = DDR_DATA_BUS_WIDTH_16; |
| 92 | |
| 93 | for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) { |
| 94 | popts->cs_local_opts[i].odt_rd_cfg = FSL_DDR_ODT_NEVER; |
| 95 | popts->cs_local_opts[i].odt_wr_cfg = FSL_DDR_ODT_CS; |
| 96 | } |
| 97 | } |