This patch sets max freq defaults for ddr2 and ddr3for fam10.
[coreboot.git] / src / northbridge / amd / amdmct / mct / mct.h
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, Inc.
5  *
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.
9  *
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.
14  *
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
18  */
19
20 #ifndef MCT_H
21 #define MCT_H
22 /*===========================================================================
23         CPU - K8/FAM10
24 ===========================================================================*/
25 #define PT_L1           0               /* CPU Package Type*/
26 #define PT_M2           1
27 #define PT_S1           2
28
29 #define J_MIN           0               /* j loop constraint. 1=CL 2.0 T*/
30 #define J_MAX           4               /* j loop constraint. 4=CL 6.0 T*/
31 #define K_MIN           1               /* k loop constraint. 1=200 Mhz*/
32 #define K_MAX           4               /* k loop constraint. 9=400 Mhz*/
33 #define CL_DEF          2               /* Default value for failsafe operation. 2=CL 4.0 T*/
34 #define T_DEF           1               /* Default value for failsafe operation. 1=5ns (cycle time)*/
35
36 #define BSCRate 1               /* reg bit field=rate of dram scrubber for ecc*/
37                                         /* memory initialization (ecc and check-bits).*/
38                                         /* 1=40 ns/64 bytes.*/
39 #define FirstPass       1               /* First pass through RcvEn training*/
40 #define SecondPass      2               /* Second pass through Rcven training*/
41
42 #define RCVREN_MARGIN   6               /* number of DLL taps to delay beyond first passing position*/
43 #define MAXASYNCLATCTL_3        60      /* Max Async Latency Control value (This value will be divided by 20)*/
44 #define DQS_FAIL        1
45 #define DQS_PASS        0
46 #define DQS_WRITEDIR    0
47 #define DQS_READDIR     1
48 #define MIN_DQS_WNDW    3
49 #define secPassOffset   6
50
51 #define PA_HOST (((24 << 3)+0) << 8)    /* Node 0 Host Bus function PCI Address bits [15:0] */
52 #define PA_MAP          (((24 << 3)+1) << 8)    /* Node 0 MAP function PCI Address bits [15:0] */
53 #define PA_DCT          (((24 << 3)+2) << 8)    /* Node 0 DCT function PCI Address bits [15:0] */
54 #define PA_DCTADDL      (((00 << 3)+2) << 8)    /* Node x DCT function, Additional Registers PCI Address bits [15:0] */
55 #define PA_NBMISC       (((24 << 3)+3) << 8)    /* Node 0 Misc PCI Address bits [15:0] */
56 #define PA_NBDEVOP      (((00 << 3)+3) << 8)    /* Node 0 Misc PCI Address bits [15:0] */
57
58 #define DCC_EN          1               /* X:2:0x94[19]*/
59 #define ILD_Lmt         3       /* X:2:0x94[18:16]*/
60
61 #define EncodedTSPD     0x00191709      /* encodes which SPD byte to get T from*/
62                                         /* versus CL X, CL X-.5, and CL X-1*/
63
64 #define Bias_TrpT       3               /* bias to convert bus clocks to bit field value*/
65 #define Bias_TrrdT      2
66 #define Bias_TrcdT      3
67 #define Bias_TrasT      3
68 #define Bias_TrcT       11
69 #define Bias_TrtpT      4
70 #define Bias_TwrT       3
71 #define Bias_TwtrT      0
72
73 #define Min_TrpT        3               /* min programmable value in busclocks*/
74 #define Max_TrpT        6               /* max programmable value in busclocks*/
75 #define Min_TrrdT       2
76 #define Max_TrrdT       5
77 #define Min_TrcdT       3
78 #define Max_TrcdT       6
79 #define Min_TrasT       5
80 #define Max_TrasT       18
81 #define Min_TrcT        11
82 #define Max_TrcT        26
83 #define Min_TrtpT       4
84 #define Max_TrtpT       5
85 #define Min_TwrT        3
86 #define Max_TwrT        6
87 #define Min_TwtrT       1
88 #define Max_TwtrT       3
89
90 /* common register bit names */
91 #define DramHoleValid   0               /* func 1, offset F0h, bit 0 */
92 #define CSEnable        0               /* func 2, offset 40h-5C, bit 0 */
93 #define Spare           1               /* func 2, offset 40h-5C, bit 1 */
94 #define TestFail        2               /* func 2, offset 40h-5C, bit 2 */
95 #define DqsRcvEnTrain   18              /* func 2, offset 78h, bit 18 */
96 #define EnDramInit      31              /* func 2, offset 7Ch, bit 31 */
97 #define DisAutoRefresh  18              /* func 2, offset 8Ch, bit 18 */
98 #define InitDram        0               /* func 2, offset 90h, bit 0 */
99 #define BurstLength32   10              /* func 2, offset 90h, bit 10 */
100 #define Width128        11              /* func 2, offset 90h, bit 11 */
101 #define X4Dimm          12              /* func 2, offset 90h, bit 12 */
102 #define UnBuffDimm      16              /* func 2, offset 90h, bit 16 */
103 #define DimmEcEn        19              /* func 2, offset 90h, bit 19 */
104 #define MemClkFreqVal   3               /* func 2, offset 94h, bit 3 */
105 #define RDqsEn          12              /* func 2, offset 94h, bit 12 */
106 #define DisDramInterface        14      /* func 2, offset 94h, bit 14 */
107 #define DctAccessWrite  30              /* func 2, offset 98h, bit 30 */
108 #define DctAccessDone   31              /* func 2, offset 98h, bit 31 */
109 #define PwrSavingsEn    10              /* func 2, offset A0h, bit 10 */
110 #define Mod64BitMux     4               /* func 2, offset A0h, bit 4 */
111 #define DisableJitter   1               /* func 2, offset A0h, bit 1 */
112 #define DramEnabled     9               /* func 2, offset A0h, bit 9 */
113 #define SyncOnUcEccEn   2               /* func 3, offset 44h, bit 2 */
114
115 /*=============================================================================
116         Jedec DDR II
117 =============================================================================*/
118 #define SPD_TYPE        2               /* SPD byte read location*/
119         #define JED_DDRSDRAM    0x07    /* Jedec defined bit field*/
120         #define JED_DDR2SDRAM   0x08    /* Jedec defined bit field*/
121
122 #define SPD_DIMMTYPE    20
123 #define SPD_ATTRIB      21
124         #define JED_DIFCKMSK    0x20    /* Differential Clock Input*/
125         #define JED_REGADCMSK   0x11    /* Registered Address/Control*/
126         #define JED_PROBEMSK    0x40    /* Analysis Probe installed*/
127 #define SPD_DEVATTRIB   22
128 #define SPD_EDCTYPE     11
129         #define JED_ECC         0x02
130         #define JED_ADRCPAR     0x04
131 #define SPD_ROWSZ       3
132 #define SPD_COLSZ       4
133 #define SPD_LBANKS      17              /* number of [logical] banks on each device*/
134 #define SPD_DMBANKS     5               /* number of physical banks on dimm*/
135     #define SPDPLBit    4               /* Dram package bit*/
136 #define SPD_BANKSZ      31              /* capacity of physical bank*/
137 #define SPD_DEVWIDTH    13
138 #define SPD_CASLAT      18
139 #define SPD_TRP 27
140 #define SPD_TRRD        28
141 #define SPD_TRCD        29
142 #define SPD_TRAS        30
143 #define SPD_TWR 36
144 #define SPD_TWTR        37
145 #define SPD_TRTP        38
146 #define SPD_TRCRFC      40
147 #define SPD_TRC 41
148 #define SPD_TRFC        42
149
150 #define SPD_MANDATEYR   93              /* Module Manufacturing Year (BCD) */
151
152 #define SPD_MANDATEWK   94              /* Module Manufacturing Week (BCD) */
153
154 /*--------------------------------------
155         Jedec DDR II related equates
156 --------------------------------------*/
157 #define MYEAR06 6               /* Manufacturing Year BCD encoding of 2006 - 06d*/
158 #define MWEEK24 0x24            /* Manufacturing Week BCD encoding of June - 24d*/
159
160 /*=============================================================================
161         Macros
162 =============================================================================*/
163
164 #define _2GB_RJ8        (2<<(30-8))
165 #define _4GB_RJ8        (4<<(30-8))
166 #define _4GB_RJ4        (4<<(30-4))
167
168 #define BigPagex8_RJ8   (1<<(17+3-8))   /* 128KB * 8 >> 8 */
169
170 /*=============================================================================
171         Global MCT Status Structure
172 =============================================================================*/
173 struct MCTStatStruc {
174         u32 GStatus;    /* Global Status bitfield*/
175         u32 HoleBase;   /* If not zero, BASE[39:8] (system address)
176                                    of sub 4GB dram hole for HW remapping.*/
177         u32 Sub4GCacheTop;      /* If not zero, the 32-bit top of cacheable memory.*/
178         u32 SysLimit;   /* LIMIT[39:8] (system address)*/
179 };
180 /*=============================================================================
181         Global MCT Configuration Status Word (GStatus)
182 =============================================================================*/
183 /*These should begin at bit 0 of GStatus[31:0]*/
184 #define GSB_MTRRshort   0               /* Ran out of MTRRs while mapping memory*/
185 #define GSB_ECCDIMMs    1               /* All banks of all Nodes are ECC capable*/
186 #define GSB_DramECCDis  2               /* Dram ECC requested but not enabled.*/
187 #define GSB_SoftHole    3               /* A Node Base gap was created*/
188 #define GSB_HWHole      4               /* A HW dram remap was created*/
189 #define GSB_NodeIntlv   5               /* Node Memory interleaving was enabled*/
190 #define GSB_SpIntRemapHole      16      /* Special condition for Node Interleave and HW remapping*/
191
192
193 /*===============================================================================
194         Local DCT Status structure (a structure for each DCT)
195 ===============================================================================*/
196
197 struct DCTStatStruc {           /* A per Node structure*/
198         u8 Node_ID;     /* Node ID of current controller*/
199         u8 ErrCode;     /* Current error condition of Node
200                                    0= no error
201                                    1= Variance Error, DCT is running but not in an optimal configuration.
202                                    2= Stop Error, DCT is NOT running
203                                    3= Fatal Error, DCT/MCT initialization has been halted.*/
204         u32 ErrStatus;  /* Error Status bit Field */
205         u32 Status;     /* Status bit Field*/
206         u8 DIMMAddr[8]; /* SPD address of DIMM controlled by MA0_CS_L[0,1]*/
207                                 /* SPD address of..MB0_CS_L[0,1]*/
208                                 /* SPD address of..MA1_CS_L[0,1]*/
209                                 /* SPD address of..MB1_CS_L[0,1]*/
210                                 /* SPD address of..MA2_CS_L[0,1]*/
211                                 /* SPD address of..MB2_CS_L[0,1]*/
212                                 /* SPD address of..MA3_CS_L[0,1]*/
213                                 /* SPD address of..MB3_CS_L[0,1]*/
214         u16 DIMMPresent;        /* For each bit n 0..7, 1=DIMM n is present.
215                                    DIMM#  Select Signal
216                                    0      MA0_CS_L[0,1]
217                                    1      MB0_CS_L[0,1]
218                                    2      MA1_CS_L[0,1]
219                                    3      MB1_CS_L[0,1]
220                                    4      MA2_CS_L[0,1]
221                                    5      MB2_CS_L[0,1]
222                                    6      MA3_CS_L[0,1]
223                                    7      MB3_CS_L[0,1]*/
224         u16 DIMMValid;          /* For each bit n 0..7, 1=DIMM n is valid and is/will be configured*/
225         u16 DIMMSPDCSE;         /* For each bit n 0..7, 1=DIMM n SPD checksum error*/
226         u16 DimmECCPresent;     /* For each bit n 0..7, 1=DIMM n is ECC capable.*/
227         u16 DimmPARPresent;     /* For each bit n 0..7, 1=DIMM n is ADR/CMD Parity capable.*/
228         u16 Dimmx4Present;              /* For each bit n 0..7, 1=DIMM n contains x4 data devices.*/
229         u16 Dimmx8Present;              /* For each bit n 0..7, 1=DIMM n contains x8 data devices.*/
230         u16 Dimmx16Present;     /* For each bit n 0..7, 1=DIMM n contains x16 data devices.*/
231         u16 DIMM1Kpage;         /* For each bit n 0..7, 1=DIMM n contains 1K page devices.*/
232         u8 MAload[2];           /* Number of devices loading MAA bus*/
233                                         /* Number of devices loading MAB bus*/
234         u8 MAdimms[2];          /* Number of DIMMs loading CH A*/
235                                         /* Number of DIMMs loading CH B*/
236         u8 DATAload[2];         /* Number of ranks loading CH A DATA*/
237                                         /* Number of ranks loading CH B DATA*/
238         u8 DIMMAutoSpeed;               /* Max valid Mfg. Speed of DIMMs
239                                            1=200Mhz
240                                            2=266Mhz
241                                            3=333Mhz
242                                            4=400Mhz */
243         u8 DIMMCASL;            /* Min valid Mfg. CL bitfield
244                                            0=2.0
245                                            1=3.0
246                                            2=4.0
247                                            3=5.0
248                                            4=6.0 */
249         u16 DIMMTrcd;   /* Minimax Trcd*40 (ns) of DIMMs*/
250         u16 DIMMTrp;    /* Minimax Trp*40 (ns) of DIMMs*/
251         u16 DIMMTrtp;   /* Minimax Trtp*40 (ns) of DIMMs*/
252         u16 DIMMTras;   /* Minimax Tras*40 (ns) of DIMMs*/
253         u16 DIMMTrc;    /* Minimax Trc*40 (ns) of DIMMs*/
254         u16 DIMMTwr;    /* Minimax Twr*40 (ns) of DIMMs*/
255         u16 DIMMTrrd;   /* Minimax Trrd*40 (ns) of DIMMs*/
256         u16 DIMMTwtr;   /* Minimax Twtr*40 (ns) of DIMMs*/
257         u8 Speed;               /* Bus Speed (to set Controller)
258                                    1=200Mhz
259                                    2=266Mhz
260                                    3=333Mhz
261                                    4=400Mhz */
262         u8 CASL;                /* CAS latency DCT setting
263                                    0=2.0
264                                    1=3.0
265                                    2=4.0
266                                    3=5.0
267                                    4=6.0 */
268         u8 Trcd;                /* DCT Trcd (busclocks) */
269         u8 Trp;         /* DCT Trp (busclocks) */
270         u8 Trtp;                /* DCT Trtp (busclocks) */
271         u8 Tras;                /* DCT Tras (busclocks) */
272         u8 Trc;         /* DCT Trc (busclocks) */
273         u8 Twr;         /* DCT Twr (busclocks) */
274         u8 Trrd;                /* DCT Trrd (busclocks) */
275         u8 Twtr;                /* DCT Twtr (busclocks) */
276         u8 Trfc[4];     /* DCT Logical DIMM0 Trfc
277                                    0=75ns (for 256Mb devs)
278                                    1=105ns (for 512Mb devs)
279                                    2=127.5ns (for 1Gb devs)
280                                    3=195ns (for 2Gb devs)
281                                    4=327.5ns (for 4Gb devs) */
282                                 /* DCT Logical DIMM1 Trfc (see Trfc0 for format) */
283                                 /* DCT Logical DIMM2 Trfc (see Trfc0 for format) */
284                                 /* DCT Logical DIMM3 Trfc (see Trfc0 for format) */
285         u16 CSPresent;  /* For each bit n 0..7, 1=Chip-select n is present */
286         u16 CSTestFail; /* For each bit n 0..7, 1=Chip-select n is present but disabled */
287         u32 DCTSysBase; /* BASE[39:8] (system address) of this Node's DCTs. */
288         u32 DCTHoleBase;        /* If not zero, BASE[39:8] (system address) of dram hole for HW remapping.  Dram hole exists on this Node's DCTs. */
289         u32 DCTSysLimit;        /* LIMIT[39:8] (system address) of this Node's DCTs */
290         u16 PresetmaxFreq;      /* Maximum OEM defined DDR frequency
291                                    200=200Mhz (DDR400)
292                                    266=266Mhz (DDR533)
293                                    333=333Mhz (DDR667)
294                                    400=400Mhz (DDR800) */
295         u8 _2Tmode;     /* 1T or 2T CMD mode (slow access mode)
296                                    1=1T
297                                    2=2T */
298         u8 TrwtTO;              /* DCT TrwtTO (busclocks)*/
299         u8 Twrrd;               /* DCT Twrrd (busclocks)*/
300         u8 Twrwr;               /* DCT Twrwr (busclocks)*/
301         u8 Trdrd;               /* DCT Trdrd (busclocks)*/
302         u32 CH_ODC_CTL[2];      /* Output Driver Strength (see BKDG FN2:Offset 9Ch, index 00h*/
303         u32 CH_ADDR_TMG[2];     /* Address Bus Timing (see BKDG FN2:Offset 9Ch, index 04h*/
304                                 /* Output Driver Strength (see BKDG FN2:Offset 9Ch, index 20h*/
305                                 /* Address Bus Timing (see BKDG FN2:Offset 9Ch, index 24h*/
306         u16 CH_EccDQSLike[2];   /* CHA DQS ECC byte like...*/
307         u8 CH_EccDQSScale[2];   /* CHA DQS ECC byte scale*/
308 //      u8 reserved_b_1;        /* Reserved*/
309                                 /* CHB DQS ECC byte like...*/
310                                 /* CHB DQS ECC byte scale*/
311 //      u8 reserved_b_2;        /*Reserved*/
312         u8 MaxAsyncLat; /* Max Asynchronous Latency (ns)*/
313         u8 CH_B_DQS[2][2][9];   /* CHA Byte 0 - 7 and Check Write DQS Delay*/
314                                 /* Reserved*/
315                                 /* CHA Byte 0 - 7 and Check Read DQS Delay*/
316                                 /* Reserved*/
317                                 /* CHB Byte 0 - 7 and Check Write DQS Delay*/
318                                 /* Reserved*/
319                                 /* CHB Byte 0 - 7 and Check Read DQS Delay*/
320                                 /* Reserved*/
321         u8 CH_D_RCVRDLY[2][4];  /* CHA DIMM 0 - 3 Receiver Enable Delay*/
322                                         /* CHB DIMM 0 - 3 Receiver Enable Delay*/
323         u32 PtrPatternBufA;     /* Ptr on stack to aligned DQS testing pattern*/
324         u32 PtrPatternBufB;     /*Ptr on stack to aligned DQS testing pattern*/
325         u8 Channel;     /* Current Channel (0= CH A, 1=CH B)*/
326         u8 ByteLane;    /* Current Byte Lane (0..7)*/
327         u8 Direction;   /* Current DQS-DQ training write direction (0=read, 1=write)*/
328         u8 Pattern;     /* Current pattern*/
329         u8 DQSDelay;    /* Current DQS delay value*/
330         u32 TrainErrors;        /* Current Training Errors*/
331 //      u8 reserved_b_3;        /* RSVD */
332         u32 AMC_TSC_DeltaLo;    /* Time Stamp Counter measurement of AMC, Low dword*/
333         u32 AMC_TSC_DeltaHi;    /* Time Stamp Counter measurement of AMC, High dword*/
334         u8 CH_B_Dly[2][2][2][8];        /* CH A byte lane 0 - 7 minimum filtered window passing DQS delay value*/
335                         /* CH A byte lane 0 - 7 maximum filtered window  passing DQS delay value*/
336                         /* CH B byte lane 0 - 7 minimum filtered window  passing DQS delay value*/
337                         /* CH B byte lane 0 - 7 maximum filtered window  passing DQS delay value*/
338                         /* CH A byte lane 0 - 7 minimum filtered window  passing DQS delay value*/
339                         /* CH A byte lane 0 - 7 maximum filtered window  passing DQS delay value*/
340                         /* CH B byte lane 0 - 7 minimum filtered window  passing DQS delay value*/
341                         /* CH B byte lane 0 - 7 maximum filtered window  passing DQS delay value*/
342         u32 LogicalCPUID;       /* The logical CPUID of the node*/
343         u16 HostBiosSrvc1;      /* Word sized general purpose field for use by host BIOS.  Scratch space.*/
344         u32 HostBiosSrvc2;      /* Dword sized general purpose field for use by host BIOS.  Scratch space.*/
345         u16 DimmQRPresent;      /* QuadRank DIMM present?*/
346         u16 DimmTrainFail;      /* Bitmap showing which dimms failed training*/
347         u16 CSTrainFail;        /* Bitmap showing which chipselects failed training*/
348         u16 DimmYr06;           /* Bitmap indicating which Dimms have a manufactur's year code <= 2006*/
349         u16 DimmWk2406; /* Bitmap indicating which Dimms have a manufactur's week code <= 24 of 2006 (June)*/
350         u16 DimmDRPresent;      /* Bitmap indicating that Dual Rank Dimms are present*/
351         u16 DimmPlPresent;      /* Bitmap indicating that Planar (1) or Stacked (0) Dimms are present.*/
352         u16 ChannelTrainFail;   /* Bitmap showing the channel information about failed Chip Selects*/
353                                 /* 0 in any bit field indicates Channel 0*/
354                                 /* 1 in any bit field indicates Channel 1*/
355 };
356
357 /*===============================================================================
358         Local Error Status Codes (DCTStatStruc.ErrCode)
359 ===============================================================================*/
360 #define SC_RunningOK            0
361 #define SC_VarianceErr          1       /* Running non-optimally*/
362 #define SC_StopError            2       /* Not Running*/
363 #define SC_FatalErr             3       /* Fatal Error, MCTB has exited immediately*/
364
365 /*===============================================================================
366      Local Error Status (DCTStatStruc.ErrStatus[31:0])
367   ===============================================================================*/
368 #define SB_NoDimms              0
369 #define SB_DIMMChkSum           1
370 #define SB_DimmMismatchM        2       /* dimm module type(buffer) mismatch*/
371 #define SB_DimmMismatchT        3       /* dimm CL/T mismatch*/
372 #define SB_DimmMismatchO        4       /* dimm organization mismatch (128-bit)*/
373 #define SB_NoTrcTrfc            5       /* SPD missing Trc or Trfc info*/
374 #define SB_NoCycTime            6       /* SPD missing byte 23 or 25*/
375 #define SB_BkIntDis             7       /* Bank interleave requested but not enabled*/
376 #define SB_DramECCDis           8       /* Dram ECC requested but not enabled*/
377 #define SB_SpareDis             9       /* Online spare requested but not enabled*/
378 #define SB_MinimumMode          10      /* Running in Minimum Mode*/
379 #define SB_NORCVREN             11      /* No DQS Receiver Enable pass window found*/
380 #define SB_CHA2BRCVREN          12      /* DQS Rcvr En pass window CHA to CH B too large*/
381 #define SB_SmallRCVR            13      /* DQS Rcvr En pass window too small (far right of dynamic range)*/
382 #define SB_NODQSPOS             14      /* No DQS-DQ passing positions*/
383 #define SB_SMALLDQS             15      /* DQS-DQ passing window too small*/
384
385 /*===============================================================================
386         Local Configuration Status (DCTStatStruc.Status[31:0])
387 ===============================================================================*/
388 #define SB_Registered           0       /* All DIMMs are Registered*/
389 #define SB_ECCDIMMs             1       /* All banks ECC capable*/
390 #define SB_PARDIMMs             2       /* All banks Addr/CMD Parity capable*/
391 #define SB_DiagClks             3       /* Jedec ALL slots clock enable diag mode*/
392 #define SB_128bitmode           4       /* DCT in 128-bit mode operation*/
393 #define SB_64MuxedMode          5       /* DCT in 64-bit mux'ed mode.*/
394 #define SB_2TMode               6       /* 2T CMD timing mode is enabled.*/
395 #define SB_SWNodeHole           7       /* Remapping of Node Base on this Node to create a gap.*/
396 #define SB_HWHole               8       /* Memory Hole created on this Node using HW remapping.*/
397
398
399
400 /*===============================================================================
401         NVRAM/run-time-configurable Items
402 ===============================================================================*/
403 /* Platform Configuration */
404 #define NV_PACK_TYPE            0       /* CPU Package Type (2-bits)
405                                            0=NPT L1
406                                            1=NPT M2
407                                            2=NPT S1*/
408 #define NV_MAX_NODES            1       /* Number of Nodes/Sockets (4-bits)*/
409 #define NV_MAX_DIMMS            2       /* Number of DIMM slots for the specified Node ID (4-bits)*/
410 #define NV_MAX_MEMCLK           3       /* Maximum platform demonstrated Memclock (10-bits)
411                                            200=200Mhz (DDR400)
412                                            266=266Mhz (DDR533)
413                                            333=333Mhz (DDR667)
414                                            400=400Mhz (DDR800)*/
415 #define NV_ECC_CAP              4       /* Bus ECC capable (1-bits)
416                                            0=Platform not capable
417                                            1=Platform is capable*/
418 #define NV_4RANKType            5       /* Quad Rank DIMM slot type (2-bits)
419                                            0=Normal
420                                            1=R4 (4-Rank Registered DIMMs in AMD server configuration)
421                                            2=S4 (Unbuffered SO-DIMMs)*/
422 #define NV_BYPMAX               6       /* Value to set DcqBypassMax field (See Function 2, Offset 94h, [27:24] of BKDG for field definition).
423                                            4=4 times bypass (normal for non-UMA systems)
424                                            7=7 times bypass (normal for UMA systems)*/
425 #define NV_RDWRQBYP             7       /* Value to set RdWrQByp field (See Function 2, Offset A0h, [3:2] of BKDG for field definition).
426                                            2=8 times (normal for non-UMA systems)
427                                            3=16 times (normal for UMA systems)*/
428
429
430 /* Dram Timing */
431 #define NV_MCTUSRTMGMODE        10      /* User Memclock Mode (2-bits)
432                                            0=Auto, no user limit
433                                            1=Auto, user limit provided in NV_MemCkVal
434                                            2=Manual, user value provided in NV_MemCkVal*/
435 #define NV_MemCkVal             11      /* Memory Clock Value (2-bits)
436                                            0=200Mhz
437                                            1=266Mhz
438                                            2=333Mhz
439                                            3=400Mhz*/
440
441 /* Dram Configuration */
442 #define NV_BankIntlv            20      /* Dram Bank (chip-select) Interleaving (1-bits)
443                                            0=disable
444                                            1=enable*/
445 #define NV_AllMemClks           21      /* Turn on All DIMM clocks (1-bits)
446                                            0=normal
447                                            1=enable all memclocks*/
448 #define NV_SPDCHK_RESTRT        22      /* SPD Check control bitmap (1-bits)
449                                            0=Exit current node init if any DIMM has SPD checksum error
450                                            1=Ignore faulty SPD checksums (Note: DIMM cannot be enabled)*/
451 #define NV_DQSTrainCTL          23      /* DQS Signal Timing Training Control
452                                            0=skip DQS training
453                                            1=perform DQS training*/
454 #define NV_NodeIntlv            24      /* Node Memory Interleaving (1-bits)
455                                            0=disable
456                                            1=enable*/
457 #define NV_BurstLen32           25      /* burstLength32 for 64-bit mode (1-bits)
458                                            0=disable (normal)
459                                            1=enable (4 beat burst when width is 64-bits)*/
460
461 /* Dram Power */
462 #define NV_CKE_PDEN             30      /* CKE based power down mode (1-bits)
463                                            0=disable
464                                            1=enable*/
465 #define NV_CKE_CTL              31      /* CKE based power down control (1-bits)
466                                            0=per Channel control
467                                            1=per Chip select control*/
468 #define NV_CLKHZAltVidC3        32      /* Memclock tri-stating during C3 and Alt VID (1-bits)
469                                            0=disable
470                                            1=enable*/
471
472 /* Memory Map/Mgt.*/
473 #define NV_BottomIO             40      /* Bottom of 32-bit IO space (8-bits)
474                                            NV_BottomIO[7:0]=Addr[31:24]*/
475 #define NV_BottomUMA            41      /* Bottom of shared graphics dram (8-bits)
476                                            NV_BottomUMA[7:0]=Addr[31:24]*/
477 #define NV_MemHole              42      /* Memory Hole Remapping (1-bits)
478                                            0=disable
479                                            1=enable  */
480
481 /* ECC */
482 #define NV_ECC                  50      /* Dram ECC enable*/
483 #define NV_NBECC                52      /* ECC MCE enable*/
484 #define NV_ChipKill             53      /* Chip-Kill ECC Mode enable*/
485 #define NV_ECCRedir             54      /* Dram ECC Redirection enable*/
486 #define NV_DramBKScrub          55      /* Dram ECC Background Scrubber CTL*/
487 #define NV_L2BKScrub            56      /* L2 ECC Background Scrubber CTL*/
488 #define NV_DCBKScrub            57      /* DCache ECC Background Scrubber CTL*/
489 #define NV_CS_SpareCTL          58      /* Chip Select Spare Control bit 0:
490                                               0=disable Spare
491                                               1=enable Spare */
492                                          /*Chip Select Spare Control bit 1-4:
493                                             Reserved, must be zero*/
494 #define NV_Parity               60      /* Parity Enable*/
495 #define NV_SyncOnUnEccEn        61      /* SyncOnUnEccEn control
496                                            0=disable
497                                            1=enable*/
498
499
500 /* global function */
501 u32 NodePresent(u32 Node);
502 u32 Get_NB32n(struct DCTStatStruc *pDCTstat, u32 addrx);
503 u32 Get_NB32(u32 addr); /* NOTE: extend addr to 32 bit for bus > 0 */
504 u32 mctGetLogicalCPUID(u32 Node);
505
506 void K8FInterleaveBanks(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
507
508 void mctInitWithWritetoCS(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
509
510 void mctGet_PS_Cfg(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
511 void Get_ChannelPS_Cfg0( unsigned MAAdimms, unsigned Speed, unsigned MAAload, unsigned DATAAload,
512                 unsigned *AddrTmgCTL, unsigned *ODC_CTL);
513 void Get_ChannelPS_Cfg1( unsigned MAAdimms, unsigned Speed, unsigned MAAload,
514                 unsigned *AddrTmgCTL, unsigned *ODC_CTL, unsigned *val);
515 void Get_ChannelPS_Cfg2( unsigned MAAdimms, unsigned Speed, unsigned MAAload,
516                 unsigned *AddrTmgCTL, unsigned *ODC_CTL, unsigned *val);
517
518 u8 MCTDefRet(void);
519
520 u32 Get_RcvrSysAddr(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 channel, u8 receiver, u8 *valid);
521 u32 Get_MCTSysAddr(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, u8 channel, u8 chipsel, u8 *valid);
522 void K8FTrainReceiverEn(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA, u8 pass);
523 void K8FTrainDQSPos(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
524 u32 SetUpperFSbase(u32 addr_hi);
525
526
527 void K8FECCInit(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
528
529 void amd_MCTInit(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
530
531 void K8FCPUMemTyping(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
532 void K8FCPUMemTyping_clear(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstatA);
533
534 void K8FWaitMemClrDelay(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat);
535 unsigned K8FCalcFinalDQSRcvValue(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, unsigned LeftRcvEn, unsigned RightRcvEn, unsigned *valid);
536
537 void K8FGetDeltaTSCPart1(struct DCTStatStruc *pDCTstat);
538 void K8FGetDeltaTSCPart2(struct DCTStatStruc *pDCTstat);
539 #endif