blob: 58b42b875c6d7b3be0ac526378b2fb5cd241683c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Kumar Gala124b0822008-08-26 15:01:29 -05002/*
York Sun6db4fdd2018-01-29 09:44:35 -08003 * Copyright 2008-2016 Freescale Semiconductor, Inc.
4 * Copyright 2017-2018 NXP Semiconductor
Kumar Gala124b0822008-08-26 15:01:29 -05005 */
6
7#ifndef DDR2_DIMM_PARAMS_H
8#define DDR2_DIMM_PARAMS_H
9
York Sunfbe65952011-03-17 11:18:10 -070010#define EDC_DATA_PARITY 1
11#define EDC_ECC 2
12#define EDC_AC_PARITY 4
13
York Sun2896cb72014-03-27 17:54:47 -070014/* Parameters for a DDR dimm computed from the SPD */
Kumar Gala124b0822008-08-26 15:01:29 -050015typedef struct dimm_params_s {
16
17 /* DIMM organization parameters */
18 char mpart[19]; /* guaranteed null terminated */
19
20 unsigned int n_ranks;
York Sun6db4fdd2018-01-29 09:44:35 -080021 unsigned int die_density;
Kumar Gala124b0822008-08-26 15:01:29 -050022 unsigned long long rank_density;
23 unsigned long long capacity;
24 unsigned int data_width;
25 unsigned int primary_sdram_width;
26 unsigned int ec_sdram_width;
27 unsigned int registered_dimm;
York Sun6db4fdd2018-01-29 09:44:35 -080028 unsigned int package_3ds; /* number of dies in 3DS DIMM */
York Sun4889c982013-06-25 11:37:47 -070029 unsigned int device_width; /* x4, x8, x16 components */
Kumar Gala124b0822008-08-26 15:01:29 -050030
31 /* SDRAM device parameters */
32 unsigned int n_row_addr;
33 unsigned int n_col_addr;
34 unsigned int edc_config; /* 0 = none, 1 = parity, 2 = ECC */
York Sun2896cb72014-03-27 17:54:47 -070035#ifdef CONFIG_SYS_FSL_DDR4
36 unsigned int bank_addr_bits;
37 unsigned int bank_group_bits;
38#else
Kumar Gala124b0822008-08-26 15:01:29 -050039 unsigned int n_banks_per_sdram_device;
York Sun2896cb72014-03-27 17:54:47 -070040#endif
Kumar Gala124b0822008-08-26 15:01:29 -050041 unsigned int burst_lengths_bitmask; /* BL=4 bit 2, BL=8 = bit 3 */
Kumar Gala124b0822008-08-26 15:01:29 -050042
43 /* used in computing base address of DIMMs */
44 unsigned long long base_address;
Dave Liu4be87b22009-03-14 12:48:30 +080045 /* mirrored DIMMs */
46 unsigned int mirrored_dimm; /* only for ddr3 */
Kumar Gala124b0822008-08-26 15:01:29 -050047
48 /* DIMM timing parameters */
49
York Sun2896cb72014-03-27 17:54:47 -070050 int mtb_ps; /* medium timebase ps */
51 int ftb_10th_ps; /* fine timebase, in 1/10 ps */
52 int taa_ps; /* minimum CAS latency time */
53 int tfaw_ps; /* four active window delay */
Dave Liu4be87b22009-03-14 12:48:30 +080054
Kumar Gala124b0822008-08-26 15:01:29 -050055 /*
56 * SDRAM clock periods
57 * The range for these are 1000-10000 so a short should be sufficient
58 */
York Sun2896cb72014-03-27 17:54:47 -070059 int tckmin_x_ps;
60 int tckmin_x_minus_1_ps;
61 int tckmin_x_minus_2_ps;
62 int tckmax_ps;
Kumar Gala124b0822008-08-26 15:01:29 -050063
64 /* SPD-defined CAS latencies */
Priyanka Jain4a717412013-09-25 10:41:19 +053065 unsigned int caslat_x;
66 unsigned int caslat_x_minus_1;
67 unsigned int caslat_x_minus_2;
Kumar Gala124b0822008-08-26 15:01:29 -050068
69 unsigned int caslat_lowest_derated; /* Derated CAS latency */
70
71 /* basic timing parameters */
York Sun2896cb72014-03-27 17:54:47 -070072 int trcd_ps;
73 int trp_ps;
74 int tras_ps;
Kumar Gala124b0822008-08-26 15:01:29 -050075
York Sun2896cb72014-03-27 17:54:47 -070076#ifdef CONFIG_SYS_FSL_DDR4
77 int trfc1_ps;
78 int trfc2_ps;
79 int trfc4_ps;
80 int trrds_ps;
81 int trrdl_ps;
82 int tccdl_ps;
York Sun6db4fdd2018-01-29 09:44:35 -080083 int trfc_slr_ps;
York Sun2896cb72014-03-27 17:54:47 -070084#else
85 int twr_ps; /* maximum = 63750 ps */
86 int trfc_ps; /* max = 255 ns + 256 ns + .75 ns
Kumar Gala124b0822008-08-26 15:01:29 -050087 = 511750 ps */
York Sun2896cb72014-03-27 17:54:47 -070088 int trrd_ps; /* maximum = 63750 ps */
89 int twtr_ps; /* maximum = 63750 ps */
90 int trtp_ps; /* byte 38, spd->trtp */
91#endif
Kumar Gala124b0822008-08-26 15:01:29 -050092
York Sun2896cb72014-03-27 17:54:47 -070093 int trc_ps; /* maximum = 254 ns + .75 ns = 254750 ps */
Kumar Gala124b0822008-08-26 15:01:29 -050094
York Sun2896cb72014-03-27 17:54:47 -070095 int refresh_rate_ps;
96 int extended_op_srt;
Kumar Gala124b0822008-08-26 15:01:29 -050097
York Sun2896cb72014-03-27 17:54:47 -070098#if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
99 int tis_ps; /* byte 32, spd->ca_setup */
100 int tih_ps; /* byte 33, spd->ca_hold */
101 int tds_ps; /* byte 34, spd->data_setup */
102 int tdh_ps; /* byte 35, spd->data_hold */
103 int tdqsq_max_ps; /* byte 44, spd->tdqsq */
104 int tqhs_ps; /* byte 45, spd->tqhs */
105#endif
yorkde879322010-07-02 22:25:55 +0000106
York Sunbc2f32a2018-01-29 10:24:08 -0800107 /* DDR3 & DDR4 RDIMM */
yorkde879322010-07-02 22:25:55 +0000108 unsigned char rcw[16]; /* Register Control Word 0-15 */
York Sun2896cb72014-03-27 17:54:47 -0700109#ifdef CONFIG_SYS_FSL_DDR4
110 unsigned int dq_mapping[18];
111 unsigned int dq_mapping_ors;
112#endif
Kumar Gala124b0822008-08-26 15:01:29 -0500113} dimm_params_t;
114
York Sun2c0b62d2015-01-06 13:18:50 -0800115unsigned int ddr_compute_dimm_parameters(const unsigned int ctrl_num,
Kumar Gala124b0822008-08-26 15:01:29 -0500116 const generic_spd_eeprom_t *spd,
117 dimm_params_t *pdimm,
118 unsigned int dimm_number);
119
120#endif