- A new test case for romcc
[coreboot.git] / src / northbridge / amd / amdk8 / coherent_ht.c
1 static void setup_coherent_ht_domain(void)
2 {
3         static const unsigned int register_values[] = {
4         /* Routing Table Node i 
5          * F0:0x40 i = 0, 
6          * F0:0x44 i = 1,
7          * F0:0x48 i = 2, 
8          * F0:0x4c i = 3,
9          * F0:0x50 i = 4, 
10          * F0:0x54 i = 5,
11          * F0:0x58 i = 6, 
12          * F0:0x5c i = 7
13          * [ 0: 3] Request Route
14          *     [0] Route to this node
15          *     [1] Route to Link 0
16          *     [2] Route to Link 1
17          *     [3] Route to Link 2
18          * [11: 8] Response Route
19          *     [0] Route to this node
20          *     [1] Route to Link 0
21          *     [2] Route to Link 1
22          *     [3] Route to Link 2
23          * [19:16] Broadcast route
24          *     [0] Route to this node
25          *     [1] Route to Link 0
26          *     [2] Route to Link 1
27          *     [3] Route to Link 2
28          */
29         PCI_ADDR(0, 0x18, 0, 0x40), 0xfff0f0f0, 0x00010101,
30         PCI_ADDR(0, 0x18, 0, 0x44), 0xfff0f0f0, 0x00010101,
31         PCI_ADDR(0, 0x18, 0, 0x48), 0xfff0f0f0, 0x00010101,
32         PCI_ADDR(0, 0x18, 0, 0x4c), 0xfff0f0f0, 0x00010101,
33         PCI_ADDR(0, 0x18, 0, 0x50), 0xfff0f0f0, 0x00010101,
34         PCI_ADDR(0, 0x18, 0, 0x54), 0xfff0f0f0, 0x00010101,
35         PCI_ADDR(0, 0x18, 0, 0x58), 0xfff0f0f0, 0x00010101,
36         PCI_ADDR(0, 0x18, 0, 0x5c), 0xfff0f0f0, 0x00010101,
37
38         /* Hypetransport Transaction Control Register 
39          * F0:0x68
40          * [ 0: 0] Disable read byte probe
41          *         0 = Probes issues
42          *         1 = Probes not issued
43          * [ 1: 1] Disable Read Doubleword probe
44          *         0 = Probes issued
45          *         1 = Probes not issued
46          * [ 2: 2] Disable write byte probes
47          *         0 = Probes issued
48          *         1 = Probes not issued
49          * [ 3: 3] Disable Write Doubleword Probes
50          *         0 = Probes issued
51          *         1 = Probes not issued.
52          * [ 4: 4] Disable Memroy Controller Target Start
53          *         0 = TgtStart packets are generated
54          *         1 = TgtStart packets are not generated.
55          * [ 5: 5] CPU1 Enable
56          *         0 = Second CPU disabled or not present
57          *         1 = Second CPU enabled.
58          * [ 6: 6] CPU Request PassPW
59          *         0 = CPU requests do not pass posted writes
60          *         1 = CPU requests pass posted writes.
61          * [ 7: 7] CPU read Respons PassPW
62          *         0 = CPU Responses do not pass posted writes
63          *         1 = CPU responses pass posted writes.
64          * [ 8: 8] Disable Probe Memory Cancel
65          *         0 = Probes may generate MemCancels
66          *         1 = Probes may not generate MemCancels
67          * [ 9: 9] Disable Remote Probe Memory Cancel.
68          *         0 = Probes hitting dirty blocks generate memory cancel packets
69          *         1 = Only probed caches on the same node as the memory controller
70          *              generate cancel packets.
71          * [10:10] Disable Fill Probe
72          *         0 = Probes issued for cache fills
73          *         1 = Probes not issued for cache fills.
74          * [11:11] Response PassPw
75          *         0 = Downstream response PassPW based on original request
76          *         1 = Downstream response PassPW set to 1
77          * [12:12] Change ISOC to Ordered
78          *         0 = Bit 1 of coherent HT RdSz/WrSz command used for iosynchronous prioritization
79          *         1 = Bit 1 of coherent HT RdSz/WrSz command used for ordering.
80          * [14:13] Buffer Release Priority select 
81          *         00 = 64
82          *         01 = 16
83          *         10 = 8
84          *         11 = 2
85          * [15:15] Limit Coherent HT Configuration Space Range
86          *         0 = No coherent HT configuration space restrictions
87          *         1 = Limit coherent HT configuration space based on node count
88          * [16:16] Local Interrupt Conversion Enable.
89          *         0 = ExtInt/NMI interrups unaffected.
90          *         1 = ExtInt/NMI broadcat interrupts converted to LINT0/1
91          * [17:17] APIC Extended Broadcast Enable.
92          *         0 = APIC broadcast is 0F
93          *         1 = APIC broadcast is FF
94          * [18:18] APIC Extended ID Enable
95          *         0 = APIC ID is 4 bits.
96          *         1 = APIC ID is 8 bits.
97          * [19:19] APIC Extended Spurious Vector Enable
98          *         0 = Lower 4 bits of spurious vector are read-only 1111
99          *         1 = Lower 4 bits of spurious vecotr are writeable.
100          * [20:20] Sequence ID Source Node Enable
101          *         0 = Normal operation
102          *         1 = Keep SeqID on routed packets for debugging.
103          * [22:21] Downstream non-posted request limit
104          *         00 = No limit
105          *         01 = Limited to 1
106          *         10 = Limited to 4
107          *         11 = Limited to 8
108          * [23:23] RESERVED
109          * [25:24] Medium-Priority Bypass Count
110          *         - Maximum # of times a medium priority access can pass a low
111          *           priority access before Medium-Priority mode is disabled for one access.
112          * [27:26] High-Priority Bypass Count
113          *         - Maximum # of times a high prioirty access can pass a medium or low
114          *           priority access before High-prioirty mode is disabled for one access.
115          * [28:28] Enable High Priority CPU Reads
116          *         0 = Cpu reads are medium prioirty
117          *         1 = Cpu reads are high prioirty
118          * [29:29] Disable Low Priority Writes
119          *         0 = Non-isochronous writes are low priority
120          *         1 = Non-isochronous writes are medium prioirty
121          * [30:30] Disable High Priority Isochronous writes
122          *         0 = Isochronous writes are high priority
123          *         1 = Isochronous writes are medium priority
124          * [31:31] Disable Medium Priority Isochronous writes
125          *         0 = Isochronous writes are medium are high
126          *         1 = With bit 30 set makes Isochrouns writes low priority.
127          */
128         PCI_ADDR(0, 0x18, 0, 0x68), 0x00800000, 0x0f00840f,
129         /* HT Initialization Control Register
130          * F0:0x6C
131          * [ 0: 0] Routing Table Disable
132          *         0 = Packets are routed according to routing tables
133          *         1 = Packets are routed according to the default link field
134          * [ 1: 1] Request Disable (BSP should clear this)
135          *         0 = Request packets may be generated
136          *         1 = Request packets may not be generated.
137          * [ 3: 2] Default Link (Read-only)
138          *         00 = LDT0
139          *         01 = LDT1
140          *         10 = LDT2
141          *         11 = CPU on same node
142          * [ 4: 4] Cold Reset
143          *         - Scratch bit cleared by a cold reset
144          * [ 5: 5] BIOS Reset Detect
145          *         - Scratch bit cleared by a cold reset
146          * [ 6: 6] INIT Detect
147          *         - Scratch bit cleared by a warm or cold reset not by an INIT
148          *
149          */
150         PCI_ADDR(0, 0x18, 0, 0x6C), 0xffffff8c, 0x00000000 | (1 << 6) |(1 << 5)| (1 << 4),
151         /* LDTi Capabilities Registers
152          * F0:0x80 i = 0,
153          * F0:0xA0 i = 1,
154          * F0:0xC0 i = 2,
155          */
156         /* LDTi Link Control Registrs
157          * F0:0x84 i = 0,
158          * F0:0xA4 i = 1,
159          * F0:0xC4 i = 2,
160          * [ 1: 1] CRC Flood Enable
161          *         0 = Do not generate sync packets on CRC error
162          *         1 = Generate sync packets on CRC error
163          * [ 2: 2] CRC Start Test (Read-Only)
164          * [ 3: 3] CRC Force Frame Error
165          *         0 = Do not generate bad CRC
166          *         1 = Generate bad CRC
167          * [ 4: 4] Link Failure
168          *         0 = No link failure detected
169          *         1 = Link failure detected
170          * [ 5: 5] Initialization Complete
171          *         0 = Initialization not complete
172          *         1 = Initialization complete
173          * [ 6: 6] Receiver off
174          *         0 = Recevier on
175          *         1 = Receiver off
176          * [ 7: 7] Transmitter Off
177          *         0 = Transmitter on
178          *         1 = Transmitter off
179          * [ 9: 8] CRC_Error
180          *         00 = No error
181          *         [0] = 1 Error on byte lane 0
182          *         [1] = 1 Error on byte lane 1
183          * [12:12] Isochrnous Enable  (Read-Only)
184          * [13:13] HT Stop Tristate Enable
185          *         0 = Driven during an LDTSTOP_L
186          *         1 = Tristated during and LDTSTOP_L
187          * [14:14] Extended CTL Time 
188          *         0 = CTL is asserted for 16 bit times during link initialization
189          *         1 = CTL is asserted for 50us during link initialization
190          * [18:16] Max Link Width In (Read-Only?)
191          *         000 = 8 bit link
192          *         001 = 16bit link
193          * [19:19] Doubleword Flow Control in (Read-Only)
194          *         0 = This link does not support doubleword flow control
195          *         1 = This link supports doubleword flow control
196          * [22:20] Max Link Width Out (Read-Only?)
197          *         000 = 8 bit link
198          *         001 = 16bit link
199          * [23:23] Doubleworld Flow Control out (Read-Only)
200          *         0 = This link does not support doubleword flow control
201          *         1 = This link supports doubleworkd flow control
202          * [26:24] Link Width In
203          *         000 = Use 8 bits
204          *         001 = Use 16 bits
205          *         010 = reserved
206          *         011 = Use 32 bits
207          *         100 = Use 2 bits
208          *         101 = Use 4 bits
209          *         110 = reserved
210          *         111 = Link physically not connected
211          * [27:27] Doubleword Flow Control In Enable
212          *         0 = Doubleword flow control disabled
213          *         1 = Doubleword flow control enabled (Not currently supported)
214          * [30:28] Link Width Out
215          *         000 = Use 8 bits
216          *         001 = Use 16 bits
217          *         010 = reserved
218          *         011 = Use 32 bits
219          *         100 = Use 2 bits
220          *         101 = Use 4 bits
221          *         110 = reserved
222          *         111 = Link physically not connected
223          * [31:31] Doubleworld Flow Control Out Enable
224          *         0 = Doubleworld flow control disabled
225          *         1 = Doubleword flow control enabled (Not currently supported)
226          */
227         PCI_ADDR(0, 0x18, 0, 0x84), 0x00009c05, 0x11110020,
228         /* LDTi Frequency/Revision Registers
229          * F0:0x88 i = 0,
230          * F0:0xA8 i = 1,
231          * F0:0xC8 i = 2,
232          * [ 4: 0] Minor Revision
233          *         Contains the HT Minor revision
234          * [ 7: 5] Major Revision
235          *         Contains the HT Major revision
236          * [11: 8] Link Frequency  (Takes effect the next time the link is reconnected)
237          *         0000 = 200Mhz
238          *         0001 = reserved
239          *         0010 = 400Mhz
240          *         0011 = reserved
241          *         0100 = 600Mhz
242          *         0101 = 800Mhz
243          *         0110 = 1000Mhz
244          *         0111 = reserved
245          *         1000 = reserved
246          *         1001 = reserved
247          *         1010 = reserved
248          *         1011 = reserved
249          *         1100 = reserved
250          *         1101 = reserved
251          *         1110 = reserved
252          *         1111 = 100 Mhz
253          * [15:12] Error (Not currently Implemented)
254          * [31:16] Indicates the frequency capabilities of the link
255          *         [16] = 1 encoding 0000 of freq supported
256          *         [17] = 1 encoding 0001 of freq supported
257          *         [18] = 1 encoding 0010 of freq supported
258          *         [19] = 1 encoding 0011 of freq supported
259          *         [20] = 1 encoding 0100 of freq supported
260          *         [21] = 1 encoding 0101 of freq supported
261          *         [22] = 1 encoding 0110 of freq supported
262          *         [23] = 1 encoding 0111 of freq supported
263          *         [24] = 1 encoding 1000 of freq supported
264          *         [25] = 1 encoding 1001 of freq supported
265          *         [26] = 1 encoding 1010 of freq supported
266          *         [27] = 1 encoding 1011 of freq supported
267          *         [28] = 1 encoding 1100 of freq supported
268          *         [29] = 1 encoding 1101 of freq supported
269          *         [30] = 1 encoding 1110 of freq supported
270          *         [31] = 1 encoding 1111 of freq supported
271          */
272         PCI_ADDR(0, 0x18, 0, 0x88), 0xfffff0ff, 0x00000200,
273         /* LDTi Feature Capability
274          * F0:0x8C i = 0,
275          * F0:0xAC i = 1,
276          * F0:0xCC i = 2,
277          */
278         /* LDTi Buffer Count Registers
279          * F0:0x90 i = 0,
280          * F0:0xB0 i = 1,
281          * F0:0xD0 i = 2,
282          */
283         /* LDTi Bus Number Registers
284          * F0:0x94 i = 0,
285          * F0:0xB4 i = 1,
286          * F0:0xD4 i = 2,
287          * For NonCoherent HT specifies the bus number downstream (behind the host bridge)
288          * [ 0: 7] Primary Bus Number
289          * [15: 8] Secondary Bus Number
290          * [23:15] Subordiante Bus Number
291          * [31:24] reserved
292          */
293         PCI_ADDR(0, 0x18, 0, 0x94), 0xff000000, 0x00ff0000,
294         /* LDTi Type Registers
295          * F0:0x98 i = 0,
296          * F0:0xB8 i = 1,
297          * F0:0xD8 i = 2,
298          */
299         };
300         int i;
301         int max;
302         print_debug("setting up coherent ht domain....\r\n");
303         max = sizeof(register_values)/sizeof(register_values[0]);
304         for(i = 0; i < max; i += 3) {
305                 device_t dev;
306                 unsigned where;
307                 unsigned long reg;
308 #if 0
309                 print_debug_hex32(register_values[i]);
310                 print_debug(" <-");
311                 print_debug_hex32(register_values[i+2]);
312                 print_debug("\r\n");
313 #endif
314                 dev = register_values[i] & ~0xff;
315                 where = register_values[i] & 0xff;
316                 reg = pci_read_config32(dev, where);
317                 reg &= register_values[i+1];
318                 reg |= register_values[i+2];
319                 pci_write_config32(dev, where, reg);
320 #if 0
321                 reg = pci_read_config32(register_values[i]);
322                 reg &= register_values[i+1];
323                 reg |= register_values[i+2] & ~register_values[i+1];
324                 pci_write_config32(register_values[i], reg);
325 #endif
326         }
327         print_debug("done.\r\n");
328 }