2 * omap iommu: main structures
4 * Copyright (C) 2008-2009 Nokia Corporation
6 * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
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.
13 #ifndef __MACH_IOMMU_H
14 #define __MACH_IOMMU_H
19 u32 pgsz
, prsvd
, valid
;
23 u32 endian
, elsz
, mixed
;
32 void __iomem
*regbase
;
35 struct iommu_domain
*domain
;
37 unsigned int refcount
;
38 spinlock_t iommu_lock
; /* global for this whole object */
41 * We don't change iopgd for a situation like pgd for a task,
42 * but share it globally for each iommu.
45 spinlock_t page_table_lock
; /* protect iopgd */
49 struct list_head mmap
;
50 struct mutex mmap_lock
; /* protect mmap */
52 void *ctx
; /* iommu context: registres saved area */
79 /* architecture specific functions */
80 struct iommu_functions
{
81 unsigned long version
;
83 int (*enable
)(struct omap_iommu
*obj
);
84 void (*disable
)(struct omap_iommu
*obj
);
85 void (*set_twl
)(struct omap_iommu
*obj
, bool on
);
86 u32 (*fault_isr
)(struct omap_iommu
*obj
, u32
*ra
);
88 void (*tlb_read_cr
)(struct omap_iommu
*obj
, struct cr_regs
*cr
);
89 void (*tlb_load_cr
)(struct omap_iommu
*obj
, struct cr_regs
*cr
);
91 struct cr_regs
*(*alloc_cr
)(struct omap_iommu
*obj
,
92 struct iotlb_entry
*e
);
93 int (*cr_valid
)(struct cr_regs
*cr
);
94 u32 (*cr_to_virt
)(struct cr_regs
*cr
);
95 void (*cr_to_e
)(struct cr_regs
*cr
, struct iotlb_entry
*e
);
96 ssize_t (*dump_cr
)(struct omap_iommu
*obj
, struct cr_regs
*cr
,
99 u32 (*get_pte_attr
)(struct iotlb_entry
*e
);
101 void (*save_ctx
)(struct omap_iommu
*obj
);
102 void (*restore_ctx
)(struct omap_iommu
*obj
);
103 ssize_t (*dump_ctx
)(struct omap_iommu
*obj
, char *buf
, ssize_t len
);
106 struct iommu_platform_data
{
108 const char *clk_name
;
109 const int nr_tlb_entries
;
115 #define OMAP_IOMMU_ERR_TLB_MISS (1 << 0)
116 #define OMAP_IOMMU_ERR_TRANS_FAULT (1 << 1)
117 #define OMAP_IOMMU_ERR_EMU_MISS (1 << 2)
118 #define OMAP_IOMMU_ERR_TBLWALK_FAULT (1 << 3)
119 #define OMAP_IOMMU_ERR_MULTIHIT_FAULT (1 << 4)
121 #if defined(CONFIG_ARCH_OMAP1)
122 #error "iommu for this processor not implemented yet"
124 #include <plat/iommu2.h>
128 * utilities for super page(16MB, 1MB, 64KB and 4KB)
131 #define iopgsz_max(bytes) \
132 (((bytes) >= SZ_16M) ? SZ_16M : \
133 ((bytes) >= SZ_1M) ? SZ_1M : \
134 ((bytes) >= SZ_64K) ? SZ_64K : \
135 ((bytes) >= SZ_4K) ? SZ_4K : 0)
137 #define bytes_to_iopgsz(bytes) \
138 (((bytes) == SZ_16M) ? MMU_CAM_PGSZ_16M : \
139 ((bytes) == SZ_1M) ? MMU_CAM_PGSZ_1M : \
140 ((bytes) == SZ_64K) ? MMU_CAM_PGSZ_64K : \
141 ((bytes) == SZ_4K) ? MMU_CAM_PGSZ_4K : -1)
143 #define iopgsz_to_bytes(iopgsz) \
144 (((iopgsz) == MMU_CAM_PGSZ_16M) ? SZ_16M : \
145 ((iopgsz) == MMU_CAM_PGSZ_1M) ? SZ_1M : \
146 ((iopgsz) == MMU_CAM_PGSZ_64K) ? SZ_64K : \
147 ((iopgsz) == MMU_CAM_PGSZ_4K) ? SZ_4K : 0)
149 #define iopgsz_ok(bytes) (bytes_to_iopgsz(bytes) >= 0)
154 extern u32
omap_iommu_arch_version(void);
156 extern void omap_iotlb_cr_to_e(struct cr_regs
*cr
, struct iotlb_entry
*e
);
159 omap_iopgtable_store_entry(struct omap_iommu
*obj
, struct iotlb_entry
*e
);
161 extern int omap_iommu_set_isr(const char *name
,
162 int (*isr
)(struct omap_iommu
*obj
, u32 da
, u32 iommu_errs
,
166 extern void omap_iommu_save_ctx(struct omap_iommu
*obj
);
167 extern void omap_iommu_restore_ctx(struct omap_iommu
*obj
);
169 extern int omap_install_iommu_arch(const struct iommu_functions
*ops
);
170 extern void omap_uninstall_iommu_arch(const struct iommu_functions
*ops
);
172 extern int omap_foreach_iommu_device(void *data
,
173 int (*fn
)(struct device
*, void *));
176 omap_iommu_dump_ctx(struct omap_iommu
*obj
, char *buf
, ssize_t len
);
178 omap_dump_tlb_entries(struct omap_iommu
*obj
, char *buf
, ssize_t len
);
179 struct device
*omap_find_iommu_device(const char *name
);
181 #endif /* __MACH_IOMMU_H */