aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/iommu.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-powerpc/iommu.h')
-rw-r--r--include/asm-powerpc/iommu.h50
1 files changed, 30 insertions, 20 deletions
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index a5e98641a2ae..f85dbd305558 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -22,17 +22,35 @@
22#define _ASM_IOMMU_H 22#define _ASM_IOMMU_H
23#ifdef __KERNEL__ 23#ifdef __KERNEL__
24 24
25#include <asm/types.h> 25#include <linux/compiler.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <asm/types.h>
30#include <asm/bitops.h>
31
32#define IOMMU_PAGE_SHIFT 12
33#define IOMMU_PAGE_SIZE (ASM_CONST(1) << IOMMU_PAGE_SHIFT)
34#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1))
35#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE)
36
37/* Boot time flags */
38extern int iommu_is_off;
39extern int iommu_force_on;
40
41/* Pure 2^n version of get_order */
42static __inline__ __attribute_const__ int get_iommu_order(unsigned long size)
43{
44 return __ilog2((size - 1) >> IOMMU_PAGE_SHIFT) + 1;
45}
46
29 47
30/* 48/*
31 * IOMAP_MAX_ORDER defines the largest contiguous block 49 * IOMAP_MAX_ORDER defines the largest contiguous block
32 * of dma space we can get. IOMAP_MAX_ORDER = 13 50 * of dma space we can get. IOMAP_MAX_ORDER = 13
33 * allows up to 2**12 pages (4096 * 4096) = 16 MB 51 * allows up to 2**12 pages (4096 * 4096) = 16 MB
34 */ 52 */
35#define IOMAP_MAX_ORDER 13 53#define IOMAP_MAX_ORDER 13
36 54
37struct iommu_table { 55struct iommu_table {
38 unsigned long it_busno; /* Bus number this table belongs to */ 56 unsigned long it_busno; /* Bus number this table belongs to */
@@ -52,39 +70,31 @@ struct iommu_table {
52struct scatterlist; 70struct scatterlist;
53struct device_node; 71struct device_node;
54 72
55#ifdef CONFIG_PPC_MULTIPLATFORM
56
57/* Walks all buses and creates iommu tables */
58extern void iommu_setup_pSeries(void);
59extern void iommu_setup_dart(void);
60
61/* Frees table for an individual device node */ 73/* Frees table for an individual device node */
62extern void iommu_free_table(struct device_node *dn); 74extern void iommu_free_table(struct device_node *dn);
63 75
64#endif /* CONFIG_PPC_MULTIPLATFORM */
65
66/* Initializes an iommu_table based in values set in the passed-in 76/* Initializes an iommu_table based in values set in the passed-in
67 * structure 77 * structure
68 */ 78 */
69extern struct iommu_table *iommu_init_table(struct iommu_table * tbl, 79extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
70 int nid); 80 int nid);
71 81
72extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, 82extern int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
73 struct scatterlist *sglist, int nelems, unsigned long mask, 83 int nelems, unsigned long mask,
74 enum dma_data_direction direction); 84 enum dma_data_direction direction);
75extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist, 85extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
76 int nelems, enum dma_data_direction direction); 86 int nelems, enum dma_data_direction direction);
77 87
78extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size, 88extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
79 dma_addr_t *dma_handle, unsigned long mask, 89 dma_addr_t *dma_handle, unsigned long mask,
80 gfp_t flag, int node); 90 gfp_t flag, int node);
81extern void iommu_free_coherent(struct iommu_table *tbl, size_t size, 91extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
82 void *vaddr, dma_addr_t dma_handle); 92 void *vaddr, dma_addr_t dma_handle);
83extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr, 93extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
84 size_t size, unsigned long mask, 94 size_t size, unsigned long mask,
85 enum dma_data_direction direction); 95 enum dma_data_direction direction);
86extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, 96extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
87 size_t size, enum dma_data_direction direction); 97 size_t size, enum dma_data_direction direction);
88 98
89extern void iommu_init_early_pSeries(void); 99extern void iommu_init_early_pSeries(void);
90extern void iommu_init_early_iSeries(void); 100extern void iommu_init_early_iSeries(void);