2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Description: Include file for all generic DDR 2 MCT files.
28 /*===========================================================================
30 ===========================================================================*/
31 #define PT_L1 0 /* CPU Package Type */
36 #define J_MIN 0 /* j loop constraint. 1=CL 2.0 T*/
37 #define J_MAX 5 /* j loop constraint. 5=CL 7.0 T*/
38 #define K_MIN 1 /* k loop constraint. 1=200 Mhz*/
39 #define K_MAX 5 /* k loop constraint. 5=533 Mhz*/
40 #define CL_DEF 2 /* Default value for failsafe operation. 2=CL 4.0 T*/
41 #define T_DEF 1 /* Default value for failsafe operation. 1=5ns (cycle time)*/
43 #define BSCRate 1 /* reg bit field=rate of dram scrubber for ecc*/
44 /* memory initialization (ecc and check-bits).*/
45 /* 1=40 ns/64 bytes.*/
46 #define FirstPass 1 /* First pass through RcvEn training*/
47 #define SecondPass 2 /* Second pass through Rcven training*/
49 #define RCVREN_MARGIN 6 /* number of DLL taps to delay beyond first passing position*/
50 #define MAXASYNCLATCTL_2 2 /* Max Async Latency Control value*/
51 #define MAXASYNCLATCTL_3 3 /* Max Async Latency Control value*/
55 #define DQS_WRITEDIR 1
57 #define MIN_DQS_WNDW 3
58 #define secPassOffset 6
59 #define Pass1MemClkDly 0x20 /* Add 1/2 Memlock delay */
60 #define MAX_RD_LAT 0x3FF
63 #define MIN_DQS_WR_FENCE 14
64 #define MAX_DQS_WR_FENCE 20
65 #define FenceTrnFinDlySeed 19
68 #define PA_HOST(Node) ((((0x18+Node) << 3)+0) << 12) /* Node 0 Host Bus function PCI Address bits [15:0]*/
69 #define PA_MAP(Node) ((((0x18+Node) << 3)+1) << 12) /* Node 0 MAP function PCI Address bits [15:0]*/
70 #define PA_DCT(Node) ((((0x18+Node) << 3)+2) << 12) /* Node 0 DCT function PCI Address bits [15:0]*/
71 //#define PA_EXT_DCT (((00 << 3)+4) << 8) /*Node 0 DCT extended configuration registers*/
72 //#define PA_DCTADDL (((00 << 3)+2) << 8) /*Node x DCT function, Additional Registers PCI Address bits [15:0]*/
73 //#define PA_EXT_DCTADDL (((00 << 3)+5) << 8) /*Node x DCT function, Additional Registers PCI Address bits [15:0]*/
75 #define PA_NBMISC(Node) ((((0x18+Node) << 3)+3) << 12) /*Node 0 Misc PCI Address bits [15:0]*/
76 //#define PA_NBDEVOP (((00 << 3)+3) << 8) /*Node 0 Misc PCI Address bits [15:0]*/
78 #define DCC_EN 1 /* X:2:0x94[19]*/
79 #define ILD_Lmt 3 /* X:2:0x94[18:16]*/
81 #define EncodedTSPD 0x00191709 /* encodes which SPD byte to get T from*/
82 /* versus CL X, CL X-.5, and CL X-1*/
84 #define Bias_TrpT 3 /* bias to convert bus clocks to bit field value*/
94 #define Min_TrpT 3 /* min programmable value in busclocks*/
95 #define Max_TrpT 6 /* max programmable value in busclocks*/
111 /*DDR2-1066 support*/
112 #define Bias_TrcdT_1066 5
113 #define Bias_TrasT_1066 15
114 #define Bias_TrrdT_1066 4
115 #define Bias_TwrT_1066 4
116 #define Bias_TrpT_1066 5
117 #define Bias_TwtrT_1066 4
118 #define Bias_TfawT_1066 15
120 #define Min_TrcdT_1066 5
121 #define Max_TrcdT_1066 12
122 #define Min_TrasT_1066 15
123 #define Max_TrasT_1066 30
124 #define Min_TrcT_1066 11
125 #define Max_TrcT_1066 42
126 #define Min_TrrdT_1066 4
127 #define Max_TrrdT_1066 7
128 #define Min_TwrT_1066 5
129 #define Max_TwrT_1066 8
130 #define Min_TrpT_1066 5
131 #define Max_TrpT_1066 12
132 #define Min_TwtrT_1066 4
133 #define Max_TwtrT_1066 7
135 /*common register bit names*/
136 #define DramHoleValid 0 /* func 1, offset F0h, bit 0*/
137 #define DramMemHoistValid 1 /* func 1, offset F0h, bit 1*/
138 #define CSEnable 0 /* func 2, offset 40h-5C, bit 0*/
139 #define Spare 1 /* func 2, offset 40h-5C, bit 1*/
140 #define TestFail 2 /* func 2, offset 40h-5C, bit 2*/
141 #define DqsRcvEnTrain 18 /* func 2, offset 78h, bit 18*/
142 #define EnDramInit 31 /* func 2, offset 7Ch, bit 31*/
143 #define DisAutoRefresh 18 /* func 2, offset 8Ch, bit 18*/
144 #define InitDram 0 /* func 2, offset 90h, bit 0*/
145 #define BurstLength32 10 /* func 2, offset 90h, bit 10*/
146 #define Width128 11 /* func 2, offset 90h, bit 11*/
147 #define X4Dimm 12 /* func 2, offset 90h, bit 12*/
148 #define UnBuffDimm 16 /* func 2, offset 90h, bit 16*/
149 #define DimmEcEn 19 /* func 2, offset 90h, bit 19*/
150 #define MemClkFreqVal 3 /* func 2, offset 94h, bit 3*/
151 #define RDqsEn 12 /* func 2, offset 94h, bit 12*/
152 #define DisDramInterface 14 /* func 2, offset 94h, bit 14*/
153 #define DctAccessWrite 30 /* func 2, offset 98h, bit 30*/
154 #define DctAccessDone 31 /* func 2, offset 98h, bit 31*/
155 #define MemClrStatus 0 /* func 2, offset A0h, bit 0*/
156 #define PwrSavingsEn 10 /* func 2, offset A0h, bit 10*/
157 #define Mod64BitMux 4 /* func 2, offset A0h, bit 4*/
158 #define DisableJitter 1 /* func 2, offset A0h, bit 1*/
159 #define MemClrDis 1 /* func 3, offset F8h, FNC 4, bit 1*/
160 #define SyncOnUcEccEn 2 /* func 3, offset 44h, bit 2*/
161 #define Dr_MemClrStatus 10 /* func 3, offset 110h, bit 10*/
162 #define MemClrBusy 9 /* func 3, offset 110h, bit 9*/
163 #define DctGangEn 4 /* func 3, offset 110h, bit 4*/
164 #define MemClrInit 3 /* func 3, offset 110h, bit 3*/
165 #define AssertCke 28 /* func 2, offset 7Ch, bit 28*/
166 #define DeassertMemRstX 27 /* func 2, offset 7Ch, bit 27*/
167 #define SendMrsCmd 26 /* func 2, offset 7Ch, bit 26*/
168 #define SendAutoRefresh 25 /* func 2, offset 7Ch, bit 25*/
169 #define SendPchgAll 24 /* func 2, offset 7Ch, bit 24*/
170 #define DisDqsBar 6 /* func 2, offset 90h, bit 6*/
171 #define DramEnabled 8 /* func 2, offset 110h, bit 8*/
172 #define LegacyBiosMode 9 /* func 2, offset 94h, bit 9*/
173 #define PrefDramTrainMode 28 /* func 2, offset 11Ch, bit 28*/
174 #define FlushWr 30 /* func 2, offset 11Ch, bit 30*/
175 #define DisAutoComp 30 /* func 2, offset 9Ch, Index 8, bit 30*/
176 #define DqsRcvTrEn 13 /* func 2, offset 9Ch, Index 8, bit 13*/
177 #define ForceAutoPchg 23 /* func 2, offset 90h, bit 23*/
178 #define ClLinesToNbDis 15 /* Bu_CFG2, bit 15*/
179 #define WbEnhWsbDis_D (48-32)
180 #define PhyFenceTrEn 3 /* func 2, offset 9Ch, Index 8, bit 3 */
181 #define ParEn 8 /* func 2, offset 90h, bit 8 */
182 #define DcqArbBypassEn 19 /* func 2, offset 94h, bit 19 */
183 #define ActiveCmdAtRst 1 /* func 2, offset A8H, bit 1 */
184 #define FlushWrOnStpGnt 29 /* func 2, offset 11Ch, bit 29 */
185 #define BankSwizzleMode 22 /* func 2, offset 94h, bit 22 */
186 #define ChSetupSync 15 /* func 2, offset 78h, bit 15 */
190 /*=============================================================================
192 ============================================================================*/
194 #define OCD_Default 2
199 /*=============================================================================
201 =============================================================================*/
202 #define SPD_TYPE 2 /*SPD byte read location*/
203 #define JED_DDRSDRAM 0x07 /*Jedec defined bit field*/
204 #define JED_DDR2SDRAM 0x08 /*Jedec defined bit field*/
206 #define SPD_DIMMTYPE 20
207 #define SPD_ATTRIB 21
208 #define JED_DIFCKMSK 0x20 /*Differential Clock Input*/
209 #define JED_REGADCMSK 0x11 /*Registered Address/Control*/
210 #define JED_PROBEMSK 0x40 /*Analysis Probe installed*/
211 #define SPD_DEVATTRIB 22
212 #define SPD_EDCTYPE 11
214 #define JED_ADRCPAR 0x04
217 #define SPD_LBANKS 17 /*number of [logical] banks on each device*/
218 #define SPD_DMBANKS 5 /*number of physical banks on dimm*/
219 #define SPDPLBit 4 /* Dram package bit*/
220 #define SPD_BANKSZ 31 /*capacity of physical bank*/
221 #define SPD_DEVWIDTH 13
222 #define SPD_CASLAT 18
230 #define SPD_TRCRFC 40
234 #define SPD_MANDATEYR 93 /*Module Manufacturing Year (BCD)*/
236 #define SPD_MANDATEWK 94 /*Module Manufacturing Week (BCD)*/
238 /*-----------------------------
239 Jdec DDR II related equates
240 -----------------------------*/
241 #define MYEAR06 6 /* Manufacturing Year BCD encoding of 2006 - 06d*/
242 #define MWEEK24 0x24 /* Manufacturing Week BCD encoding of June - 24d*/
244 /*=============================================================================
246 =============================================================================*/
248 #define _2GB_RJ8 (2<<(30-8))
249 #define _4GB_RJ8 (4<<(30-8))
250 #define _4GB_RJ4 (4<<(30-4))
252 #define BigPagex8_RJ8 (1<<(17+3-8)) /*128KB * 8 >> 8 */
254 /*=============================================================================
255 Global MCT Status Structure
256 =============================================================================*/
257 struct MCTStatStruc {
258 u32 GStatus; /* Global Status bitfield*/
259 u32 HoleBase; /* If not zero, BASE[39:8] (system address)
260 of sub 4GB dram hole for HW remapping.*/
261 u32 Sub4GCacheTop; /* If not zero, the 32-bit top of cacheable memory.*/
262 u32 SysLimit; /* LIMIT[39:8] (system address)*/
265 /*=============================================================================
266 Global MCT Configuration Status Word (GStatus)
267 =============================================================================*/
268 /*These should begin at bit 0 of GStatus[31:0]*/
269 #define GSB_MTRRshort 0 /* Ran out of MTRRs while mapping memory*/
270 #define GSB_ECCDIMMs 1 /* All banks of all Nodes are ECC capable*/
271 #define GSB_DramECCDis 2 /* Dram ECC requested but not enabled.*/
272 #define GSB_SoftHole 3 /* A Node Base gap was created*/
273 #define GSB_HWHole 4 /* A HW dram remap was created*/
274 #define GSB_NodeIntlv 5 /* Node Memory interleaving was enabled*/
275 #define GSB_SpIntRemapHole 16 /* Special condition for Node Interleave and HW remapping*/
276 #define GSB_EnDIMMSpareNW 17 /* Indicates that DIMM Spare can be used without a warm reset */
277 /* NOTE: This is a local bit used by memory code */
280 /*===============================================================================
281 Local DCT Status structure (a structure for each DCT)
282 ===============================================================================*/
284 struct DCTStatStruc { /* A per Node structure*/
285 /* DCTStatStruct_F - start */
286 u8 Node_ID; /* Node ID of current controller*/
287 u8 ErrCode; /* Current error condition of Node
289 1= Variance Error, DCT is running but not in an optimal configuration.
290 2= Stop Error, DCT is NOT running
291 3= Fatal Error, DCT/MCT initialization has been halted.*/
292 u32 ErrStatus; /* Error Status bit Field */
293 u32 Status; /* Status bit Field*/
294 u8 DIMMAddr[8]; /* SPD address of DIMM controlled by MA0_CS_L[0,1]*/
295 /* SPD address of..MB0_CS_L[0,1]*/
296 /* SPD address of..MA1_CS_L[0,1]*/
297 /* SPD address of..MB1_CS_L[0,1]*/
298 /* SPD address of..MA2_CS_L[0,1]*/
299 /* SPD address of..MB2_CS_L[0,1]*/
300 /* SPD address of..MA3_CS_L[0,1]*/
301 /* SPD address of..MB3_CS_L[0,1]*/
302 u16 DIMMPresent; /*For each bit n 0..7, 1=DIMM n is present.
312 u16 DIMMValid; /* For each bit n 0..7, 1=DIMM n is valid and is/will be configured*/
313 u16 DIMMMismatch; /* For each bit n 0..7, 1=DIMM n is mismatched, channel B is always considered the mismatch */
314 u16 DIMMSPDCSE; /* For each bit n 0..7, 1=DIMM n SPD checksum error*/
315 u16 DimmECCPresent; /* For each bit n 0..7, 1=DIMM n is ECC capable.*/
316 u16 DimmPARPresent; /* For each bit n 0..7, 1=DIMM n is ADR/CMD Parity capable.*/
317 u16 Dimmx4Present; /* For each bit n 0..7, 1=DIMM n contains x4 data devices.*/
318 u16 Dimmx8Present; /* For each bit n 0..7, 1=DIMM n contains x8 data devices.*/
319 u16 Dimmx16Present; /* For each bit n 0..7, 1=DIMM n contains x16 data devices.*/
320 u16 DIMM2Kpage; /* For each bit n 0..7, 1=DIMM n contains 1K page devices.*/
321 u8 MAload[2]; /* Number of devices loading MAA bus*/
322 /* Number of devices loading MAB bus*/
323 u8 MAdimms[2]; /*Number of DIMMs loading CH A*/
324 /* Number of DIMMs loading CH B*/
325 u8 DATAload[2]; /*Number of ranks loading CH A DATA*/
326 /* Number of ranks loading CH B DATA*/
327 u8 DIMMAutoSpeed; /*Max valid Mfg. Speed of DIMMs
333 u8 DIMMCASL; /* Min valid Mfg. CL bitfield
339 u16 DIMMTrcd; /* Minimax Trcd*40 (ns) of DIMMs*/
340 u16 DIMMTrp; /* Minimax Trp*40 (ns) of DIMMs*/
341 u16 DIMMTrtp; /* Minimax Trtp*40 (ns) of DIMMs*/
342 u16 DIMMTras; /* Minimax Tras*40 (ns) of DIMMs*/
343 u16 DIMMTrc; /* Minimax Trc*40 (ns) of DIMMs*/
344 u16 DIMMTwr; /* Minimax Twr*40 (ns) of DIMMs*/
345 u16 DIMMTrrd; /* Minimax Trrd*40 (ns) of DIMMs*/
346 u16 DIMMTwtr; /* Minimax Twtr*40 (ns) of DIMMs*/
347 u8 Speed; /* Bus Speed (to set Controller)
352 u8 CASL; /* CAS latency DCT setting
358 u8 Trcd; /* DCT Trcd (busclocks) */
359 u8 Trp; /* DCT Trp (busclocks) */
360 u8 Trtp; /* DCT Trtp (busclocks) */
361 u8 Tras; /* DCT Tras (busclocks) */
362 u8 Trc; /* DCT Trc (busclocks) */
363 u8 Twr; /* DCT Twr (busclocks) */
364 u8 Trrd; /* DCT Trrd (busclocks) */
365 u8 Twtr; /* DCT Twtr (busclocks) */
366 u8 Trfc[4]; /* DCT Logical DIMM0 Trfc
367 0=75ns (for 256Mb devs)
368 1=105ns (for 512Mb devs)
369 2=127.5ns (for 1Gb devs)
370 3=195ns (for 2Gb devs)
371 4=327.5ns (for 4Gb devs) */
372 /* DCT Logical DIMM1 Trfc (see Trfc0 for format) */
373 /* DCT Logical DIMM2 Trfc (see Trfc0 for format) */
374 /* DCT Logical DIMM3 Trfc (see Trfc0 for format) */
375 u16 CSPresent; /* For each bit n 0..7, 1=Chip-select n is present */
376 u16 CSTestFail; /* For each bit n 0..7, 1=Chip-select n is present but disabled */
377 u32 DCTSysBase; /* BASE[39:8] (system address) of this Node's DCTs. */
378 u32 DCTHoleBase; /* If not zero, BASE[39:8] (system address) of dram hole for HW remapping. Dram hole exists on this Node's DCTs. */
379 u32 DCTSysLimit; /* LIMIT[39:8] (system address) of this Node's DCTs */
380 u16 PresetmaxFreq; /* Maximum OEM defined DDR frequency
384 400=400Mhz (DDR800) */
385 u8 _2Tmode; /* 1T or 2T CMD mode (slow access mode)
388 u8 TrwtTO; /* DCT TrwtTO (busclocks)*/
389 u8 Twrrd; /* DCT Twrrd (busclocks)*/
390 u8 Twrwr; /* DCT Twrwr (busclocks)*/
391 u8 Trdrd; /* DCT Trdrd (busclocks)*/
392 u32 CH_ODC_CTL[2]; /* Output Driver Strength (see BKDG FN2:Offset 9Ch, index 00h*/
393 u32 CH_ADDR_TMG[2]; /* Address Bus Timing (see BKDG FN2:Offset 9Ch, index 04h*/
394 /* Output Driver Strength (see BKDG FN2:Offset 9Ch, index 20h*/
395 /* Address Bus Timing (see BKDG FN2:Offset 9Ch, index 24h*/
396 u16 CH_EccDQSLike[2]; /* CHA DQS ECC byte like...*/
397 u8 CH_EccDQSScale[2]; /* CHA DQS ECC byte scale*/
398 /* CHA DQS ECC byte like...*/
399 /* CHA DQS ECC byte scale*/
400 u8 MaxAsyncLat; /* Max Asynchronous Latency (ns)*/
401 // NOTE: Not used in Barcelona - u8 CH_D_RCVRDLY[2][4];
402 /* CHA DIMM 0 - 4 Receiver Enable Delay*/
403 /* CHB DIMM 0 - 4 Receiver Enable Delay */
404 // NOTE: Not used in Barcelona - u8 CH_D_B_DQS[2][2][8];
405 /* CHA Byte 0-7 Write DQS Delay */
406 /* CHA Byte 0-7 Read DQS Delay */
407 /* CHB Byte 0-7 Write DQS Delay */
408 /* CHB Byte 0-7 Read DQS Delay */
409 u32 PtrPatternBufA; /* Ptr on stack to aligned DQS testing pattern*/
410 u32 PtrPatternBufB; /* Ptr on stack to aligned DQS testing pattern*/
411 u8 Channel; /* Current Channel (0= CH A, 1=CH B)*/
412 u8 ByteLane; /* Current Byte Lane (0..7)*/
413 u8 Direction; /* Current DQS-DQ training write direction (0=read, 1=write)*/
414 u8 Pattern; /* Current pattern*/
415 u8 DQSDelay; /* Current DQS delay value*/
416 u32 TrainErrors; /* Current Training Errors*/
418 u32 AMC_TSC_DeltaLo; /* Time Stamp Counter measurement of AMC, Low dword*/
419 u32 AMC_TSC_DeltaHi; /* Time Stamp Counter measurement of AMC, High dword*/
420 // NOTE: Not used in Barcelona - u8 CH_D_DIR_MaxMin_B_Dly[2][4][2][2][8];
421 /* CH A byte lane 0 - 7 minimum filtered window passing DQS delay value*/
422 /* CH A byte lane 0 - 7 maximum filtered window passing DQS delay value*/
423 /* CH B byte lane 0 - 7 minimum filtered window passing DQS delay value*/
424 /* CH B byte lane 0 - 7 maximum filtered window passing DQS delay value*/
425 /* CH A byte lane 0 - 7 minimum filtered window passing DQS delay value*/
426 /* CH A byte lane 0 - 7 maximum filtered window passing DQS delay value*/
427 /* CH B byte lane 0 - 7 minimum filtered window passing DQS delay value*/
428 /* CH B byte lane 0 - 7 maximum filtered window passing DQS delay value*/
429 u32 LogicalCPUID; /* The logical CPUID of the node*/
430 u16 HostBiosSrvc1; /* Word sized general purpose field for use by host BIOS. Scratch space.*/
431 u32 HostBiosSrvc2; /* Dword sized general purpose field for use by host BIOS. Scratch space.*/
432 u16 DimmQRPresent; /* QuadRank DIMM present?*/
433 u16 DimmTrainFail; /* Bitmap showing which dimms failed training*/
434 u16 CSTrainFail; /* Bitmap showing which chipselects failed training*/
435 u16 DimmYr06; /* Bitmap indicating which Dimms have a manufactur's year code <= 2006*/
436 u16 DimmWk2406; /* Bitmap indicating which Dimms have a manufactur's week code <= 24 of 2006 (June)*/
437 u16 DimmDRPresent; /* Bitmap indicating that Dual Rank Dimms are present*/
438 u16 DimmPlPresent; /* Bitmap indicating that Planar (1) or Stacked (0) Dimms are present.*/
439 u16 ChannelTrainFai; /* Bitmap showing the chanel informaiton about failed Chip Selects
440 0 in any bit field indicates Channel 0
441 1 in any bit field indicates Channel 1 */
442 u16 CSUsrTestFail; /* Chip selects excluded by user */
443 /* DCTStatStruct_F - end */
445 u16 CH_MaxRdLat[2]; /* Max Read Latency (ns) for DCT 0*/
446 /* Max Read Latency (ns) for DCT 1*/
447 u8 CH_D_DIR_B_DQS[2][4][2][9]; /* [A/B] [DIMM1-4] [R/W] [DQS] */
448 /* CHA DIMM0 Byte 0 - 7 and Check Write DQS Delay*/
449 /* CHA DIMM0 Byte 0 - 7 and Check Read DQS Delay*/
450 /* CHA DIMM1 Byte 0 - 7 and Check Write DQS Delay*/
451 /* CHA DIMM1 Byte 0 - 7 and Check Read DQS Delay*/
452 /* CHB DIMM0 Byte 0 - 7 and Check Write DQS Delay*/
453 /* CHB DIMM0 Byte 0 - 7 and Check Read DQS Delay*/
454 /* CHB DIMM1 Byte 0 - 7 and Check Write DQS Delay*/
455 /* CHB DIMM1 Byte 0 - 7 and Check Read DQS Delay*/
456 u8 CH_D_B_RCVRDLY[2][4][8]; /* [A/B] [DIMM0-3] [DQS] */
457 /* CHA DIMM 0 Receiver Enable Delay*/
458 /* CHA DIMM 1 Receiver Enable Delay*/
459 /* CHA DIMM 2 Receiver Enable Delay*/
460 /* CHA DIMM 3 Receiver Enable Delay*/
462 /* CHB DIMM 0 Receiver Enable Delay*/
463 /* CHB DIMM 1 Receiver Enable Delay*/
464 /* CHB DIMM 2 Receiver Enable Delay*/
465 /* CHB DIMM 3 Receiver Enable Delay*/
466 u8 CH_D_BC_RCVRDLY[2][4];
467 /* CHA DIMM 0 - 4 Check Byte Receiver Enable Delay*/
468 /* CHB DIMM 0 - 4 Check Byte Receiver Enable Delay*/
469 u8 DIMMValidDCT[2]; /* DIMM# in DCT0*/
471 u8 MaxDCTs; /* Max number of DCTs in system*/
472 // NOTE: removed u8 DCT. Use ->dev_ for pci R/W; /*DCT pointer*/
473 u8 GangedMode; /* Ganged mode enabled, 0 = disabled, 1 = enabled*/
474 u8 DRPresent; /* Family 10 present flag, 0 = n0t Fam10, 1 = Fam10*/
475 u32 NodeSysLimit; /* BASE[39:8],for DCT0+DCT1 system address*/
478 // NOTE: Not used - u8 NodeSpeed /* Bus Speed (to set Controller)
482 // NOTE: Not used - u8 NodeCASL /* CAS latency DCT setting
489 u8 CurrRcvrCHADelay; /* for keep current RcvrEnDly of chA*/
490 u16 T1000; /* get the T1000 figure (cycle time (ns)*1K)*/
491 u8 DqsRcvEn_Pass; /* for TrainRcvrEn byte lane pass flag*/
492 u8 DqsRcvEn_Saved; /* for TrainRcvrEn byte lane saved flag*/
493 u8 SeedPass1Remainder; /* for Phy assisted DQS receiver enable training*/
495 /* for second pass - Second pass should never run for Fam10*/
496 // NOTE: Not used for Barcelona - u8 CH_D_B_RCVRDLY_1[2][4][8]; /* CHA DIMM 0 Receiver Enable Delay*/
497 /* CHA DIMM 1 Receiver Enable Delay*/
498 /* CHA DIMM 2 Receiver Enable Delay*/
499 /* CHA DIMM 3 Receiver Enable Delay*/
501 /* CHB DIMM 0 Receiver Enable Delay*/
502 /* CHB DIMM 1 Receiver Enable Delay*/
503 /* CHB DIMM 2 Receiver Enable Delay*/
504 /* CHB DIMM 3 Receiver Enable Delay*/
506 u8 ClToNB_flag; /* is used to restore ClLinesToNbDis bit after memory */
507 u32 NodeSysBase; /* for channel interleave usage */
509 /* New for LB Support */
517 /*===============================================================================
518 Local Error Status Codes (DCTStatStruc.ErrCode)
519 ===============================================================================*/
520 #define SC_RunningOK 0
521 #define SC_VarianceErr 1 /* Running non-optimally*/
522 #define SC_StopError 2 /* Not Running*/
523 #define SC_FatalErr 3 /* Fatal Error, MCTB has exited immediately*/
525 /*===============================================================================
526 Local Error Status (DCTStatStruc.ErrStatus[31:0])
527 ===============================================================================*/
529 #define SB_DIMMChkSum 1
530 #define SB_DimmMismatchM 2 /* dimm module type(buffer) mismatch*/
531 #define SB_DimmMismatchT 3 /* dimm CL/T mismatch*/
532 #define SB_DimmMismatchO 4 /* dimm organization mismatch (128-bit)*/
533 #define SB_NoTrcTrfc 5 /* SPD missing Trc or Trfc info*/
534 #define SB_NoCycTime 6 /* SPD missing byte 23 or 25*/
535 #define SB_BkIntDis 7 /* Bank interleave requested but not enabled*/
536 #define SB_DramECCDis 8 /* Dram ECC requested but not enabled*/
537 #define SB_SpareDis 9 /* Online spare requested but not enabled*/
538 #define SB_MinimumMode 10 /* Running in Minimum Mode*/
539 #define SB_NORCVREN 11 /* No DQS Receiver Enable pass window found*/
540 #define SB_CHA2BRCVREN 12 /* DQS Rcvr En pass window CHA to CH B too large*/
541 #define SB_SmallRCVR 13 /* DQS Rcvr En pass window too small (far right of dynamic range)*/
542 #define SB_NODQSPOS 14 /* No DQS-DQ passing positions*/
543 #define SB_SMALLDQS 15 /* DQS-DQ passing window too small*/
544 #define SB_DCBKScrubDis 16 /* DCache scrub requested but not enabled */
546 /*===============================================================================
547 Local Configuration Status (DCTStatStruc.Status[31:0])
548 ===============================================================================*/
549 #define SB_Registered 0 /* All DIMMs are Registered*/
550 #define SB_ECCDIMMs 1 /* All banks ECC capable*/
551 #define SB_PARDIMMs 2 /* All banks Addr/CMD Parity capable*/
552 #define SB_DiagClks 3 /* Jedec ALL slots clock enable diag mode*/
553 #define SB_128bitmode 4 /* DCT in 128-bit mode operation*/
554 #define SB_64MuxedMode 5 /* DCT in 64-bit mux'ed mode.*/
555 #define SB_2TMode 6 /* 2T CMD timing mode is enabled.*/
556 #define SB_SWNodeHole 7 /* Remapping of Node Base on this Node to create a gap.*/
557 #define SB_HWHole 8 /* Memory Hole created on this Node using HW remapping.*/
558 #define SB_Over400MHz 9 /* DCT freq >= 400MHz flag*/
559 #define SB_DQSPos_Pass2 10 /* Using for TrainDQSPos DIMM0/1, when freq>=400MHz*/
560 #define SB_DQSRcvLimit 11 /* Using for DQSRcvEnTrain to know we have reached to upper bound.*/
561 #define SB_ExtConfig 12 /* Indicator the default setting for extend PCI configuration support*/
566 /*===============================================================================
567 NVRAM/run-time-configurable Items
568 ===============================================================================*/
569 /*Platform Configuration*/
570 #define NV_PACK_TYPE 0 /* CPU Package Type (2-bits)
574 #define NV_MAX_NODES 1 /* Number of Nodes/Sockets (4-bits)*/
575 #define NV_MAX_DIMMS 2 /* Number of DIMM slots for the specified Node ID (4-bits)*/
576 #define NV_MAX_MEMCLK 3 /* Maximum platform demonstrated Memclock (10-bits)
580 400=400Mhz (DDR800)*/
581 #define NV_ECC_CAP 4 /* Bus ECC capable (1-bits)
582 0=Platform not capable
583 1=Platform is capable*/
584 #define NV_4RANKType 5 /* Quad Rank DIMM slot type (2-bits)
586 1=R4 (4-Rank Registered DIMMs in AMD server configuration)
587 2=S4 (Unbuffered SO-DIMMs)*/
588 #define NV_BYPMAX 6 /* Value to set DcqBypassMax field (See Function 2, Offset 94h, [27:24] of BKDG for field definition).
589 4=4 times bypass (normal for non-UMA systems)
590 7=7 times bypass (normal for UMA systems)*/
591 #define NV_RDWRQBYP 7 /* Value to set RdWrQByp field (See Function 2, Offset A0h, [3:2] of BKDG for field definition).
592 2=8 times (normal for non-UMA systems)
593 3=16 times (normal for UMA systems)*/
597 #define NV_MCTUSRTMGMODE 10 /* User Memclock Mode (2-bits)
598 0=Auto, no user limit
599 1=Auto, user limit provided in NV_MemCkVal
600 2=Manual, user value provided in NV_MemCkVal*/
601 #define NV_MemCkVal 11 /* Memory Clock Value (2-bits)
607 /*Dram Configuration*/
608 #define NV_BankIntlv 20 /* Dram Bank (chip-select) Interleaving (1-bits)
611 #define NV_AllMemClks 21 /* Turn on All DIMM clocks (1-bits)
613 1=enable all memclocks*/
614 #define NV_SPDCHK_RESTRT 22 /* SPD Check control bitmap (1-bits)
615 0=Exit current node init if any DIMM has SPD checksum error
616 1=Ignore faulty SPD checksums (Note: DIMM cannot be enabled)*/
617 #define NV_DQSTrainCTL 23 /* DQS Signal Timing Training Control
619 1=perform DQS training*/
620 #define NV_NodeIntlv 24 /* Node Memory Interleaving (1-bits)
623 #define NV_BurstLen32 25 /* BurstLength32 for 64-bit mode (1-bits)
625 1=enable (4 beat burst when width is 64-bits)*/
628 #define NV_CKE_PDEN 30 /* CKE based power down mode (1-bits)
631 #define NV_CKE_CTL 31 /* CKE based power down control (1-bits)
632 0=per Channel control
633 1=per Chip select control*/
634 #define NV_CLKHZAltVidC3 32 /* Memclock tri-stating during C3 and Alt VID (1-bits)
639 #define NV_BottomIO 40 /* Bottom of 32-bit IO space (8-bits)
640 NV_BottomIO[7:0]=Addr[31:24]*/
641 #define NV_BottomUMA 41 /* Bottom of shared graphics dram (8-bits)
642 NV_BottomUMA[7:0]=Addr[31:24]*/
643 #define NV_MemHole 42 /* Memory Hole Remapping (1-bits)
648 #define NV_ECC 50 /* Dram ECC enable*/
649 #define NV_NBECC 52 /* ECC MCE enable*/
650 #define NV_ChipKill 53 /* Chip-Kill ECC Mode enable*/
651 #define NV_ECCRedir 54 /* Dram ECC Redirection enable*/
652 #define NV_DramBKScrub 55 /* Dram ECC Background Scrubber CTL*/
653 #define NV_L2BKScrub 56 /* L2 ECC Background Scrubber CTL*/
654 #define NV_DCBKScrub 57 /* DCache ECC Background Scrubber CTL*/
655 #define NV_CS_SpareCTL 58 /* Chip Select Spare Control bit 0:
658 /* Chip Select Spare Control bit 1-4:
659 Reserved, must be zero*/
660 #define NV_SyncOnUnEccEn 61 /* SyncOnUnEccEn control
663 #define NV_Unganged 62
665 #define NV_ChannelIntlv 63 /* Channel Interleaving (3-bits)
667 yy1b = enable with DctSelIntLvAddr set to yyb */
670 #ifndef MAX_NODES_SUPPORTED
671 #define MAX_NODES_SUPPORTED 8
674 #ifndef MAX_DIMMS_SUPPORTED
675 #define MAX_DIMMS_SUPPORTED 8
678 #ifndef MAX_CS_SUPPORTED
679 #define MAX_CS_SUPPORTED 8
682 #ifndef MCT_DIMM_SPARE_NO_WARM
683 #define MCT_DIMM_SPARE_NO_WARM 0
687 u32 Get_NB32(u32 dev, u32 reg);
688 void Set_NB32(u32 dev, u32 reg, u32 val);
689 u32 Get_NB32_index(u32 dev, u32 index_reg, u32 index);
690 void Set_NB32_index(u32 dev, u32 index_reg, u32 index, u32 data);
691 u32 Get_NB32_index_wait(u32 dev, u32 index_reg, u32 index);
692 void Set_NB32_index_wait(u32 dev, u32 index_reg, u32 index, u32 data);
693 u32 OtherTiming_A_D(struct DCTStatStruc *pDCTstat, u32 val);
694 void mct_ForceAutoPrecharge_D(struct DCTStatStruc *pDCTstat, u32 dct);
695 u32 Modify_D3CMP(struct DCTStatStruc *pDCTstat, u32 dct, u32 value);
696 u8 mct_checkNumberOfDqsRcvEn_1Pass(u8 pass);
697 u32 SetupDqsPattern_1PassA(u8 Pass);
698 u32 SetupDqsPattern_1PassB(u8 Pass);
699 u8 mct_Get_Start_RcvrEnDly_1Pass(u8 Pass);
700 u8 mct_Average_RcvrEnDly_Pass(struct DCTStatStruc *pDCTstat, u8 RcvrEnDly, u8 RcvrEnDlyLimit, u8 Channel, u8 Receiver, u8 Pass);
701 void CPUMemTyping_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
702 u32 mctGetLogicalCPUID(u32 Node);
703 u8 ECCInit_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
704 void TrainReceiverEn_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA, u8 Pass);
705 void mct_TrainDQSPos_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
706 void mctSetEccDQSRcvrEn_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
707 void TrainMaxReadLatency_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
708 void mct_EndDQSTraining_D(struct MCTStatStruc *pMCTstat,struct DCTStatStruc *pDCTstatA);
709 void mct_SetRcvrEnDly_D(struct DCTStatStruc *pDCTstat, u8 RcvrEnDly, u8 FinalValue, u8 Channel, u8 Receiver, u32 dev, u32 index_reg, u8 Addl_Index, u8 Pass);
710 void SetEccDQSRcvrEn_D(struct DCTStatStruc *pDCTstat, u8 Channel);
711 void mctGet_PS_Cfg_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u32 dct);
712 void InterleaveBanks_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 dct);
713 void mct_SetDramConfigHi_D(struct DCTStatStruc *pDCTstat, u32 dct, u32 DramConfigHi);
714 void mct_DramInit_Hw_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 dct);
715 void SyncSetting(struct DCTStatStruc *pDCTstat);
716 void mct_SetClToNB_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
717 void mct_SetWbEnhWsbDis_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
718 void mct_TrainRcvrEn_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 Pass);
719 void mct_EnableDimmEccEn_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 _DisableDramECC);
720 u32 procOdtWorkaround(struct DCTStatStruc *pDCTstat, u32 dct, u32 val);
721 void mct_BeforeDramInit_D(struct DCTStatStruc *pDCTstat, u32 dct);
722 void mctGet_DIMMAddr(struct DCTStatStruc *pDCTstat, u32 node);
723 void mctSMBhub_Init(u32 node);
724 int mctRead_SPD(u32 smaddr, u32 reg);
725 void InterleaveNodes_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
726 void InterleaveChannels_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
727 void mct_BeforeDQSTrain_Samp_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
728 static void StoreDQSDatStrucVal_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 ChipSel);
729 void phyAssistedMemFnceTraining(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
730 u8 mct_SaveRcvEnDly_D_1Pass(struct DCTStatStruc *pDCTstat, u8 pass);
731 static void mct_AdjustScrub_D(struct DCTStatStruc *pDCTstat, u16 *scrub_request);
732 static u8 mct_InitReceiver_D(struct DCTStatStruc *pDCTstat, u8 dct);
733 static void mct_Wait_10ns (u32 cycles);
734 u8 mct_RcvrRankEnabled_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 Channel, u8 ChipSel);
735 u32 mct_GetRcvrSysAddr_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 channel, u8 receiver, u8 *valid);
736 void mct_Read1LTestPattern_D(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u32 addr);