1 #ifndef __ARCH_OMAP_MMU_H
2 #define __ARCH_OMAP_MMU_H
4 #include <linux/device.h>
5 #include <linux/workqueue.h>
21 int usecount; /* reference count by mmap */
23 void *buf; /* virtual address of the buffer,
24 * i.e. 0xc0000000 - */
25 void *vadr; /* DSP shadow space,
26 * i.e. 0xe0000000 - 0xe0ffffff */
31 } link; /* grouping */
34 struct cam_ram_regset {
54 struct omap_mmu_tlb_lock {
60 struct omap_mmu_tlb_entry;
62 #ifdef CONFIG_ARCH_OMAP1
63 extern struct omap_mmu_ops omap1_mmu_ops;
64 extern void omap_mmu_itack(struct omap_mmu *mmu);
65 #elif defined(CONFIG_ARCH_OMAP2)
66 extern struct omap_mmu_ops omap2_mmu_ops;
67 static inline void omap_mmu_itack(struct omap_mmu *mmu)
73 int (*startup)(struct omap_mmu *mmu);
74 void (*shutdown)(struct omap_mmu *mmu);
77 void (*read_tlb)(struct omap_mmu *, struct cam_ram_regset *);
78 void (*load_tlb)(struct omap_mmu *, struct cam_ram_regset *);
79 ssize_t (*show)(struct omap_mmu *, char *, struct omap_mmu_tlb_lock *);
81 /* CAM / RAM operations */
82 struct cam_ram_regset *(*cam_ram_alloc)(struct omap_mmu *,
83 struct omap_mmu_tlb_entry *);
84 int (*cam_ram_valid)(struct cam_ram_regset *);
85 unsigned long (*cam_va)(struct cam_ram_regset *);
87 /* Memory operations */
88 int (*mem_enable)(struct omap_mmu *, void *);
89 int (*mem_disable)(struct omap_mmu *, void *);
91 void (*interrupt)(struct omap_mmu *);
93 /* PTE attribute operations */
94 pgprot_t (*pte_get_attr)(struct omap_mmu_tlb_entry *);
102 unsigned long membase, memsize;
105 enum omap_mmu_type type;
109 struct rw_semaphore exmap_sem;
110 struct exmap_tbl *exmap_tbl;
112 unsigned int nr_tlb_entries;
113 unsigned int nr_exmap_preserved;
115 struct mm_struct *twl_mm;
117 /* Size of virtual address space, in bits */
118 unsigned int addrspace;
122 unsigned long fault_address;
123 struct work_struct irq_work;
125 struct omap_mmu_ops *ops;
128 #define omap_mmu_internal_memory(mmu, addr) \
129 (likely(mmu->membase) && (((unsigned long)(addr) >= mmu->membase) && \
130 ((unsigned long)(addr) < mmu->membase + mmu->memsize)))
132 #define INIT_EXMAP_TBL_ENTRY(ent,b,v,typ,od) \
138 (ent)->usecount = 0; \
139 (ent)->type = (typ); \
140 (ent)->order = (od); \
141 (ent)->link.next = -1; \
142 (ent)->link.prev = -1; \
145 #define INIT_EXMAP_TBL_ENTRY_4KB_PRESERVED(ent,b,v) \
151 (ent)->usecount = 0; \
152 (ent)->type = EXMAP_TYPE_MEM; \
154 (ent)->link.next = -1; \
155 (ent)->link.prev = -1; \
158 #define omap_mmu_to_virt(mmu, db) ((void *)((mmu)->membase + (db)))
159 #define virt_to_omap_mmu(mmu, va) \
160 (((unsigned long)(va) - (mmu)->membase))
162 /* arch/arm/plat-omap/mmu.c */
163 int omap_mmu_register(struct omap_mmu *mmu);
164 void omap_mmu_unregister(struct omap_mmu *mmu);
166 void omap_mmu_enable(struct omap_mmu *mmu, int reset);
167 void omap_mmu_disable(struct omap_mmu *mmu);
169 int omap_mmu_mem_enable(struct omap_mmu *mmu, void *addr);
170 void omap_mmu_mem_disable(struct omap_mmu *mmu, void *addr);
172 void omap_mmu_read_tlb(struct omap_mmu *mmu, struct omap_mmu_tlb_lock *lock,
173 struct cam_ram_regset *cr);
175 int omap_mmu_load_tlb_entry(struct omap_mmu *, struct omap_mmu_tlb_entry *);
176 int omap_mmu_clear_tlb_entry(struct omap_mmu *, unsigned long vadr);
178 int omap_mmu_load_pte_entry(struct omap_mmu *mmu,
179 struct omap_mmu_tlb_entry *entry);
180 int omap_mmu_clear_pte_entry(struct omap_mmu *mmu, unsigned long vadr);
182 int omap_mmu_kmem_reserve(struct omap_mmu *mmu, unsigned long size);
183 void omap_mmu_kmem_release(void);
185 unsigned long omap_mmu_virt_to_phys(struct omap_mmu *mmu, void *vadr,
188 int omap_mmu_exmap(struct omap_mmu *mmu, unsigned long dspadr,
189 unsigned long padr, unsigned long size,
190 enum exmap_type type);
191 int omap_mmu_exunmap(struct omap_mmu *mmu, unsigned long dspadr);
192 void omap_mmu_exmap_flush(struct omap_mmu *mmu);
193 void omap_mmu_exmap_use(struct omap_mmu *mmu, void *vadr, size_t len);
194 void omap_mmu_exmap_unuse(struct omap_mmu *mmu, void *vadr, size_t len);
196 int exmap_set_armmmu(struct omap_mmu *mmu, unsigned long virt,
197 unsigned long phys, unsigned long size);
198 void exmap_clear_armmmu(struct omap_mmu *mmu, unsigned long virt,
200 void exmap_setup_preserved_mem_page(struct omap_mmu *mmu, void *buf,
201 unsigned long dspadr, int index);
202 void exmap_clear_mem_page(struct omap_mmu *mmu, unsigned long dspadr);
203 int exmap_valid(struct omap_mmu *mmu, void *vadr, size_t len);
205 /* To be obsolete for backward compatibility */
206 ssize_t __omap_mmu_mem_read(struct omap_mmu *mmu, struct bin_attribute *,
207 char *buf, loff_t offset, size_t count);
208 ssize_t __omap_mmu_mem_write(struct omap_mmu *mmu, struct bin_attribute *,
209 char *buf, loff_t offset, size_t count);
211 #endif /* __ARCH_OMAP_MMU_H */