Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 1 | /* |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 2 | * Copyright 2008-2014 Freescale Semiconductor, Inc. |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 3 | * |
Tom Rini | e237880 | 2016-01-14 22:05:13 -0500 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0 |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef DDR2_DIMM_PARAMS_H |
| 8 | #define DDR2_DIMM_PARAMS_H |
| 9 | |
York Sun | fbe6595 | 2011-03-17 11:18:10 -0700 | [diff] [blame] | 10 | #define EDC_DATA_PARITY 1 |
| 11 | #define EDC_ECC 2 |
| 12 | #define EDC_AC_PARITY 4 |
| 13 | |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 14 | /* Parameters for a DDR dimm computed from the SPD */ |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 15 | typedef struct dimm_params_s { |
| 16 | |
| 17 | /* DIMM organization parameters */ |
| 18 | char mpart[19]; /* guaranteed null terminated */ |
| 19 | |
| 20 | unsigned int n_ranks; |
| 21 | unsigned long long rank_density; |
| 22 | unsigned long long capacity; |
| 23 | unsigned int data_width; |
| 24 | unsigned int primary_sdram_width; |
| 25 | unsigned int ec_sdram_width; |
| 26 | unsigned int registered_dimm; |
York Sun | 4889c98 | 2013-06-25 11:37:47 -0700 | [diff] [blame] | 27 | unsigned int device_width; /* x4, x8, x16 components */ |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 28 | |
| 29 | /* SDRAM device parameters */ |
| 30 | unsigned int n_row_addr; |
| 31 | unsigned int n_col_addr; |
| 32 | unsigned int edc_config; /* 0 = none, 1 = parity, 2 = ECC */ |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 33 | #ifdef CONFIG_SYS_FSL_DDR4 |
| 34 | unsigned int bank_addr_bits; |
| 35 | unsigned int bank_group_bits; |
| 36 | #else |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 37 | unsigned int n_banks_per_sdram_device; |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 38 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 39 | unsigned int burst_lengths_bitmask; /* BL=4 bit 2, BL=8 = bit 3 */ |
| 40 | unsigned int row_density; |
| 41 | |
| 42 | /* used in computing base address of DIMMs */ |
| 43 | unsigned long long base_address; |
Dave Liu | 4be87b2 | 2009-03-14 12:48:30 +0800 | [diff] [blame] | 44 | /* mirrored DIMMs */ |
| 45 | unsigned int mirrored_dimm; /* only for ddr3 */ |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 46 | |
| 47 | /* DIMM timing parameters */ |
| 48 | |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 49 | int mtb_ps; /* medium timebase ps */ |
| 50 | int ftb_10th_ps; /* fine timebase, in 1/10 ps */ |
| 51 | int taa_ps; /* minimum CAS latency time */ |
| 52 | int tfaw_ps; /* four active window delay */ |
Dave Liu | 4be87b2 | 2009-03-14 12:48:30 +0800 | [diff] [blame] | 53 | |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 54 | /* |
| 55 | * SDRAM clock periods |
| 56 | * The range for these are 1000-10000 so a short should be sufficient |
| 57 | */ |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 58 | int tckmin_x_ps; |
| 59 | int tckmin_x_minus_1_ps; |
| 60 | int tckmin_x_minus_2_ps; |
| 61 | int tckmax_ps; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 62 | |
| 63 | /* SPD-defined CAS latencies */ |
Priyanka Jain | 4a71741 | 2013-09-25 10:41:19 +0530 | [diff] [blame] | 64 | unsigned int caslat_x; |
| 65 | unsigned int caslat_x_minus_1; |
| 66 | unsigned int caslat_x_minus_2; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 67 | |
| 68 | unsigned int caslat_lowest_derated; /* Derated CAS latency */ |
| 69 | |
| 70 | /* basic timing parameters */ |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 71 | int trcd_ps; |
| 72 | int trp_ps; |
| 73 | int tras_ps; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 74 | |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 75 | #ifdef CONFIG_SYS_FSL_DDR4 |
| 76 | int trfc1_ps; |
| 77 | int trfc2_ps; |
| 78 | int trfc4_ps; |
| 79 | int trrds_ps; |
| 80 | int trrdl_ps; |
| 81 | int tccdl_ps; |
| 82 | #else |
| 83 | int twr_ps; /* maximum = 63750 ps */ |
| 84 | int trfc_ps; /* max = 255 ns + 256 ns + .75 ns |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 85 | = 511750 ps */ |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 86 | int trrd_ps; /* maximum = 63750 ps */ |
| 87 | int twtr_ps; /* maximum = 63750 ps */ |
| 88 | int trtp_ps; /* byte 38, spd->trtp */ |
| 89 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 90 | |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 91 | int trc_ps; /* maximum = 254 ns + .75 ns = 254750 ps */ |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 92 | |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 93 | int refresh_rate_ps; |
| 94 | int extended_op_srt; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 95 | |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 96 | #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2) |
| 97 | int tis_ps; /* byte 32, spd->ca_setup */ |
| 98 | int tih_ps; /* byte 33, spd->ca_hold */ |
| 99 | int tds_ps; /* byte 34, spd->data_setup */ |
| 100 | int tdh_ps; /* byte 35, spd->data_hold */ |
| 101 | int tdqsq_max_ps; /* byte 44, spd->tdqsq */ |
| 102 | int tqhs_ps; /* byte 45, spd->tqhs */ |
| 103 | #endif |
york | de87932 | 2010-07-02 22:25:55 +0000 | [diff] [blame] | 104 | |
| 105 | /* DDR3 RDIMM */ |
| 106 | unsigned char rcw[16]; /* Register Control Word 0-15 */ |
York Sun | 2896cb7 | 2014-03-27 17:54:47 -0700 | [diff] [blame] | 107 | #ifdef CONFIG_SYS_FSL_DDR4 |
| 108 | unsigned int dq_mapping[18]; |
| 109 | unsigned int dq_mapping_ors; |
| 110 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 111 | } dimm_params_t; |
| 112 | |
York Sun | 2c0b62d | 2015-01-06 13:18:50 -0800 | [diff] [blame] | 113 | unsigned int ddr_compute_dimm_parameters(const unsigned int ctrl_num, |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 114 | const generic_spd_eeprom_t *spd, |
| 115 | dimm_params_t *pdimm, |
| 116 | unsigned int dimm_number); |
| 117 | |
| 118 | #endif |