blob: 611291acbd77edd4f6367a202971260e7f77f729 [file] [log] [blame]
Scott Duplichan1ba2eee2010-10-19 04:58:49 +00001/*
2 * This file is part of the coreboot project.
3 *
Timothy Pearson586d6e22015-02-16 14:57:06 -06004 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
Scott Duplichan1ba2eee2010-10-19 04:58:49 +00005 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Scott Duplichan1ba2eee2010-10-19 04:58:49 +000015 */
16
17#ifndef AMDFAM10_H
Scott Duplichan1ba2eee2010-10-19 04:58:49 +000018#define AMDFAM10_H
Damien Zammit75a3d1f2016-11-28 00:29:10 +110019
20#include <inttypes.h>
21#include <arch/io.h>
22#include <device/device.h>
23#include "early_ht.h"
24
25#include "inline_helper.c"
26struct DCTStatStruc;
27struct MCTStatStruc;
28
29#define RES_PCI_IO 0x10
30#define RES_PORT_IO_8 0x22
31#define RES_PORT_IO_32 0x20
32#define RES_MEM_IO 0x40
33
34#define NODE_ID 0x60
35#define HT_INIT_CONTROL 0x6c
36#define HTIC_ColdR_Detect (1<<4)
37#define HTIC_BIOSR_Detect (1<<5)
38#define HTIC_INIT_Detect (1<<6)
39
Scott Duplichan1ba2eee2010-10-19 04:58:49 +000040/* Definitions of various FAM10 registers */
41/* Function 0 */
42#define HT_TRANSACTION_CONTROL 0x68
43#define HTTC_DIS_RD_B_P (1 << 0)
44#define HTTC_DIS_RD_DW_P (1 << 1)
45#define HTTC_DIS_WR_B_P (1 << 2)
46#define HTTC_DIS_WR_DW_P (1 << 3)
47#define HTTC_DIS_MTS (1 << 4)
48#define HTTC_CPU1_EN (1 << 5)
49#define HTTC_CPU_REQ_PASS_PW (1 << 6)
50#define HTTC_CPU_RD_RSP_PASS_PW (1 << 7)
51#define HTTC_DIS_P_MEM_C (1 << 8)
52#define HTTC_DIS_RMT_MEM_C (1 << 9)
53#define HTTC_DIS_FILL_P (1 << 10)
54#define HTTC_RSP_PASS_PW (1 << 11)
55#define HTTC_BUF_REL_PRI_SHIFT 13
56#define HTTC_BUF_REL_PRI_MASK 3
57#define HTTC_BUF_REL_PRI_64 0
58#define HTTC_BUF_REL_PRI_16 1
59#define HTTC_BUF_REL_PRI_8 2
60#define HTTC_BUF_REL_PRI_2 3
61#define HTTC_LIMIT_CLDT_CFG (1 << 15)
62#define HTTC_LINT_EN (1 << 16)
63#define HTTC_APIC_EXT_BRD_CST (1 << 17)
64#define HTTC_APIC_EXT_ID (1 << 18)
65#define HTTC_APIC_EXT_SPUR (1 << 19)
66#define HTTC_SEQ_ID_SRC_NODE_EN (1 << 20)
67#define HTTC_DS_NP_REQ_LIMIT_SHIFT 21
68#define HTTC_DS_NP_REQ_LIMIT_MASK 3
69#define HTTC_DS_NP_REQ_LIMIT_NONE 0
70#define HTTC_DS_NP_REQ_LIMIT_1 1
71#define HTTC_DS_NP_REQ_LIMIT_4 2
72#define HTTC_DS_NP_REQ_LIMIT_8 3
73
74
75/* Function 1 */
76#define PCI_IO_BASE0 0xc0
77#define PCI_IO_BASE1 0xc8
78#define PCI_IO_BASE2 0xd0
79#define PCI_IO_BASE3 0xd8
80#define PCI_IO_BASE_VGA_EN (1 << 4)
81#define PCI_IO_BASE_NO_ISA (1 << 5)
82
83/* Function 2 */
84// 0x1xx is for DCT1
85#define DRAM_CSBASE 0x40
86#define DRAM_CSMASK 0x60
87#define DRAM_BANK_ADDR_MAP 0x80
88
89#define DRAM_CTRL 0x78
90#define DC_RdPtrInit_SHIFT 0
91#define DC_RdPrtInit_MASK 0xf
92#define DC_Twrrd3_2_SHIFT 8 /*DDR3 */
93#define DC_Twrrd3_2_MASK 3
94#define DC_Twrwr3_2_SHIFT 10 /*DDR3 */
95#define DC_Twrwr3_2_MASK 3
96#define DC_Trdrd3_2_SHIFT 12 /*DDR3 */
97#define DC_Trdrd3_2_MASK 3
98#define DC_AltVidC3MemClkTriEn (1<<16)
99#define DC_DqsRcvEnTrain (1<<18)
100#define DC_MaxRdLatency_SHIFT 22
101#define DC_MaxRdLatency_MASK 0x3ff
102
103#define DRAM_INIT 0x7c
104#define DI_MrsAddress_SHIFT 0
105#define DI_MrsAddress_MASK 0xffff
106#define DI_MrsBank_SHIFT 16
107#define DI_MrsBank_MASK 7
108#define DI_MrsChipSel_SHIFT 20
109#define DI_MrsChipSel_MASK 7
110#define DI_SendRchgAll (1<<24)
111#define DI_SendAutoRefresh (1<<25)
112#define DI_SendMrsCmd (1<<26)
113#define DI_DeassertMemRstX (1<<27)
114#define DI_AssertCke (1<<28)
115#define DI_SendZQCmd (1<<29) /*DDR3 */
116#define DI_EnMrsCmd (1<<30)
117#define DI_EnDramInit (1<<31)
118
119#define DRAM_MRS 0x84
120#define DM_BurstCtrl_SHIFT 0
121#define DM_BurstCtrl_MASK 3
122#define DM_DrvImpCtrl_SHIFT 2 /* DDR3 */
123#define DM_DrvImpCtrl_MASK 3
124#define DM_Twr_SHIFT 4 /* DDR3 */
125#define DM_Twr_MASK 7
126#define DM_Twr_BASE 4
127#define DM_Twr_MIN 5
128#define DM_Twr_MAX 12
129#define DM_DramTerm_SHIFT 7 /*DDR3 */
130#define DM_DramTerm_MASK 7
131#define DM_DramTermDyn_SHIFT 10 /* DDR3 */
132#define DM_DramTermDyn_MASK 3
133#define DM_Ooff (1<<13)
134#define DM_ASR (1<<18)
135#define DM_SRT (1<<19)
136#define DM_Tcwl_SHIFT 20
137#define DM_Tcwl_MASK 7
138#define DM_PchgPDModeSel (1<<23) /* DDR3 */
139#define DM_MPrLoc_SHIFT 24 /* DDR3 */
140#define DM_MPrLoc_MASK 3
141#define DM_MprEn (1<<26) /* DDR3 */
142
143#define DRAM_TIMING_LOW 0x88
144#define DTL_TCL_SHIFT 0
145#define DTL_TCL_MASK 0xf
146#define DTL_TCL_BASE 1 /* DDR3 =4 */
147#define DTL_TCL_MIN 3 /* DDR3 =4 */
148#define DTL_TCL_MAX 6 /* DDR3 =12 */
149#define DTL_TRCD_SHIFT 4
150#define DTL_TRCD_MASK 3 /* DDR3 =7 */
151#define DTL_TRCD_BASE 3 /* DDR3 =5 */
152#define DTL_TRCD_MIN 3 /* DDR3 =5 */
153#define DTL_TRCD_MAX 6 /* DDR3 =12 */
154#define DTL_TRP_SHIFT 8 /* DDR3 =7 */
155#define DTL_TRP_MASK 3 /* DDR3 =7 */
156#define DTL_TRP_BASE 3 /* DDR3 =5 */
157#define DTL_TRP_MIN 3 /* DDR3 =5 */
158#define DTL_TRP_MAX 6 /* DDR3 =12 */
159#define DTL_TRTP_SHIFT 11 /*DDR3 =10 */
160#define DTL_TRTP_MASK 1 /*DDR3 =3 */
161#define DTL_TRTP_BASE 2 /* DDR3 =4 */
162#define DTL_TRTP_MIN 2 /* 4 for 64 bytes*/ /* DDR3 =4 for 32bytes or 64bytes */
163#define DTL_TRTP_MAX 3 /* 5 for 64 bytes */ /* DDR3 =7 for 32Bytes or 64bytes */
164#define DTL_TRAS_SHIFT 12
165#define DTL_TRAS_MASK 0xf
166#define DTL_TRAS_BASE 3 /* DDR3 =15 */
167#define DTL_TRAS_MIN 5 /* DDR3 =15 */
168#define DTL_TRAS_MAX 18 /*DDR3 =30 */
169#define DTL_TRC_SHIFT 16
170#define DTL_TRC_MASK 0xf /* DDR3 =0x1f */
171#define DTL_TRC_BASE 11
172#define DTL_TRC_MIN 11
173#define DTL_TRC_MAX 26 /* DDR3 =43 */
174#define DTL_TWR_SHIFT 20 /* only for DDR2, DDR3's is on DC */
175#define DTL_TWR_MASK 3
176#define DTL_TWR_BASE 3
177#define DTL_TWR_MIN 3
178#define DTL_TWR_MAX 6
179#define DTL_TRRD_SHIFT 22
180#define DTL_TRRD_MASK 3
181#define DTL_TRRD_BASE 2 /* DDR3 =4 */
182#define DTL_TRRD_MIN 2 /* DDR3 =4 */
183#define DTL_TRRD_MAX 5 /* DDR3 =7 */
184#define DTL_MemClkDis_SHIFT 24 /* Channel A */
185#define DTL_MemClkDis3 (1 << 26)
186#define DTL_MemClkDis2 (1 << 27)
187#define DTL_MemClkDis1 (1 << 28)
188#define DTL_MemClkDis0 (1 << 29)
189/* DTL_MemClkDis for m2 and s1g1 is different */
190
191#define DRAM_TIMING_HIGH 0x8c
192#define DTH_TRWTWB_SHIFT 0
193#define DTH_TRWTWB_MASK 3
194#define DTH_TRWTWB_BASE 3 /* DDR3 =4 */
195#define DTH_TRWTWB_MIN 3 /* DDR3 =5 */
196#define DTH_TRWTWB_MAX 10 /* DDR3 =11 */
197#define DTH_TRWTTO_SHIFT 4
198#define DTH_TRWTTO_MASK 7
199#define DTH_TRWTTO_BASE 2 /* DDR3 =3 */
200#define DTH_TRWTTO_MIN 2 /* DDR3 =3 */
201#define DTH_TRWTTO_MAX 9 /* DDR3 =10 */
202#define DTH_TWTR_SHIFT 8
203#define DTH_TWTR_MASK 3
204#define DTH_TWTR_BASE 0 /* DDR3 =4 */
205#define DTH_TWTR_MIN 1 /* DDR3 =4 */
206#define DTH_TWTR_MAX 3 /* DDR3 =7 */
207#define DTH_TWRRD_SHIFT 10
208#define DTH_TWRRD_MASK 3 /* For DDR3 3_2 is at 0x78 DC */
209#define DTH_TWRRD_BASE 0 /* DDR3 =0 */
210#define DTH_TWRRD_MIN 0 /* DDR3 =2 */
211#define DTH_TWRRD_MAX 3 /* DDR3 =12 */
212#define DTH_TWRWR_SHIFT 12
213#define DTH_TWRWR_MASK 3 /* For DDR3 3_2 is at 0x78 DC */
214#define DTH_TWRWR_BASE 1
215#define DTH_TWRWR_MIN 1 /* DDR3 =3 */
216#define DTH_TWRWR_MAX 3 /* DDR3 =12 */
217#define DTH_TRDRD_SHIFT 14
218#define DTH_TRDRD_MASK 3 /* For DDR3 3_2 is at 0x78 DC */
219#define DTH_TRDRD_BASE 2
220#define DTH_TRDRD_MIN 2
221#define DTH_TRDRD_MAX 5 /* DDR3 =10 */
222#define DTH_TREF_SHIFT 16
223#define DTH_TREF_MASK 3
224#define DTH_TREF_7_8_US 2
225#define DTH_TREF_3_9_US 3
226#define DTH_DisAutoRefresh (1<<18)
227#define DTH_TRFC0_SHIFT 20 /* for Logical DIMM0 */
228#define DTH_TRFC_MASK 7
229#define DTH_TRFC_75_256M 0
230#define DTH_TRFC_105_512M 1
231#define DTH_TRFC_127_5_1G 2
232#define DTH_TRFC_195_2G 3
233#define DTH_TRFC_327_5_4G 4
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000234#define DTH_TRFC1_SHIFT 23 /*for Logical DIMM1 */
235#define DTH_TRFC2_SHIFT 26 /*for Logical DIMM2 */
236#define DTH_TRFC3_SHIFT 29 /*for Logical DIMM3 */
237
238#define DRAM_CONFIG_LOW 0x90
239#define DCL_InitDram (1<<0)
240#define DCL_ExitSelfRef (1<<1)
241#define DCL_PllLockTime_SHIFT 2
242#define DCL_PllLockTime_MASK 3
243#define DCL_PllLockTime_15US 0
244#define DCL_PllLockTime_6US 1
245#define DCL_DramTerm_SHIFT 4
246#define DCL_DramTerm_MASK 3
247#define DCL_DramTerm_No 0
248#define DCL_DramTerm_75_OH 1
249#define DCL_DramTerm_150_OH 2
250#define DCL_DramTerm_50_OH 3
251#define DCL_DisDqsBar (1<<6) /* only for DDR2 */
252#define DCL_DramDrvWeak (1<<7) /* only for DDR2 */
253#define DCL_ParEn (1<<8)
254#define DCL_SelfRefRateEn (1<<9) /* only for DDR2 */
255#define DCL_BurstLength32 (1<<10) /* only for DDR3 */
256#define DCL_Width128 (1<<11)
257#define DCL_X4Dimm_SHIFT 12
258#define DCL_X4Dimm_MASK 0xf
259#define DCL_UnBuffDimm (1<<16)
260#define DCL_EnPhyDqsRcvEnTr (1<<18)
261#define DCL_DimmEccEn (1<<19)
262#define DCL_DynPageCloseEn (1<<20)
263#define DCL_IdleCycInit_SHIFT 21
264#define DCL_IdleCycInit_MASK 3
265#define DCL_IdleCycInit_16CLK 0
266#define DCL_IdleCycInit_32CLK 1
267#define DCL_IdleCycInit_64CLK 2
268#define DCL_IdleCycInit_96CLK 3
269#define DCL_ForceAutoPchg (1<<23)
270
271#define DRAM_CONFIG_HIGH 0x94
272#define DCH_MemClkFreq_SHIFT 0
273#define DCH_MemClkFreq_MASK 7
274#define DCH_MemClkFreq_200MHz 0 /* DDR2 */
275#define DCH_MemClkFreq_266MHz 1 /* DDR2 */
276#define DCH_MemClkFreq_333MHz 2 /* DDR2 */
277#define DCH_MemClkFreq_400MHz 3 /* DDR2 and DDR 3*/
278#define DCH_MemClkFreq_533MHz 4 /* DDR 3 */
279#define DCH_MemClkFreq_667MHz 5 /* DDR 3 */
280#define DCH_MemClkFreq_800MHz 6 /* DDR 3 */
281#define DCH_MemClkFreqVal (1<<3)
282#define DCH_Ddr3Mode (1<<8)
283#define DCH_LegacyBiosMode (1<<9)
284#define DCH_ZqcsInterval_SHIFT 10
285#define DCH_ZqcsInterval_MASK 3
286#define DCH_ZqcsInterval_DIS 0
287#define DCH_ZqcsInterval_64MS 1
288#define DCH_ZqcsInterval_128MS 2
289#define DCH_ZqcsInterval_256MS 3
290#define DCH_RDqsEn (1<<12) /* only for DDR2 */
291#define DCH_DisSimulRdWr (1<<13)
292#define DCH_DisDramInterface (1<<14)
293#define DCH_PowerDownEn (1<<15)
294#define DCH_PowerDownMode_SHIFT 16
295#define DCH_PowerDownMode_MASK 1
296#define DCH_PowerDownMode_Channel_CKE 0
297#define DCH_PowerDownMode_ChipSelect_CKE 1
298#define DCH_FourRankSODimm (1<<17)
299#define DCH_FourRankRDimm (1<<18)
300#define DCH_SlowAccessMode (1<<20)
301#define DCH_BankSwizzleMode (1<<22)
302#define DCH_DcqBypassMax_SHIFT 24
303#define DCH_DcqBypassMax_MASK 0xf
304#define DCH_DcqBypassMax_BASE 0
305#define DCH_DcqBypassMax_MIN 0
306#define DCH_DcqBypassMax_MAX 15
307#define DCH_FourActWindow_SHIFT 28
308#define DCH_FourActWindow_MASK 0xf
309#define DCH_FourActWindow_BASE 7 /* DDR3 15 */
310#define DCH_FourActWindow_MIN 8 /* DDR3 16 */
311#define DCH_FourActWindow_MAX 20 /* DDR3 30 */
312
313
314// for 0x98 index and 0x9c data for DCT0
315// for 0x198 index and 0x19c data for DCT1
316// even at ganged mode, 0x198/0x19c will be used for channnel B
317
318#define DRAM_CTRL_ADDI_DATA_OFFSET 0x98
319#define DCAO_DctOffset_SHIFT 0
320#define DCAO_DctOffset_MASK 0x3fffffff
321#define DCAO_DctAccessWrite (1<<30)
322#define DCAO_DctAccessDone (1<<31)
323
324#define DRAM_CTRL_ADDI_DATA_PORT 0x9c
325
326#define DRAM_OUTPUT_DRV_COMP_CTRL 0x00
327#define DODCC_CkeDrvStren_SHIFT 0
328#define DODCC_CkeDrvStren_MASK 3
329#define DODCC_CkeDrvStren_1_0X 0
330#define DODCC_CkeDrvStren_1_25X 1
331#define DODCC_CkeDrvStren_1_5X 2
332#define DODCC_CkeDrvStren_2_0X 3
333#define DODCC_CsOdtDrvStren_SHIFT 4
334#define DODCC_CsOdtDrvStren_MASK 3
335#define DODCC_CsOdtDrvStren_1_0X 0
336#define DODCC_CsOdtDrvStren_1_25X 1
337#define DODCC_CsOdtDrvStren_1_5X 2
338#define DODCC_CsOdtDrvStren_2_0X 3
339#define DODCC_AddrCmdDrvStren_SHIFT 8
340#define DODCC_AddrCmdDrvStren_MASK 3
341#define DODCC_AddrCmdDrvStren_1_0X 0
342#define DODCC_AddrCmdDrvStren_1_25X 1
343#define DODCC_AddrCmdDrvStren_1_5X 2
344#define DODCC_AddrCmdDrvStren_2_0X 3
345#define DODCC_ClkDrvStren_SHIFT 12
346#define DODCC_ClkDrvStren_MASK 3
347#define DODCC_ClkDrvStren_0_75X 0
348#define DODCC_ClkDrvStren_1_0X 1
349#define DODCC_ClkDrvStren_1_25X 2
350#define DODCC_ClkDrvStren_1_5X 3
351#define DODCC_DataDrvStren_SHIFT 16
352#define DODCC_DataDrvStren_MASK 3
353#define DODCC_DataDrvStren_0_75X 0
354#define DODCC_DataDrvStren_1_0X 1
355#define DODCC_DataDrvStren_1_25X 2
356#define DODCC_DataDrvStren_1_5X 3
357#define DODCC_DqsDrvStren_SHIFT 20
358#define DODCC_DqsDrvStren_MASK 3
359#define DODCC_DqsDrvStren_0_75X 0
360#define DODCC_DqsDrvStren_1_0X 1
361#define DODCC_DqsDrvStren_1_25X 2
362#define DODCC_DqsDrvStren_1_5X 3
363#define DODCC_ProcOdt_SHIFT 28
364#define DODCC_ProcOdt_MASK 3
365#define DODCC_ProcOdt_300_OHMS 0
366#define DODCC_ProcOdt_150_OHMS 1
367#define DODCC_ProcOdt_75_OHMS 2
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000368
369/*
370 for DDR2 400, 533, 667, F2x[1,0]9C_x[02:01], [03], [06:05], [07] controll timing of all DIMMs
371 for DDR2 800, DDR3 800, 1067, 1333, 1600, F2x[1,0]9C_x[02:01], [03], [06:05], [07] controll timing of DIMM0
372 F2x[1,0]9C_x[102:101], [103], [106:105], [107] controll timing of DIMM1
373 So Socket F with Four Logical DIMM will only support DDR2 800 ?
374*/
375/* there are index +100 ===> for DIMM1
376that are corresponding to 0x01, 0x02, 0x03, 0x05, 0x06, 0x07
377*/
378//02/15/2006 18:37
379#define DRAM_WRITE_DATA_TIMING_CTRL_LOW 0x01
380#define DWDTC_WrDatFineDlyByte0_SHIFT 0
381#define DWDTC_WrDatFineDlyByte_MASK 0x1f
382#define DWDTC_WrDatFineDlyByte_BASE 0
383#define DWDTC_WrDatFineDlyByte_MIN 0
384#define DWDTC_WrDatFineDlyByte_MAX 31 // 1/64 MEMCLK
385#define DWDTC_WrDatGrossDlyByte0_SHIFT 5
386#define DWDTC_WrDatGrossDlyByte_MASK 0x3
387#define DWDTC_WrDatGrossDlyByte_NO_DELAY 0
388#define DWDTC_WrDatGrossDlyByte_0_5_ 1
389#define DWDTC_WrDatGrossDlyByte_1 2
390#define DWDTC_WrDatFineDlyByte1_SHIFT 8
391#define DWDTC_WrDatGrossDlyByte1_SHIFT 13
392#define DWDTC_WrDatFineDlyByte2_SHIFT 16
393#define DWDTC_WrDatGrossDlyByte2_SHIFT 21
394#define DWDTC_WrDatFineDlyByte3_SHIFT 24
395#define DWDTC_WrDatGrossDlyByte3_SHIFT 29
396
397#define DRAM_WRITE_DATA_TIMING_CTRL_HIGH 0x02
398#define DWDTC_WrDatFineDlyByte4_SHIFT 0
399#define DWDTC_WrDatGrossDlyByte4_SHIFT 5
400#define DWDTC_WrDatFineDlyByte5_SHIFT 8
401#define DWDTC_WrDatGrossDlyByte5_SHIFT 13
402#define DWDTC_WrDatFineDlyByte6_SHIFT 16
403#define DWDTC_WrDatGrossDlyByte6_SHIFT 21
404#define DWDTC_WrDatFineDlyByte7_SHIFT 24
405#define DWDTC_WrDatGrossDlyByte7_SHIFT 29
406
407#define DRAM_WRITE_ECC_TIMING_CTRL 0x03
408#define DWETC_WrChkFinDly_SHIFT 0
409#define DWETC_WrChkGrossDly_SHIFT 5
410
411#define DRAM_ADDR_CMD_TIMING_CTRL 0x04
412#define DACTC_CkeFineDelay_SHIFT 0
413#define DACTC_CkeFineDelay_MASK 0x1f
414#define DACTC_CkeFineDelay_BASE 0
415#define DACTC_CkeFineDelay_MIN 0
416#define DACTC_CkeFineDelay_MAX 31
417#define DACTC_CkeSetup (1<<5)
418#define DACTC_CsOdtFineDelay_SHIFT 8
419#define DACTC_CsOdtFineDelay_MASK 0x1f
420#define DACTC_CsOdtFineDelay_BASE 0
421#define DACTC_CsOdtFineDelay_MIN 0
422#define DACTC_CsOdtFineDelay_MAX 31
423#define DACTC_CsOdtSetup (1<<13)
424#define DACTC_AddrCmdFineDelay_SHIFT 16
425#define DACTC_AddrCmdFineDelay_MASK 0x1f
426#define DACTC_AddrCmdFineDelay_BASE 0
427#define DACTC_AddrCmdFineDelay_MIN 0
428#define DACTC_AddrCmdFineDelay_MAX 31
429#define DACTC_AddrCmdSetup (1<<21)
430
431#define DRAM_READ_DQS_TIMING_CTRL_LOW 0x05
432#define DRDTC_RdDqsTimeByte0_SHIFT 0
433#define DRDTC_RdDqsTimeByte_MASK 0x3f
434#define DRDTC_RdDqsTimeByte_BASE 0
435#define DRDTC_RdDqsTimeByte_MIN 0
436#define DRDTC_RdDqsTimeByte_MAX 63 // 1/128 MEMCLK
437#define DRDTC_RdDqsTimeByte1_SHIFT 8
438#define DRDTC_RdDqsTimeByte2_SHIFT 16
439#define DRDTC_RdDqsTimeByte3_SHIFT 24
440
441#define DRAM_READ_DQS_TIMING_CTRL_HIGH 0x06
442#define DRDTC_RdDqsTimeByte4_SHIFT 0
443#define DRDTC_RdDqsTimeByte5_SHIFT 8
444#define DRDTC_RdDqsTimeByte6_SHIFT 16
445#define DRDTC_RdDqsTimeByte7_SHIFT 24
446
447#define DRAM_READ_DQS_ECC_TIMING_CTRL 0x07
448#define DRDETC_RdDqsTimeCheck_SHIFT 0
449
450#define DRAM_PHY_CTRL 0x08
451#define DPC_WrtLvTrEn (1<<0)
452#define DPC_WrtLvTrMode (1<<1)
453#define DPC_TrNibbleSel (1<<2)
454#define DPC_TrDimmSel_SHIFT 4
455#define DPC_TrDimmSel_MASK 3 /* 0-->dimm0, 1-->dimm1, 2--->dimm2, 3--->dimm3 */
456#define DPC_WrLvOdt_SHIFT 8
457#define DPC_WrLvOdt_MASK 0xf /* bit 0-->odt 0, ...*/
458#define DPC_WrLvODtEn (1<<12)
459#define DPC_DqsRcvTrEn (1<<13)
460#define DPC_DisAutoComp (1<<30)
461#define DPC_AsyncCompUpdate (1<<31)
462
463#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_0_0 0x10 //DIMM0 Channel A
464#define DDRETC_DqsRcvEnFineDelayByte0_SHIFT 0
465#define DDRETC_DqsRcvEnFineDelayByte0_MASK 0x1f
466#define DDRETC_DqsRcvEnGrossDelayByte0_SHIFT 5
467#define DDRETC_DqsRcvEnGrossDelayByte0_MASK 0x3
468#define DDRETC_DqsRcvEnFineDelayByte1_SHIFT 8
469#define DDRETC_DqsRcvEnGrossDelayByte1_SHIFT 13
470#define DDRETC_DqsRcvEnFineDelayByte2_SHIFT 16
471#define DDRETC_DqsRcvEnGrossDelayByte2_SHIFT 21
472#define DDRETC_DqsRcvEnFineDelayByte3_SHIFT 24
473#define DDRETC_DqsRcvEnGrossDelayByte3_SHIFT 29
474
475#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_0_1 0x11 //DIMM0 Channel A
476#define DDRETC_DqsRcvEnFineDelayByte4_SHIFT 0
477#define DDRETC_DqsRcvEnGrossDelayByte4_SHIFT 5
478#define DDRETC_DqsRcvEnFineDelayByte5_SHIFT 8
479#define DDRETC_DqsRcvEnGrossDelayByte5_SHIFT 13
480#define DDRETC_DqsRcvEnFineDelayByte6_SHIFT 16
481#define DDRETC_DqsRcvEnGrossDelayByte6_SHIFT 21
482#define DDRETC_DqsRcvEnFineDelayByte7_SHIFT 24
483#define DDRETC_DqsRcvEnGrossDelayByte7_SHIFT 29
484
485#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_0_0 0x12
486#define DDRETCE_WrChkFineDlyByte0_SHIFT 0
487#define DDRETCE_WrChkGrossDlyByte0_SHIFT 5
488
489#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_0_2 0x20 //DIMM0 channel B
490#define DDRETC_DqsRcvEnFineDelayByte8_SHIFT 0
491#define DDRETC_DqsRcvEnGrossDelayByte8_SHIFT 5
492#define DDRETC_DqsRcvEnFineDelayByte9_SHIFT 8
493#define DDRETC_DqsRcvEnGrossDelayByte9_SHIFT 13
494#define DDRETC_DqsRcvEnFineDelayByte10_SHIFT 16
495#define DDRETC_DqsRcvEnGrossDelayByte10_SHIFT 21
496#define DDRETC_DqsRcvEnFineDelayByte11_SHIFT 24
497#define DDRETC_DqsRcvEnGrossDelayByte11_SHIFT 29
498
499#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_0_3 0x21 // DIMM0 Channel B
500#define DDRETC_DqsRcvEnFineDelayByte12_SHIFT 0
501#define DDRETC_DqsRcvEnGrossDelayByte12_SHIFT 5
502#define DDRETC_DqsRcvEnFineDelayByte13_SHIFT 8
503#define DDRETC_DqsRcvEnGrossDelayByte13_SHIFT 13
504#define DDRETC_DqsRcvEnFineDelayByte14_SHIFT 16
505#define DDRETC_DqsRcvEnGrossDelayByte14_SHIFT 21
506#define DDRETC_DqsRcvEnFineDelayByte15_SHIFT 24
507#define DDRETC_DqsRcvEnGrossDelayByte15_SHIFT 29
508
509#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_0_1 0x22
510#define DDRETCE_WrChkFineDlyByte1_SHIFT 0
511#define DDRETCE_WrChkGrossDlyByte1_SHIFT 5
512
513#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_1_0 0x13 //DIMM1
514#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_1_1 0x14
515#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_1_0 0x15
516#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_1_2 0x23
517#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_1_3 0x24
518#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_1_1 0x25
519
520#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_2_0 0x16 // DIMM2
521#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_2_1 0x17
522#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_2_0 0x18
523#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_2_2 0x26
524#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_2_3 0x27
525#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_2_1 0x28
526
527#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_3_0 0x19 // DIMM3
528#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_3_1 0x1a
529#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_3_0 0x1b
530#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_3_2 0x29
531#define DRAM_DQS_RECV_ENABLE_TIME_CTRL_3_3 0x2a
532#define DRAM_DQS_RECV_ENABLE_TIMING_CTRL_ECC_3_1 0x2b
533
534/* 04.06.2006 19:12 */
535
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000536#define DRAM_PHASE_RECOVERY_CTRL_0 0x50
537#define DPRC_PhRecFineDlyByte0_SHIFT 0
538#define DDWTC_PhRecFineDlyByte0_MASK 0x1f
539#define DDWTC_PhRecGrossDlyByte0_SHIFT 5
540#define DDWTC_PhRecGrossDlyByte0_MASK 0x3
541#define DDWTC_PhRecFineDlyByte1_SHIFT 8
542#define DDWTC_PhRecGrossDlyByte1_SHIFT 13
543#define DDWTC_PhRecFineDlyByte2_SHIFT 16
544#define DDWTC_PhRecGrossDlyByte2_SHIFT 21
545#define DDWTC_PhRecFineDlyByte3_SHIFT 24
546#define DDWTC_PhRecGrossDlyByte3_SHIFT 29
547
548#define DRAM_PHASE_RECOVERY_CTRL_1 0x51
549#define DPRC_PhRecFineDlyByte4_SHIFT 0
550#define DDWTC_PhRecGrossDlyByte4_SHIFT 5
551#define DDWTC_PhRecFineDlyByte5_SHIFT 8
552#define DDWTC_PhRecGrossDlyByte5_SHIFT 13
553#define DDWTC_PhRecFineDlyByte6_SHIFT 16
554#define DDWTC_PhRecGrossDlyByte6_SHIFT 21
555#define DDWTC_PhRecFineDlyByte7_SHIFT 24
556#define DDWTC_PhRecGrossDlyByte7_SHIFT 29
557
558#define DRAM_ECC_PHASE_RECOVERY_CTRL 0x52
559#define DEPRC_PhRecEccDlyByte0_SHIFT 0
560#define DEPRC_PhRecEccGrossDlyByte0_SHIFT 5
561
562#define DRAM_WRITE_LEVEL_ERROR 0x53 /* read only */
563#define DWLE_WrLvErr_SHIFT 0
564#define DWLE_WrLvErr_MASK 0xff
565
566#define DRAM_CTRL_MISC 0xa0
567#define DCM_MemCleared (1<<0) /* RD == F2x110 [MemCleared] */
568#define DCM_DramEnabled (1<<9) /* RD == F2x110 [DramEnabled] */
569
570#define NB_TIME_STAMP_COUNT_LOW 0xb0
571#define TscLow_SHIFT 0
572#define TscLow_MASK 0xffffffff
573
574#define NB_TIME_STAMP_COUNT_HIGH 0xb4
575#define TscHigh_SHIFT 0
576#define TscHigh_Mask 0xff
577
578#define DCT_DEBUG_CTRL 0xf0 /* 0xf0 for DCT0, 0x1f0 is for DCT1*/
579#define DDC_DllAdjust_SHIFT 0
580#define DDC_DllAdjust_MASK 0xff
581#define DDC_DllSlower (1<<8)
582#define DDC_DllFaster (1<<9)
583#define DDC_WrtDqsAdjust_SHIFT 16
584#define DDC_WrtDqsAdjust_MASK 0x7
585#define DDC_WrtDqsAdjustEn (1<<19)
586
587#define DRAM_CTRL_SEL_LOW 0x110
588#define DCSL_DctSelHiRngEn (1<<0)
589#define DCSL_DctSelHi (1<<1)
590#define DCSL_DctSelIntLvEn (1<<2)
591#define DCSL_MemClrInit (1<<3) /* WR only */
592#define DCSL_DctGangEn (1<<4)
593#define DCSL_DctDataIntLv (1<<5)
594#define DCSL_DctSelIntLvAddr_SHIFT
595#define DCSL_DctSelIntLvAddr_MASK 3
596#define DCSL_DramEnable (1<<8) /* RD only */
597#define DCSL_MemClrBusy (1<<9) /* RD only */
598#define DCSL_MemCleared (1<<10) /* RD only */
599#define DCSL_DctSelBaseAddr_47_27_SHIFT 11
600#define DCSL_DctSelBaseAddr_47_27_MASK 0x1fffff
601
602#define DRAM_CTRL_SEL_HIGH 0x114
603#define DCSH_DctSelBaseOffset_47_26_SHIFT 10
604#define DCSH_DctSelBaseOffset_47_26_MASK 0x3fffff
605
606#define MEM_CTRL_CONF_LOW 0x118
607#define MCCL_MctPriCpuRd (1<<0)
608#define MCCL_MctPriCpuWr (1<<1)
609#define MCCL_MctPriIsocRd_SHIFT 4
610#define MCCL_MctPriIsoc_MASK 0x3
611#define MCCL_MctPriIsocWr_SHIFT 6
612#define MCCL_MctPriIsocWe_MASK 0x3
613#define MCCL_MctPriDefault_SHIFT 8
614#define MCCL_MctPriDefault_MASK 0x3
615#define MCCL_MctPriWr_SHIFT 10
616#define MCCL_MctPriWr_MASK 0x3
617#define MCCL_MctPriIsoc_SHIFT 12
618#define MCCL_MctPriIsoc_MASK 0x3
619#define MCCL_MctPriTrace_SHIFT 14
620#define MCCL_MctPriTrace_MASK 0x3
621#define MCCL_MctPriScrub_SHIFT 16
622#define MCCL_MctPriScrub_MASK 0x3
623#define MCCL_McqMedPriByPassMax_SHIFT 20
624#define MCCL_McqMedPriByPassMax_MASK 0x7
625#define MCCL_McqHiPriByPassMax_SHIFT 24
626#define MCCL_McqHiPriByPassMax_MASK 0x7
627#define MCCL_MctVarPriCntLmt_SHIFT 28
628#define MCCL_MctVarPriCntLmt_MASK 0x7
629
630#define MEM_CTRL_CONF_HIGH 0x11c
631#define MCCH_DctWrLimit_SHIFT 0
632#define MCCH_DctWrLimit_MASK 0x3
633#define MCCH_MctWrLimit_SHIFT 2
634#define MCCH_MctWrLimit_MASK 0x1f
635#define MCCH_MctPrefReqLimit_SHIFT 7
636#define MCCH_MctPrefReqLimit_MASK 0x1f
637#define MCCH_PrefCpuDis (1<<12)
638#define MCCH_PrefIoDis (1<<13)
639#define MCCH_PrefIoFixStrideEn (1<<14)
640#define MCCH_PrefFixStrideEn (1<<15)
641#define MCCH_PrefFixDist_SHIFT 16
642#define MCCH_PrefFixDist_MASK 0x3
643#define MCCH_PrefConfSat_SHIFT 18
644#define MCCH_PrefConfSat_MASK 0x3
645#define MCCH_PrefOneConf_SHIFT 20
646#define MCCH_PrefOneConf_MASK 0x3
647#define MCCH_PrefTwoConf_SHIFT 22
648#define MCCH_PrefTwoConf_MASK 0x7
649#define MCCH_PrefThreeConf_SHIFT 25
650#define MCCH_prefThreeConf_MASK 0x7
651#define MCCH_PrefDramTrainMode (1<<28)
652#define MCCH_FlushWrOnStpGnt (1<<29)
653#define MCCH_FlushWr (1<<30)
654#define MCCH_MctScrubEn (1<<31)
655
656
657/* Function 3 */
658#define MCA_NB_CONTROL 0x40
659#define MNCT_CorrEccEn (1<<0)
660#define MNCT_UnCorrEccEn (1<<1)
661#define MNCT_CrcErr0En (1<<2) /* Link 0 */
662#define MNCT_CrcErr1En (1<<3)
663#define MNCT_CrcErr2En (1<<4)
664#define MBCT_SyncPkt0En (1<<5) /* Link 0 */
665#define MBCT_SyncPkt1En (1<<6)
666#define MBCT_SyncPkt2En (1<<7)
667#define MBCT_MstrAbrtEn (1<<8)
668#define MBCT_TgtAbrtEn (1<<9)
669#define MBCT_GartTblEkEn (1<<10)
670#define MBCT_AtomicRMWEn (1<<11)
671#define MBCT_WdogTmrRptEn (1<<12)
672#define MBCT_DevErrEn (1<<13)
673#define MBCT_L3ArrayCorEn (1<<14)
674#define MBCT_L3ArrayUncEn (1<<15)
675#define MBCT_HtProtEn (1<<16)
676#define MBCT_HtDataEn (1<<17)
677#define MBCT_DramParEn (1<<18)
678#define MBCT_RtryHt0En (1<<19) /* Link 0 */
679#define MBCT_RtryHt1En (1<<20)
680#define MBCT_RtryHt2En (1<<21)
681#define MBCT_RtryHt3En (1<<22)
682#define MBCT_CrcErr3En (1<<23) /* Link 3*/
683#define MBCT_SyncPkt3En (1<<24) /* Link 4 */
684#define MBCT_McaUsPwDatErrEn (1<<25)
685#define MBCT_NbArrayParEn (1<<26)
686#define MBCT_TblWlkDatErrEn (1<<27)
687#define MBCT_FbDimmCorErrEn (1<<28)
688#define MBCT_FbDimmUnCorErrEn (1<<29)
689
690
691
692#define MCA_NB_CONFIG 0x44
693#define MNC_CpuRdDatErrEn (1<<1)
694#define MNC_SyncOnUcEccEn (1<<2)
695#define MNC_SynvPktGenDis (1<<3)
696#define MNC_SyncPktPropDis (1<<4)
697#define MNC_IoMstAbortDis (1<<5)
698#define MNC_CpuErrDis (1<<6)
699#define MNC_IoErrDis (1<<7)
700#define MNC_WdogTmrDis (1<<8)
701#define MNC_WdogTmrCntSel_2_0_SHIFT 9 /* 3 is ar f3x180 */
702#define MNC_WdogTmrCntSel_2_0_MASK 0x3
703#define MNC_WdogTmrBaseSel_SHIFT 12
704#define MNC_WdogTmrBaseSel_MASK 0x3
705#define MNC_LdtLinkSel_SHIFT 14
706#define MNC_LdtLinkSel_MASK 0x3
707#define MNC_GenCrcErrByte0 (1<<16)
708#define MNC_GenCrcErrByte1 (1<<17)
709#define MNC_SubLinkSel_SHIFT 18
710#define MNC_SubLinkSel_MASK 0x3
711#define MNC_SyncOnWdogEn (1<<20)
712#define MNC_SyncOnAnyErrEn (1<<21)
713#define MNC_DramEccEn (1<<22)
714#define MNC_ChipKillEccEn (1<<23)
715#define MNC_IoRdDatErrEn (1<<24)
716#define MNC_DisPciCfgCpuErrRsp (1<<25)
717#define MNC_CorrMcaExcEn (1<<26)
718#define MNC_NbMcaToMstCpuEn (1<<27)
719#define MNC_DisTgtAbtCpuErrRsp (1<<28)
720#define MNC_DisMstAbtCpuErrRsp (1<<29)
721#define MNC_SyncOnDramAdrParErrEn (1<<30)
722#define MNC_NbMcaLogEn (1<<31)
723
724#define MCA_NB_STATUS_LOW 0x48
725#define MNSL_ErrorCode_SHIFT 0
726#define MNSL_ErrorCode_MASK 0xffff
727#define MNSL_ErrorCodeExt_SHIFT 16
728#define MNSL_ErrorCodeExt_MASK 0x1f
729#define MNSL_Syndrome_15_8_SHIFT 24
730#define MNSL_Syndrome_15_8_MASK 0xff
731
732#define MCA_NB_STATUS_HIGH 0x4c
733#define MNSH_ErrCPU_SHIFT 0
734#define MNSH_ErrCPU_MASK 0xf
735#define MNSH_LDTLink_SHIFT 4
736#define MNSH_LDTLink_MASK 0xf
737#define MNSH_ErrScrub (1<<8)
738#define MNSH_SubLink (1<<9)
739#define MNSH_McaStatusSubCache_SHIFT 10
740#define MNSH_McaStatusSubCache_MASK 0x3
741#define MNSH_Deffered (1<<12)
742#define MNSH_UnCorrECC (1<<13)
743#define MNSH_CorrECC (1<<14)
744#define MNSH_Syndrome_7_0_SHIFT 15
745#define MNSH_Syndrome_7_0_MASK 0xff
746#define MNSH_PCC (1<<25)
747#define MNSH_ErrAddrVal (1<<26)
748#define MNSH_ErrMiscVal (1<<27)
749#define MNSH_ErrEn (1<<28)
750#define MNSH_ErrUnCorr (1<<29)
751#define MNSH_ErrOver (1<<30)
752#define MNSH_ErrValid (1<<31)
753
754#define MCA_NB_ADDR_LOW 0x50
755#define MNAL_ErrAddr_31_1_SHIFT 1
756#define MNAL_ErrAddr_31_1_MASK 0x7fffffff
757
758#define MCA_NB_ADDR_HIGH 0x54
759#define MNAL_ErrAddr_47_32_SHIFT 0
760#define MNAL_ErrAddr_47_32_MASK 0xffff
761
762#define DRAM_SCRUB_RATE_CTRL 0x58
763#define SCRUB_NONE 0
764#define SCRUB_40ns 1
765#define SCRUB_80ns 2
766#define SCRUB_160ns 3
767#define SCRUB_320ns 4
768#define SCRUB_640ns 5
769#define SCRUB_1_28us 6
770#define SCRUB_2_56us 7
771#define SCRUB_5_12us 8
772#define SCRUB_10_2us 9
773#define SCRUB_20_5us 0xa
774#define SCRUB_41_0us 0xb
775#define SCRUB_81_9us 0xc
776#define SCRUB_163_8us 0xd
777#define SCRUB_327_7us 0xe
778#define SCRUB_655_4us 0xf
779#define SCRUB_1_31ms 0x10
780#define SCRUB_2_62ms 0x11
781#define SCRUB_5_24ms 0x12
782#define SCRUB_10_49ms 0x13
783#define SCRUB_20_97ms 0x14
784#define SCRUB_42ms 0x15
785#define SCRUB_84ms 0x16
786#define DSRC_DramScrub_SHFIT 0
787#define DSRC_DramScrub_MASK 0x1f
788#define DSRC_L2Scrub_SHIFT 8
789#define DSRC_L2Scrub_MASK 0x1f
790#define DSRC_DcacheScrub_SHIFT 16
791#define DSRC_DcacheScrub_MASK 0x1f
792#define DSRC_L3Scrub_SHIFT 24
793#define DSRC_L3Scrub_MASK 0x1f
794
795#define DRAM_SCRUB_ADDR_LOW 0x5C
796#define DSAL_ScrubReDirEn (1<<0)
797#define DSAL_ScrubAddrLo_SHIFT 6
798#define DSAL_ScrubAddrLo_MASK 0x3ffffff
799
800#define DRAM_SCRUB_ADDR_HIGH 0x60
801#define DSAH_ScrubAddrHi_SHIFT 0
802#define DSAH_ScrubAddrHi_MASK 0xffff
803
804#define HW_THERMAL_CTRL 0x64
805
806#define SW_THERMAL_CTRL 0x68
807
808#define DATA_BUF_CNT 0x6c
809
810#define SRI_XBAR_CMD_BUF_CNT 0x70
811
812#define XBAR_SRI_CMD_BUF_CNT 0x74
813
814#define MCT_XBAR_CMD_BUF_CNT 0x78
815
816#define ACPI_PWR_STATE_CTRL 0x80 /* till 0x84 */
817
818#define NB_CONFIG_LOW 0x88
819#define NB_CONFIG_HIGH 0x8c
820
821#define GART_APERTURE_CTRL 0x90
822
823#define GART_APERTURE_BASE 0x94
824
825#define GART_TBL_BASE 0x98
826
827#define GART_CACHE_CTRL 0x9c
828
829#define PWR_CTRL_MISC 0xa0
830
831#define RPT_TEMP_CTRL 0xa4
832
833#define ON_LINE_SPARE_CTRL 0xb0
834
835#define SBI_P_STATE_LIMIT 0xc4
836
837#define CLK_PWR_TIMING_CTRL0 0xd4
838#define CLK_PWR_TIMING_CTRL1 0xd8
839#define CLK_PWR_TIMING_CTRL2 0xdc
840
841#define THERMTRIP_STATUS 0xE4
842
843
844#define NORTHBRIDGE_CAP 0xE8
845#define NBCAP_TwoChanDRAMcap (1 << 0)
846#define NBCAP_DualNodeMPcap (1 << 1)
847#define NBCAP_EightNodeMPcap (1 << 2)
848#define NBCAP_ECCcap (1 << 3)
849#define NBCAP_ChipkillECCcap (1 << 4)
850#define NBCAP_DdrMaxRate_SHIFT 5
851#define NBCAP_DdrMaxRate_MASK 7
852#define NBCAP_DdrMaxRate_400 7
853#define NBCAP_DdrMaxRate_533 6
854#define NBCAP_DdrMaxRate_667 5
855#define NBCAP_DdrMaxRate_800 4
856#define NBCAP_DdrMaxRate_1067 3
857#define NBCAP_DdrMaxRate_1333 2
858#define NBCAP_DdrMaxRate_1600 1
859#define NBCAP_DdrMaxRate_3_2G 6
860#define NBCAP_DdrMaxRate_4_0G 5
861#define NBCAP_DdrMaxRate_4_8G 4
862#define NBCAP_DdrMaxRate_6_4G 3
863#define NBCAP_DdrMaxRate_8_0G 2
864#define NBCAP_DdrMaxRate_9_6G 1
865#define NBCAP_Mem_ctrl_cap (1 << 8)
866#define MBCAP_SVMCap (1<<9)
867#define NBCAP_HtcCap (1<<10)
868#define NBCAP_CmpCap_SHIFT 12
869#define NBCAP_CmpCap_MASK 3
870#define NBCAP_MpCap_SHIFT 16
871#define NBCAP_MpCap_MASK 7
872#define NBCAP_MpCap_1N 7
873#define NBCAP_MpCap_2N 6
874#define NBCAP_MpCap_4N 5
875#define NBCAP_MpCap_8N 4
876#define NBCAP_MpCap_32N 0
877#define NBCAP_UnGangEn_SHIFT 20
878#define NBCAP_UnGangEn_MASK 0xf
879#define NBCAP_L3Cap (1<<25)
880#define NBCAP_HtAcCap (1<<26)
881
882/* 04/04/2006 18:00 */
883
884#define EXT_NB_MCA_CTRL 0x180
885
886#define NB_EXT_CONF 0x188
887#define DOWNCORE_CTRL 0x190
888#define DWNCC_DisCore_SHIFT 0
889#define DWNCC_DisCore_MASK 0xf
890
891/* Function 5 for FBDIMM */
892#define FBD_DRAM_TIMING_LOW
893
894#define LinkConnected (1 << 0)
895#define InitComplete (1 << 1)
896#define NonCoherent (1 << 2)
897#define ConnectionPending (1 << 4)
898
899// Use the LAPIC timer count register to hold each core's init status
900// Format: byte 0 - state
901// byte 1 - fid_max
902// byte 2 - nb_cof_vid_update
903// byte 3 - apic id
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700904
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000905#define LAPIC_MSG_REG 0x380
906#define F10_APSTATE_STARTED 0x13 // start of AP execution
Timothy Pearson730a0432015-10-16 13:51:51 -0500907#define F10_APSTATE_ASLEEP 0x14 // AP sleeping
908#define F10_APSTATE_STOPPED 0x15 // allow AP to stop
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000909#define F10_APSTATE_RESET 0x01 // waiting for warm reset
910
Timothy Pearson730a0432015-10-16 13:51:51 -0500911#define MAX_CORES_SUPPORTED 128
912
stepan8301d832010-12-08 07:07:33 +0000913#include "nums.h"
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000914
915#ifdef __PRE_RAM__
Elyes HAOUAS04f8fd92016-09-19 10:24:34 -0600916#if NODE_NUMS == 64
917 #define NODE_PCI(x, fn) ((x < 32)?(PCI_DEV(CONFIG_CBB,(CONFIG_CDB+x),fn)):(PCI_DEV((CONFIG_CBB-1),(CONFIG_CDB+x-32),fn)))
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000918#else
919 #define NODE_PCI(x, fn) PCI_DEV(CONFIG_CBB,(CONFIG_CDB+x),fn)
920#endif
921#endif
922
Damien Zammit75a3d1f2016-11-28 00:29:10 +1100923/* Include wrapper for MCT (works for DDR2 or DDR3) */
924#include <northbridge/amd/amdmct/wrappers/mcti.h>
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000925
926struct link_pair_t {
Antonello Dettorif65ccb22016-09-03 10:45:33 +0200927 pci_devfn_t udev;
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000928 u32 upos;
929 u32 uoffs;
Antonello Dettorif65ccb22016-09-03 10:45:33 +0200930 pci_devfn_t dev;
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000931 u32 pos;
932 u32 offs;
933 u8 host;
934 u8 nodeid;
935 u8 linkn;
936 u8 rsv;
937} __attribute__((packed));
938
939struct nodes_info_t {
940 u32 nodes_in_group; // could be 2, 3, 4, 5, 6, 7, 8
941 u32 groups_in_plane; // could be 1, 2, 3, 4, 5
942 u32 planes; // could be 1, 2
943 u32 up_planes; // down planes will be [up_planes, planes)
944} __attribute__((packed));
945
Timothy Pearson586d6e22015-02-16 14:57:06 -0600946struct ht_link_config {
Timothy Pearson8ac49292015-09-07 15:55:50 -0500947 uint32_t ht_speed_limit; // Speed in MHz; 0 for autodetect (default)
Timothy Pearson586d6e22015-02-16 14:57:06 -0600948};
949
Furquan Shaikh20f25dd2014-04-22 10:41:05 -0700950/* be careful with the alignment of sysinfo, bacause sysinfo may be shared by coreboot_car and ramstage stage. and ramstage may be running at 64bit later.*/
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000951
952struct sys_info {
953 int32_t needs_reset;
954
955 u8 ln[NODE_NUMS*NODE_NUMS];// [0, 3] link n, [4, 7] will be hop num
956 u16 ln_tn[NODE_NUMS*8]; // for 0x0zzz: bit [0,7] target node num, bit[8,11] respone link from target num; 0x80ff mean not inited, 0x4yyy mean non coherent and yyy is link pair index
957 struct nodes_info_t nodes_info;
958 u32 nodes;
959
960 u8 host_link_freq[NODE_NUMS*8]; // record freq for every link from cpu, 0x0f means don't need to touch it
961 u16 host_link_freq_cap[NODE_NUMS*8]; //cap
962
Timothy Pearson586d6e22015-02-16 14:57:06 -0600963 struct ht_link_config ht_link_cfg;
964
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000965 u32 segbit;
966 u32 sbdn;
967 u32 sblk;
968 u32 sbbusn;
969
970 u32 ht_c_num;
971 u32 ht_c_conf_bus[HC_NUMS]; // 4-->32
972
973 struct link_pair_t link_pair[HC_NUMS*4];// enough? only in_conherent, 32 chain and every chain have 4 HT device
974 u32 link_pair_num;
975
976 struct mem_controller ctrl[NODE_NUMS];
977
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000978 struct MCTStatStruc MCTstat;
979 struct DCTStatStruc DCTstatA[NODE_NUMS];
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000980} __attribute__((packed));
981
Damien Zammit75a3d1f2016-11-28 00:29:10 +1100982
983/*
Patrick Georgibbc880e2012-11-20 18:20:56 +0100984#ifdef __PRE_RAM__
985extern struct sys_info sysinfo_car;
986#endif
Damien Zammit75a3d1f2016-11-28 00:29:10 +1100987*/
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000988#ifndef __PRE_RAM__
989device_t get_node_pci(u32 nodeid, u32 fn);
990#endif
991
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000992#ifdef __PRE_RAM__
Antonello Dettorif65ccb22016-09-03 10:45:33 +0200993void showallroutes(int level, pci_devfn_t dev);
Scott Duplichan1ba2eee2010-10-19 04:58:49 +0000994
995void setup_resource_map_offset(const u32 *register_values, u32 max, u32
996 offset_pci_dev, u32 offset_io_base);
997
998void setup_resource_map_x_offset(const u32 *register_values, u32 max, u32
999 offset_pci_dev, u32 offset_io_base);
1000
1001void setup_resource_map_x(const u32 *register_values, u32 max);
Damien Zammit75a3d1f2016-11-28 00:29:10 +11001002void setup_resource_map(const u32 *register_values, u32 max);
Scott Duplichan1ba2eee2010-10-19 04:58:49 +00001003
1004/* reset_test.c */
1005u32 cpu_init_detected(u8 nodeid);
1006u32 bios_reset_detected(void);
1007u32 cold_reset_detected(void);
1008u32 other_reset_detected(void);
Damien Zammit75a3d1f2016-11-28 00:29:10 +11001009u32 warm_reset_detect(u8 nodeid);
1010void distinguish_cpu_resets(u8 nodeid);
Scott Duplichan1ba2eee2010-10-19 04:58:49 +00001011u32 get_sblk(void);
1012u8 get_sbbusn(u8 sblk);
Damien Zammit75a3d1f2016-11-28 00:29:10 +11001013void set_bios_reset(void);
1014
Scott Duplichan1ba2eee2010-10-19 04:58:49 +00001015#endif
1016
Scott Duplichan314dd0b2011-03-08 23:01:46 +00001017#include "northbridge/amd/amdht/porting.h"
1018BOOL AMD_CB_ManualBUIDSwapList(u8 Node, u8 Link, const u8 **List);
1019
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +02001020struct acpi_rsdp;
1021
Antonello Dettorif65ccb22016-09-03 10:45:33 +02001022#ifndef __SIMPLE_DEVICE__
Alexander Couzens83fc32f2015-04-12 22:28:37 +02001023unsigned long northbridge_write_acpi_tables(device_t device,
1024 unsigned long start,
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +02001025 struct acpi_rsdp *rsdp);
Alexander Couzens5eea4582015-04-12 22:18:55 +02001026void northbridge_acpi_write_vars(device_t device);
Antonello Dettorif65ccb22016-09-03 10:45:33 +02001027#endif
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +02001028
Damien Zammit75a3d1f2016-11-28 00:29:10 +11001029void set_sysinfo_in_ram(u32 val);
1030
Scott Duplichan1ba2eee2010-10-19 04:58:49 +00001031#endif /* AMDFAM10_H */