2 Memory controller configuration.
4 Copyright (c) 2013-2015 Intel Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __DDR_MEMORY_CONTROLLER_H__
10 #define __DDR_MEMORY_CONTROLLER_H__
13 // DDR timing data definitions.
14 // These are used to create bitmaps of valid timing configurations.
17 #define DUAL_CHANNEL_DDR_TIMING_DATA_FREQUENCY_UNKNOWN 0xFF
18 #define DUAL_CHANNEL_DDR_TIMING_DATA_REFRESH_RATE_UNKNOWN 0xFF
20 #define DUAL_CHANNEL_DDR_TIMING_DATA_TCL_20 0x01
21 #define DUAL_CHANNEL_DDR_TIMING_DATA_TCL_25 0x00
22 #define DUAL_CHANNEL_DDR_TIMING_DATA_TCL_30 0x02
23 #define DUAL_CHANNEL_DDR_TIMING_DATA_TCL_ALL 0x03
26 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRCD_02 0x02
27 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRCD_03 0x01
28 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRCD_04 0x00
29 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRCD_ALL 0x03
31 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRP_02 0x02
32 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRP_03 0x01
33 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRP_04 0x00
34 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRP_ALL 0x03
36 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_05 0x05
37 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_06 0x04
38 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_07 0x03
39 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_08 0x02
40 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_09 0x01
41 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_10 0x00
42 #define DUAL_CHANNEL_DDR_TIMING_DATA_TRAS_ALL 0x07
44 #define DUAL_CHANNEL_DDR_DATA_TYPE_REGISTERED 0x01
45 #define DUAL_CHANNEL_DDR_DATA_TYPE_UNREGISTERED 0x02
46 #define DUAL_CHANNEL_DDR_DATA_TYPE_BUFFERED 0x04
47 #define DUAL_CHANNEL_DDR_DATA_TYPE_UNBUFFERED 0x08
48 #define DUAL_CHANNEL_DDR_DATA_TYPE_SDR 0x10
49 #define DUAL_CHANNEL_DDR_DATA_TYPE_DDR 0x20
53 // Maximum number of SDRAM channels supported by the memory controller
55 #define MAX_CHANNELS 1
58 // Maximum number of DIMM sockets supported by the memory controller
63 // Maximum number of sides supported per DIMM
68 // Maximum number of "Socket Sets", where a "Socket Set is a set of matching
69 // DIMM's from the various channels
71 #define MAX_SOCKET_SETS 2
74 // Maximum number of rows supported by the memory controller
76 #define MAX_ROWS (MAX_SIDES * MAX_SOCKETS)
79 // Maximum number of memory ranges supported by the memory controller
81 #define MAX_RANGES (MAX_ROWS + 5)
84 // Maximum Number of Log entries
86 #define MEMORY_LOG_MAX_INDEX 16
89 typedef struct _MEMORY_LOG_ENTRY
{
90 EFI_STATUS_CODE_VALUE Event
;
91 EFI_STATUS_CODE_TYPE Severity
;
95 typedef struct _MEMORY_LOG
{
97 MEMORY_LOG_ENTRY Entry
[MEMORY_LOG_MAX_INDEX
];
105 #define DUAL_CHANNEL_DDR_ECC_TYPE_NONE 0x01 // No error checking
106 #define DUAL_CHANNEL_DDR_ECC_TYPE_EC 0x02 // Error checking only
107 #define DUAL_CHANNEL_DDR_ECC_TYPE_SECC 0x04 // Software Scrubbing ECC
108 #define DUAL_CHANNEL_DDR_ECC_TYPE_HECC 0x08 // Hardware Scrubbing ECC
109 #define DUAL_CHANNEL_DDR_ECC_TYPE_CKECC 0x10 // Chip Kill ECC
112 // Row configuration status values
114 #define DUAL_CHANNEL_DDR_ROW_CONFIG_SUCCESS 0x00 // No error
115 #define DUAL_CHANNEL_DDR_ROW_CONFIG_UNKNOWN 0x01 // Pattern mismatch, no memory
116 #define DUAL_CHANNEL_DDR_ROW_CONFIG_UNSUPPORTED 0x02 // Memory type not supported
117 #define DUAL_CHANNEL_DDR_ROW_CONFIG_ADDRESS_ERROR 0x03 // Row/Col/Bnk mismatch
118 #define DUAL_CHANNEL_DDR_ROW_CONFIG_ECC_ERROR 0x04 // Received ECC error
119 #define DUAL_CHANNEL_DDR_ROW_CONFIG_NOT_PRESENT 0x05 // Row is not present
120 #define DUAL_CHANNEL_DDR_ROW_CONFIG_DISABLED 0x06 // Row is disabled
124 // Memory range types
127 DualChannelDdrMainMemory
,
128 DualChannelDdrSmramCacheable
,
129 DualChannelDdrSmramNonCacheable
,
130 DualChannelDdrGraphicsMemoryCacheable
,
131 DualChannelDdrGraphicsMemoryNonCacheable
,
132 DualChannelDdrReservedMemory
,
133 DualChannelDdrMaxMemoryRangeType
134 } DUAL_CHANNEL_DDR_MEMORY_RANGE_TYPE
;
137 // Memory map range information
140 EFI_PHYSICAL_ADDRESS PhysicalAddress
;
141 EFI_PHYSICAL_ADDRESS CpuAddress
;
142 EFI_PHYSICAL_ADDRESS RangeLength
;
143 DUAL_CHANNEL_DDR_MEMORY_RANGE_TYPE Type
;
144 } DUAL_CHANNEL_DDR_MEMORY_MAP_RANGE
;
146 unsigned dramType
:1; /**< Type: 0 = RESERVED; 1 = DDR2 */
147 unsigned dramWidth
:1; /**< Width: 0 = x8; 1 = x16 */
148 unsigned dramDensity
:2; /**< Density: 00b = 2Gb; 01b = 1Gb; 10b = 512Mb; 11b = 256Mb */
149 unsigned dramSpeed
:1; /**< Speed Grade: 0 = RESERVED; 1 = 800MT/s;*/
150 unsigned dramTimings
:3; /**< Timings: 4-4-4, 5-5-5, 6-6-6 */
151 unsigned dramRanks
:1; /**< Ranks: 0 = Single Rank; 1 = Dual Rank */
152 } DramGeometry
; /**< DRAM Geometry Descriptor */
154 typedef union _RegDRP
{
157 unsigned rank0Enabled
:1; /**< Rank 0 Enable */
158 unsigned rank0DevWidth
:2; /**< DRAM Device Width (x8,x16) */
159 unsigned rank0DevDensity
:2; /**< DRAM Device Density (256Mb,512Mb,1Gb,2Gb) */
160 unsigned reserved2
:1;
161 unsigned rank1Enabled
:1; /**< Rank 1 Enable */
162 unsigned reserved3
:5;
163 unsigned dramType
:1; /**< DRAM Type (0=DDR2) */
164 unsigned reserved4
:5;
165 unsigned reserved5
:14;
167 } RegDRP
; /**< DRAM Rank Population and Interface Register */
173 unsigned dramFrequency
:3; /**< DRAM Frequency (000=RESERVED,010=667,011=800) */
174 unsigned tRP
:2; /**< Precharge to Activate Delay (3,4,5,6) */
175 unsigned reserved1
:1;
176 unsigned tRCD
:2; /**< Activate to CAS Delay (3,4,5,6) */
177 unsigned reserved2
:1;
178 unsigned tCL
:2; /**< CAS Latency (3,4,5,6) */
179 unsigned reserved3
:21;
181 } RegDTR0
; /**< DRAM Timing Register 0 */
186 unsigned tWRRD_dly
:2; /**< Additional Write to Read Delay (0,1,2,3) */
187 unsigned reserved1
:1;
188 unsigned tRDWR_dly
:2; /**< Additional Read to Write Delay (0,1,2,3) */
189 unsigned reserved2
:1;
190 unsigned tRDRD_dr_dly
:1; /**< Additional Read to Read Delay (1,2) */
191 unsigned reserved3
:1;
192 unsigned tRD_dly
:3; /**< Additional Read Data Sampling Delay (0-7) */
193 unsigned reserved4
:1;
194 unsigned tRCVEN_halfclk_dly
:4; /**< Additional RCVEN Half Clock Delay Control */
195 unsigned reserved5
:1;
196 unsigned readDqDelay
:2; /**< Read DQ Delay */
197 unsigned reserved6
:13;
199 } RegDTR1
; /**< DRAM Timing Register 1 */
204 unsigned ckStaticDisable
:1; /**< CK/CK# Static Disable */
205 unsigned reserved1
:3;
206 unsigned ckeStaticDisable
:2; /**< CKE Static Disable */
207 unsigned reserved2
:8;
208 unsigned refreshPeriod
:2; /**< Refresh Period (disabled,128clks,3.9us,7.8us) */
209 unsigned refreshQueueDepth
:2; /**< Refresh Queue Depth (1,2,4,8) */
210 unsigned reserved5
:13;
211 unsigned initComplete
:1; /**< Initialization Complete */
216 // MRC Data Structure
229 UINT8 refreshPeriod
; /**< Placeholder for the chosen refresh
230 * period. This value will NOT be
231 * programmed into DCO until all
232 * initialization is done.
234 UINT8 ddr2Odt
; /**< 0 = Disabled, 1 = 75 ohm, 2 = 150ohm, 3 = 50ohm */
235 UINT8 sku
; /**< Detected QuarkNcSocId SKU */
236 UINT8 capabilities
; /**< Capabilities Available on this part */
237 UINT8 state
; /**< NORMAL_BOOT, S3_RESUME */
238 UINT32 memSize
; /**< Memory size */
239 UINT16 pmBase
; /**< PM Base */
240 UINT16 mrcVersion
; /**< MRC Version */
241 UINT32 hecbase
; /**< HECBASE shifted left 16 bits */
242 DramGeometry geometry
; /**< DRAM Geometry */
243 } MRC_DATA_STRUCTURE
; /**< QuarkNcSocId Memory Parameters for MRC */
245 typedef struct _EFI_MEMINIT_CONFIG_DATA
{
246 MRC_DATA_STRUCTURE MrcData
;
247 } EFI_MEMINIT_CONFIG_DATA
;