diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-ppc64/iommu.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-ppc64/iommu.h')
-rw-r--r-- | include/asm-ppc64/iommu.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/include/asm-ppc64/iommu.h b/include/asm-ppc64/iommu.h new file mode 100644 index 000000000000..bd53ca4dcfa2 --- /dev/null +++ b/include/asm-ppc64/iommu.h | |||
@@ -0,0 +1,166 @@ | |||
1 | /* | ||
2 | * iommu.h | ||
3 | * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation | ||
4 | * Rewrite, cleanup: | ||
5 | * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #ifndef _ASM_IOMMU_H | ||
23 | #define _ASM_IOMMU_H | ||
24 | |||
25 | #include <asm/types.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/dma-mapping.h> | ||
29 | |||
30 | /* | ||
31 | * IOMAP_MAX_ORDER defines the largest contiguous block | ||
32 | * of dma (tce) space we can get. IOMAP_MAX_ORDER = 13 | ||
33 | * allows up to 2**12 pages (4096 * 4096) = 16 MB | ||
34 | */ | ||
35 | #define IOMAP_MAX_ORDER 13 | ||
36 | |||
37 | /* | ||
38 | * Tces come in two formats, one for the virtual bus and a different | ||
39 | * format for PCI | ||
40 | */ | ||
41 | #define TCE_VB 0 | ||
42 | #define TCE_PCI 1 | ||
43 | |||
44 | /* tce_entry | ||
45 | * Used by pSeries (SMP) and iSeries/pSeries LPAR, but there it's | ||
46 | * abstracted so layout is irrelevant. | ||
47 | */ | ||
48 | union tce_entry { | ||
49 | unsigned long te_word; | ||
50 | struct { | ||
51 | unsigned int tb_cacheBits :6; /* Cache hash bits - not used */ | ||
52 | unsigned int tb_rsvd :6; | ||
53 | unsigned long tb_rpn :40; /* Real page number */ | ||
54 | unsigned int tb_valid :1; /* Tce is valid (vb only) */ | ||
55 | unsigned int tb_allio :1; /* Tce is valid for all lps (vb only) */ | ||
56 | unsigned int tb_lpindex :8; /* LpIndex for user of TCE (vb only) */ | ||
57 | unsigned int tb_pciwr :1; /* Write allowed (pci only) */ | ||
58 | unsigned int tb_rdwr :1; /* Read allowed (pci), Write allowed (vb) */ | ||
59 | } te_bits; | ||
60 | #define te_cacheBits te_bits.tb_cacheBits | ||
61 | #define te_rpn te_bits.tb_rpn | ||
62 | #define te_valid te_bits.tb_valid | ||
63 | #define te_allio te_bits.tb_allio | ||
64 | #define te_lpindex te_bits.tb_lpindex | ||
65 | #define te_pciwr te_bits.tb_pciwr | ||
66 | #define te_rdwr te_bits.tb_rdwr | ||
67 | }; | ||
68 | |||
69 | |||
70 | struct iommu_table { | ||
71 | unsigned long it_busno; /* Bus number this table belongs to */ | ||
72 | unsigned long it_size; /* Size of iommu table in entries */ | ||
73 | unsigned long it_offset; /* Offset into global table */ | ||
74 | unsigned long it_base; /* mapped address of tce table */ | ||
75 | unsigned long it_index; /* which iommu table this is */ | ||
76 | unsigned long it_type; /* type: PCI or Virtual Bus */ | ||
77 | unsigned long it_blocksize; /* Entries in each block (cacheline) */ | ||
78 | unsigned long it_hint; /* Hint for next alloc */ | ||
79 | unsigned long it_largehint; /* Hint for large allocs */ | ||
80 | unsigned long it_halfpoint; /* Breaking point for small/large allocs */ | ||
81 | spinlock_t it_lock; /* Protects it_map */ | ||
82 | unsigned long *it_map; /* A simple allocation bitmap for now */ | ||
83 | }; | ||
84 | |||
85 | #ifdef CONFIG_PPC_ISERIES | ||
86 | struct iommu_table_cb { | ||
87 | unsigned long itc_busno; /* Bus number for this tce table */ | ||
88 | unsigned long itc_start; /* Will be NULL for secondary */ | ||
89 | unsigned long itc_totalsize; /* Size (in pages) of whole table */ | ||
90 | unsigned long itc_offset; /* Index into real tce table of the | ||
91 | start of our section */ | ||
92 | unsigned long itc_size; /* Size (in pages) of our section */ | ||
93 | unsigned long itc_index; /* Index of this tce table */ | ||
94 | unsigned short itc_maxtables; /* Max num of tables for partition */ | ||
95 | unsigned char itc_virtbus; /* Flag to indicate virtual bus */ | ||
96 | unsigned char itc_slotno; /* IOA Tce Slot Index */ | ||
97 | unsigned char itc_rsvd[4]; | ||
98 | }; | ||
99 | |||
100 | extern struct iommu_table vio_tce_table; /* Tce table for virtual bus */ | ||
101 | #endif /* CONFIG_PPC_ISERIES */ | ||
102 | |||
103 | struct scatterlist; | ||
104 | |||
105 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
106 | |||
107 | /* Walks all buses and creates iommu tables */ | ||
108 | extern void iommu_setup_pSeries(void); | ||
109 | extern void iommu_setup_u3(void); | ||
110 | |||
111 | /* Frees table for an individual device node */ | ||
112 | extern void iommu_free_table(struct device_node *dn); | ||
113 | |||
114 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
115 | |||
116 | #ifdef CONFIG_PPC_PSERIES | ||
117 | |||
118 | /* Creates table for an individual device node */ | ||
119 | extern void iommu_devnode_init_pSeries(struct device_node *dn); | ||
120 | |||
121 | #endif /* CONFIG_PPC_PSERIES */ | ||
122 | |||
123 | #ifdef CONFIG_PPC_ISERIES | ||
124 | |||
125 | /* Walks all buses and creates iommu tables */ | ||
126 | extern void iommu_setup_iSeries(void); | ||
127 | |||
128 | /* Initializes tables for bio buses */ | ||
129 | extern void __init iommu_vio_init(void); | ||
130 | |||
131 | struct iSeries_Device_Node; | ||
132 | /* Creates table for an individual device node */ | ||
133 | extern void iommu_devnode_init_iSeries(struct iSeries_Device_Node *dn); | ||
134 | |||
135 | #endif /* CONFIG_PPC_ISERIES */ | ||
136 | |||
137 | /* Initializes an iommu_table based in values set in the passed-in | ||
138 | * structure | ||
139 | */ | ||
140 | extern struct iommu_table *iommu_init_table(struct iommu_table * tbl); | ||
141 | |||
142 | extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, | ||
143 | struct scatterlist *sglist, int nelems, | ||
144 | enum dma_data_direction direction); | ||
145 | extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist, | ||
146 | int nelems, enum dma_data_direction direction); | ||
147 | |||
148 | extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size, | ||
149 | dma_addr_t *dma_handle, unsigned int __nocast flag); | ||
150 | extern void iommu_free_coherent(struct iommu_table *tbl, size_t size, | ||
151 | void *vaddr, dma_addr_t dma_handle); | ||
152 | extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr, | ||
153 | size_t size, enum dma_data_direction direction); | ||
154 | extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, | ||
155 | size_t size, enum dma_data_direction direction); | ||
156 | |||
157 | extern void iommu_init_early_pSeries(void); | ||
158 | extern void iommu_init_early_iSeries(void); | ||
159 | extern void iommu_init_early_u3(void); | ||
160 | |||
161 | extern void pci_iommu_init(void); | ||
162 | extern void pci_direct_iommu_init(void); | ||
163 | |||
164 | extern void alloc_u3_dart_table(void); | ||
165 | |||
166 | #endif /* _ASM_IOMMU_H */ | ||