Rename __attribute__((packed)) --> __packed
[coreboot.git] / src / northbridge / amd / amdk8 / pre_f.h
blob5b1478bf3c9ef0e16f419a7e21d21dcd131051d8
1 #ifndef AMDK8_PRE_F_H
2 #define AMDK8_PRE_F_H
4 #include <compiler.h>
6 /* Definitions of various K8 registers */
7 /* Function 0 */
8 #define HT_TRANSACTION_CONTROL 0x68
9 #define HTTC_DIS_RD_B_P (1 << 0)
10 #define HTTC_DIS_RD_DW_P (1 << 1)
11 #define HTTC_DIS_WR_B_P (1 << 2)
12 #define HTTC_DIS_WR_DW_P (1 << 3)
13 #define HTTC_DIS_MTS (1 << 4)
14 #define HTTC_CPU1_EN (1 << 5)
15 #define HTTC_CPU_REQ_PASS_PW (1 << 6)
16 #define HTTC_CPU_RD_RSP_PASS_PW (1 << 7)
17 #define HTTC_DIS_P_MEM_C (1 << 8)
18 #define HTTC_DIS_RMT_MEM_C (1 << 9)
19 #define HTTC_DIS_FILL_P (1 << 10)
20 #define HTTC_RSP_PASS_PW (1 << 11)
21 #define HTTC_CHG_ISOC_TO_ORD (1 << 12)
22 #define HTTC_BUF_REL_PRI_SHIFT 13
23 #define HTTC_BUF_REL_PRI_MASK 3
24 #define HTTC_BUF_REL_PRI_64 0
25 #define HTTC_BUF_REL_PRI_16 1
26 #define HTTC_BUF_REL_PRI_8 2
27 #define HTTC_BUF_REL_PRI_2 3
28 #define HTTC_LIMIT_CLDT_CFG (1 << 15)
29 #define HTTC_LINT_EN (1 << 16)
30 #define HTTC_APIC_EXT_BRD_CST (1 << 17)
31 #define HTTC_APIC_EXT_ID (1 << 18)
32 #define HTTC_APIC_EXT_SPUR (1 << 19)
33 #define HTTC_SEQ_ID_SRC_NODE_EN (1 << 20)
34 #define HTTC_DS_NP_REQ_LIMIT_SHIFT 21
35 #define HTTC_DS_NP_REQ_LIMIT_MASK 3
36 #define HTTC_DS_NP_REQ_LIMIT_NONE 0
37 #define HTTC_DS_NP_REQ_LIMIT_1 1
38 #define HTTC_DS_NP_REQ_LIMIT_4 2
39 #define HTTC_DS_NP_REQ_LIMIT_8 3
40 #define HTTC_MED_PRI_BYP_CNT_SHIFT 24
41 #define HTTC_MED_PRI_BYP_CNT_MASK 3
42 #define HTTC_HI_PRI_BYP_CNT_SHIFT 26
43 #define HTTC_HI_PRI_BYP_CNT_MASK 3
46 /* Function 1 */
47 #define PCI_IO_BASE0 0xc0
48 #define PCI_IO_BASE1 0xc8
49 #define PCI_IO_BASE2 0xd0
50 #define PCI_IO_BASE3 0xd8
51 #define PCI_IO_BASE_VGA_EN (1 << 4)
52 #define PCI_IO_BASE_NO_ISA (1 << 5)
55 /* Function 2 */
56 #define DRAM_CSBASE 0x40
57 #define DRAM_CSMASK 0x60
58 #define DRAM_BANK_ADDR_MAP 0x80
60 #define DRAM_TIMING_LOW 0x88
61 #define DTL_TCL_SHIFT 0
62 #define DTL_TCL_MASK 0x7
63 #define DTL_CL_2 1
64 #define DTL_CL_3 2
65 #define DTL_CL_2_5 5
66 #define DTL_TRC_SHIFT 4
67 #define DTL_TRC_MASK 0xf
68 #define DTL_TRC_BASE 7
69 #define DTL_TRC_MIN 7
70 #define DTL_TRC_MAX 22
71 #define DTL_TRFC_SHIFT 8
72 #define DTL_TRFC_MASK 0xf
73 #define DTL_TRFC_BASE 9
74 #define DTL_TRFC_MIN 9
75 #define DTL_TRFC_MAX 24
76 #define DTL_TRCD_SHIFT 12
77 #define DTL_TRCD_MASK 0x7
78 #define DTL_TRCD_BASE 0
79 #define DTL_TRCD_MIN 2
80 #define DTL_TRCD_MAX 6
81 #define DTL_TRRD_SHIFT 16
82 #define DTL_TRRD_MASK 0x7
83 #define DTL_TRRD_BASE 0
84 #define DTL_TRRD_MIN 2
85 #define DTL_TRRD_MAX 4
86 #define DTL_TRAS_SHIFT 20
87 #define DTL_TRAS_MASK 0xf
88 #define DTL_TRAS_BASE 0
89 #define DTL_TRAS_MIN 5
90 #define DTL_TRAS_MAX 15
91 #define DTL_TRP_SHIFT 24
92 #define DTL_TRP_MASK 0x7
93 #define DTL_TRP_BASE 0
94 #define DTL_TRP_MIN 2
95 #define DTL_TRP_MAX 6
96 #define DTL_TWR_SHIFT 28
97 #define DTL_TWR_MASK 0x1
98 #define DTL_TWR_BASE 2
99 #define DTL_TWR_MIN 2
100 #define DTL_TWR_MAX 3
102 #define DRAM_TIMING_HIGH 0x8c
103 #define DTH_TWTR_SHIFT 0
104 #define DTH_TWTR_MASK 0x1
105 #define DTH_TWTR_BASE 1
106 #define DTH_TWTR_MIN 1
107 #define DTH_TWTR_MAX 2
108 #define DTH_TRWT_SHIFT 4
109 #define DTH_TRWT_MASK 0x7
110 #define DTH_TRWT_BASE 1
111 #define DTH_TRWT_MIN 1
112 #define DTH_TRWT_MAX 6
113 #define DTH_TREF_SHIFT 8
114 #define DTH_TREF_MASK 0x1f
115 #define DTH_TREF_100MHZ_4K 0x00
116 #define DTH_TREF_133MHZ_4K 0x01
117 #define DTH_TREF_166MHZ_4K 0x02
118 #define DTH_TREF_200MHZ_4K 0x03
119 #define DTH_TREF_100MHZ_8K 0x08
120 #define DTH_TREF_133MHZ_8K 0x09
121 #define DTH_TREF_166MHZ_8K 0x0A
122 #define DTH_TREF_200MHZ_8K 0x0B
123 #define DTH_TWCL_SHIFT 20
124 #define DTH_TWCL_MASK 0x7
125 #define DTH_TWCL_BASE 1
126 #define DTH_TWCL_MIN 1
127 #define DTH_TWCL_MAX 2
129 #define DRAM_CONFIG_LOW 0x90
130 #define DCL_DLL_Disable (1<<0)
131 #define DCL_D_DRV (1<<1)
132 #define DCL_QFC_EN (1<<2)
133 #define DCL_DisDqsHys (1<<3)
134 #define DCL_Burst2Opt (1<<5)
135 #define DCL_DramInit (1<<8)
136 #define DCL_DualDIMMen (1<<9)
137 #define DCL_DramEnable (1<<10)
138 #define DCL_MemClrStatus (1<<11)
139 #define DCL_ESR (1<<12)
140 #define DCL_SRS (1<<13)
141 #define DCL_128BitEn (1<<16)
142 #define DCL_DimmEccEn (1<<17)
143 #define DCL_UnBuffDimm (1<<18)
144 #define DCL_32ByteEn (1<<19)
145 #define DCL_x4DIMM_SHIFT 20
146 #define DCL_DisInRcvrs (1<<24)
147 #define DCL_BypMax_SHIFT 25
148 #define DCL_En2T (1<<28)
149 #define DCL_UpperCSMap (1<<29)
151 #define DRAM_CONFIG_HIGH 0x94
152 #define DCH_ASYNC_LAT_SHIFT 0
153 #define DCH_ASYNC_LAT_MASK 0xf
154 #define DCH_ASYNC_LAT_BASE 0
155 #define DCH_ASYNC_LAT_MIN 0
156 #define DCH_ASYNC_LAT_MAX 15
157 #define DCH_RDPREAMBLE_SHIFT 8
158 #define DCH_RDPREAMBLE_MASK 0xf
159 #define DCH_RDPREAMBLE_BASE ((2<<1)+0) /* 2.0 ns */
160 #define DCH_RDPREAMBLE_MIN ((2<<1)+0) /* 2.0 ns */
161 #define DCH_RDPREAMBLE_MAX ((9<<1)+1) /* 9.5 ns */
162 #define DCH_IDLE_LIMIT_SHIFT 16
163 #define DCH_IDLE_LIMIT_MASK 0x7
164 #define DCH_IDLE_LIMIT_0 0
165 #define DCH_IDLE_LIMIT_4 1
166 #define DCH_IDLE_LIMIT_8 2
167 #define DCH_IDLE_LIMIT_16 3
168 #define DCH_IDLE_LIMIT_32 4
169 #define DCH_IDLE_LIMIT_64 5
170 #define DCH_IDLE_LIMIT_128 6
171 #define DCH_IDLE_LIMIT_256 7
172 #define DCH_DYN_IDLE_CTR_EN (1 << 19)
173 #define DCH_MEMCLK_SHIFT 20
174 #define DCH_MEMCLK_MASK 0x7
175 #define DCH_MEMCLK_100MHZ 0
176 #define DCH_MEMCLK_133MHZ 2
177 #define DCH_MEMCLK_166MHZ 5
178 #define DCH_MEMCLK_200MHZ 7
179 #define DCH_MEMCLK_VALID (1 << 25)
180 #define DCH_MEMCLK_EN0 (1 << 26)
181 #define DCH_MEMCLK_EN1 (1 << 27)
182 #define DCH_MEMCLK_EN2 (1 << 28)
183 #define DCH_MEMCLK_EN3 (1 << 29)
185 /* Function 3 */
186 #define MCA_NB_CONFIG 0x44
187 #define MNC_ECC_EN (1 << 22)
188 #define MNC_CHIPKILL_EN (1 << 23)
189 #define SCRUB_CONTROL 0x58
190 #define SCRUB_NONE 0
191 #define SCRUB_40ns 1
192 #define SCRUB_80ns 2
193 #define SCRUB_160ns 3
194 #define SCRUB_320ns 4
195 #define SCRUB_640ns 5
196 #define SCRUB_1_28us 6
197 #define SCRUB_2_56us 7
198 #define SCRUB_5_12us 8
199 #define SCRUB_10_2us 9
200 #define SCRUB_20_5us 10
201 #define SCRUB_41_0us 11
202 #define SCRUB_81_9us 12
203 #define SCRUB_163_8us 13
204 #define SCRUB_327_7us 14
205 #define SCRUB_655_4us 15
206 #define SCRUB_1_31ms 16
207 #define SCRUB_2_62ms 17
208 #define SCRUB_5_24ms 18
209 #define SCRUB_10_49ms 19
210 #define SCRUB_20_97ms 20
211 #define SCRUB_42ms 21
212 #define SCRUB_84ms 22
213 #define SC_DRAM_SCRUB_RATE_SHFIT 0
214 #define SC_DRAM_SCRUB_RATE_MASK 0x1f
215 #define SC_L2_SCRUB_RATE_SHIFT 8
216 #define SC_L2_SCRUB_RATE_MASK 0x1f
217 #define SC_L1D_SCRUB_RATE_SHIFT 16
218 #define SC_L1D_SCRUB_RATE_MASK 0x1f
219 #define SCRUB_ADDR_LOW 0x5C
220 #define SCRUB_ADDR_HIGH 0x60
221 #define NORTHBRIDGE_CAP 0xE8
222 #define NBCAP_128Bit (1 << 0)
223 #define NBCAP_MP (1 << 1)
224 #define NBCAP_BIG_MP (1 << 2)
225 #define NBCAP_ECC (1 << 3)
226 #define NBCAP_CHIPKILL_ECC (1 << 4)
227 #define NBCAP_MEMCLK_SHIFT 5
228 #define NBCAP_MEMCLK_MASK 3
229 #define NBCAP_MEMCLK_100MHZ 3
230 #define NBCAP_MEMCLK_133MHZ 2
231 #define NBCAP_MEMCLK_166MHZ 1
232 #define NBCAP_MEMCLK_200MHZ 0
233 #define NBCAP_MEMCTRL (1 << 8)
236 #define LinkConnected (1 << 0)
237 #define InitComplete (1 << 1)
238 #define NonCoherent (1 << 2)
239 #define ConnectionPending (1 << 4)
241 #include "raminit.h"
242 //struct definitions
244 struct link_pair_st {
245 pci_devfn_t udev;
246 uint32_t upos;
247 uint32_t uoffs;
248 pci_devfn_t dev;
249 uint32_t pos;
250 uint32_t offs;
252 } __packed;
254 struct sys_info {
255 uint8_t ctrl_present[NODE_NUMS];
256 struct mem_controller ctrl[NODE_NUMS];
258 uint32_t nodes;
259 struct link_pair_st link_pair[16];// enough? only in_conherent
260 uint32_t link_pair_num;
261 uint32_t ht_c_num;
262 uint32_t sbdn;
263 uint32_t sblk;
264 uint32_t sbbusn;
265 } __packed;
267 #ifdef __PRE_RAM__
268 #include <arch/early_variables.h>
269 extern struct sys_info sysinfo_car;
270 #endif
272 #endif /* AMDK8_PRE_F_H */