Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / util / romcc / tests / linux_test2.c
1 #include "linux_syscall.h"
2 #include "linux_console.h"
3
4
5 static void setup_coherent_ht_domain(void)
6 {
7         static const unsigned int register_values[] = {
8 #if 1
9         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x40) & 0xFF)), 0xfff0f0f0, 0x00010101,
10         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x44) & 0xFF)), 0xfff0f0f0, 0x00010101,
11         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x48) & 0xFF)), 0xfff0f0f0, 0x00010101,
12         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x4c) & 0xFF)), 0xfff0f0f0, 0x00010101,
13         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x50) & 0xFF)), 0xfff0f0f0, 0x00010101,
14         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x54) & 0xFF)), 0xfff0f0f0, 0x00010101,
15         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x58) & 0xFF)), 0xfff0f0f0, 0x00010101,
16         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x5c) & 0xFF)), 0xfff0f0f0, 0x00010101,
17         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x68) & 0xFF)), 0x00800000, 0x0f00840f,
18         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x6C) & 0xFF)), 0xffffff8c, 0x00000000 | (1 << 6) |(1 << 5)| (1 << 4),
19         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x84) & 0xFF)), 0x00009c05, 0x11110020,
20         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x88) & 0xFF)), 0xfffff0ff, 0x00000200,
21         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x94) & 0xFF)), 0xff000000, 0x00ff0000,
22         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x44) & 0xFF)), 0x0000f8f8, 0x003f0000,
23         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x4C) & 0xFF)), 0x0000f8f8, 0x00000001,
24         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x54) & 0xFF)), 0x0000f8f8, 0x00000002,
25         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x5C) & 0xFF)), 0x0000f8f8, 0x00000003,
26         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x64) & 0xFF)), 0x0000f8f8, 0x00000004,
27         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x6C) & 0xFF)), 0x0000f8f8, 0x00000005,
28         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x74) & 0xFF)), 0x0000f8f8, 0x00000006,
29         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x7C) & 0xFF)), 0x0000f8f8, 0x00000007,
30         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x40) & 0xFF)), 0x0000f8fc, 0x00000003,
31         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x48) & 0xFF)), 0x0000f8fc, 0x00400000,
32         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x50) & 0xFF)), 0x0000f8fc, 0x00400000,
33         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x58) & 0xFF)), 0x0000f8fc, 0x00400000,
34         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x60) & 0xFF)), 0x0000f8fc, 0x00400000,
35         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x68) & 0xFF)), 0x0000f8fc, 0x00400000,
36         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x70) & 0xFF)), 0x0000f8fc, 0x00400000,
37         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x78) & 0xFF)), 0x0000f8fc, 0x00400000,
38         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x84) & 0xFF)), 0x00000048, 0x00e1ff00,
39         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x8C) & 0xFF)), 0x00000048, 0x00dfff00,
40         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x94) & 0xFF)), 0x00000048, 0x00e3ff00,
41         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x9C) & 0xFF)), 0x00000048, 0x00000000,
42         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xA4) & 0xFF)), 0x00000048, 0x00000000,
43         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xAC) & 0xFF)), 0x00000048, 0x00000000,
44         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xB4) & 0xFF)), 0x00000048, 0x00000b00,
45         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xBC) & 0xFF)), 0x00000048, 0x00fe0b00,
46         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x80) & 0xFF)), 0x000000f0, 0x00e00003,
47         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x88) & 0xFF)), 0x000000f0, 0x00d80003,
48         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x90) & 0xFF)), 0x000000f0, 0x00e20003,
49         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0x98) & 0xFF)), 0x000000f0, 0x00000000,
50         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xA0) & 0xFF)), 0x000000f0, 0x00000000,
51         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xA8) & 0xFF)), 0x000000f0, 0x00000000,
52         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xB0) & 0xFF)), 0x000000f0, 0x00000a03,
53         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xB8) & 0xFF)), 0x000000f0, 0x00400003,
54         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xC4) & 0xFF)), 0xFE000FC8, 0x0000d000,
55         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xCC) & 0xFF)), 0xFE000FC8, 0x000ff000,
56         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xD4) & 0xFF)), 0xFE000FC8, 0x00000000,
57         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xDC) & 0xFF)), 0xFE000FC8, 0x00000000,
58         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xC0) & 0xFF)), 0xFE000FCC, 0x0000d003,
59         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xC8) & 0xFF)), 0xFE000FCC, 0x00001013,
60         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xD0) & 0xFF)), 0xFE000FCC, 0x00000000,
61         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xD8) & 0xFF)), 0xFE000FCC, 0x00000000,
62         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xE0) & 0xFF)), 0x0000FC88, 0xff000003,
63         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xE4) & 0xFF)), 0x0000FC88, 0x00000000,
64         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xE8) & 0xFF)), 0x0000FC88, 0x00000000,
65         ( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((1) & 0x07) << 8) | ((0xEC) & 0xFF)), 0x0000FC88, 0x00000000,
66 #else
67 #define PCI_ADDR(BUS, DEV, FN, WHERE) ( \
68         (((BUS) & 0xFF) << 16) | \
69         (((DEV) & 0x1f) << 11) | \
70         (((FN) & 0x07) << 8) | \
71         ((WHERE) & 0xFF))
72
73         /* Routing Table Node i
74          * F0:0x40 i = 0,
75          * F0:0x44 i = 1,
76          * F0:0x48 i = 2,
77          * F0:0x4c i = 3,
78          * F0:0x50 i = 4,
79          * F0:0x54 i = 5,
80          * F0:0x58 i = 6,
81          * F0:0x5c i = 7
82          * [ 0: 3] Request Route
83          *     [0] Route to this node
84          *     [1] Route to Link 0
85          *     [2] Route to Link 1
86          *     [3] Route to Link 2
87          * [11: 8] Response Route
88          *     [0] Route to this node
89          *     [1] Route to Link 0
90          *     [2] Route to Link 1
91          *     [3] Route to Link 2
92          * [19:16] Broadcast route
93          *     [0] Route to this node
94          *     [1] Route to Link 0
95          *     [2] Route to Link 1
96          *     [3] Route to Link 2
97          */
98         PCI_ADDR(0, 0x18, 0, 0x40), 0xfff0f0f0, 0x00010101,
99         PCI_ADDR(0, 0x18, 0, 0x44), 0xfff0f0f0, 0x00010101,
100         PCI_ADDR(0, 0x18, 0, 0x48), 0xfff0f0f0, 0x00010101,
101         PCI_ADDR(0, 0x18, 0, 0x4c), 0xfff0f0f0, 0x00010101,
102         PCI_ADDR(0, 0x18, 0, 0x50), 0xfff0f0f0, 0x00010101,
103         PCI_ADDR(0, 0x18, 0, 0x54), 0xfff0f0f0, 0x00010101,
104         PCI_ADDR(0, 0x18, 0, 0x58), 0xfff0f0f0, 0x00010101,
105         PCI_ADDR(0, 0x18, 0, 0x5c), 0xfff0f0f0, 0x00010101,
106
107         /* Hypetransport Transaction Control Register
108          * F0:0x68
109          * [ 0: 0] Disable read byte probe
110          *         0 = Probes issues
111          *         1 = Probes not issued
112          * [ 1: 1] Disable Read Doubleword probe
113          *         0 = Probes issued
114          *         1 = Probes not issued
115          * [ 2: 2] Disable write byte probes
116          *         0 = Probes issued
117          *         1 = Probes not issued
118          * [ 3: 3] Disable Write Doubleword Probes
119          *         0 = Probes issued
120          *         1 = Probes not issued.
121          * [ 4: 4] Disable Memroy Controller Target Start
122          *         0 = TgtStart packets are generated
123          *         1 = TgtStart packets are not generated.
124          * [ 5: 5] CPU1 Enable
125          *         0 = Second CPU disabled or not present
126          *         1 = Second CPU enabled.
127          * [ 6: 6] CPU Request PassPW
128          *         0 = CPU requests do not pass posted writes
129          *         1 = CPU requests pass posted writes.
130          * [ 7: 7] CPU read Respons PassPW
131          *         0 = CPU Responses do not pass posted writes
132          *         1 = CPU responses pass posted writes.
133          * [ 8: 8] Disable Probe Memory Cancel
134          *         0 = Probes may generate MemCancels
135          *         1 = Probes may not generate MemCancels
136          * [ 9: 9] Disable Remote Probe Memory Cancel.
137          *         0 = Probes hitting dirty blocks generate memory cancel packets
138          *         1 = Only probed caches on the same node as the memory controller
139          *              generate cancel packets.
140          * [10:10] Disable Fill Probe
141          *         0 = Probes issued for cache fills
142          *         1 = Probes not issued for cache fills.
143          * [11:11] Response PassPw
144          *         0 = Downstream response PassPW based on original request
145          *         1 = Downstream response PassPW set to 1
146          * [12:12] Change ISOC to Ordered
147          *         0 = Bit 1 of coherent HT RdSz/WrSz command used for iosynchronous prioritization
148          *         1 = Bit 1 of coherent HT RdSz/WrSz command used for ordering.
149          * [14:13] Buffer Release Priority select
150          *         00 = 64
151          *         01 = 16
152          *         10 = 8
153          *         11 = 2
154          * [15:15] Limit Coherent HT Configuration Space Range
155          *         0 = No coherent HT configuration space restrictions
156          *         1 = Limit coherent HT configuration space based on node count
157          * [16:16] Local Interrupt Conversion Enable.
158          *         0 = ExtInt/NMI interrups unaffected.
159          *         1 = ExtInt/NMI broadcat interrupts converted to LINT0/1
160          * [17:17] APIC Extended Broadcast Enable.
161          *         0 = APIC broadcast is 0F
162          *         1 = APIC broadcast is FF
163          * [18:18] APIC Extended ID Enable
164          *         0 = APIC ID is 4 bits.
165          *         1 = APIC ID is 8 bits.
166          * [19:19] APIC Extended Spurious Vector Enable
167          *         0 = Lower 4 bits of spurious vector are read-only 1111
168          *         1 = Lower 4 bits of spurious vecotr are writeable.
169          * [20:20] Sequence ID Source Node Enable
170          *         0 = Normal operation
171          *         1 = Keep SeqID on routed packets for debugging.
172          * [22:21] Downstream non-posted request limit
173          *         00 = No limit
174          *         01 = Limited to 1
175          *         10 = Limited to 4
176          *         11 = Limited to 8
177          * [23:23] RESERVED
178          * [25:24] Medium-Priority Bypass Count
179          *         - Maximum # of times a medium priority access can pass a low
180          *           priority access before Medium-Priority mode is disabled for one access.
181          * [27:26] High-Priority Bypass Count
182          *         - Maximum # of times a high prioirty access can pass a medium or low
183          *           priority access before High-prioirty mode is disabled for one access.
184          * [28:28] Enable High Priority CPU Reads
185          *         0 = Cpu reads are medium prioirty
186          *         1 = Cpu reads are high prioirty
187          * [29:29] Disable Low Priority Writes
188          *         0 = Non-isochronous writes are low priority
189          *         1 = Non-isochronous writes are medium prioirty
190          * [30:30] Disable High Priority Isochronous writes
191          *         0 = Isochronous writes are high priority
192          *         1 = Isochronous writes are medium priority
193          * [31:31] Disable Medium Priority Isochronous writes
194          *         0 = Isochronous writes are medium are high
195          *         1 = With bit 30 set makes Isochrouns writes low priority.
196          */
197         PCI_ADDR(0, 0x18, 0, 0x68), 0x00800000, 0x0f00840f,
198         /* HT Initialization Control Register
199          * F0:0x6C
200          * [ 0: 0] Routing Table Disable
201          *         0 = Packets are routed according to routing tables
202          *         1 = Packets are routed according to the default link field
203          * [ 1: 1] Request Disable (BSP should clear this)
204          *         0 = Request packets may be generated
205          *         1 = Request packets may not be generated.
206          * [ 3: 2] Default Link (Read-only)
207          *         00 = LDT0
208          *         01 = LDT1
209          *         10 = LDT2
210          *         11 = CPU on same node
211          * [ 4: 4] Cold Reset
212          *         - Scratch bit cleared by a cold reset
213          * [ 5: 5] BIOS Reset Detect
214          *         - Scratch bit cleared by a cold reset
215          * [ 6: 6] INIT Detect
216          *         - Scratch bit cleared by a warm or cold reset not by an INIT
217          *
218          */
219         PCI_ADDR(0, 0x18, 0, 0x6C), 0xffffff8c, 0x00000000 | (1 << 6) |(1 << 5)| (1 << 4),
220         /* LDTi Capabilities Registers
221          * F0:0x80 i = 0,
222          * F0:0xA0 i = 1,
223          * F0:0xC0 i = 2,
224          */
225         /* LDTi Link Control Registrs
226          * F0:0x84 i = 0,
227          * F0:0xA4 i = 1,
228          * F0:0xC4 i = 2,
229          * [ 1: 1] CRC Flood Enable
230          *         0 = Do not generate sync packets on CRC error
231          *         1 = Generate sync packets on CRC error
232          * [ 2: 2] CRC Start Test (Read-Only)
233          * [ 3: 3] CRC Force Frame Error
234          *         0 = Do not generate bad CRC
235          *         1 = Generate bad CRC
236          * [ 4: 4] Link Failure
237          *         0 = No link failure detected
238          *         1 = Link failure detected
239          * [ 5: 5] Initialization Complete
240          *         0 = Initialization not complete
241          *         1 = Initialization complete
242          * [ 6: 6] Receiver off
243          *         0 = Recevier on
244          *         1 = Receiver off
245          * [ 7: 7] Transmitter Off
246          *         0 = Transmitter on
247          *         1 = Transmitter off
248          * [ 9: 8] CRC_Error
249          *         00 = No error
250          *         [0] = 1 Error on byte lane 0
251          *         [1] = 1 Error on byte lane 1
252          * [12:12] Isochrnous Enable  (Read-Only)
253          * [13:13] HT Stop Tristate Enable
254          *         0 = Driven during an LDTSTOP_L
255          *         1 = Tristated during and LDTSTOP_L
256          * [14:14] Extended CTL Time
257          *         0 = CTL is asserted for 16 bit times during link initialization
258          *         1 = CTL is asserted for 50us during link initialization
259          * [18:16] Max Link Width In (Read-Only?)
260          *         000 = 8 bit link
261          *         001 = 16bit link
262          * [19:19] Doubleword Flow Control in (Read-Only)
263          *         0 = This link does not support doubleword flow control
264          *         1 = This link supports doubleword flow control
265          * [22:20] Max Link Width Out (Read-Only?)
266          *         000 = 8 bit link
267          *         001 = 16bit link
268          * [23:23] Doubleworld Flow Control out (Read-Only)
269          *         0 = This link does not support doubleword flow control
270          *         1 = This link supports doubleworkd flow control
271          * [26:24] Link Width In
272          *         000 = Use 8 bits
273          *         001 = Use 16 bits
274          *         010 = reserved
275          *         011 = Use 32 bits
276          *         100 = Use 2 bits
277          *         101 = Use 4 bits
278          *         110 = reserved
279          *         111 = Link physically not connected
280          * [27:27] Doubleword Flow Control In Enable
281          *         0 = Doubleword flow control disabled
282          *         1 = Doubleword flow control enabled (Not currently supported)
283          * [30:28] Link Width Out
284          *         000 = Use 8 bits
285          *         001 = Use 16 bits
286          *         010 = reserved
287          *         011 = Use 32 bits
288          *         100 = Use 2 bits
289          *         101 = Use 4 bits
290          *         110 = reserved
291          *         111 = Link physically not connected
292          * [31:31] Doubleworld Flow Control Out Enable
293          *         0 = Doubleworld flow control disabled
294          *         1 = Doubleword flow control enabled (Not currently supported)
295          */
296         PCI_ADDR(0, 0x18, 0, 0x84), 0x00009c05, 0x11110020,
297         /* LDTi Frequency/Revision Registers
298          * F0:0x88 i = 0,
299          * F0:0xA8 i = 1,
300          * F0:0xC8 i = 2,
301          * [ 4: 0] Minor Revision
302          *         Contains the HT Minor revision
303          * [ 7: 5] Major Revision
304          *         Contains the HT Major revision
305          * [11: 8] Link Frequency  (Takes effect the next time the link is reconnected)
306          *         0000 = 200Mhz
307          *         0001 = reserved
308          *         0010 = 400Mhz
309          *         0011 = reserved
310          *         0100 = 600Mhz
311          *         0101 = 800Mhz
312          *         0110 = 1000Mhz
313          *         0111 = reserved
314          *         1000 = reserved
315          *         1001 = reserved
316          *         1010 = reserved
317          *         1011 = reserved
318          *         1100 = reserved
319          *         1101 = reserved
320          *         1110 = reserved
321          *         1111 = 100 Mhz
322          * [15:12] Error (Not currently Implemented)
323          * [31:16] Indicates the frequency capabilities of the link
324          *         [16] = 1 encoding 0000 of freq supported
325          *         [17] = 1 encoding 0001 of freq supported
326          *         [18] = 1 encoding 0010 of freq supported
327          *         [19] = 1 encoding 0011 of freq supported
328          *         [20] = 1 encoding 0100 of freq supported
329          *         [21] = 1 encoding 0101 of freq supported
330          *         [22] = 1 encoding 0110 of freq supported
331          *         [23] = 1 encoding 0111 of freq supported
332          *         [24] = 1 encoding 1000 of freq supported
333          *         [25] = 1 encoding 1001 of freq supported
334          *         [26] = 1 encoding 1010 of freq supported
335          *         [27] = 1 encoding 1011 of freq supported
336          *         [28] = 1 encoding 1100 of freq supported
337          *         [29] = 1 encoding 1101 of freq supported
338          *         [30] = 1 encoding 1110 of freq supported
339          *         [31] = 1 encoding 1111 of freq supported
340          */
341         PCI_ADDR(0, 0x18, 0, 0x88), 0xfffff0ff, 0x00000200,
342         /* LDTi Feature Capability
343          * F0:0x8C i = 0,
344          * F0:0xAC i = 1,
345          * F0:0xCC i = 2,
346          */
347         /* LDTi Buffer Count Registers
348          * F0:0x90 i = 0,
349          * F0:0xB0 i = 1,
350          * F0:0xD0 i = 2,
351          */
352         /* LDTi Bus Number Registers
353          * F0:0x94 i = 0,
354          * F0:0xB4 i = 1,
355          * F0:0xD4 i = 2,
356          * For NonCoherent HT specifies the bus number downstream (behind the host bridge)
357          * [ 0: 7] Primary Bus Number
358          * [15: 8] Secondary Bus Number
359          * [23:15] Subordiante Bus Number
360          * [31:24] reserved
361          */
362         PCI_ADDR(0, 0x18, 0, 0x94), 0xff000000, 0x00ff0000,
363         /* LDTi Type Registers
364          * F0:0x98 i = 0,
365          * F0:0xB8 i = 1,
366          * F0:0xD8 i = 2,
367          */
368         /* Careful set limit registers before base registers which contain the enables */
369         /* DRAM Limit i Registers
370          * F1:0x44 i = 0
371          * F1:0x4C i = 1
372          * F1:0x54 i = 2
373          * F1:0x5C i = 3
374          * F1:0x64 i = 4
375          * F1:0x6C i = 5
376          * F1:0x74 i = 6
377          * F1:0x7C i = 7
378          * [ 2: 0] Destination Node ID
379          *         000 = Node 0
380          *         001 = Node 1
381          *         010 = Node 2
382          *         011 = Node 3
383          *         100 = Node 4
384          *         101 = Node 5
385          *         110 = Node 6
386          *         111 = Node 7
387          * [ 7: 3] Reserved
388          * [10: 8] Interleave select
389          *         specifies the values of A[14:12] to use with interleave enable.
390          * [15:11] Reserved
391          * [31:16] DRAM Limit Address i Bits 39-24
392          *         This field defines the upper address bits of a 40 bit  address
393          *         that define the end of the DRAM region.
394          */
395 #if MEMORY_1024MB
396         PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x003f0000,
397 #endif
398 #if MEMORY_512MB
399         PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x001f0000,
400 #endif
401         PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x00000001,
402         PCI_ADDR(0, 0x18, 1, 0x54), 0x0000f8f8, 0x00000002,
403         PCI_ADDR(0, 0x18, 1, 0x5C), 0x0000f8f8, 0x00000003,
404         PCI_ADDR(0, 0x18, 1, 0x64), 0x0000f8f8, 0x00000004,
405         PCI_ADDR(0, 0x18, 1, 0x6C), 0x0000f8f8, 0x00000005,
406         PCI_ADDR(0, 0x18, 1, 0x74), 0x0000f8f8, 0x00000006,
407         PCI_ADDR(0, 0x18, 1, 0x7C), 0x0000f8f8, 0x00000007,
408         /* DRAM Base i Registers
409          * F1:0x40 i = 0
410          * F1:0x48 i = 1
411          * F1:0x50 i = 2
412          * F1:0x58 i = 3
413          * F1:0x60 i = 4
414          * F1:0x68 i = 5
415          * F1:0x70 i = 6
416          * F1:0x78 i = 7
417          * [ 0: 0] Read Enable
418          *         0 = Reads Disabled
419          *         1 = Reads Enabled
420          * [ 1: 1] Write Enable
421          *         0 = Writes Disabled
422          *         1 = Writes Enabled
423          * [ 7: 2] Reserved
424          * [10: 8] Interleave Enable
425          *         000 = No interleave
426          *         001 = Interleave on A[12] (2 nodes)
427          *         010 = reserved
428          *         011 = Interleave on A[12] and A[14] (4 nodes)
429          *         100 = reserved
430          *         101 = reserved
431          *         110 = reserved
432          *         111 = Interleve on A[12] and A[13] and A[14] (8 nodes)
433          * [15:11] Reserved
434          * [13:16] DRAM Base Address i Bits 39-24
435          *         This field defines the upper address bits of a 40-bit address
436          *         that define the start of the DRAM region.
437          */
438         PCI_ADDR(0, 0x18, 1, 0x40), 0x0000f8fc, 0x00000003,
439 #if MEMORY_1024MB
440         PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00400000,
441         PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00400000,
442         PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00400000,
443         PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00400000,
444         PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00400000,
445         PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00400000,
446         PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00400000,
447 #endif
448 #if MEMORY_512MB
449         PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00200000,
450         PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00200000,
451         PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00200000,
452         PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00200000,
453         PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00200000,
454         PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00200000,
455         PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00200000,
456 #endif
457
458         /* Memory-Mapped I/O Limit i Registers
459          * F1:0x84 i = 0
460          * F1:0x8C i = 1
461          * F1:0x94 i = 2
462          * F1:0x9C i = 3
463          * F1:0xA4 i = 4
464          * F1:0xAC i = 5
465          * F1:0xB4 i = 6
466          * F1:0xBC i = 7
467          * [ 2: 0] Destination Node ID
468          *         000 = Node 0
469          *         001 = Node 1
470          *         010 = Node 2
471          *         011 = Node 3
472          *         100 = Node 4
473          *         101 = Node 5
474          *         110 = Node 6
475          *         111 = Node 7
476          * [ 3: 3] Reserved
477          * [ 5: 4] Destination Link ID
478          *         00 = Link 0
479          *         01 = Link 1
480          *         10 = Link 2
481          *         11 = Reserved
482          * [ 6: 6] Reserved
483          * [ 7: 7] Non-Posted
484          *         0 = CPU writes may be posted
485          *         1 = CPU writes must be non-posted
486          * [31: 8] Memory-Mapped I/O Limit Address i (39-16)
487          *         This field defines the upp adddress bits of a 40-bit address that
488          *         defines the end of a memory-mapped I/O region n
489          */
490         PCI_ADDR(0, 0x18, 1, 0x84), 0x00000048, 0x00e1ff00,
491         PCI_ADDR(0, 0x18, 1, 0x8C), 0x00000048, 0x00dfff00,
492         PCI_ADDR(0, 0x18, 1, 0x94), 0x00000048, 0x00e3ff00,
493         PCI_ADDR(0, 0x18, 1, 0x9C), 0x00000048, 0x00000000,
494         PCI_ADDR(0, 0x18, 1, 0xA4), 0x00000048, 0x00000000,
495         PCI_ADDR(0, 0x18, 1, 0xAC), 0x00000048, 0x00000000,
496         PCI_ADDR(0, 0x18, 1, 0xB4), 0x00000048, 0x00000b00,
497         PCI_ADDR(0, 0x18, 1, 0xBC), 0x00000048, 0x00fe0b00,
498
499         /* Memory-Mapped I/O Base i Registers
500          * F1:0x80 i = 0
501          * F1:0x88 i = 1
502          * F1:0x90 i = 2
503          * F1:0x98 i = 3
504          * F1:0xA0 i = 4
505          * F1:0xA8 i = 5
506          * F1:0xB0 i = 6
507          * F1:0xB8 i = 7
508          * [ 0: 0] Read Enable
509          *         0 = Reads disabled
510          *         1 = Reads Enabled
511          * [ 1: 1] Write Enable
512          *         0 = Writes disabled
513          *         1 = Writes Enabled
514          * [ 2: 2] Cpu Disable
515          *         0 = Cpu can use this I/O range
516          *         1 = Cpu requests do not use this I/O range
517          * [ 3: 3] Lock
518          *         0 = base/limit registers i are read/write
519          *         1 = base/limit registers i are read-only
520          * [ 7: 4] Reserved
521          * [31: 8] Memory-Mapped I/O Base Address i (39-16)
522          *         This field defines the upper address bits of a 40bit address
523          *         that defines the start of memory-mapped I/O region i
524          */
525         PCI_ADDR(0, 0x18, 1, 0x80), 0x000000f0, 0x00e00003,
526         PCI_ADDR(0, 0x18, 1, 0x88), 0x000000f0, 0x00d80003,
527         PCI_ADDR(0, 0x18, 1, 0x90), 0x000000f0, 0x00e20003,
528         PCI_ADDR(0, 0x18, 1, 0x98), 0x000000f0, 0x00000000,
529         PCI_ADDR(0, 0x18, 1, 0xA0), 0x000000f0, 0x00000000,
530         PCI_ADDR(0, 0x18, 1, 0xA8), 0x000000f0, 0x00000000,
531         PCI_ADDR(0, 0x18, 1, 0xB0), 0x000000f0, 0x00000a03,
532 #if MEMORY_1024MB
533         PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00400003,
534 #endif
535 #if MEMORY_512MB
536         PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00200003,
537 #endif
538
539         /* PCI I/O Limit i Registers
540          * F1:0xC4 i = 0
541          * F1:0xCC i = 1
542          * F1:0xD4 i = 2
543          * F1:0xDC i = 3
544          * [ 2: 0] Destination Node ID
545          *         000 = Node 0
546          *         001 = Node 1
547          *         010 = Node 2
548          *         011 = Node 3
549          *         100 = Node 4
550          *         101 = Node 5
551          *         110 = Node 6
552          *         111 = Node 7
553          * [ 3: 3] Reserved
554          * [ 5: 4] Destination Link ID
555          *         00 = Link 0
556          *         01 = Link 1
557          *         10 = Link 2
558          *         11 = reserved
559          * [11: 6] Reserved
560          * [24:12] PCI I/O Limit Address i
561          *         This field defines the end of PCI I/O region n
562          * [31:25] Reserved
563          */
564         PCI_ADDR(0, 0x18, 1, 0xC4), 0xFE000FC8, 0x0000d000,
565         PCI_ADDR(0, 0x18, 1, 0xCC), 0xFE000FC8, 0x000ff000,
566         PCI_ADDR(0, 0x18, 1, 0xD4), 0xFE000FC8, 0x00000000,
567         PCI_ADDR(0, 0x18, 1, 0xDC), 0xFE000FC8, 0x00000000,
568
569         /* PCI I/O Base i Registers
570          * F1:0xC0 i = 0
571          * F1:0xC8 i = 1
572          * F1:0xD0 i = 2
573          * F1:0xD8 i = 3
574          * [ 0: 0] Read Enable
575          *         0 = Reads Disabled
576          *         1 = Reads Enabled
577          * [ 1: 1] Write Enable
578          *         0 = Writes Disabled
579          *         1 = Writes Enabled
580          * [ 3: 2] Reserved
581          * [ 4: 4] VGA Enable
582          *         0 = VGA matches Disabled
583          *         1 = matches all address < 64K and where A[9:0] is in the
584          *             range 3B0-3BB or 3C0-3DF independen of the base & limit registers
585          * [ 5: 5] ISA Enable
586          *         0 = ISA matches Disabled
587          *         1 = Blocks address < 64K and in the last 768 bytes of eack 1K block
588          *             from matching agains this base/limit pair
589          * [11: 6] Reserved
590          * [24:12] PCI I/O Base i
591          *         This field defines the start of PCI I/O region n
592          * [31:25] Reserved
593          */
594         PCI_ADDR(0, 0x18, 1, 0xC0), 0xFE000FCC, 0x0000d003,
595         PCI_ADDR(0, 0x18, 1, 0xC8), 0xFE000FCC, 0x00001013,
596         PCI_ADDR(0, 0x18, 1, 0xD0), 0xFE000FCC, 0x00000000,
597         PCI_ADDR(0, 0x18, 1, 0xD8), 0xFE000FCC, 0x00000000,
598
599         /* Config Base and Limit i Registers
600          * F1:0xE0 i = 0
601          * F1:0xE4 i = 1
602          * F1:0xE8 i = 2
603          * F1:0xEC i = 3
604          * [ 0: 0] Read Enable
605          *         0 = Reads Disabled
606          *         1 = Reads Enabled
607          * [ 1: 1] Write Enable
608          *         0 = Writes Disabled
609          *         1 = Writes Enabled
610          * [ 2: 2] Device Number Compare Enable
611          *         0 = The ranges are based on bus number
612          *         1 = The ranges are ranges of devices on bus 0
613          * [ 3: 3] Reserved
614          * [ 6: 4] Destination Node
615          *         000 = Node 0
616          *         001 = Node 1
617          *         010 = Node 2
618          *         011 = Node 3
619          *         100 = Node 4
620          *         101 = Node 5
621          *         110 = Node 6
622          *         111 = Node 7
623          * [ 7: 7] Reserved
624          * [ 9: 8] Destination Link
625          *         00 = Link 0
626          *         01 = Link 1
627          *         10 = Link 2
628          *         11 - Reserved
629          * [15:10] Reserved
630          * [23:16] Bus Number Base i
631          *         This field defines the lowest bus number in configuration region i
632          * [31:24] Bus Number Limit i
633          *         This field defines the highest bus number in configuration regin i
634          */
635         PCI_ADDR(0, 0x18, 1, 0xE0), 0x0000FC88, 0xff000003,
636         PCI_ADDR(0, 0x18, 1, 0xE4), 0x0000FC88, 0x00000000,
637         PCI_ADDR(0, 0x18, 1, 0xE8), 0x0000FC88, 0x00000000,
638         PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
639 #endif
640         };
641         int i;
642         int max;
643         print_debug("setting up coherent ht domain....\r\n");
644         max = sizeof(register_values)/sizeof(register_values[0]);
645         for(i = 0; i < max; i += 3) {
646                 unsigned long reg;
647 #if 1
648                 print_debug_hex32(register_values[i]);
649                 print_debug(" <-");
650                 print_debug_hex32(register_values[i+2]);
651                 print_debug("\r\n");
652 #endif
653 #if 0
654                 reg = pci_read_config32(register_values[i]);
655                 reg &= register_values[i+1];
656                 reg |= register_values[i+2] & ~register_values[i+1];
657                 pci_write_config32(register_values[i], reg);
658 #endif
659         }
660         print_debug("done.\r\n");
661 }
662
663 static void main(void)
664 {
665         static const char msg[] = "hello world\r\n";
666 #if 0
667         write(STDOUT_FILENO, msg, sizeof(msg));
668 #endif
669 #if 1
670         setup_coherent_ht_domain();
671 #endif
672         _exit(0);
673 }