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