Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Freescale Semiconductor, Inc. |
| 3 | * |
York Sun | 3aab0cd | 2013-08-12 14:57:12 -0700 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/fsl_law.h> |
| 9 | #include <asm/fsl_ddr_sdram.h> |
| 10 | #include <asm/fsl_ddr_dimm_params.h> |
| 11 | |
Po Liu | 9c25ee6 | 2013-09-26 09:40:11 +0800 | [diff] [blame] | 12 | #include "cpld.h" |
| 13 | |
| 14 | #define C29XPCIE_HARDWARE_REVA 0x40 |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 15 | /* |
| 16 | * Micron MT41J128M16HA-15E |
| 17 | * */ |
| 18 | dimm_params_t ddr_raw_timing = { |
| 19 | .n_ranks = 1, |
| 20 | .rank_density = 536870912u, |
| 21 | .capacity = 536870912u, |
| 22 | .primary_sdram_width = 32, |
| 23 | .ec_sdram_width = 8, |
| 24 | .registered_dimm = 0, |
| 25 | .mirrored_dimm = 0, |
| 26 | .n_row_addr = 14, |
| 27 | .n_col_addr = 10, |
| 28 | .n_banks_per_sdram_device = 8, |
| 29 | .edc_config = 2, |
| 30 | .burst_lengths_bitmask = 0x0c, |
| 31 | |
Priyanka Jain | 0dd38a3 | 2013-09-25 10:41:19 +0530 | [diff] [blame] | 32 | .tckmin_x_ps = 1650, |
| 33 | .caslat_x = 0x7e << 4, /* 5,6,7,8,9,10 */ |
| 34 | .taa_ps = 14050, |
| 35 | .twr_ps = 15000, |
| 36 | .trcd_ps = 13500, |
| 37 | .trrd_ps = 75000, |
| 38 | .trp_ps = 13500, |
| 39 | .tras_ps = 40000, |
| 40 | .trc_ps = 49500, |
| 41 | .trfc_ps = 160000, |
| 42 | .twtr_ps = 75000, |
| 43 | .trtp_ps = 75000, |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 44 | .refresh_rate_ps = 7800000, |
Priyanka Jain | 0dd38a3 | 2013-09-25 10:41:19 +0530 | [diff] [blame] | 45 | .tfaw_ps = 30000, |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | int fsl_ddr_get_dimm_params(dimm_params_t *pdimm, |
| 49 | unsigned int controller_number, |
| 50 | unsigned int dimm_number) |
| 51 | { |
| 52 | const char dimm_model[] = "Fixed DDR on board"; |
| 53 | |
| 54 | if ((controller_number == 0) && (dimm_number == 0)) { |
| 55 | memcpy(pdimm, &ddr_raw_timing, sizeof(dimm_params_t)); |
| 56 | memset(pdimm->mpart, 0, sizeof(pdimm->mpart)); |
| 57 | memcpy(pdimm->mpart, dimm_model, sizeof(dimm_model) - 1); |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | void fsl_ddr_board_options(memctl_options_t *popts, |
| 64 | dimm_params_t *pdimm, |
| 65 | unsigned int ctrl_num) |
| 66 | { |
Po Liu | 9c25ee6 | 2013-09-26 09:40:11 +0800 | [diff] [blame] | 67 | struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 68 | int i; |
Po Liu | 9c25ee6 | 2013-09-26 09:40:11 +0800 | [diff] [blame] | 69 | |
Po Liu | 0e61077 | 2013-08-21 14:23:42 +0800 | [diff] [blame] | 70 | popts->clk_adjust = 4; |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 71 | popts->cpo_override = 0x1f; |
| 72 | popts->write_data_delay = 4; |
| 73 | popts->half_strength_driver_enable = 1; |
| 74 | popts->bstopre = 0x3cf; |
| 75 | popts->quad_rank_present = 1; |
| 76 | popts->rtt_override = 1; |
| 77 | popts->rtt_override_value = 1; |
| 78 | popts->dynamic_power = 1; |
| 79 | /* Write leveling override */ |
| 80 | popts->wrlvl_en = 1; |
| 81 | popts->wrlvl_override = 1; |
| 82 | popts->wrlvl_sample = 0xf; |
| 83 | popts->wrlvl_start = 0x4; |
| 84 | popts->trwt_override = 1; |
| 85 | popts->trwt = 0; |
| 86 | |
Po Liu | 9c25ee6 | 2013-09-26 09:40:11 +0800 | [diff] [blame] | 87 | if (in_8(&cpld_data->hwver) == C29XPCIE_HARDWARE_REVA) |
| 88 | popts->ecc_mode = 0; |
| 89 | |
Mingkai Hu | a8d9758 | 2013-07-04 17:33:43 +0800 | [diff] [blame] | 90 | for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) { |
| 91 | popts->cs_local_opts[i].odt_rd_cfg = FSL_DDR_ODT_NEVER; |
| 92 | popts->cs_local_opts[i].odt_wr_cfg = FSL_DDR_ODT_CS; |
| 93 | } |
| 94 | } |