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;
63 int (*startup)(struct omap_mmu *mmu);
64 void (*shutdown)(struct omap_mmu *mmu);
67 void (*read_tlb)(struct omap_mmu *, struct cam_ram_regset *);
68 void (*load_tlb)(struct omap_mmu *, struct cam_ram_regset *);
69 ssize_t (*show)(struct omap_mmu *, char *, struct omap_mmu_tlb_lock *);
71 /* CAM / RAM operations */
72 struct cam_ram_regset *(*cam_ram_alloc)(struct omap_mmu_tlb_entry *);
73 int (*cam_ram_valid)(struct cam_ram_regset *);
74 unsigned long (*cam_va)(struct cam_ram_regset *);
76 /* Memory operations */
77 int (*mem_enable)(struct omap_mmu *, void *);
78 int (*mem_disable)(struct omap_mmu *, void *);
80 void (*interrupt)(struct omap_mmu *);
82 /* PTE attribute operations */
83 pgprot_t (*pte_get_attr)(struct omap_mmu_tlb_entry *);
91 unsigned long membase, memsize;
94 enum omap_mmu_type type;
98 struct rw_semaphore exmap_sem;
99 struct exmap_tbl *exmap_tbl;
101 unsigned int nr_tlb_entries;
102 unsigned int nr_exmap_preserved;
104 struct mm_struct *twl_mm;
106 /* Size of virtual address space, in bits */
107 unsigned int addrspace;
111 unsigned long fault_address;
112 struct work_struct irq_work;
114 struct omap_mmu_ops *ops;
117 #define omap_mmu_internal_memory(mmu, addr) \
118 (likely(mmu->membase) && (((unsigned long)(addr) >= mmu->membase) && \
119 ((unsigned long)(addr) < mmu->membase + mmu->memsize)))
121 #define INIT_EXMAP_TBL_ENTRY(ent,b,v,typ,od) \
127 (ent)->usecount = 0; \
128 (ent)->type = (typ); \
129 (ent)->order = (od); \
130 (ent)->link.next = -1; \
131 (ent)->link.prev = -1; \
134 #define INIT_EXMAP_TBL_ENTRY_4KB_PRESERVED(ent,b,v) \
140 (ent)->usecount = 0; \
141 (ent)->type = EXMAP_TYPE_MEM; \
143 (ent)->link.next = -1; \
144 (ent)->link.prev = -1; \
147 #define omap_mmu_to_virt(mmu, db) ((void *)((mmu)->membase + (db)))
148 #define virt_to_omap_mmu(mmu, va) \
149 (((unsigned long)(va) - (mmu)->membase))
151 /* arch/arm/plat-omap/mmu.c */
152 int omap_mmu_register(struct omap_mmu *mmu);
153 void omap_mmu_unregister(struct omap_mmu *mmu);
155 void omap_mmu_enable(struct omap_mmu *mmu, int reset);
156 void omap_mmu_disable(struct omap_mmu *mmu);
158 int omap_mmu_mem_enable(struct omap_mmu *mmu, void *addr);
159 void omap_mmu_mem_disable(struct omap_mmu *mmu, void *addr);
161 void omap_mmu_read_tlb(struct omap_mmu *mmu, struct omap_mmu_tlb_lock *lock,
162 struct cam_ram_regset *cr);
164 int omap_mmu_load_tlb_entry(struct omap_mmu *, struct omap_mmu_tlb_entry *);
165 int omap_mmu_clear_tlb_entry(struct omap_mmu *, unsigned long vadr);
167 int omap_mmu_load_pte_entry(struct omap_mmu *mmu,
168 struct omap_mmu_tlb_entry *entry);
169 int omap_mmu_clear_pte_entry(struct omap_mmu *mmu, unsigned long vadr);
171 int omap_mmu_kmem_reserve(struct omap_mmu *mmu, unsigned long size);
172 void omap_mmu_kmem_release(void);
174 unsigned long omap_mmu_virt_to_phys(struct omap_mmu *mmu, void *vadr,
177 int omap_mmu_exmap(struct omap_mmu *mmu, unsigned long dspadr,
178 unsigned long padr, unsigned long size,
179 enum exmap_type type);
180 int omap_mmu_exunmap(struct omap_mmu *mmu, unsigned long dspadr);
181 void omap_mmu_exmap_flush(struct omap_mmu *mmu);
182 void omap_mmu_exmap_use(struct omap_mmu *mmu, void *vadr, size_t len);
183 void omap_mmu_exmap_unuse(struct omap_mmu *mmu, void *vadr, size_t len);
185 int exmap_set_armmmu(unsigned long virt, unsigned long phys, unsigned long size);
186 void exmap_clear_armmmu(unsigned long virt, unsigned long size);
187 void exmap_setup_preserved_mem_page(struct omap_mmu *mmu, void *buf,
188 unsigned long dspadr, int index);
189 void exmap_clear_mem_page(struct omap_mmu *mmu, unsigned long dspadr);
190 int exmap_valid(struct omap_mmu *mmu, void *vadr, size_t len);
192 /* To be obsolete for backward compatibility */
193 ssize_t __omap_mmu_mem_read(struct omap_mmu *mmu, char *buf, loff_t offset, size_t count);
194 ssize_t __omap_mmu_mem_write(struct omap_mmu *mmu, char *buf, loff_t offset, size_t count);
196 #endif /* __ARCH_OMAP_MMU_H */