aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/omap-iommu.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu/omap-iommu.h')
-rw-r--r--drivers/iommu/omap-iommu.h98
1 files changed, 48 insertions, 50 deletions
diff --git a/drivers/iommu/omap-iommu.h b/drivers/iommu/omap-iommu.h
index 4f1b68c08c15..d736630df3c8 100644
--- a/drivers/iommu/omap-iommu.h
+++ b/drivers/iommu/omap-iommu.h
@@ -10,9 +10,8 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#if defined(CONFIG_ARCH_OMAP1) 13#ifndef _OMAP_IOMMU_H
14#error "iommu for this processor not implemented yet" 14#define _OMAP_IOMMU_H
15#endif
16 15
17struct iotlb_entry { 16struct iotlb_entry {
18 u32 da; 17 u32 da;
@@ -30,10 +29,9 @@ struct omap_iommu {
30 const char *name; 29 const char *name;
31 void __iomem *regbase; 30 void __iomem *regbase;
32 struct device *dev; 31 struct device *dev;
33 void *isr_priv;
34 struct iommu_domain *domain; 32 struct iommu_domain *domain;
33 struct dentry *debug_dir;
35 34
36 unsigned int refcount;
37 spinlock_t iommu_lock; /* global for this whole object */ 35 spinlock_t iommu_lock; /* global for this whole object */
38 36
39 /* 37 /*
@@ -67,34 +65,6 @@ struct cr_regs {
67 }; 65 };
68}; 66};
69 67
70/* architecture specific functions */
71struct iommu_functions {
72 unsigned long version;
73
74 int (*enable)(struct omap_iommu *obj);
75 void (*disable)(struct omap_iommu *obj);
76 void (*set_twl)(struct omap_iommu *obj, bool on);
77 u32 (*fault_isr)(struct omap_iommu *obj, u32 *ra);
78
79 void (*tlb_read_cr)(struct omap_iommu *obj, struct cr_regs *cr);
80 void (*tlb_load_cr)(struct omap_iommu *obj, struct cr_regs *cr);
81
82 struct cr_regs *(*alloc_cr)(struct omap_iommu *obj,
83 struct iotlb_entry *e);
84 int (*cr_valid)(struct cr_regs *cr);
85 u32 (*cr_to_virt)(struct cr_regs *cr);
86 void (*cr_to_e)(struct cr_regs *cr, struct iotlb_entry *e);
87 ssize_t (*dump_cr)(struct omap_iommu *obj, struct cr_regs *cr,
88 char *buf);
89
90 u32 (*get_pte_attr)(struct iotlb_entry *e);
91
92 void (*save_ctx)(struct omap_iommu *obj);
93 void (*restore_ctx)(struct omap_iommu *obj);
94 ssize_t (*dump_ctx)(struct omap_iommu *obj, char *buf, ssize_t len);
95};
96
97#ifdef CONFIG_IOMMU_API
98/** 68/**
99 * dev_to_omap_iommu() - retrieves an omap iommu object from a user device 69 * dev_to_omap_iommu() - retrieves an omap iommu object from a user device
100 * @dev: iommu client device 70 * @dev: iommu client device
@@ -105,7 +75,6 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
105 75
106 return arch_data->iommu_dev; 76 return arch_data->iommu_dev;
107} 77}
108#endif
109 78
110/* 79/*
111 * MMU Register offsets 80 * MMU Register offsets
@@ -133,6 +102,28 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
133/* 102/*
134 * MMU Register bit definitions 103 * MMU Register bit definitions
135 */ 104 */
105/* IRQSTATUS & IRQENABLE */
106#define MMU_IRQ_MULTIHITFAULT (1 << 4)
107#define MMU_IRQ_TABLEWALKFAULT (1 << 3)
108#define MMU_IRQ_EMUMISS (1 << 2)
109#define MMU_IRQ_TRANSLATIONFAULT (1 << 1)
110#define MMU_IRQ_TLBMISS (1 << 0)
111
112#define __MMU_IRQ_FAULT \
113 (MMU_IRQ_MULTIHITFAULT | MMU_IRQ_EMUMISS | MMU_IRQ_TRANSLATIONFAULT)
114#define MMU_IRQ_MASK \
115 (__MMU_IRQ_FAULT | MMU_IRQ_TABLEWALKFAULT | MMU_IRQ_TLBMISS)
116#define MMU_IRQ_TWL_MASK (__MMU_IRQ_FAULT | MMU_IRQ_TABLEWALKFAULT)
117#define MMU_IRQ_TLB_MISS_MASK (__MMU_IRQ_FAULT | MMU_IRQ_TLBMISS)
118
119/* MMU_CNTL */
120#define MMU_CNTL_SHIFT 1
121#define MMU_CNTL_MASK (7 << MMU_CNTL_SHIFT)
122#define MMU_CNTL_EML_TLB (1 << 3)
123#define MMU_CNTL_TWL_EN (1 << 2)
124#define MMU_CNTL_MMU_EN (1 << 1)
125
126/* CAM */
136#define MMU_CAM_VATAG_SHIFT 12 127#define MMU_CAM_VATAG_SHIFT 12
137#define MMU_CAM_VATAG_MASK \ 128#define MMU_CAM_VATAG_MASK \
138 ((~0UL >> MMU_CAM_VATAG_SHIFT) << MMU_CAM_VATAG_SHIFT) 129 ((~0UL >> MMU_CAM_VATAG_SHIFT) << MMU_CAM_VATAG_SHIFT)
@@ -144,6 +135,7 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
144#define MMU_CAM_PGSZ_4K (2 << 0) 135#define MMU_CAM_PGSZ_4K (2 << 0)
145#define MMU_CAM_PGSZ_16M (3 << 0) 136#define MMU_CAM_PGSZ_16M (3 << 0)
146 137
138/* RAM */
147#define MMU_RAM_PADDR_SHIFT 12 139#define MMU_RAM_PADDR_SHIFT 12
148#define MMU_RAM_PADDR_MASK \ 140#define MMU_RAM_PADDR_MASK \
149 ((~0UL >> MMU_RAM_PADDR_SHIFT) << MMU_RAM_PADDR_SHIFT) 141 ((~0UL >> MMU_RAM_PADDR_SHIFT) << MMU_RAM_PADDR_SHIFT)
@@ -165,6 +157,12 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
165 157
166#define MMU_GP_REG_BUS_ERR_BACK_EN 0x1 158#define MMU_GP_REG_BUS_ERR_BACK_EN 0x1
167 159
160#define get_cam_va_mask(pgsz) \
161 (((pgsz) == MMU_CAM_PGSZ_16M) ? 0xff000000 : \
162 ((pgsz) == MMU_CAM_PGSZ_1M) ? 0xfff00000 : \
163 ((pgsz) == MMU_CAM_PGSZ_64K) ? 0xffff0000 : \
164 ((pgsz) == MMU_CAM_PGSZ_4K) ? 0xfffff000 : 0)
165
168/* 166/*
169 * utilities for super page(16MB, 1MB, 64KB and 4KB) 167 * utilities for super page(16MB, 1MB, 64KB and 4KB)
170 */ 168 */
@@ -192,27 +190,25 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
192/* 190/*
193 * global functions 191 * global functions
194 */ 192 */
195extern u32 omap_iommu_arch_version(void); 193#ifdef CONFIG_OMAP_IOMMU_DEBUG
196
197extern void omap_iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e);
198
199extern int
200omap_iopgtable_store_entry(struct omap_iommu *obj, struct iotlb_entry *e);
201
202extern void omap_iommu_save_ctx(struct device *dev);
203extern void omap_iommu_restore_ctx(struct device *dev);
204
205extern int omap_foreach_iommu_device(void *data,
206 int (*fn)(struct device *, void *));
207
208extern int omap_install_iommu_arch(const struct iommu_functions *ops);
209extern void omap_uninstall_iommu_arch(const struct iommu_functions *ops);
210
211extern ssize_t 194extern ssize_t
212omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len); 195omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len);
213extern size_t 196extern size_t
214omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len); 197omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len);
215 198
199void omap_iommu_debugfs_init(void);
200void omap_iommu_debugfs_exit(void);
201
202void omap_iommu_debugfs_add(struct omap_iommu *obj);
203void omap_iommu_debugfs_remove(struct omap_iommu *obj);
204#else
205static inline void omap_iommu_debugfs_init(void) { }
206static inline void omap_iommu_debugfs_exit(void) { }
207
208static inline void omap_iommu_debugfs_add(struct omap_iommu *obj) { }
209static inline void omap_iommu_debugfs_remove(struct omap_iommu *obj) { }
210#endif
211
216/* 212/*
217 * register accessors 213 * register accessors
218 */ 214 */
@@ -225,3 +221,5 @@ static inline void iommu_write_reg(struct omap_iommu *obj, u32 val, size_t offs)
225{ 221{
226 __raw_writel(val, obj->regbase + offs); 222 __raw_writel(val, obj->regbase + offs);
227} 223}
224
225#endif /* _OMAP_IOMMU_H */