aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2012-11-02 15:24:03 -0400
committerTony Lindgren <tony@atomide.com>2012-11-20 13:04:29 -0500
commitc8d35c84f5494d8d294205b598f927a11fd41f34 (patch)
tree2a28d6147cc9a0790419d4a2b5ae8ff75919f4f6
parent2f7702af64d6ae7ae8b7f6d5dca1bf8bdaf0ac1f (diff)
ARM: OMAP2+: Move plat/iovmm.h to include/linux/omap-iommu.h
Looks like the iommu framework does not have generic functions exported for all the needs yet. The hardware specific functions are defined in files like intel-iommu.h and amd-iommu.h. Follow the same standard for omap-iommu.h. This is needed because we are removing plat and mach includes for ARM common zImage support. Further work should continue in the iommu framework context as only pure platform data will be communicated from arch/arm/*omap*/* code to the iommu framework. Cc: Ido Yariv <ido@wizery.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Omar Ramirez Luna <omar.luna@linaro.org> Cc: linux-media@vger.kernel.org Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Ohad Ben-Cohen <ohad@wizery.com> Acked-by: Joerg Roedel <joro@8bytes.org> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap2/iommu2.c1
-rw-r--r--arch/arm/plat-omap/include/plat/iommu.h10
-rw-r--r--arch/arm/plat-omap/include/plat/iovmm.h89
-rw-r--r--drivers/iommu/omap-iommu-debug.c2
-rw-r--r--drivers/iommu/omap-iommu.c1
-rw-r--r--drivers/iommu/omap-iovmm.c46
-rw-r--r--drivers/media/platform/omap3isp/isp.c1
-rw-r--r--drivers/media/platform/omap3isp/isp.h4
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c1
-rw-r--r--drivers/media/platform/omap3isp/ispstat.c1
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c2
-rw-r--r--include/linux/omap-iommu.h52
12 files changed, 107 insertions, 103 deletions
diff --git a/arch/arm/mach-omap2/iommu2.c b/arch/arm/mach-omap2/iommu2.c
index eefc37912ef3..e8116cf58e15 100644
--- a/arch/arm/mach-omap2/iommu2.c
+++ b/arch/arm/mach-omap2/iommu2.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/jiffies.h> 16#include <linux/jiffies.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/omap-iommu.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/stringify.h> 20#include <linux/stringify.h>
20 21
diff --git a/arch/arm/plat-omap/include/plat/iommu.h b/arch/arm/plat-omap/include/plat/iommu.h
index 7e8c7b66ee35..a4b71b14975a 100644
--- a/arch/arm/plat-omap/include/plat/iommu.h
+++ b/arch/arm/plat-omap/include/plat/iommu.h
@@ -216,13 +216,10 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
216#define MMU_RAM_PADDR_SHIFT 12 216#define MMU_RAM_PADDR_SHIFT 12
217#define MMU_RAM_PADDR_MASK \ 217#define MMU_RAM_PADDR_MASK \
218 ((~0UL >> MMU_RAM_PADDR_SHIFT) << MMU_RAM_PADDR_SHIFT) 218 ((~0UL >> MMU_RAM_PADDR_SHIFT) << MMU_RAM_PADDR_SHIFT)
219#define MMU_RAM_ENDIAN_SHIFT 9 219
220#define MMU_RAM_ENDIAN_MASK (1 << MMU_RAM_ENDIAN_SHIFT) 220#define MMU_RAM_ENDIAN_MASK (1 << MMU_RAM_ENDIAN_SHIFT)
221#define MMU_RAM_ENDIAN_BIG (1 << MMU_RAM_ENDIAN_SHIFT)
222#define MMU_RAM_ENDIAN_LITTLE (0 << MMU_RAM_ENDIAN_SHIFT)
223#define MMU_RAM_ELSZ_SHIFT 7
224#define MMU_RAM_ELSZ_MASK (3 << MMU_RAM_ELSZ_SHIFT) 221#define MMU_RAM_ELSZ_MASK (3 << MMU_RAM_ELSZ_SHIFT)
225#define MMU_RAM_ELSZ_8 (0 << MMU_RAM_ELSZ_SHIFT) 222
226#define MMU_RAM_ELSZ_16 (1 << MMU_RAM_ELSZ_SHIFT) 223#define MMU_RAM_ELSZ_16 (1 << MMU_RAM_ELSZ_SHIFT)
227#define MMU_RAM_ELSZ_32 (2 << MMU_RAM_ELSZ_SHIFT) 224#define MMU_RAM_ELSZ_32 (2 << MMU_RAM_ELSZ_SHIFT)
228#define MMU_RAM_ELSZ_NONE (3 << MMU_RAM_ELSZ_SHIFT) 225#define MMU_RAM_ELSZ_NONE (3 << MMU_RAM_ELSZ_SHIFT)
@@ -269,9 +266,6 @@ extern int omap_iommu_set_isr(const char *name,
269 void *priv), 266 void *priv),
270 void *isr_priv); 267 void *isr_priv);
271 268
272extern void omap_iommu_save_ctx(struct device *dev);
273extern void omap_iommu_restore_ctx(struct device *dev);
274
275extern int omap_install_iommu_arch(const struct iommu_functions *ops); 269extern int omap_install_iommu_arch(const struct iommu_functions *ops);
276extern void omap_uninstall_iommu_arch(const struct iommu_functions *ops); 270extern void omap_uninstall_iommu_arch(const struct iommu_functions *ops);
277 271
diff --git a/arch/arm/plat-omap/include/plat/iovmm.h b/arch/arm/plat-omap/include/plat/iovmm.h
deleted file mode 100644
index 498e57cda6cd..000000000000
--- a/arch/arm/plat-omap/include/plat/iovmm.h
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * omap iommu: simple virtual address space management
3 *
4 * Copyright (C) 2008-2009 Nokia Corporation
5 *
6 * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __IOMMU_MMAP_H
14#define __IOMMU_MMAP_H
15
16#include <linux/iommu.h>
17
18struct iovm_struct {
19 struct omap_iommu *iommu; /* iommu object which this belongs to */
20 u32 da_start; /* area definition */
21 u32 da_end;
22 u32 flags; /* IOVMF_: see below */
23 struct list_head list; /* linked in ascending order */
24 const struct sg_table *sgt; /* keep 'page' <-> 'da' mapping */
25 void *va; /* mpu side mapped address */
26};
27
28/*
29 * IOVMF_FLAGS: attribute for iommu virtual memory area(iovma)
30 *
31 * lower 16 bit is used for h/w and upper 16 bit is for s/w.
32 */
33#define IOVMF_SW_SHIFT 16
34
35/*
36 * iovma: h/w flags derived from cam and ram attribute
37 */
38#define IOVMF_CAM_MASK (~((1 << 10) - 1))
39#define IOVMF_RAM_MASK (~IOVMF_CAM_MASK)
40
41#define IOVMF_PGSZ_MASK (3 << 0)
42#define IOVMF_PGSZ_1M MMU_CAM_PGSZ_1M
43#define IOVMF_PGSZ_64K MMU_CAM_PGSZ_64K
44#define IOVMF_PGSZ_4K MMU_CAM_PGSZ_4K
45#define IOVMF_PGSZ_16M MMU_CAM_PGSZ_16M
46
47#define IOVMF_ENDIAN_MASK (1 << 9)
48#define IOVMF_ENDIAN_BIG MMU_RAM_ENDIAN_BIG
49#define IOVMF_ENDIAN_LITTLE MMU_RAM_ENDIAN_LITTLE
50
51#define IOVMF_ELSZ_MASK (3 << 7)
52#define IOVMF_ELSZ_8 MMU_RAM_ELSZ_8
53#define IOVMF_ELSZ_16 MMU_RAM_ELSZ_16
54#define IOVMF_ELSZ_32 MMU_RAM_ELSZ_32
55#define IOVMF_ELSZ_NONE MMU_RAM_ELSZ_NONE
56
57#define IOVMF_MIXED_MASK (1 << 6)
58#define IOVMF_MIXED MMU_RAM_MIXED
59
60/*
61 * iovma: s/w flags, used for mapping and umapping internally.
62 */
63#define IOVMF_MMIO (1 << IOVMF_SW_SHIFT)
64#define IOVMF_ALLOC (2 << IOVMF_SW_SHIFT)
65#define IOVMF_ALLOC_MASK (3 << IOVMF_SW_SHIFT)
66
67/* "superpages" is supported just with physically linear pages */
68#define IOVMF_DISCONT (1 << (2 + IOVMF_SW_SHIFT))
69#define IOVMF_LINEAR (2 << (2 + IOVMF_SW_SHIFT))
70#define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT))
71
72#define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT))
73
74
75extern struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da);
76extern u32
77omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da,
78 const struct sg_table *sgt, u32 flags);
79extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain,
80 struct device *dev, u32 da);
81extern u32
82omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev,
83 u32 da, size_t bytes, u32 flags);
84extern void
85omap_iommu_vfree(struct iommu_domain *domain, struct device *dev,
86 const u32 da);
87extern void *omap_da_to_va(struct device *dev, u32 da);
88
89#endif /* __IOMMU_MMAP_H */
diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 0cac372b0d43..cf4a0b5c1d82 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -18,9 +18,9 @@
18#include <linux/uaccess.h> 18#include <linux/uaccess.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/debugfs.h> 20#include <linux/debugfs.h>
21#include <linux/omap-iommu.h>
21 22
22#include <plat/iommu.h> 23#include <plat/iommu.h>
23#include <plat/iovmm.h>
24 24
25#include "omap-iopgtable.h" 25#include "omap-iopgtable.h"
26 26
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index f2bbfb0fd0e0..eadcfde757ee 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -19,6 +19,7 @@
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/iommu.h> 21#include <linux/iommu.h>
22#include <linux/omap-iommu.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
23#include <linux/spinlock.h> 24#include <linux/spinlock.h>
24 25
diff --git a/drivers/iommu/omap-iovmm.c b/drivers/iommu/omap-iovmm.c
index b332392397ce..9852101cf042 100644
--- a/drivers/iommu/omap-iovmm.c
+++ b/drivers/iommu/omap-iovmm.c
@@ -17,15 +17,59 @@
17#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <linux/iommu.h> 19#include <linux/iommu.h>
20#include <linux/omap-iommu.h>
20 21
21#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
22#include <asm/mach/map.h> 23#include <asm/mach/map.h>
23 24
24#include <plat/iommu.h> 25#include <plat/iommu.h>
25#include <plat/iovmm.h>
26 26
27#include "omap-iopgtable.h" 27#include "omap-iopgtable.h"
28 28
29/*
30 * IOVMF_FLAGS: attribute for iommu virtual memory area(iovma)
31 *
32 * lower 16 bit is used for h/w and upper 16 bit is for s/w.
33 */
34#define IOVMF_SW_SHIFT 16
35
36/*
37 * iovma: h/w flags derived from cam and ram attribute
38 */
39#define IOVMF_CAM_MASK (~((1 << 10) - 1))
40#define IOVMF_RAM_MASK (~IOVMF_CAM_MASK)
41
42#define IOVMF_PGSZ_MASK (3 << 0)
43#define IOVMF_PGSZ_1M MMU_CAM_PGSZ_1M
44#define IOVMF_PGSZ_64K MMU_CAM_PGSZ_64K
45#define IOVMF_PGSZ_4K MMU_CAM_PGSZ_4K
46#define IOVMF_PGSZ_16M MMU_CAM_PGSZ_16M
47
48#define IOVMF_ENDIAN_MASK (1 << 9)
49#define IOVMF_ENDIAN_BIG MMU_RAM_ENDIAN_BIG
50
51#define IOVMF_ELSZ_MASK (3 << 7)
52#define IOVMF_ELSZ_16 MMU_RAM_ELSZ_16
53#define IOVMF_ELSZ_32 MMU_RAM_ELSZ_32
54#define IOVMF_ELSZ_NONE MMU_RAM_ELSZ_NONE
55
56#define IOVMF_MIXED_MASK (1 << 6)
57#define IOVMF_MIXED MMU_RAM_MIXED
58
59/*
60 * iovma: s/w flags, used for mapping and umapping internally.
61 */
62#define IOVMF_MMIO (1 << IOVMF_SW_SHIFT)
63#define IOVMF_ALLOC (2 << IOVMF_SW_SHIFT)
64#define IOVMF_ALLOC_MASK (3 << IOVMF_SW_SHIFT)
65
66/* "superpages" is supported just with physically linear pages */
67#define IOVMF_DISCONT (1 << (2 + IOVMF_SW_SHIFT))
68#define IOVMF_LINEAR (2 << (2 + IOVMF_SW_SHIFT))
69#define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT))
70
71#define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT))
72
29static struct kmem_cache *iovm_area_cachep; 73static struct kmem_cache *iovm_area_cachep;
30 74
31/* return the offset of the first scatterlist entry in a sg table */ 75/* return the offset of the first scatterlist entry in a sg table */
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 99640d8c1db0..7f182f0ff3da 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -61,6 +61,7 @@
61#include <linux/i2c.h> 61#include <linux/i2c.h>
62#include <linux/interrupt.h> 62#include <linux/interrupt.h>
63#include <linux/module.h> 63#include <linux/module.h>
64#include <linux/omap-iommu.h>
64#include <linux/platform_device.h> 65#include <linux/platform_device.h>
65#include <linux/regulator/consumer.h> 66#include <linux/regulator/consumer.h>
66#include <linux/slab.h> 67#include <linux/slab.h>
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 8be7487c326f..8d6866942b85 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -31,11 +31,9 @@
31#include <media/v4l2-device.h> 31#include <media/v4l2-device.h>
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/iommu.h>
34#include <linux/platform_device.h> 35#include <linux/platform_device.h>
35#include <linux/wait.h> 36#include <linux/wait.h>
36#include <linux/iommu.h>
37#include <plat/iommu.h>
38#include <plat/iovmm.h>
39 37
40#include "ispstat.h" 38#include "ispstat.h"
41#include "ispccdc.h" 39#include "ispccdc.h"
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 60181ab96063..6ae1ffb277e7 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -30,6 +30,7 @@
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/omap-iommu.h>
33#include <linux/sched.h> 34#include <linux/sched.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35#include <media/v4l2-event.h> 36#include <media/v4l2-event.h>
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c
index d7ac76b5c2ae..35c38237449d 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/omap-iommu.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/uaccess.h> 31#include <linux/uaccess.h>
31 32
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index a0b737fecf13..a4b829027d71 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -27,6 +27,7 @@
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/omap-iommu.h>
30#include <linux/pagemap.h> 31#include <linux/pagemap.h>
31#include <linux/scatterlist.h> 32#include <linux/scatterlist.h>
32#include <linux/sched.h> 33#include <linux/sched.h>
@@ -35,7 +36,6 @@
35#include <media/v4l2-dev.h> 36#include <media/v4l2-dev.h>
36#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
37#include <plat/iommu.h> 38#include <plat/iommu.h>
38#include <plat/iovmm.h>
39#include <plat/omap-pm.h> 39#include <plat/omap-pm.h>
40 40
41#include "ispvideo.h" 41#include "ispvideo.h"
diff --git a/include/linux/omap-iommu.h b/include/linux/omap-iommu.h
new file mode 100644
index 000000000000..cac78de09c07
--- /dev/null
+++ b/include/linux/omap-iommu.h
@@ -0,0 +1,52 @@
1/*
2 * omap iommu: simple virtual address space management
3 *
4 * Copyright (C) 2008-2009 Nokia Corporation
5 *
6 * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _INTEL_IOMMU_H_
14#define _INTEL_IOMMU_H_
15
16struct iovm_struct {
17 struct omap_iommu *iommu; /* iommu object which this belongs to */
18 u32 da_start; /* area definition */
19 u32 da_end;
20 u32 flags; /* IOVMF_: see below */
21 struct list_head list; /* linked in ascending order */
22 const struct sg_table *sgt; /* keep 'page' <-> 'da' mapping */
23 void *va; /* mpu side mapped address */
24};
25
26#define MMU_RAM_ENDIAN_SHIFT 9
27#define MMU_RAM_ENDIAN_LITTLE (0 << MMU_RAM_ENDIAN_SHIFT)
28#define MMU_RAM_ELSZ_8 (0 << MMU_RAM_ELSZ_SHIFT)
29#define IOVMF_ENDIAN_LITTLE MMU_RAM_ENDIAN_LITTLE
30#define MMU_RAM_ELSZ_SHIFT 7
31#define IOVMF_ELSZ_8 MMU_RAM_ELSZ_8
32
33struct iommu_domain;
34
35extern struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da);
36extern u32
37omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da,
38 const struct sg_table *sgt, u32 flags);
39extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain,
40 struct device *dev, u32 da);
41extern u32
42omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev,
43 u32 da, size_t bytes, u32 flags);
44extern void
45omap_iommu_vfree(struct iommu_domain *domain, struct device *dev,
46 const u32 da);
47extern void *omap_da_to_va(struct device *dev, u32 da);
48
49extern void omap_iommu_save_ctx(struct device *dev);
50extern void omap_iommu_restore_ctx(struct device *dev);
51
52#endif