1 #ifndef __ARCH_OMAP_MMU_H
2 #define __ARCH_OMAP_MMU_H
4 #include <linux/device.h>
5 #include <linux/workqueue.h>
7 #define MMU_REVISION 0x00
8 #define MMU_SYSCONFIG 0x10
9 #define MMU_SYSSTATUS 0x14
10 #define MMU_IRQSTATUS 0x18
11 #define MMU_IRQENABLE 0x1c
12 #define MMU_WALKING_ST 0x40
14 #define MMU_FAULT_AD 0x48
17 #define MMU_LD_TLB 0x54
20 #define MMU_GFLUSH 0x60
21 #define MMU_FLUSH_ENTRY 0x64
22 #define MMU_READ_CAM 0x68
23 #define MMU_READ_RAM 0x6c
24 #define MMU_EMU_FAULT_AD 0x70
40 int usecount; /* reference count by mmap */
42 void *buf; /* virtual address of the buffer,
43 * i.e. 0xc0000000 - */
44 void *vadr; /* DSP shadow space,
45 * i.e. 0xe0000000 - 0xe0ffffff */
50 } link; /* grouping */
53 struct cam_ram_regset {
73 struct omap_mmu_tlb_lock {
79 struct omap_mmu_tlb_entry;
82 int (*startup)(struct omap_mmu *mmu);
83 void (*shutdown)(struct omap_mmu *mmu);
86 void (*read_tlb)(struct omap_mmu *, struct cam_ram_regset *);
87 void (*load_tlb)(struct omap_mmu *, struct cam_ram_regset *);
88 ssize_t (*show)(struct omap_mmu *, char *, struct omap_mmu_tlb_lock *);
90 /* CAM / RAM operations */
91 struct cam_ram_regset *(*cam_ram_alloc)(struct omap_mmu_tlb_entry *);
92 int (*cam_ram_valid)(struct cam_ram_regset *);
93 unsigned long (*cam_va)(struct cam_ram_regset *);
95 /* Memory operations */
96 int (*mem_enable)(struct omap_mmu *, void *);
97 int (*mem_disable)(struct omap_mmu *, void *);
99 void (*interrupt)(struct omap_mmu *);
101 /* PTE attribute operations */
102 pgprot_t (*pte_get_attr)(struct omap_mmu_tlb_entry *);
110 unsigned long membase, memsize;
113 enum omap_mmu_type type;
117 struct rw_semaphore exmap_sem;
118 struct exmap_tbl *exmap_tbl;
120 unsigned int nr_tlb_entries;
121 unsigned int nr_exmap_preserved;
123 struct mm_struct *twl_mm;
125 /* Size of virtual address space, in bits */
126 unsigned int addrspace;
130 unsigned long fault_address;
131 struct work_struct irq_work;
133 struct omap_mmu_ops *ops;
136 #define omap_mmu_internal_memory(mmu, addr) \
137 (likely(mmu->membase) && (((unsigned long)(addr) >= mmu->membase) && \
138 ((unsigned long)(addr) < mmu->membase + mmu->memsize)))
140 #define INIT_EXMAP_TBL_ENTRY(ent,b,v,typ,od) \
146 (ent)->usecount = 0; \
147 (ent)->type = (typ); \
148 (ent)->order = (od); \
149 (ent)->link.next = -1; \
150 (ent)->link.prev = -1; \
153 #define INIT_EXMAP_TBL_ENTRY_4KB_PRESERVED(ent,b,v) \
159 (ent)->usecount = 0; \
160 (ent)->type = EXMAP_TYPE_MEM; \
162 (ent)->link.next = -1; \
163 (ent)->link.prev = -1; \
166 #define omap_mmu_to_virt(mmu, db) ((void *)((mmu)->membase + (db)))
167 #define virt_to_omap_mmu(mmu, va) \
168 (((unsigned long)(va) - (mmu)->membase))
170 /* arch/arm/plat-omap/mmu.c */
171 int omap_mmu_register(struct omap_mmu *mmu);
172 void omap_mmu_unregister(struct omap_mmu *mmu);
174 void omap_mmu_enable(struct omap_mmu *mmu, int reset);
175 void omap_mmu_disable(struct omap_mmu *mmu);
177 int omap_mmu_mem_enable(struct omap_mmu *mmu, void *addr);
178 void omap_mmu_mem_disable(struct omap_mmu *mmu, void *addr);
180 void omap_mmu_read_tlb(struct omap_mmu *mmu, struct omap_mmu_tlb_lock *lock,
181 struct cam_ram_regset *cr);
183 int omap_mmu_load_tlb_entry(struct omap_mmu *, struct omap_mmu_tlb_entry *);
184 int omap_mmu_clear_tlb_entry(struct omap_mmu *, unsigned long vadr);
186 int omap_mmu_load_pte_entry(struct omap_mmu *mmu,
187 struct omap_mmu_tlb_entry *entry);
188 int omap_mmu_clear_pte_entry(struct omap_mmu *mmu, unsigned long vadr);
190 int omap_mmu_kmem_reserve(struct omap_mmu *mmu, unsigned long size);
191 void omap_mmu_kmem_release(void);
193 unsigned long omap_mmu_virt_to_phys(struct omap_mmu *mmu, void *vadr,
196 int omap_mmu_exmap(struct omap_mmu *mmu, unsigned long dspadr,
197 unsigned long padr, unsigned long size,
198 enum exmap_type type);
199 int omap_mmu_exunmap(struct omap_mmu *mmu, unsigned long dspadr);
200 void omap_mmu_exmap_flush(struct omap_mmu *mmu);
201 void omap_mmu_exmap_use(struct omap_mmu *mmu, void *vadr, size_t len);
202 void omap_mmu_exmap_unuse(struct omap_mmu *mmu, void *vadr, size_t len);
204 int exmap_set_armmmu(unsigned long virt, unsigned long phys, unsigned long size);
205 void exmap_clear_armmmu(unsigned long virt, unsigned long size);
206 void exmap_setup_preserved_mem_page(struct omap_mmu *mmu, void *buf,
207 unsigned long dspadr, int index);
208 void exmap_clear_mem_page(struct omap_mmu *mmu, unsigned long dspadr);
209 int exmap_valid(struct omap_mmu *mmu, void *vadr, size_t len);
211 /* To be obsolete for backward compatibility */
212 ssize_t __omap_mmu_mem_read(struct omap_mmu *mmu, char *buf, loff_t offset, size_t count);
213 ssize_t __omap_mmu_mem_write(struct omap_mmu *mmu, char *buf, loff_t offset, size_t count);
215 #endif /* __ARCH_OMAP_MMU_H */