diff options
-rw-r--r-- | arch/ia64/sn/kernel/io_init.c | 2 | ||||
-rw-r--r-- | arch/ia64/sn/pci/Makefile | 2 | ||||
-rw-r--r-- | arch/ia64/sn/pci/tioca_provider.c | 668 | ||||
-rw-r--r-- | include/asm-ia64/sn/pcibus_provider_defs.h | 3 | ||||
-rw-r--r-- | include/asm-ia64/sn/tioca.h | 596 | ||||
-rw-r--r-- | include/asm-ia64/sn/tioca_provider.h | 206 |
6 files changed, 1475 insertions, 2 deletions
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c index 9f9d0464f72c..18160a06a8c9 100644 --- a/arch/ia64/sn/kernel/io_init.c +++ b/arch/ia64/sn/kernel/io_init.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "xtalk/hubdev.h" | 19 | #include "xtalk/hubdev.h" |
20 | #include <asm/sn/io.h> | 20 | #include <asm/sn/io.h> |
21 | #include <asm/sn/simulator.h> | 21 | #include <asm/sn/simulator.h> |
22 | #include <asm/sn/tioca_provider.h> | ||
22 | 23 | ||
23 | char master_baseio_wid; | 24 | char master_baseio_wid; |
24 | nasid_t master_nasid = INVALID_NASID; /* Partition Master */ | 25 | nasid_t master_nasid = INVALID_NASID; /* Partition Master */ |
@@ -393,6 +394,7 @@ static int __init sn_pci_init(void) | |||
393 | sn_pci_provider[i] = &sn_pci_default_provider; | 394 | sn_pci_provider[i] = &sn_pci_default_provider; |
394 | 395 | ||
395 | pcibr_init_provider(); | 396 | pcibr_init_provider(); |
397 | tioca_init_provider(); | ||
396 | 398 | ||
397 | /* | 399 | /* |
398 | * This is needed to avoid bounce limit checks in the blk layer | 400 | * This is needed to avoid bounce limit checks in the blk layer |
diff --git a/arch/ia64/sn/pci/Makefile b/arch/ia64/sn/pci/Makefile index b5dca0097a8e..2f915bce25f9 100644 --- a/arch/ia64/sn/pci/Makefile +++ b/arch/ia64/sn/pci/Makefile | |||
@@ -7,4 +7,4 @@ | |||
7 | # | 7 | # |
8 | # Makefile for the sn pci general routines. | 8 | # Makefile for the sn pci general routines. |
9 | 9 | ||
10 | obj-y := pci_dma.o pcibr/ | 10 | obj-y := pci_dma.o tioca_provider.o pcibr/ |
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c new file mode 100644 index 000000000000..2234d61cdd4b --- /dev/null +++ b/arch/ia64/sn/pci/tioca_provider.c | |||
@@ -0,0 +1,668 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2003-2005 Silicon Graphics, Inc. All Rights Reserved. | ||
7 | */ | ||
8 | |||
9 | #include <linux/types.h> | ||
10 | #include <linux/interrupt.h> | ||
11 | #include <linux/pci.h> | ||
12 | #include <asm/sn/sn_sal.h> | ||
13 | #include <asm/sn/addrs.h> | ||
14 | #include <asm/sn/pcidev.h> | ||
15 | #include <asm/sn/pcibus_provider_defs.h> | ||
16 | #include <asm/sn/tioca_provider.h> | ||
17 | |||
18 | uint32_t tioca_gart_found; | ||
19 | EXPORT_SYMBOL(tioca_gart_found); /* used by agp-sgi */ | ||
20 | |||
21 | LIST_HEAD(tioca_list); | ||
22 | EXPORT_SYMBOL(tioca_list); /* used by agp-sgi */ | ||
23 | |||
24 | static int tioca_gart_init(struct tioca_kernel *); | ||
25 | |||
26 | /** | ||
27 | * tioca_gart_init - Initialize SGI TIOCA GART | ||
28 | * @tioca_common: ptr to common prom/kernel struct identifying the | ||
29 | * | ||
30 | * If the indicated tioca has devices present, initialize its associated | ||
31 | * GART MMR's and kernel memory. | ||
32 | */ | ||
33 | static int | ||
34 | tioca_gart_init(struct tioca_kernel *tioca_kern) | ||
35 | { | ||
36 | uint64_t ap_reg; | ||
37 | uint64_t offset; | ||
38 | struct page *tmp; | ||
39 | struct tioca_common *tioca_common; | ||
40 | volatile struct tioca *ca_base; | ||
41 | |||
42 | tioca_common = tioca_kern->ca_common; | ||
43 | ca_base = (struct tioca *)tioca_common->ca_common.bs_base; | ||
44 | |||
45 | if (list_empty(tioca_kern->ca_devices)) | ||
46 | return 0; | ||
47 | |||
48 | ap_reg = 0; | ||
49 | |||
50 | /* | ||
51 | * Validate aperature size | ||
52 | */ | ||
53 | |||
54 | switch (CA_APERATURE_SIZE >> 20) { | ||
55 | case 4: | ||
56 | ap_reg |= (0x3ff << CA_GART_AP_SIZE_SHFT); /* 4MB */ | ||
57 | break; | ||
58 | case 8: | ||
59 | ap_reg |= (0x3fe << CA_GART_AP_SIZE_SHFT); /* 8MB */ | ||
60 | break; | ||
61 | case 16: | ||
62 | ap_reg |= (0x3fc << CA_GART_AP_SIZE_SHFT); /* 16MB */ | ||
63 | break; | ||
64 | case 32: | ||
65 | ap_reg |= (0x3f8 << CA_GART_AP_SIZE_SHFT); /* 32 MB */ | ||
66 | break; | ||
67 | case 64: | ||
68 | ap_reg |= (0x3f0 << CA_GART_AP_SIZE_SHFT); /* 64 MB */ | ||
69 | break; | ||
70 | case 128: | ||
71 | ap_reg |= (0x3e0 << CA_GART_AP_SIZE_SHFT); /* 128 MB */ | ||
72 | break; | ||
73 | case 256: | ||
74 | ap_reg |= (0x3c0 << CA_GART_AP_SIZE_SHFT); /* 256 MB */ | ||
75 | break; | ||
76 | case 512: | ||
77 | ap_reg |= (0x380 << CA_GART_AP_SIZE_SHFT); /* 512 MB */ | ||
78 | break; | ||
79 | case 1024: | ||
80 | ap_reg |= (0x300 << CA_GART_AP_SIZE_SHFT); /* 1GB */ | ||
81 | break; | ||
82 | case 2048: | ||
83 | ap_reg |= (0x200 << CA_GART_AP_SIZE_SHFT); /* 2GB */ | ||
84 | break; | ||
85 | case 4096: | ||
86 | ap_reg |= (0x000 << CA_GART_AP_SIZE_SHFT); /* 4 GB */ | ||
87 | break; | ||
88 | default: | ||
89 | printk(KERN_ERR "%s: Invalid CA_APERATURE_SIZE " | ||
90 | "0x%lx\n", __FUNCTION__, (ulong) CA_APERATURE_SIZE); | ||
91 | return -1; | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Set up other aperature parameters | ||
96 | */ | ||
97 | |||
98 | if (PAGE_SIZE >= 16384) { | ||
99 | tioca_kern->ca_ap_pagesize = 16384; | ||
100 | ap_reg |= CA_GART_PAGE_SIZE; | ||
101 | } else { | ||
102 | tioca_kern->ca_ap_pagesize = 4096; | ||
103 | } | ||
104 | |||
105 | tioca_kern->ca_ap_size = CA_APERATURE_SIZE; | ||
106 | tioca_kern->ca_ap_bus_base = CA_APERATURE_BASE; | ||
107 | tioca_kern->ca_gart_entries = | ||
108 | tioca_kern->ca_ap_size / tioca_kern->ca_ap_pagesize; | ||
109 | |||
110 | ap_reg |= (CA_GART_AP_ENB_AGP | CA_GART_AP_ENB_PCI); | ||
111 | ap_reg |= tioca_kern->ca_ap_bus_base; | ||
112 | |||
113 | /* | ||
114 | * Allocate and set up the GART | ||
115 | */ | ||
116 | |||
117 | tioca_kern->ca_gart_size = tioca_kern->ca_gart_entries * sizeof(u64); | ||
118 | tmp = | ||
119 | alloc_pages_node(tioca_kern->ca_closest_node, | ||
120 | GFP_KERNEL | __GFP_ZERO, | ||
121 | get_order(tioca_kern->ca_gart_size)); | ||
122 | |||
123 | if (!tmp) { | ||
124 | printk(KERN_ERR "%s: Could not allocate " | ||
125 | "%lu bytes (order %d) for GART\n", | ||
126 | __FUNCTION__, | ||
127 | tioca_kern->ca_gart_size, | ||
128 | get_order(tioca_kern->ca_gart_size)); | ||
129 | return -ENOMEM; | ||
130 | } | ||
131 | |||
132 | tioca_kern->ca_gart = page_address(tmp); | ||
133 | tioca_kern->ca_gart_coretalk_addr = | ||
134 | PHYS_TO_TIODMA(virt_to_phys(tioca_kern->ca_gart)); | ||
135 | |||
136 | /* | ||
137 | * Compute PCI/AGP convenience fields | ||
138 | */ | ||
139 | |||
140 | offset = CA_PCI32_MAPPED_BASE - CA_APERATURE_BASE; | ||
141 | tioca_kern->ca_pciap_base = CA_PCI32_MAPPED_BASE; | ||
142 | tioca_kern->ca_pciap_size = CA_PCI32_MAPPED_SIZE; | ||
143 | tioca_kern->ca_pcigart_start = offset / tioca_kern->ca_ap_pagesize; | ||
144 | tioca_kern->ca_pcigart_base = | ||
145 | tioca_kern->ca_gart_coretalk_addr + offset; | ||
146 | tioca_kern->ca_pcigart = | ||
147 | &tioca_kern->ca_gart[tioca_kern->ca_pcigart_start]; | ||
148 | tioca_kern->ca_pcigart_entries = | ||
149 | tioca_kern->ca_pciap_size / tioca_kern->ca_ap_pagesize; | ||
150 | tioca_kern->ca_pcigart_pagemap = | ||
151 | kcalloc(1, tioca_kern->ca_pcigart_entries / 8, GFP_KERNEL); | ||
152 | if (!tioca_kern->ca_pcigart_pagemap) { | ||
153 | free_pages((unsigned long)tioca_kern->ca_gart, | ||
154 | get_order(tioca_kern->ca_gart_size)); | ||
155 | return -1; | ||
156 | } | ||
157 | |||
158 | offset = CA_AGP_MAPPED_BASE - CA_APERATURE_BASE; | ||
159 | tioca_kern->ca_gfxap_base = CA_AGP_MAPPED_BASE; | ||
160 | tioca_kern->ca_gfxap_size = CA_AGP_MAPPED_SIZE; | ||
161 | tioca_kern->ca_gfxgart_start = offset / tioca_kern->ca_ap_pagesize; | ||
162 | tioca_kern->ca_gfxgart_base = | ||
163 | tioca_kern->ca_gart_coretalk_addr + offset; | ||
164 | tioca_kern->ca_gfxgart = | ||
165 | &tioca_kern->ca_gart[tioca_kern->ca_gfxgart_start]; | ||
166 | tioca_kern->ca_gfxgart_entries = | ||
167 | tioca_kern->ca_gfxap_size / tioca_kern->ca_ap_pagesize; | ||
168 | |||
169 | /* | ||
170 | * various control settings: | ||
171 | * use agp op-combining | ||
172 | * use GET semantics to fetch memory | ||
173 | * participate in coherency domain | ||
174 | * prefetch TLB entries | ||
175 | */ | ||
176 | |||
177 | ca_base->ca_control1 |= CA_AGPDMA_OP_ENB_COMBDELAY; /* PV895469 ? */ | ||
178 | ca_base->ca_control2 &= ~(CA_GART_MEM_PARAM); | ||
179 | ca_base->ca_control2 |= (0x2ull << CA_GART_MEM_PARAM_SHFT); | ||
180 | tioca_kern->ca_gart_iscoherent = 1; | ||
181 | ca_base->ca_control2 |= | ||
182 | (CA_GART_WR_PREFETCH_ENB | CA_GART_RD_PREFETCH_ENB); | ||
183 | |||
184 | /* | ||
185 | * Unmask GART fetch error interrupts. Clear residual errors first. | ||
186 | */ | ||
187 | |||
188 | ca_base->ca_int_status_alias = CA_GART_FETCH_ERR; | ||
189 | ca_base->ca_mult_error_alias = CA_GART_FETCH_ERR; | ||
190 | ca_base->ca_int_mask &= ~CA_GART_FETCH_ERR; | ||
191 | |||
192 | /* | ||
193 | * Program the aperature and gart registers in TIOCA | ||
194 | */ | ||
195 | |||
196 | ca_base->ca_gart_aperature = ap_reg; | ||
197 | ca_base->ca_gart_ptr_table = tioca_kern->ca_gart_coretalk_addr | 1; | ||
198 | |||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * tioca_fastwrite_enable - enable AGP FW for a tioca and its functions | ||
204 | * @tioca_kernel: structure representing the CA | ||
205 | * | ||
206 | * Given a CA, scan all attached functions making sure they all support | ||
207 | * FastWrite. If so, enable FastWrite for all functions and the CA itself. | ||
208 | */ | ||
209 | |||
210 | void | ||
211 | tioca_fastwrite_enable(struct tioca_kernel *tioca_kern) | ||
212 | { | ||
213 | int cap_ptr; | ||
214 | uint64_t ca_control1; | ||
215 | uint32_t reg; | ||
216 | struct tioca *tioca_base; | ||
217 | struct pci_dev *pdev; | ||
218 | struct tioca_common *common; | ||
219 | |||
220 | common = tioca_kern->ca_common; | ||
221 | |||
222 | /* | ||
223 | * Scan all vga controllers on this bus making sure they all | ||
224 | * suport FW. If not, return. | ||
225 | */ | ||
226 | |||
227 | list_for_each_entry(pdev, tioca_kern->ca_devices, bus_list) { | ||
228 | if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8)) | ||
229 | continue; | ||
230 | |||
231 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); | ||
232 | if (!cap_ptr) | ||
233 | return; /* no AGP CAP means no FW */ | ||
234 | |||
235 | pci_read_config_dword(pdev, cap_ptr + PCI_AGP_STATUS, ®); | ||
236 | if (!(reg & PCI_AGP_STATUS_FW)) | ||
237 | return; /* function doesn't support FW */ | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * Set fw for all vga fn's | ||
242 | */ | ||
243 | |||
244 | list_for_each_entry(pdev, tioca_kern->ca_devices, bus_list) { | ||
245 | if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8)) | ||
246 | continue; | ||
247 | |||
248 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); | ||
249 | pci_read_config_dword(pdev, cap_ptr + PCI_AGP_COMMAND, ®); | ||
250 | reg |= PCI_AGP_COMMAND_FW; | ||
251 | pci_write_config_dword(pdev, cap_ptr + PCI_AGP_COMMAND, reg); | ||
252 | } | ||
253 | |||
254 | /* | ||
255 | * Set ca's fw to match | ||
256 | */ | ||
257 | |||
258 | tioca_base = (struct tioca *)common->ca_common.bs_base; | ||
259 | ca_control1 = tioca_base->ca_control1; | ||
260 | ca_control1 |= CA_AGP_FW_ENABLE; | ||
261 | tioca_base->ca_control1 = ca_control1; | ||
262 | } | ||
263 | |||
264 | EXPORT_SYMBOL(tioca_fastwrite_enable); /* used by agp-sgi */ | ||
265 | |||
266 | /** | ||
267 | * tioca_dma_d64 - create a DMA mapping using 64-bit direct mode | ||
268 | * @paddr: system physical address | ||
269 | * | ||
270 | * Map @paddr into 64-bit CA bus space. No device context is necessary. | ||
271 | * Bits 53:0 come from the coretalk address. We just need to mask in the | ||
272 | * following optional bits of the 64-bit pci address: | ||
273 | * | ||
274 | * 63:60 - Coretalk Packet Type - 0x1 for Mem Get/Put (coherent) | ||
275 | * 0x2 for PIO (non-coherent) | ||
276 | * We will always use 0x1 | ||
277 | * 55:55 - Swap bytes Currently unused | ||
278 | */ | ||
279 | static uint64_t | ||
280 | tioca_dma_d64(unsigned long paddr) | ||
281 | { | ||
282 | dma_addr_t bus_addr; | ||
283 | |||
284 | bus_addr = PHYS_TO_TIODMA(paddr); | ||
285 | |||
286 | BUG_ON(!bus_addr); | ||
287 | BUG_ON(bus_addr >> 54); | ||
288 | |||
289 | /* Set upper nibble to Cache Coherent Memory op */ | ||
290 | bus_addr |= (1UL << 60); | ||
291 | |||
292 | return bus_addr; | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * tioca_dma_d48 - create a DMA mapping using 48-bit direct mode | ||
297 | * @pdev: linux pci_dev representing the function | ||
298 | * @paddr: system physical address | ||
299 | * | ||
300 | * Map @paddr into 64-bit bus space of the CA associated with @pcidev_info. | ||
301 | * | ||
302 | * The CA agp 48 bit direct address falls out as follows: | ||
303 | * | ||
304 | * When direct mapping AGP addresses, the 48 bit AGP address is | ||
305 | * constructed as follows: | ||
306 | * | ||
307 | * [47:40] - Low 8 bits of the page Node ID extracted from coretalk | ||
308 | * address [47:40]. The upper 8 node bits are fixed | ||
309 | * and come from the xxx register bits [5:0] | ||
310 | * [39:38] - Chiplet ID extracted from coretalk address [39:38] | ||
311 | * [37:00] - node offset extracted from coretalk address [37:00] | ||
312 | * | ||
313 | * Since the node id in general will be non-zero, and the chiplet id | ||
314 | * will always be non-zero, it follows that the device must support | ||
315 | * a dma mask of at least 0xffffffffff (40 bits) to target node 0 | ||
316 | * and in general should be 0xffffffffffff (48 bits) to target nodes | ||
317 | * up to 255. Nodes above 255 need the support of the xxx register, | ||
318 | * and so a given CA can only directly target nodes in the range | ||
319 | * xxx - xxx+255. | ||
320 | */ | ||
321 | static uint64_t | ||
322 | tioca_dma_d48(struct pci_dev *pdev, uint64_t paddr) | ||
323 | { | ||
324 | struct tioca_common *tioca_common; | ||
325 | struct tioca *ca_base; | ||
326 | uint64_t ct_addr; | ||
327 | dma_addr_t bus_addr; | ||
328 | uint32_t node_upper; | ||
329 | uint64_t agp_dma_extn; | ||
330 | struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev); | ||
331 | |||
332 | tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info; | ||
333 | ca_base = (struct tioca *)tioca_common->ca_common.bs_base; | ||
334 | |||
335 | ct_addr = PHYS_TO_TIODMA(paddr); | ||
336 | if (!ct_addr) | ||
337 | return 0; | ||
338 | |||
339 | bus_addr = (dma_addr_t) (ct_addr & 0xffffffffffff); | ||
340 | node_upper = ct_addr >> 48; | ||
341 | |||
342 | if (node_upper > 64) { | ||
343 | printk(KERN_ERR "%s: coretalk addr 0x%p node id out " | ||
344 | "of range\n", __FUNCTION__, (void *)ct_addr); | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | agp_dma_extn = ca_base->ca_agp_dma_addr_extn; | ||
349 | if (node_upper != (agp_dma_extn >> CA_AGP_DMA_NODE_ID_SHFT)) { | ||
350 | printk(KERN_ERR "%s: coretalk upper node (%u) " | ||
351 | "mismatch with ca_agp_dma_addr_extn (%lu)\n", | ||
352 | __FUNCTION__, | ||
353 | node_upper, (agp_dma_extn >> CA_AGP_DMA_NODE_ID_SHFT)); | ||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | return bus_addr; | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * tioca_dma_mapped - create a DMA mapping using a CA GART | ||
362 | * @pdev: linux pci_dev representing the function | ||
363 | * @paddr: host physical address to map | ||
364 | * @req_size: len (bytes) to map | ||
365 | * | ||
366 | * Map @paddr into CA address space using the GART mechanism. The mapped | ||
367 | * dma_addr_t is guarenteed to be contiguous in CA bus space. | ||
368 | */ | ||
369 | static dma_addr_t | ||
370 | tioca_dma_mapped(struct pci_dev *pdev, uint64_t paddr, size_t req_size) | ||
371 | { | ||
372 | int i, ps, ps_shift, entry, entries, mapsize, last_entry; | ||
373 | uint64_t xio_addr, end_xio_addr; | ||
374 | struct tioca_common *tioca_common; | ||
375 | struct tioca_kernel *tioca_kern; | ||
376 | dma_addr_t bus_addr = 0; | ||
377 | struct tioca_dmamap *ca_dmamap; | ||
378 | void *map; | ||
379 | unsigned long flags; | ||
380 | struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);; | ||
381 | |||
382 | tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info; | ||
383 | tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private; | ||
384 | |||
385 | xio_addr = PHYS_TO_TIODMA(paddr); | ||
386 | if (!xio_addr) | ||
387 | return 0; | ||
388 | |||
389 | spin_lock_irqsave(&tioca_kern->ca_lock, flags); | ||
390 | |||
391 | /* | ||
392 | * allocate a map struct | ||
393 | */ | ||
394 | |||
395 | ca_dmamap = kcalloc(1, sizeof(struct tioca_dmamap), GFP_ATOMIC); | ||
396 | if (!ca_dmamap) | ||
397 | goto map_return; | ||
398 | |||
399 | /* | ||
400 | * Locate free entries that can hold req_size. Account for | ||
401 | * unaligned start/length when allocating. | ||
402 | */ | ||
403 | |||
404 | ps = tioca_kern->ca_ap_pagesize; /* will be power of 2 */ | ||
405 | ps_shift = ffs(ps) - 1; | ||
406 | end_xio_addr = xio_addr + req_size - 1; | ||
407 | |||
408 | entries = (end_xio_addr >> ps_shift) - (xio_addr >> ps_shift) + 1; | ||
409 | |||
410 | map = tioca_kern->ca_pcigart_pagemap; | ||
411 | mapsize = tioca_kern->ca_pcigart_entries; | ||
412 | |||
413 | entry = find_first_zero_bit(map, mapsize); | ||
414 | while (entry < mapsize) { | ||
415 | last_entry = find_next_bit(map, mapsize, entry); | ||
416 | |||
417 | if (last_entry - entry >= entries) | ||
418 | break; | ||
419 | |||
420 | entry = find_next_zero_bit(map, mapsize, last_entry); | ||
421 | } | ||
422 | |||
423 | if (entry > mapsize) | ||
424 | goto map_return; | ||
425 | |||
426 | for (i = 0; i < entries; i++) | ||
427 | set_bit(entry + i, map); | ||
428 | |||
429 | bus_addr = tioca_kern->ca_pciap_base + (entry * ps); | ||
430 | |||
431 | ca_dmamap->cad_dma_addr = bus_addr; | ||
432 | ca_dmamap->cad_gart_size = entries; | ||
433 | ca_dmamap->cad_gart_entry = entry; | ||
434 | list_add(&ca_dmamap->cad_list, &tioca_kern->ca_list); | ||
435 | |||
436 | if (xio_addr % ps) { | ||
437 | tioca_kern->ca_pcigart[entry] = tioca_paddr_to_gart(xio_addr); | ||
438 | bus_addr += xio_addr & (ps - 1); | ||
439 | xio_addr &= ~(ps - 1); | ||
440 | xio_addr += ps; | ||
441 | entry++; | ||
442 | } | ||
443 | |||
444 | while (xio_addr < end_xio_addr) { | ||
445 | tioca_kern->ca_pcigart[entry] = tioca_paddr_to_gart(xio_addr); | ||
446 | xio_addr += ps; | ||
447 | entry++; | ||
448 | } | ||
449 | |||
450 | tioca_tlbflush(tioca_kern); | ||
451 | |||
452 | map_return: | ||
453 | spin_unlock_irqrestore(&tioca_kern->ca_lock, flags); | ||
454 | return bus_addr; | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * tioca_dma_unmap - release CA mapping resources | ||
459 | * @pdev: linux pci_dev representing the function | ||
460 | * @bus_addr: bus address returned by an earlier tioca_dma_map | ||
461 | * @dir: mapping direction (unused) | ||
462 | * | ||
463 | * Locate mapping resources associated with @bus_addr and release them. | ||
464 | * For mappings created using the direct modes (64 or 48) there are no | ||
465 | * resources to release. | ||
466 | */ | ||
467 | void | ||
468 | tioca_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr, int dir) | ||
469 | { | ||
470 | int i, entry; | ||
471 | struct tioca_common *tioca_common; | ||
472 | struct tioca_kernel *tioca_kern; | ||
473 | struct tioca_dmamap *map; | ||
474 | struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev); | ||
475 | unsigned long flags; | ||
476 | |||
477 | tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info; | ||
478 | tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private; | ||
479 | |||
480 | /* return straight away if this isn't be a mapped address */ | ||
481 | |||
482 | if (bus_addr < tioca_kern->ca_pciap_base || | ||
483 | bus_addr >= (tioca_kern->ca_pciap_base + tioca_kern->ca_pciap_size)) | ||
484 | return; | ||
485 | |||
486 | spin_lock_irqsave(&tioca_kern->ca_lock, flags); | ||
487 | |||
488 | list_for_each_entry(map, &tioca_kern->ca_dmamaps, cad_list) | ||
489 | if (map->cad_dma_addr == bus_addr) | ||
490 | break; | ||
491 | |||
492 | BUG_ON(map == NULL); | ||
493 | |||
494 | entry = map->cad_gart_entry; | ||
495 | |||
496 | for (i = 0; i < map->cad_gart_size; i++, entry++) { | ||
497 | clear_bit(entry, tioca_kern->ca_pcigart_pagemap); | ||
498 | tioca_kern->ca_pcigart[entry] = 0; | ||
499 | } | ||
500 | tioca_tlbflush(tioca_kern); | ||
501 | |||
502 | list_del(&map->cad_list); | ||
503 | spin_unlock_irqrestore(&tioca_kern->ca_lock, flags); | ||
504 | kfree(map); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * tioca_dma_map - map pages for PCI DMA | ||
509 | * @pdev: linux pci_dev representing the function | ||
510 | * @paddr: host physical address to map | ||
511 | * @byte_count: bytes to map | ||
512 | * | ||
513 | * This is the main wrapper for mapping host physical pages to CA PCI space. | ||
514 | * The mapping mode used is based on the devices dma_mask. As a last resort | ||
515 | * use the GART mapped mode. | ||
516 | */ | ||
517 | uint64_t | ||
518 | tioca_dma_map(struct pci_dev *pdev, uint64_t paddr, size_t byte_count) | ||
519 | { | ||
520 | uint64_t mapaddr; | ||
521 | |||
522 | /* | ||
523 | * If card is 64 or 48 bit addresable, use a direct mapping. 32 | ||
524 | * bit direct is so restrictive w.r.t. where the memory resides that | ||
525 | * we don't use it even though CA has some support. | ||
526 | */ | ||
527 | |||
528 | if (pdev->dma_mask == ~0UL) | ||
529 | mapaddr = tioca_dma_d64(paddr); | ||
530 | else if (pdev->dma_mask == 0xffffffffffffUL) | ||
531 | mapaddr = tioca_dma_d48(pdev, paddr); | ||
532 | else | ||
533 | mapaddr = 0; | ||
534 | |||
535 | /* Last resort ... use PCI portion of CA GART */ | ||
536 | |||
537 | if (mapaddr == 0) | ||
538 | mapaddr = tioca_dma_mapped(pdev, paddr, byte_count); | ||
539 | |||
540 | return mapaddr; | ||
541 | } | ||
542 | |||
543 | /** | ||
544 | * tioca_error_intr_handler - SGI TIO CA error interrupt handler | ||
545 | * @irq: unused | ||
546 | * @arg: pointer to tioca_common struct for the given CA | ||
547 | * @pt: unused | ||
548 | * | ||
549 | * Handle a CA error interrupt. Simply a wrapper around a SAL call which | ||
550 | * defers processing to the SGI prom. | ||
551 | */ | ||
552 | static irqreturn_t | ||
553 | tioca_error_intr_handler(int irq, void *arg, struct pt_regs *pt) | ||
554 | { | ||
555 | struct tioca_common *soft = arg; | ||
556 | struct ia64_sal_retval ret_stuff; | ||
557 | uint64_t segment; | ||
558 | uint64_t busnum; | ||
559 | ret_stuff.status = 0; | ||
560 | ret_stuff.v0 = 0; | ||
561 | |||
562 | segment = 0; | ||
563 | busnum = soft->ca_common.bs_persist_busnum; | ||
564 | |||
565 | SAL_CALL_NOLOCK(ret_stuff, | ||
566 | (u64) SN_SAL_IOIF_ERROR_INTERRUPT, | ||
567 | segment, busnum, 0, 0, 0, 0, 0); | ||
568 | |||
569 | return IRQ_HANDLED; | ||
570 | } | ||
571 | |||
572 | /** | ||
573 | * tioca_bus_fixup - perform final PCI fixup for a TIO CA bus | ||
574 | * @prom_bussoft: Common prom/kernel struct representing the bus | ||
575 | * | ||
576 | * Replicates the tioca_common pointed to by @prom_bussoft in kernel | ||
577 | * space. Allocates and initializes a kernel-only area for a given CA, | ||
578 | * and sets up an irq for handling CA error interrupts. | ||
579 | * | ||
580 | * On successful setup, returns the kernel version of tioca_common back to | ||
581 | * the caller. | ||
582 | */ | ||
583 | void * | ||
584 | tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft) | ||
585 | { | ||
586 | struct tioca_common *tioca_common; | ||
587 | struct tioca_kernel *tioca_kern; | ||
588 | struct pci_bus *bus; | ||
589 | |||
590 | /* sanity check prom rev */ | ||
591 | |||
592 | if (sn_sal_rev_major() < 4 || | ||
593 | (sn_sal_rev_major() == 4 && sn_sal_rev_minor() < 6)) { | ||
594 | printk | ||
595 | (KERN_ERR "%s: SGI prom rev 4.06 or greater required " | ||
596 | "for tioca support\n", __FUNCTION__); | ||
597 | return NULL; | ||
598 | } | ||
599 | |||
600 | /* | ||
601 | * Allocate kernel bus soft and copy from prom. | ||
602 | */ | ||
603 | |||
604 | tioca_common = kcalloc(1, sizeof(struct tioca_common), GFP_KERNEL); | ||
605 | if (!tioca_common) | ||
606 | return NULL; | ||
607 | |||
608 | memcpy(tioca_common, prom_bussoft, sizeof(struct tioca_common)); | ||
609 | tioca_common->ca_common.bs_base |= __IA64_UNCACHED_OFFSET; | ||
610 | |||
611 | /* init kernel-private area */ | ||
612 | |||
613 | tioca_kern = kcalloc(1, sizeof(struct tioca_kernel), GFP_KERNEL); | ||
614 | if (!tioca_kern) { | ||
615 | kfree(tioca_common); | ||
616 | return NULL; | ||
617 | } | ||
618 | |||
619 | tioca_kern->ca_common = tioca_common; | ||
620 | spin_lock_init(&tioca_kern->ca_lock); | ||
621 | INIT_LIST_HEAD(&tioca_kern->ca_dmamaps); | ||
622 | tioca_kern->ca_closest_node = | ||
623 | nasid_to_cnodeid(tioca_common->ca_closest_nasid); | ||
624 | tioca_common->ca_kernel_private = (uint64_t) tioca_kern; | ||
625 | |||
626 | bus = pci_find_bus(0, tioca_common->ca_common.bs_persist_busnum); | ||
627 | BUG_ON(!bus); | ||
628 | tioca_kern->ca_devices = &bus->devices; | ||
629 | |||
630 | /* init GART */ | ||
631 | |||
632 | if (tioca_gart_init(tioca_kern) < 0) { | ||
633 | kfree(tioca_kern); | ||
634 | kfree(tioca_common); | ||
635 | return NULL; | ||
636 | } | ||
637 | |||
638 | tioca_gart_found++; | ||
639 | list_add(&tioca_kern->ca_list, &tioca_list); | ||
640 | |||
641 | if (request_irq(SGI_TIOCA_ERROR, | ||
642 | tioca_error_intr_handler, | ||
643 | SA_SHIRQ, "TIOCA error", (void *)tioca_common)) | ||
644 | printk(KERN_WARNING | ||
645 | "%s: Unable to get irq %d. " | ||
646 | "Error interrupts won't be routed for TIOCA bus %d\n", | ||
647 | __FUNCTION__, SGI_TIOCA_ERROR, | ||
648 | (int)tioca_common->ca_common.bs_persist_busnum); | ||
649 | |||
650 | return tioca_common; | ||
651 | } | ||
652 | |||
653 | static struct sn_pcibus_provider tioca_pci_interfaces = { | ||
654 | .dma_map = tioca_dma_map, | ||
655 | .dma_map_consistent = tioca_dma_map, | ||
656 | .dma_unmap = tioca_dma_unmap, | ||
657 | .bus_fixup = tioca_bus_fixup, | ||
658 | }; | ||
659 | |||
660 | /** | ||
661 | * tioca_init_provider - init SN PCI provider ops for TIO CA | ||
662 | */ | ||
663 | int | ||
664 | tioca_init_provider(void) | ||
665 | { | ||
666 | sn_pci_provider[PCIIO_ASIC_TYPE_TIOCA] = &tioca_pci_interfaces; | ||
667 | return 0; | ||
668 | } | ||
diff --git a/include/asm-ia64/sn/pcibus_provider_defs.h b/include/asm-ia64/sn/pcibus_provider_defs.h index f546b4ece33c..04e27d5b3820 100644 --- a/include/asm-ia64/sn/pcibus_provider_defs.h +++ b/include/asm-ia64/sn/pcibus_provider_defs.h | |||
@@ -17,8 +17,9 @@ | |||
17 | #define PCIIO_ASIC_TYPE_PPB 1 | 17 | #define PCIIO_ASIC_TYPE_PPB 1 |
18 | #define PCIIO_ASIC_TYPE_PIC 2 | 18 | #define PCIIO_ASIC_TYPE_PIC 2 |
19 | #define PCIIO_ASIC_TYPE_TIOCP 3 | 19 | #define PCIIO_ASIC_TYPE_TIOCP 3 |
20 | #define PCIIO_ASIC_TYPE_TIOCA 4 | ||
20 | 21 | ||
21 | #define PCIIO_ASIC_MAX_TYPES 4 | 22 | #define PCIIO_ASIC_MAX_TYPES 5 |
22 | 23 | ||
23 | /* | 24 | /* |
24 | * Common pciio bus provider data. There should be one of these as the | 25 | * Common pciio bus provider data. There should be one of these as the |
diff --git a/include/asm-ia64/sn/tioca.h b/include/asm-ia64/sn/tioca.h new file mode 100644 index 000000000000..bc1aacfb9483 --- /dev/null +++ b/include/asm-ia64/sn/tioca.h | |||
@@ -0,0 +1,596 @@ | |||
1 | #ifndef _ASM_IA64_SN_TIO_TIOCA_H | ||
2 | #define _ASM_IA64_SN_TIO_TIOCA_H | ||
3 | |||
4 | /* | ||
5 | * This file is subject to the terms and conditions of the GNU General Public | ||
6 | * License. See the file "COPYING" in the main directory of this archive | ||
7 | * for more details. | ||
8 | * | ||
9 | * Copyright (c) 2003-2005 Silicon Graphics, Inc. All rights reserved. | ||
10 | */ | ||
11 | |||
12 | |||
13 | #define TIOCA_PART_NUM 0xE020 | ||
14 | #define TIOCA_MFGR_NUM 0x24 | ||
15 | #define TIOCA_REV_A 0x1 | ||
16 | |||
17 | /* | ||
18 | * Register layout for TIO:CA. See below for bitmasks for each register. | ||
19 | */ | ||
20 | |||
21 | struct tioca { | ||
22 | uint64_t ca_id; /* 0x000000 */ | ||
23 | uint64_t ca_control1; /* 0x000008 */ | ||
24 | uint64_t ca_control2; /* 0x000010 */ | ||
25 | uint64_t ca_status1; /* 0x000018 */ | ||
26 | uint64_t ca_status2; /* 0x000020 */ | ||
27 | uint64_t ca_gart_aperature; /* 0x000028 */ | ||
28 | uint64_t ca_gfx_detach; /* 0x000030 */ | ||
29 | uint64_t ca_inta_dest_addr; /* 0x000038 */ | ||
30 | uint64_t ca_intb_dest_addr; /* 0x000040 */ | ||
31 | uint64_t ca_err_int_dest_addr; /* 0x000048 */ | ||
32 | uint64_t ca_int_status; /* 0x000050 */ | ||
33 | uint64_t ca_int_status_alias; /* 0x000058 */ | ||
34 | uint64_t ca_mult_error; /* 0x000060 */ | ||
35 | uint64_t ca_mult_error_alias; /* 0x000068 */ | ||
36 | uint64_t ca_first_error; /* 0x000070 */ | ||
37 | uint64_t ca_int_mask; /* 0x000078 */ | ||
38 | uint64_t ca_crm_pkterr_type; /* 0x000080 */ | ||
39 | uint64_t ca_crm_pkterr_type_alias; /* 0x000088 */ | ||
40 | uint64_t ca_crm_ct_error_detail_1; /* 0x000090 */ | ||
41 | uint64_t ca_crm_ct_error_detail_2; /* 0x000098 */ | ||
42 | uint64_t ca_crm_tnumto; /* 0x0000A0 */ | ||
43 | uint64_t ca_gart_err; /* 0x0000A8 */ | ||
44 | uint64_t ca_pcierr_type; /* 0x0000B0 */ | ||
45 | uint64_t ca_pcierr_addr; /* 0x0000B8 */ | ||
46 | |||
47 | uint64_t ca_pad_0000C0[3]; /* 0x0000{C0..D0} */ | ||
48 | |||
49 | uint64_t ca_pci_rd_buf_flush; /* 0x0000D8 */ | ||
50 | uint64_t ca_pci_dma_addr_extn; /* 0x0000E0 */ | ||
51 | uint64_t ca_agp_dma_addr_extn; /* 0x0000E8 */ | ||
52 | uint64_t ca_force_inta; /* 0x0000F0 */ | ||
53 | uint64_t ca_force_intb; /* 0x0000F8 */ | ||
54 | uint64_t ca_debug_vector_sel; /* 0x000100 */ | ||
55 | uint64_t ca_debug_mux_core_sel; /* 0x000108 */ | ||
56 | uint64_t ca_debug_mux_pci_sel; /* 0x000110 */ | ||
57 | uint64_t ca_debug_domain_sel; /* 0x000118 */ | ||
58 | |||
59 | uint64_t ca_pad_000120[28]; /* 0x0001{20..F8} */ | ||
60 | |||
61 | uint64_t ca_gart_ptr_table; /* 0x200 */ | ||
62 | uint64_t ca_gart_tlb_addr[8]; /* 0x2{08..40} */ | ||
63 | }; | ||
64 | |||
65 | /* | ||
66 | * Mask/shift definitions for TIO:CA registers. The convention here is | ||
67 | * to mainly use the names as they appear in the "TIO AEGIS Programmers' | ||
68 | * Reference" with a CA_ prefix added. Some exceptions were made to fix | ||
69 | * duplicate field names or to generalize fields that are common to | ||
70 | * different registers (ca_debug_mux_core_sel and ca_debug_mux_pci_sel for | ||
71 | * example). | ||
72 | * | ||
73 | * Fields consisting of a single bit have a single #define have a single | ||
74 | * macro declaration to mask the bit. Fields consisting of multiple bits | ||
75 | * have two declarations: one to mask the proper bits in a register, and | ||
76 | * a second with the suffix "_SHFT" to identify how far the mask needs to | ||
77 | * be shifted right to get its base value. | ||
78 | */ | ||
79 | |||
80 | /* ==== ca_control1 */ | ||
81 | #define CA_SYS_BIG_END (1ull << 0) | ||
82 | #define CA_DMA_AGP_SWAP (1ull << 1) | ||
83 | #define CA_DMA_PCI_SWAP (1ull << 2) | ||
84 | #define CA_PIO_IO_SWAP (1ull << 3) | ||
85 | #define CA_PIO_MEM_SWAP (1ull << 4) | ||
86 | #define CA_GFX_WR_SWAP (1ull << 5) | ||
87 | #define CA_AGP_FW_ENABLE (1ull << 6) | ||
88 | #define CA_AGP_CAL_CYCLE (0x7ull << 7) | ||
89 | #define CA_AGP_CAL_CYCLE_SHFT 7 | ||
90 | #define CA_AGP_CAL_PRSCL_BYP (1ull << 10) | ||
91 | #define CA_AGP_INIT_CAL_ENB (1ull << 11) | ||
92 | #define CA_INJ_ADDR_PERR (1ull << 12) | ||
93 | #define CA_INJ_DATA_PERR (1ull << 13) | ||
94 | /* bits 15:14 unused */ | ||
95 | #define CA_PCIM_IO_NBE_AD (0x7ull << 16) | ||
96 | #define CA_PCIM_IO_NBE_AD_SHFT 16 | ||
97 | #define CA_PCIM_FAST_BTB_ENB (1ull << 19) | ||
98 | /* bits 23:20 unused */ | ||
99 | #define CA_PIO_ADDR_OFFSET (0xffull << 24) | ||
100 | #define CA_PIO_ADDR_OFFSET_SHFT 24 | ||
101 | /* bits 35:32 unused */ | ||
102 | #define CA_AGPDMA_OP_COMBDELAY (0x1full << 36) | ||
103 | #define CA_AGPDMA_OP_COMBDELAY_SHFT 36 | ||
104 | /* bit 41 unused */ | ||
105 | #define CA_AGPDMA_OP_ENB_COMBDELAY (1ull << 42) | ||
106 | #define CA_PCI_INT_LPCNT (0xffull << 44) | ||
107 | #define CA_PCI_INT_LPCNT_SHFT 44 | ||
108 | /* bits 63:52 unused */ | ||
109 | |||
110 | /* ==== ca_control2 */ | ||
111 | #define CA_AGP_LATENCY_TO (0xffull << 0) | ||
112 | #define CA_AGP_LATENCY_TO_SHFT 0 | ||
113 | #define CA_PCI_LATENCY_TO (0xffull << 8) | ||
114 | #define CA_PCI_LATENCY_TO_SHFT 8 | ||
115 | #define CA_PCI_MAX_RETRY (0x3ffull << 16) | ||
116 | #define CA_PCI_MAX_RETRY_SHFT 16 | ||
117 | /* bits 27:26 unused */ | ||
118 | #define CA_RT_INT_EN (0x3ull << 28) | ||
119 | #define CA_RT_INT_EN_SHFT 28 | ||
120 | #define CA_MSI_INT_ENB (1ull << 30) | ||
121 | #define CA_PCI_ARB_ERR_ENB (1ull << 31) | ||
122 | #define CA_GART_MEM_PARAM (0x3ull << 32) | ||
123 | #define CA_GART_MEM_PARAM_SHFT 32 | ||
124 | #define CA_GART_RD_PREFETCH_ENB (1ull << 34) | ||
125 | #define CA_GART_WR_PREFETCH_ENB (1ull << 35) | ||
126 | #define CA_GART_FLUSH_TLB (1ull << 36) | ||
127 | /* bits 39:37 unused */ | ||
128 | #define CA_CRM_TNUMTO_PERIOD (0x1fffull << 40) | ||
129 | #define CA_CRM_TNUMTO_PERIOD_SHFT 40 | ||
130 | /* bits 55:53 unused */ | ||
131 | #define CA_CRM_TNUMTO_ENB (1ull << 56) | ||
132 | #define CA_CRM_PRESCALER_BYP (1ull << 57) | ||
133 | /* bits 59:58 unused */ | ||
134 | #define CA_CRM_MAX_CREDIT (0x7ull << 60) | ||
135 | #define CA_CRM_MAX_CREDIT_SHFT 60 | ||
136 | /* bit 63 unused */ | ||
137 | |||
138 | /* ==== ca_status1 */ | ||
139 | #define CA_CORELET_ID (0x3ull << 0) | ||
140 | #define CA_CORELET_ID_SHFT 0 | ||
141 | #define CA_INTA_N (1ull << 2) | ||
142 | #define CA_INTB_N (1ull << 3) | ||
143 | #define CA_CRM_CREDIT_AVAIL (0x7ull << 4) | ||
144 | #define CA_CRM_CREDIT_AVAIL_SHFT 4 | ||
145 | /* bit 7 unused */ | ||
146 | #define CA_CRM_SPACE_AVAIL (0x7full << 8) | ||
147 | #define CA_CRM_SPACE_AVAIL_SHFT 8 | ||
148 | /* bit 15 unused */ | ||
149 | #define CA_GART_TLB_VAL (0xffull << 16) | ||
150 | #define CA_GART_TLB_VAL_SHFT 16 | ||
151 | /* bits 63:24 unused */ | ||
152 | |||
153 | /* ==== ca_status2 */ | ||
154 | #define CA_GFX_CREDIT_AVAIL (0xffull << 0) | ||
155 | #define CA_GFX_CREDIT_AVAIL_SHFT 0 | ||
156 | #define CA_GFX_OPQ_AVAIL (0xffull << 8) | ||
157 | #define CA_GFX_OPQ_AVAIL_SHFT 8 | ||
158 | #define CA_GFX_WRBUFF_AVAIL (0xffull << 16) | ||
159 | #define CA_GFX_WRBUFF_AVAIL_SHFT 16 | ||
160 | #define CA_ADMA_OPQ_AVAIL (0xffull << 24) | ||
161 | #define CA_ADMA_OPQ_AVAIL_SHFT 24 | ||
162 | #define CA_ADMA_WRBUFF_AVAIL (0xffull << 32) | ||
163 | #define CA_ADMA_WRBUFF_AVAIL_SHFT 32 | ||
164 | #define CA_ADMA_RDBUFF_AVAIL (0x7full << 40) | ||
165 | #define CA_ADMA_RDBUFF_AVAIL_SHFT 40 | ||
166 | #define CA_PCI_PIO_OP_STAT (1ull << 47) | ||
167 | #define CA_PDMA_OPQ_AVAIL (0xfull << 48) | ||
168 | #define CA_PDMA_OPQ_AVAIL_SHFT 48 | ||
169 | #define CA_PDMA_WRBUFF_AVAIL (0xfull << 52) | ||
170 | #define CA_PDMA_WRBUFF_AVAIL_SHFT 52 | ||
171 | #define CA_PDMA_RDBUFF_AVAIL (0x3ull << 56) | ||
172 | #define CA_PDMA_RDBUFF_AVAIL_SHFT 56 | ||
173 | /* bits 63:58 unused */ | ||
174 | |||
175 | /* ==== ca_gart_aperature */ | ||
176 | #define CA_GART_AP_ENB_AGP (1ull << 0) | ||
177 | #define CA_GART_PAGE_SIZE (1ull << 1) | ||
178 | #define CA_GART_AP_ENB_PCI (1ull << 2) | ||
179 | /* bits 11:3 unused */ | ||
180 | #define CA_GART_AP_SIZE (0x3ffull << 12) | ||
181 | #define CA_GART_AP_SIZE_SHFT 12 | ||
182 | #define CA_GART_AP_BASE (0x3ffffffffffull << 22) | ||
183 | #define CA_GART_AP_BASE_SHFT 22 | ||
184 | |||
185 | /* ==== ca_inta_dest_addr | ||
186 | ==== ca_intb_dest_addr | ||
187 | ==== ca_err_int_dest_addr */ | ||
188 | /* bits 2:0 unused */ | ||
189 | #define CA_INT_DEST_ADDR (0x7ffffffffffffull << 3) | ||
190 | #define CA_INT_DEST_ADDR_SHFT 3 | ||
191 | /* bits 55:54 unused */ | ||
192 | #define CA_INT_DEST_VECT (0xffull << 56) | ||
193 | #define CA_INT_DEST_VECT_SHFT 56 | ||
194 | |||
195 | /* ==== ca_int_status */ | ||
196 | /* ==== ca_int_status_alias */ | ||
197 | /* ==== ca_mult_error */ | ||
198 | /* ==== ca_mult_error_alias */ | ||
199 | /* ==== ca_first_error */ | ||
200 | /* ==== ca_int_mask */ | ||
201 | #define CA_PCI_ERR (1ull << 0) | ||
202 | /* bits 3:1 unused */ | ||
203 | #define CA_GART_FETCH_ERR (1ull << 4) | ||
204 | #define CA_GFX_WR_OVFLW (1ull << 5) | ||
205 | #define CA_PIO_REQ_OVFLW (1ull << 6) | ||
206 | #define CA_CRM_PKTERR (1ull << 7) | ||
207 | #define CA_CRM_DVERR (1ull << 8) | ||
208 | #define CA_TNUMTO (1ull << 9) | ||
209 | #define CA_CXM_RSP_CRED_OVFLW (1ull << 10) | ||
210 | #define CA_CXM_REQ_CRED_OVFLW (1ull << 11) | ||
211 | #define CA_PIO_INVALID_ADDR (1ull << 12) | ||
212 | #define CA_PCI_ARB_TO (1ull << 13) | ||
213 | #define CA_AGP_REQ_OFLOW (1ull << 14) | ||
214 | #define CA_SBA_TYPE1_ERR (1ull << 15) | ||
215 | /* bit 16 unused */ | ||
216 | #define CA_INTA (1ull << 17) | ||
217 | #define CA_INTB (1ull << 18) | ||
218 | #define CA_MULT_INTA (1ull << 19) | ||
219 | #define CA_MULT_INTB (1ull << 20) | ||
220 | #define CA_GFX_CREDIT_OVFLW (1ull << 21) | ||
221 | /* bits 63:22 unused */ | ||
222 | |||
223 | /* ==== ca_crm_pkterr_type */ | ||
224 | /* ==== ca_crm_pkterr_type_alias */ | ||
225 | #define CA_CRM_PKTERR_SBERR_HDR (1ull << 0) | ||
226 | #define CA_CRM_PKTERR_DIDN (1ull << 1) | ||
227 | #define CA_CRM_PKTERR_PACTYPE (1ull << 2) | ||
228 | #define CA_CRM_PKTERR_INV_TNUM (1ull << 3) | ||
229 | #define CA_CRM_PKTERR_ADDR_RNG (1ull << 4) | ||
230 | #define CA_CRM_PKTERR_ADDR_ALGN (1ull << 5) | ||
231 | #define CA_CRM_PKTERR_HDR_PARAM (1ull << 6) | ||
232 | #define CA_CRM_PKTERR_CW_ERR (1ull << 7) | ||
233 | #define CA_CRM_PKTERR_SBERR_NH (1ull << 8) | ||
234 | #define CA_CRM_PKTERR_EARLY_TERM (1ull << 9) | ||
235 | #define CA_CRM_PKTERR_EARLY_TAIL (1ull << 10) | ||
236 | #define CA_CRM_PKTERR_MSSNG_TAIL (1ull << 11) | ||
237 | #define CA_CRM_PKTERR_MSSNG_HDR (1ull << 12) | ||
238 | /* bits 15:13 unused */ | ||
239 | #define CA_FIRST_CRM_PKTERR_SBERR_HDR (1ull << 16) | ||
240 | #define CA_FIRST_CRM_PKTERR_DIDN (1ull << 17) | ||
241 | #define CA_FIRST_CRM_PKTERR_PACTYPE (1ull << 18) | ||
242 | #define CA_FIRST_CRM_PKTERR_INV_TNUM (1ull << 19) | ||
243 | #define CA_FIRST_CRM_PKTERR_ADDR_RNG (1ull << 20) | ||
244 | #define CA_FIRST_CRM_PKTERR_ADDR_ALGN (1ull << 21) | ||
245 | #define CA_FIRST_CRM_PKTERR_HDR_PARAM (1ull << 22) | ||
246 | #define CA_FIRST_CRM_PKTERR_CW_ERR (1ull << 23) | ||
247 | #define CA_FIRST_CRM_PKTERR_SBERR_NH (1ull << 24) | ||
248 | #define CA_FIRST_CRM_PKTERR_EARLY_TERM (1ull << 25) | ||
249 | #define CA_FIRST_CRM_PKTERR_EARLY_TAIL (1ull << 26) | ||
250 | #define CA_FIRST_CRM_PKTERR_MSSNG_TAIL (1ull << 27) | ||
251 | #define CA_FIRST_CRM_PKTERR_MSSNG_HDR (1ull << 28) | ||
252 | /* bits 63:29 unused */ | ||
253 | |||
254 | /* ==== ca_crm_ct_error_detail_1 */ | ||
255 | #define CA_PKT_TYPE (0xfull << 0) | ||
256 | #define CA_PKT_TYPE_SHFT 0 | ||
257 | #define CA_SRC_ID (0x3ull << 4) | ||
258 | #define CA_SRC_ID_SHFT 4 | ||
259 | #define CA_DATA_SZ (0x3ull << 6) | ||
260 | #define CA_DATA_SZ_SHFT 6 | ||
261 | #define CA_TNUM (0xffull << 8) | ||
262 | #define CA_TNUM_SHFT 8 | ||
263 | #define CA_DW_DATA_EN (0xffull << 16) | ||
264 | #define CA_DW_DATA_EN_SHFT 16 | ||
265 | #define CA_GFX_CRED (0xffull << 24) | ||
266 | #define CA_GFX_CRED_SHFT 24 | ||
267 | #define CA_MEM_RD_PARAM (0x3ull << 32) | ||
268 | #define CA_MEM_RD_PARAM_SHFT 32 | ||
269 | #define CA_PIO_OP (1ull << 34) | ||
270 | #define CA_CW_ERR (1ull << 35) | ||
271 | /* bits 62:36 unused */ | ||
272 | #define CA_VALID (1ull << 63) | ||
273 | |||
274 | /* ==== ca_crm_ct_error_detail_2 */ | ||
275 | /* bits 2:0 unused */ | ||
276 | #define CA_PKT_ADDR (0x1fffffffffffffull << 3) | ||
277 | #define CA_PKT_ADDR_SHFT 3 | ||
278 | /* bits 63:56 unused */ | ||
279 | |||
280 | /* ==== ca_crm_tnumto */ | ||
281 | #define CA_CRM_TNUMTO_VAL (0xffull << 0) | ||
282 | #define CA_CRM_TNUMTO_VAL_SHFT 0 | ||
283 | #define CA_CRM_TNUMTO_WR (1ull << 8) | ||
284 | /* bits 63:9 unused */ | ||
285 | |||
286 | /* ==== ca_gart_err */ | ||
287 | #define CA_GART_ERR_SOURCE (0x3ull << 0) | ||
288 | #define CA_GART_ERR_SOURCE_SHFT 0 | ||
289 | /* bits 3:2 unused */ | ||
290 | #define CA_GART_ERR_ADDR (0xfffffffffull << 4) | ||
291 | #define CA_GART_ERR_ADDR_SHFT 4 | ||
292 | /* bits 63:40 unused */ | ||
293 | |||
294 | /* ==== ca_pcierr_type */ | ||
295 | #define CA_PCIERR_DATA (0xffffffffull << 0) | ||
296 | #define CA_PCIERR_DATA_SHFT 0 | ||
297 | #define CA_PCIERR_ENB (0xfull << 32) | ||
298 | #define CA_PCIERR_ENB_SHFT 32 | ||
299 | #define CA_PCIERR_CMD (0xfull << 36) | ||
300 | #define CA_PCIERR_CMD_SHFT 36 | ||
301 | #define CA_PCIERR_A64 (1ull << 40) | ||
302 | #define CA_PCIERR_SLV_SERR (1ull << 41) | ||
303 | #define CA_PCIERR_SLV_WR_PERR (1ull << 42) | ||
304 | #define CA_PCIERR_SLV_RD_PERR (1ull << 43) | ||
305 | #define CA_PCIERR_MST_SERR (1ull << 44) | ||
306 | #define CA_PCIERR_MST_WR_PERR (1ull << 45) | ||
307 | #define CA_PCIERR_MST_RD_PERR (1ull << 46) | ||
308 | #define CA_PCIERR_MST_MABT (1ull << 47) | ||
309 | #define CA_PCIERR_MST_TABT (1ull << 48) | ||
310 | #define CA_PCIERR_MST_RETRY_TOUT (1ull << 49) | ||
311 | |||
312 | #define CA_PCIERR_TYPES \ | ||
313 | (CA_PCIERR_A64|CA_PCIERR_SLV_SERR| \ | ||
314 | CA_PCIERR_SLV_WR_PERR|CA_PCIERR_SLV_RD_PERR| \ | ||
315 | CA_PCIERR_MST_SERR|CA_PCIERR_MST_WR_PERR|CA_PCIERR_MST_RD_PERR| \ | ||
316 | CA_PCIERR_MST_MABT|CA_PCIERR_MST_TABT|CA_PCIERR_MST_RETRY_TOUT) | ||
317 | |||
318 | /* bits 63:50 unused */ | ||
319 | |||
320 | /* ==== ca_pci_dma_addr_extn */ | ||
321 | #define CA_UPPER_NODE_OFFSET (0x3full << 0) | ||
322 | #define CA_UPPER_NODE_OFFSET_SHFT 0 | ||
323 | /* bits 7:6 unused */ | ||
324 | #define CA_CHIPLET_ID (0x3ull << 8) | ||
325 | #define CA_CHIPLET_ID_SHFT 8 | ||
326 | /* bits 11:10 unused */ | ||
327 | #define CA_PCI_DMA_NODE_ID (0xffffull << 12) | ||
328 | #define CA_PCI_DMA_NODE_ID_SHFT 12 | ||
329 | /* bits 27:26 unused */ | ||
330 | #define CA_PCI_DMA_PIO_MEM_TYPE (1ull << 28) | ||
331 | /* bits 63:29 unused */ | ||
332 | |||
333 | |||
334 | /* ==== ca_agp_dma_addr_extn */ | ||
335 | /* bits 19:0 unused */ | ||
336 | #define CA_AGP_DMA_NODE_ID (0xffffull << 20) | ||
337 | #define CA_AGP_DMA_NODE_ID_SHFT 20 | ||
338 | /* bits 27:26 unused */ | ||
339 | #define CA_AGP_DMA_PIO_MEM_TYPE (1ull << 28) | ||
340 | /* bits 63:29 unused */ | ||
341 | |||
342 | /* ==== ca_debug_vector_sel */ | ||
343 | #define CA_DEBUG_MN_VSEL (0xfull << 0) | ||
344 | #define CA_DEBUG_MN_VSEL_SHFT 0 | ||
345 | #define CA_DEBUG_PP_VSEL (0xfull << 4) | ||
346 | #define CA_DEBUG_PP_VSEL_SHFT 4 | ||
347 | #define CA_DEBUG_GW_VSEL (0xfull << 8) | ||
348 | #define CA_DEBUG_GW_VSEL_SHFT 8 | ||
349 | #define CA_DEBUG_GT_VSEL (0xfull << 12) | ||
350 | #define CA_DEBUG_GT_VSEL_SHFT 12 | ||
351 | #define CA_DEBUG_PD_VSEL (0xfull << 16) | ||
352 | #define CA_DEBUG_PD_VSEL_SHFT 16 | ||
353 | #define CA_DEBUG_AD_VSEL (0xfull << 20) | ||
354 | #define CA_DEBUG_AD_VSEL_SHFT 20 | ||
355 | #define CA_DEBUG_CX_VSEL (0xfull << 24) | ||
356 | #define CA_DEBUG_CX_VSEL_SHFT 24 | ||
357 | #define CA_DEBUG_CR_VSEL (0xfull << 28) | ||
358 | #define CA_DEBUG_CR_VSEL_SHFT 28 | ||
359 | #define CA_DEBUG_BA_VSEL (0xfull << 32) | ||
360 | #define CA_DEBUG_BA_VSEL_SHFT 32 | ||
361 | #define CA_DEBUG_PE_VSEL (0xfull << 36) | ||
362 | #define CA_DEBUG_PE_VSEL_SHFT 36 | ||
363 | #define CA_DEBUG_BO_VSEL (0xfull << 40) | ||
364 | #define CA_DEBUG_BO_VSEL_SHFT 40 | ||
365 | #define CA_DEBUG_BI_VSEL (0xfull << 44) | ||
366 | #define CA_DEBUG_BI_VSEL_SHFT 44 | ||
367 | #define CA_DEBUG_AS_VSEL (0xfull << 48) | ||
368 | #define CA_DEBUG_AS_VSEL_SHFT 48 | ||
369 | #define CA_DEBUG_PS_VSEL (0xfull << 52) | ||
370 | #define CA_DEBUG_PS_VSEL_SHFT 52 | ||
371 | #define CA_DEBUG_PM_VSEL (0xfull << 56) | ||
372 | #define CA_DEBUG_PM_VSEL_SHFT 56 | ||
373 | /* bits 63:60 unused */ | ||
374 | |||
375 | /* ==== ca_debug_mux_core_sel */ | ||
376 | /* ==== ca_debug_mux_pci_sel */ | ||
377 | #define CA_DEBUG_MSEL0 (0x7ull << 0) | ||
378 | #define CA_DEBUG_MSEL0_SHFT 0 | ||
379 | /* bit 3 unused */ | ||
380 | #define CA_DEBUG_NSEL0 (0x7ull << 4) | ||
381 | #define CA_DEBUG_NSEL0_SHFT 4 | ||
382 | /* bit 7 unused */ | ||
383 | #define CA_DEBUG_MSEL1 (0x7ull << 8) | ||
384 | #define CA_DEBUG_MSEL1_SHFT 8 | ||
385 | /* bit 11 unused */ | ||
386 | #define CA_DEBUG_NSEL1 (0x7ull << 12) | ||
387 | #define CA_DEBUG_NSEL1_SHFT 12 | ||
388 | /* bit 15 unused */ | ||
389 | #define CA_DEBUG_MSEL2 (0x7ull << 16) | ||
390 | #define CA_DEBUG_MSEL2_SHFT 16 | ||
391 | /* bit 19 unused */ | ||
392 | #define CA_DEBUG_NSEL2 (0x7ull << 20) | ||
393 | #define CA_DEBUG_NSEL2_SHFT 20 | ||
394 | /* bit 23 unused */ | ||
395 | #define CA_DEBUG_MSEL3 (0x7ull << 24) | ||
396 | #define CA_DEBUG_MSEL3_SHFT 24 | ||
397 | /* bit 27 unused */ | ||
398 | #define CA_DEBUG_NSEL3 (0x7ull << 28) | ||
399 | #define CA_DEBUG_NSEL3_SHFT 28 | ||
400 | /* bit 31 unused */ | ||
401 | #define CA_DEBUG_MSEL4 (0x7ull << 32) | ||
402 | #define CA_DEBUG_MSEL4_SHFT 32 | ||
403 | /* bit 35 unused */ | ||
404 | #define CA_DEBUG_NSEL4 (0x7ull << 36) | ||
405 | #define CA_DEBUG_NSEL4_SHFT 36 | ||
406 | /* bit 39 unused */ | ||
407 | #define CA_DEBUG_MSEL5 (0x7ull << 40) | ||
408 | #define CA_DEBUG_MSEL5_SHFT 40 | ||
409 | /* bit 43 unused */ | ||
410 | #define CA_DEBUG_NSEL5 (0x7ull << 44) | ||
411 | #define CA_DEBUG_NSEL5_SHFT 44 | ||
412 | /* bit 47 unused */ | ||
413 | #define CA_DEBUG_MSEL6 (0x7ull << 48) | ||
414 | #define CA_DEBUG_MSEL6_SHFT 48 | ||
415 | /* bit 51 unused */ | ||
416 | #define CA_DEBUG_NSEL6 (0x7ull << 52) | ||
417 | #define CA_DEBUG_NSEL6_SHFT 52 | ||
418 | /* bit 55 unused */ | ||
419 | #define CA_DEBUG_MSEL7 (0x7ull << 56) | ||
420 | #define CA_DEBUG_MSEL7_SHFT 56 | ||
421 | /* bit 59 unused */ | ||
422 | #define CA_DEBUG_NSEL7 (0x7ull << 60) | ||
423 | #define CA_DEBUG_NSEL7_SHFT 60 | ||
424 | /* bit 63 unused */ | ||
425 | |||
426 | |||
427 | /* ==== ca_debug_domain_sel */ | ||
428 | #define CA_DEBUG_DOMAIN_L (1ull << 0) | ||
429 | #define CA_DEBUG_DOMAIN_H (1ull << 1) | ||
430 | /* bits 63:2 unused */ | ||
431 | |||
432 | /* ==== ca_gart_ptr_table */ | ||
433 | #define CA_GART_PTR_VAL (1ull << 0) | ||
434 | /* bits 11:1 unused */ | ||
435 | #define CA_GART_PTR_ADDR (0xfffffffffffull << 12) | ||
436 | #define CA_GART_PTR_ADDR_SHFT 12 | ||
437 | /* bits 63:56 unused */ | ||
438 | |||
439 | /* ==== ca_gart_tlb_addr[0-7] */ | ||
440 | #define CA_GART_TLB_ADDR (0xffffffffffffffull << 0) | ||
441 | #define CA_GART_TLB_ADDR_SHFT 0 | ||
442 | /* bits 62:56 unused */ | ||
443 | #define CA_GART_TLB_ENTRY_VAL (1ull << 63) | ||
444 | |||
445 | /* | ||
446 | * PIO address space ranges for TIO:CA | ||
447 | */ | ||
448 | |||
449 | /* CA internal registers */ | ||
450 | #define CA_PIO_ADMIN 0x00000000 | ||
451 | #define CA_PIO_ADMIN_LEN 0x00010000 | ||
452 | |||
453 | /* GFX Write Buffer - Diagnostics */ | ||
454 | #define CA_PIO_GFX 0x00010000 | ||
455 | #define CA_PIO_GFX_LEN 0x00010000 | ||
456 | |||
457 | /* AGP DMA Write Buffer - Diagnostics */ | ||
458 | #define CA_PIO_AGP_DMAWRITE 0x00020000 | ||
459 | #define CA_PIO_AGP_DMAWRITE_LEN 0x00010000 | ||
460 | |||
461 | /* AGP DMA READ Buffer - Diagnostics */ | ||
462 | #define CA_PIO_AGP_DMAREAD 0x00030000 | ||
463 | #define CA_PIO_AGP_DMAREAD_LEN 0x00010000 | ||
464 | |||
465 | /* PCI Config Type 0 */ | ||
466 | #define CA_PIO_PCI_TYPE0_CONFIG 0x01000000 | ||
467 | #define CA_PIO_PCI_TYPE0_CONFIG_LEN 0x01000000 | ||
468 | |||
469 | /* PCI Config Type 1 */ | ||
470 | #define CA_PIO_PCI_TYPE1_CONFIG 0x02000000 | ||
471 | #define CA_PIO_PCI_TYPE1_CONFIG_LEN 0x01000000 | ||
472 | |||
473 | /* PCI I/O Cycles - mapped to PCI Address 0x00000000-0x04ffffff */ | ||
474 | #define CA_PIO_PCI_IO 0x03000000 | ||
475 | #define CA_PIO_PCI_IO_LEN 0x05000000 | ||
476 | |||
477 | /* PCI MEM Cycles - mapped to PCI with CA_PIO_ADDR_OFFSET of ca_control1 */ | ||
478 | /* use Fast Write if enabled and coretalk packet type is a GFX request */ | ||
479 | #define CA_PIO_PCI_MEM_OFFSET 0x08000000 | ||
480 | #define CA_PIO_PCI_MEM_OFFSET_LEN 0x08000000 | ||
481 | |||
482 | /* PCI MEM Cycles - mapped to PCI Address 0x00000000-0xbfffffff */ | ||
483 | /* use Fast Write if enabled and coretalk packet type is a GFX request */ | ||
484 | #define CA_PIO_PCI_MEM 0x40000000 | ||
485 | #define CA_PIO_PCI_MEM_LEN 0xc0000000 | ||
486 | |||
487 | /* | ||
488 | * DMA space | ||
489 | * | ||
490 | * The CA aperature (ie. bus address range) mapped by the GART is segmented into | ||
491 | * two parts. The lower portion of the aperature is used for mapping 32 bit | ||
492 | * PCI addresses which are managed by the dma interfaces in this file. The | ||
493 | * upper poprtion of the aperature is used for mapping 48 bit AGP addresses. | ||
494 | * The AGP portion of the aperature is managed by the agpgart_be.c driver | ||
495 | * in drivers/linux/agp. There are ca-specific hooks in that driver to | ||
496 | * manipulate the gart, but management of the AGP portion of the aperature | ||
497 | * is the responsibility of that driver. | ||
498 | * | ||
499 | * CA allows three main types of DMA mapping: | ||
500 | * | ||
501 | * PCI 64-bit Managed by this driver | ||
502 | * PCI 32-bit Managed by this driver | ||
503 | * AGP 48-bit Managed by hooks in the /dev/agpgart driver | ||
504 | * | ||
505 | * All of the above can optionally be remapped through the GART. The following | ||
506 | * table lists the combinations of addressing types and GART remapping that | ||
507 | * is currently supported by the driver (h/w supports all, s/w limits this): | ||
508 | * | ||
509 | * PCI64 PCI32 AGP48 | ||
510 | * GART no yes yes | ||
511 | * Direct yes yes no | ||
512 | * | ||
513 | * GART remapping of PCI64 is not done because there is no need to. The | ||
514 | * 64 bit PCI address holds all of the information necessary to target any | ||
515 | * memory in the system. | ||
516 | * | ||
517 | * AGP48 is always mapped through the GART. Management of the AGP48 portion | ||
518 | * of the aperature is the responsibility of code in the agpgart_be driver. | ||
519 | * | ||
520 | * The non-64 bit bus address space will currently be partitioned like this: | ||
521 | * | ||
522 | * 0xffff_ffff_ffff +-------- | ||
523 | * | AGP48 direct | ||
524 | * | Space managed by this driver | ||
525 | * CA_AGP_DIRECT_BASE +-------- | ||
526 | * | AGP GART mapped (gfx aperature) | ||
527 | * | Space managed by /dev/agpgart driver | ||
528 | * | This range is exposed to the agpgart | ||
529 | * | driver as the "graphics aperature" | ||
530 | * CA_AGP_MAPPED_BASE +----- | ||
531 | * | PCI GART mapped | ||
532 | * | Space managed by this driver | ||
533 | * CA_PCI32_MAPPED_BASE +---- | ||
534 | * | PCI32 direct | ||
535 | * | Space managed by this driver | ||
536 | * 0xC000_0000 +-------- | ||
537 | * (CA_PCI32_DIRECT_BASE) | ||
538 | * | ||
539 | * The bus address range CA_PCI32_MAPPED_BASE through CA_AGP_DIRECT_BASE | ||
540 | * is what we call the CA aperature. Addresses falling in this range will | ||
541 | * be remapped using the GART. | ||
542 | * | ||
543 | * The bus address range CA_AGP_MAPPED_BASE through CA_AGP_DIRECT_BASE | ||
544 | * is what we call the graphics aperature. This is a subset of the CA | ||
545 | * aperature and is under the control of the agpgart_be driver. | ||
546 | * | ||
547 | * CA_PCI32_MAPPED_BASE, CA_AGP_MAPPED_BASE, and CA_AGP_DIRECT_BASE are | ||
548 | * somewhat arbitrary values. The known constraints on choosing these is: | ||
549 | * | ||
550 | * 1) CA_AGP_DIRECT_BASE-CA_PCI32_MAPPED_BASE+1 (the CA aperature size) | ||
551 | * must be one of the values supported by the ca_gart_aperature register. | ||
552 | * Currently valid values are: 4MB through 4096MB in powers of 2 increments | ||
553 | * | ||
554 | * 2) CA_AGP_DIRECT_BASE-CA_AGP_MAPPED_BASE+1 (the gfx aperature size) | ||
555 | * must be in MB units since that's what the agpgart driver assumes. | ||
556 | */ | ||
557 | |||
558 | /* | ||
559 | * Define Bus DMA ranges. These are configurable (see constraints above) | ||
560 | * and will probably need tuning based on experience. | ||
561 | */ | ||
562 | |||
563 | |||
564 | /* | ||
565 | * 11/24/03 | ||
566 | * CA has an addressing glitch w.r.t. PCI direct 32 bit DMA that makes it | ||
567 | * generally unusable. The problem is that for PCI direct 32 | ||
568 | * DMA's, all 32 bits of the bus address are used to form the lower 32 bits | ||
569 | * of the coretalk address, and coretalk bits 38:32 come from a register. | ||
570 | * Since only PCI bus addresses 0xC0000000-0xFFFFFFFF (1GB) are available | ||
571 | * for DMA (the rest is allocated to PIO), host node addresses need to be | ||
572 | * such that their lower 32 bits fall in the 0xC0000000-0xffffffff range | ||
573 | * as well. So there can be no PCI32 direct DMA below 3GB!! For this | ||
574 | * reason we set the CA_PCI32_DIRECT_SIZE to 0 which essentially makes | ||
575 | * tioca_dma_direct32() a noop but preserves the code flow should this issue | ||
576 | * be fixed in a respin. | ||
577 | * | ||
578 | * For now, all PCI32 DMA's must be mapped through the GART. | ||
579 | */ | ||
580 | |||
581 | #define CA_PCI32_DIRECT_BASE 0xC0000000UL /* BASE not configurable */ | ||
582 | #define CA_PCI32_DIRECT_SIZE 0x00000000UL /* 0 MB */ | ||
583 | |||
584 | #define CA_PCI32_MAPPED_BASE 0xC0000000UL | ||
585 | #define CA_PCI32_MAPPED_SIZE 0x40000000UL /* 2GB */ | ||
586 | |||
587 | #define CA_AGP_MAPPED_BASE 0x80000000UL | ||
588 | #define CA_AGP_MAPPED_SIZE 0x40000000UL /* 2GB */ | ||
589 | |||
590 | #define CA_AGP_DIRECT_BASE 0x40000000UL /* 2GB */ | ||
591 | #define CA_AGP_DIRECT_SIZE 0x40000000UL | ||
592 | |||
593 | #define CA_APERATURE_BASE (CA_AGP_MAPPED_BASE) | ||
594 | #define CA_APERATURE_SIZE (CA_AGP_MAPPED_SIZE+CA_PCI32_MAPPED_SIZE) | ||
595 | |||
596 | #endif /* _ASM_IA64_SN_TIO_TIOCA_H */ | ||
diff --git a/include/asm-ia64/sn/tioca_provider.h b/include/asm-ia64/sn/tioca_provider.h new file mode 100644 index 000000000000..b6acc22ab239 --- /dev/null +++ b/include/asm-ia64/sn/tioca_provider.h | |||
@@ -0,0 +1,206 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (c) 2003-2005 Silicon Graphics, Inc. All rights reserved. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H | ||
10 | #define _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H | ||
11 | |||
12 | #include <asm/sn/tioca.h> | ||
13 | |||
14 | /* | ||
15 | * WAR enables | ||
16 | * Defines for individual WARs. Each is a bitmask of applicable | ||
17 | * part revision numbers. (1 << 1) == rev A, (1 << 2) == rev B, | ||
18 | * (3 << 1) == (rev A or rev B), etc | ||
19 | */ | ||
20 | |||
21 | #define TIOCA_WAR_ENABLED(pv, tioca_common) \ | ||
22 | ((1 << tioca_common->ca_rev) & pv) | ||
23 | |||
24 | /* TIO:ICE:FRZ:Freezer loses a PIO data ucred on PIO RD RSP with CW error */ | ||
25 | #define PV907908 (1 << 1) | ||
26 | /* ATI config space problems after BIOS execution starts */ | ||
27 | #define PV908234 (1 << 1) | ||
28 | /* CA:AGPDMA write request data mismatch with ABC1CL merge */ | ||
29 | #define PV895469 (1 << 1) | ||
30 | /* TIO:CA TLB invalidate of written GART entries possibly not occuring in CA*/ | ||
31 | #define PV910244 (1 << 1) | ||
32 | |||
33 | struct tioca_dmamap{ | ||
34 | struct list_head cad_list; /* headed by ca_list */ | ||
35 | |||
36 | dma_addr_t cad_dma_addr; /* Linux dma handle */ | ||
37 | uint cad_gart_entry; /* start entry in ca_gart_pagemap */ | ||
38 | uint cad_gart_size; /* #entries for this map */ | ||
39 | }; | ||
40 | |||
41 | /* | ||
42 | * Kernel only fields. Prom may look at this stuff for debugging only. | ||
43 | * Access this structure through the ca_kernel_private ptr. | ||
44 | */ | ||
45 | |||
46 | struct tioca_common ; | ||
47 | |||
48 | struct tioca_kernel { | ||
49 | struct tioca_common *ca_common; /* tioca this belongs to */ | ||
50 | struct list_head ca_list; /* list of all ca's */ | ||
51 | struct list_head ca_dmamaps; | ||
52 | spinlock_t ca_lock; /* Kernel lock */ | ||
53 | cnodeid_t ca_closest_node; | ||
54 | struct list_head *ca_devices; /* bus->devices */ | ||
55 | |||
56 | /* | ||
57 | * General GART stuff | ||
58 | */ | ||
59 | uint64_t ca_ap_size; /* size of aperature in bytes */ | ||
60 | uint32_t ca_gart_entries; /* # uint64_t entries in gart */ | ||
61 | uint32_t ca_ap_pagesize; /* aperature page size in bytes */ | ||
62 | uint64_t ca_ap_bus_base; /* bus address of CA aperature */ | ||
63 | uint64_t ca_gart_size; /* gart size in bytes */ | ||
64 | uint64_t *ca_gart; /* gart table vaddr */ | ||
65 | uint64_t ca_gart_coretalk_addr; /* gart coretalk addr */ | ||
66 | uint8_t ca_gart_iscoherent; /* used in tioca_tlbflush */ | ||
67 | |||
68 | /* PCI GART convenience values */ | ||
69 | uint64_t ca_pciap_base; /* pci aperature bus base address */ | ||
70 | uint64_t ca_pciap_size; /* pci aperature size (bytes) */ | ||
71 | uint64_t ca_pcigart_base; /* gfx GART bus base address */ | ||
72 | uint64_t *ca_pcigart; /* gfx GART vm address */ | ||
73 | uint32_t ca_pcigart_entries; | ||
74 | uint32_t ca_pcigart_start; /* PCI start index in ca_gart */ | ||
75 | void *ca_pcigart_pagemap; | ||
76 | |||
77 | /* AGP GART convenience values */ | ||
78 | uint64_t ca_gfxap_base; /* gfx aperature bus base address */ | ||
79 | uint64_t ca_gfxap_size; /* gfx aperature size (bytes) */ | ||
80 | uint64_t ca_gfxgart_base; /* gfx GART bus base address */ | ||
81 | uint64_t *ca_gfxgart; /* gfx GART vm address */ | ||
82 | uint32_t ca_gfxgart_entries; | ||
83 | uint32_t ca_gfxgart_start; /* agpgart start index in ca_gart */ | ||
84 | }; | ||
85 | |||
86 | /* | ||
87 | * Common tioca info shared between kernel and prom | ||
88 | * | ||
89 | * DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES | ||
90 | * TO THE PROM VERSION. | ||
91 | */ | ||
92 | |||
93 | struct tioca_common { | ||
94 | struct pcibus_bussoft ca_common; /* common pciio header */ | ||
95 | |||
96 | uint32_t ca_rev; | ||
97 | uint32_t ca_closest_nasid; | ||
98 | |||
99 | uint64_t ca_prom_private; | ||
100 | uint64_t ca_kernel_private; | ||
101 | }; | ||
102 | |||
103 | /** | ||
104 | * tioca_paddr_to_gart - Convert an SGI coretalk address to a CA GART entry | ||
105 | * @paddr: page address to convert | ||
106 | * | ||
107 | * Convert a system [coretalk] address to a GART entry. GART entries are | ||
108 | * formed using the following: | ||
109 | * | ||
110 | * data = ( (1<<63) | ( (REMAP_NODE_ID << 40) | (MD_CHIPLET_ID << 38) | | ||
111 | * (REMAP_SYS_ADDR) ) >> 12 ) | ||
112 | * | ||
113 | * DATA written to 1 GART TABLE Entry in system memory is remapped system | ||
114 | * addr for 1 page | ||
115 | * | ||
116 | * The data is for coretalk address format right shifted 12 bits with a | ||
117 | * valid bit. | ||
118 | * | ||
119 | * GART_TABLE_ENTRY [ 25:0 ] -- REMAP_SYS_ADDRESS[37:12]. | ||
120 | * GART_TABLE_ENTRY [ 27:26 ] -- SHUB MD chiplet id. | ||
121 | * GART_TABLE_ENTRY [ 41:28 ] -- REMAP_NODE_ID. | ||
122 | * GART_TABLE_ENTRY [ 63 ] -- Valid Bit | ||
123 | */ | ||
124 | static inline u64 | ||
125 | tioca_paddr_to_gart(unsigned long paddr) | ||
126 | { | ||
127 | /* | ||
128 | * We are assuming right now that paddr already has the correct | ||
129 | * format since the address from xtalk_dmaXXX should already have | ||
130 | * NODE_ID, CHIPLET_ID, and SYS_ADDR in the correct locations. | ||
131 | */ | ||
132 | |||
133 | return ((paddr) >> 12) | (1UL << 63); | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * tioca_physpage_to_gart - Map a host physical page for SGI CA based DMA | ||
138 | * @page_addr: system page address to map | ||
139 | */ | ||
140 | |||
141 | static inline unsigned long | ||
142 | tioca_physpage_to_gart(uint64_t page_addr) | ||
143 | { | ||
144 | uint64_t coretalk_addr; | ||
145 | |||
146 | coretalk_addr = PHYS_TO_TIODMA(page_addr); | ||
147 | if (!coretalk_addr) { | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | return tioca_paddr_to_gart(coretalk_addr); | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * tioca_tlbflush - invalidate cached SGI CA GART TLB entries | ||
156 | * @tioca_kernel: CA context | ||
157 | * | ||
158 | * Invalidate tlb entries for a given CA GART. Main complexity is to account | ||
159 | * for revA bug. | ||
160 | */ | ||
161 | static inline void | ||
162 | tioca_tlbflush(struct tioca_kernel *tioca_kernel) | ||
163 | { | ||
164 | volatile uint64_t tmp; | ||
165 | volatile struct tioca *ca_base; | ||
166 | struct tioca_common *tioca_common; | ||
167 | |||
168 | tioca_common = tioca_kernel->ca_common; | ||
169 | ca_base = (struct tioca *)tioca_common->ca_common.bs_base; | ||
170 | |||
171 | /* | ||
172 | * Explicit flushes not needed if GART is in cached mode | ||
173 | */ | ||
174 | if (tioca_kernel->ca_gart_iscoherent) { | ||
175 | if (TIOCA_WAR_ENABLED(PV910244, tioca_common)) { | ||
176 | /* | ||
177 | * PV910244: RevA CA needs explicit flushes. | ||
178 | * Need to put GART into uncached mode before | ||
179 | * flushing otherwise the explicit flush is ignored. | ||
180 | * | ||
181 | * Alternate WAR would be to leave GART cached and | ||
182 | * touch every CL aligned GART entry. | ||
183 | */ | ||
184 | |||
185 | ca_base->ca_control2 &= ~(CA_GART_MEM_PARAM); | ||
186 | ca_base->ca_control2 |= CA_GART_FLUSH_TLB; | ||
187 | ca_base->ca_control2 |= | ||
188 | (0x2ull << CA_GART_MEM_PARAM_SHFT); | ||
189 | tmp = ca_base->ca_control2; | ||
190 | } | ||
191 | |||
192 | return; | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Gart in uncached mode ... need an explicit flush. | ||
197 | */ | ||
198 | |||
199 | ca_base->ca_control2 |= CA_GART_FLUSH_TLB; | ||
200 | tmp = ca_base->ca_control2; | ||
201 | } | ||
202 | |||
203 | extern uint32_t tioca_gart_found; | ||
204 | extern int tioca_init_provider(void); | ||
205 | extern void tioca_fastwrite_enable(struct tioca_kernel *tioca_kern); | ||
206 | #endif /* _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H */ | ||