blob: c6c819ea0a9ed8737a7bcf5f6bc5245a4534ef52 [file] [log] [blame]
Kumar Gala58e5e9a2008-08-26 15:01:29 -05001/*
York Sunc0c32af2018-01-29 09:44:35 -08002 * Copyright 2008-2016 Freescale Semiconductor, Inc.
3 * Copyright 2017-2018 NXP Semiconductor
Kumar Gala58e5e9a2008-08-26 15:01:29 -05004 *
Tom Rini5b8031c2016-01-14 22:05:13 -05005 * SPDX-License-Identifier: GPL-2.0
Kumar Gala58e5e9a2008-08-26 15:01:29 -05006 */
7
8#ifndef DDR2_DIMM_PARAMS_H
9#define DDR2_DIMM_PARAMS_H
10
York Sun08b3f752011-03-17 11:18:10 -070011#define EDC_DATA_PARITY 1
12#define EDC_ECC 2
13#define EDC_AC_PARITY 4
14
York Sun34e026f2014-03-27 17:54:47 -070015/* Parameters for a DDR dimm computed from the SPD */
Kumar Gala58e5e9a2008-08-26 15:01:29 -050016typedef struct dimm_params_s {
17
18 /* DIMM organization parameters */
19 char mpart[19]; /* guaranteed null terminated */
20
21 unsigned int n_ranks;
York Sunc0c32af2018-01-29 09:44:35 -080022 unsigned int die_density;
Kumar Gala58e5e9a2008-08-26 15:01:29 -050023 unsigned long long rank_density;
24 unsigned long long capacity;
25 unsigned int data_width;
26 unsigned int primary_sdram_width;
27 unsigned int ec_sdram_width;
28 unsigned int registered_dimm;
York Sunc0c32af2018-01-29 09:44:35 -080029 unsigned int package_3ds; /* number of dies in 3DS DIMM */
York Sunb61e0612013-06-25 11:37:47 -070030 unsigned int device_width; /* x4, x8, x16 components */
Kumar Gala58e5e9a2008-08-26 15:01:29 -050031
32 /* SDRAM device parameters */
33 unsigned int n_row_addr;
34 unsigned int n_col_addr;
35 unsigned int edc_config; /* 0 = none, 1 = parity, 2 = ECC */
York Sun34e026f2014-03-27 17:54:47 -070036#ifdef CONFIG_SYS_FSL_DDR4
37 unsigned int bank_addr_bits;
38 unsigned int bank_group_bits;
39#else
Kumar Gala58e5e9a2008-08-26 15:01:29 -050040 unsigned int n_banks_per_sdram_device;
York Sun34e026f2014-03-27 17:54:47 -070041#endif
Kumar Gala58e5e9a2008-08-26 15:01:29 -050042 unsigned int burst_lengths_bitmask; /* BL=4 bit 2, BL=8 = bit 3 */
43 unsigned int row_density;
44
45 /* used in computing base address of DIMMs */
46 unsigned long long base_address;
Dave Liuc360cea2009-03-14 12:48:30 +080047 /* mirrored DIMMs */
48 unsigned int mirrored_dimm; /* only for ddr3 */
Kumar Gala58e5e9a2008-08-26 15:01:29 -050049
50 /* DIMM timing parameters */
51
York Sun34e026f2014-03-27 17:54:47 -070052 int mtb_ps; /* medium timebase ps */
53 int ftb_10th_ps; /* fine timebase, in 1/10 ps */
54 int taa_ps; /* minimum CAS latency time */
55 int tfaw_ps; /* four active window delay */
Dave Liuc360cea2009-03-14 12:48:30 +080056
Kumar Gala58e5e9a2008-08-26 15:01:29 -050057 /*
58 * SDRAM clock periods
59 * The range for these are 1000-10000 so a short should be sufficient
60 */
York Sun34e026f2014-03-27 17:54:47 -070061 int tckmin_x_ps;
62 int tckmin_x_minus_1_ps;
63 int tckmin_x_minus_2_ps;
64 int tckmax_ps;
Kumar Gala58e5e9a2008-08-26 15:01:29 -050065
66 /* SPD-defined CAS latencies */
Priyanka Jain0dd38a32013-09-25 10:41:19 +053067 unsigned int caslat_x;
68 unsigned int caslat_x_minus_1;
69 unsigned int caslat_x_minus_2;
Kumar Gala58e5e9a2008-08-26 15:01:29 -050070
71 unsigned int caslat_lowest_derated; /* Derated CAS latency */
72
73 /* basic timing parameters */
York Sun34e026f2014-03-27 17:54:47 -070074 int trcd_ps;
75 int trp_ps;
76 int tras_ps;
Kumar Gala58e5e9a2008-08-26 15:01:29 -050077
York Sun34e026f2014-03-27 17:54:47 -070078#ifdef CONFIG_SYS_FSL_DDR4
79 int trfc1_ps;
80 int trfc2_ps;
81 int trfc4_ps;
82 int trrds_ps;
83 int trrdl_ps;
84 int tccdl_ps;
York Sunc0c32af2018-01-29 09:44:35 -080085 int trfc_slr_ps;
York Sun34e026f2014-03-27 17:54:47 -070086#else
87 int twr_ps; /* maximum = 63750 ps */
88 int trfc_ps; /* max = 255 ns + 256 ns + .75 ns
Kumar Gala58e5e9a2008-08-26 15:01:29 -050089 = 511750 ps */
York Sun34e026f2014-03-27 17:54:47 -070090 int trrd_ps; /* maximum = 63750 ps */
91 int twtr_ps; /* maximum = 63750 ps */
92 int trtp_ps; /* byte 38, spd->trtp */
93#endif
Kumar Gala58e5e9a2008-08-26 15:01:29 -050094
York Sun34e026f2014-03-27 17:54:47 -070095 int trc_ps; /* maximum = 254 ns + .75 ns = 254750 ps */
Kumar Gala58e5e9a2008-08-26 15:01:29 -050096
York Sun34e026f2014-03-27 17:54:47 -070097 int refresh_rate_ps;
98 int extended_op_srt;
Kumar Gala58e5e9a2008-08-26 15:01:29 -050099
York Sun34e026f2014-03-27 17:54:47 -0700100#if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
101 int tis_ps; /* byte 32, spd->ca_setup */
102 int tih_ps; /* byte 33, spd->ca_hold */
103 int tds_ps; /* byte 34, spd->data_setup */
104 int tdh_ps; /* byte 35, spd->data_hold */
105 int tdqsq_max_ps; /* byte 44, spd->tdqsq */
106 int tqhs_ps; /* byte 45, spd->tqhs */
107#endif
york9490ff42010-07-02 22:25:55 +0000108
109 /* DDR3 RDIMM */
110 unsigned char rcw[16]; /* Register Control Word 0-15 */
York Sun34e026f2014-03-27 17:54:47 -0700111#ifdef CONFIG_SYS_FSL_DDR4
112 unsigned int dq_mapping[18];
113 unsigned int dq_mapping_ors;
114#endif
Kumar Gala58e5e9a2008-08-26 15:01:29 -0500115} dimm_params_t;
116
York Sun03e664d2015-01-06 13:18:50 -0800117unsigned int ddr_compute_dimm_parameters(const unsigned int ctrl_num,
Kumar Gala58e5e9a2008-08-26 15:01:29 -0500118 const generic_spd_eeprom_t *spd,
119 dimm_params_t *pdimm,
120 unsigned int dimm_number);
121
122#endif