Jordan Crouse | 6d76c4d | 2012-03-26 09:50:43 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2002,2007-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef __KGSL_MMU_H |
| 14 | #define __KGSL_MMU_H |
| 15 | |
Shubhraprakash Das | 84fdb11 | 2012-04-04 12:49:31 -0600 | [diff] [blame] | 16 | /* |
| 17 | * These defines control the split between ttbr1 and ttbr0 pagetables of IOMMU |
| 18 | * and what ranges of memory we map to them |
| 19 | */ |
| 20 | #define KGSL_IOMMU_GLOBAL_MEM_BASE 0xC0000000 |
| 21 | #define KGSL_IOMMU_GLOBAL_MEM_SIZE SZ_4M |
| 22 | #define KGSL_IOMMU_TTBR1_SPLIT 2 |
| 23 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 24 | #define KGSL_MMU_ALIGN_SHIFT 13 |
| 25 | #define KGSL_MMU_ALIGN_MASK (~((1 << KGSL_MMU_ALIGN_SHIFT) - 1)) |
| 26 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | /* Identifier for the global page table */ |
| 28 | /* Per process page tables will probably pass in the thread group |
| 29 | as an identifier */ |
| 30 | |
| 31 | #define KGSL_MMU_GLOBAL_PT 0 |
Shubhraprakash Das | 19ca4a6 | 2012-05-18 12:11:20 -0600 | [diff] [blame] | 32 | #define KGSL_MMU_PRIV_BANK_TABLE_NAME 0xFFFFFFFF |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 33 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 34 | struct kgsl_device; |
| 35 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 36 | #define GSL_PT_SUPER_PTE 8 |
| 37 | #define GSL_PT_PAGE_WV 0x00000001 |
| 38 | #define GSL_PT_PAGE_RV 0x00000002 |
| 39 | #define GSL_PT_PAGE_DIRTY 0x00000004 |
| 40 | |
| 41 | /* MMU registers - the register locations for all cores are the |
| 42 | same. The method for getting to those locations differs between |
| 43 | 2D and 3D, but the 2D and 3D register functions do that magic |
| 44 | for us */ |
| 45 | |
| 46 | #define MH_MMU_CONFIG 0x0040 |
| 47 | #define MH_MMU_VA_RANGE 0x0041 |
| 48 | #define MH_MMU_PT_BASE 0x0042 |
| 49 | #define MH_MMU_PAGE_FAULT 0x0043 |
| 50 | #define MH_MMU_TRAN_ERROR 0x0044 |
| 51 | #define MH_MMU_INVALIDATE 0x0045 |
| 52 | #define MH_MMU_MPU_BASE 0x0046 |
| 53 | #define MH_MMU_MPU_END 0x0047 |
| 54 | |
| 55 | #define MH_INTERRUPT_MASK 0x0A42 |
| 56 | #define MH_INTERRUPT_STATUS 0x0A43 |
| 57 | #define MH_INTERRUPT_CLEAR 0x0A44 |
| 58 | #define MH_AXI_ERROR 0x0A45 |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 59 | #define MH_ARBITER_CONFIG 0x0A40 |
| 60 | #define MH_DEBUG_CTRL 0x0A4E |
| 61 | #define MH_DEBUG_DATA 0x0A4F |
| 62 | #define MH_AXI_HALT_CONTROL 0x0A50 |
| 63 | #define MH_CLNT_INTF_CTRL_CONFIG1 0x0A54 |
| 64 | #define MH_CLNT_INTF_CTRL_CONFIG2 0x0A55 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 65 | |
| 66 | /* MH_MMU_CONFIG bit definitions */ |
| 67 | |
| 68 | #define MH_MMU_CONFIG__RB_W_CLNT_BEHAVIOR__SHIFT 0x00000004 |
| 69 | #define MH_MMU_CONFIG__CP_W_CLNT_BEHAVIOR__SHIFT 0x00000006 |
| 70 | #define MH_MMU_CONFIG__CP_R0_CLNT_BEHAVIOR__SHIFT 0x00000008 |
| 71 | #define MH_MMU_CONFIG__CP_R1_CLNT_BEHAVIOR__SHIFT 0x0000000a |
| 72 | #define MH_MMU_CONFIG__CP_R2_CLNT_BEHAVIOR__SHIFT 0x0000000c |
| 73 | #define MH_MMU_CONFIG__CP_R3_CLNT_BEHAVIOR__SHIFT 0x0000000e |
| 74 | #define MH_MMU_CONFIG__CP_R4_CLNT_BEHAVIOR__SHIFT 0x00000010 |
| 75 | #define MH_MMU_CONFIG__VGT_R0_CLNT_BEHAVIOR__SHIFT 0x00000012 |
| 76 | #define MH_MMU_CONFIG__VGT_R1_CLNT_BEHAVIOR__SHIFT 0x00000014 |
| 77 | #define MH_MMU_CONFIG__TC_R_CLNT_BEHAVIOR__SHIFT 0x00000016 |
| 78 | #define MH_MMU_CONFIG__PA_W_CLNT_BEHAVIOR__SHIFT 0x00000018 |
| 79 | |
| 80 | /* MMU Flags */ |
| 81 | #define KGSL_MMUFLAGS_TLBFLUSH 0x10000000 |
| 82 | #define KGSL_MMUFLAGS_PTUPDATE 0x20000000 |
| 83 | |
| 84 | #define MH_INTERRUPT_MASK__AXI_READ_ERROR 0x00000001L |
| 85 | #define MH_INTERRUPT_MASK__AXI_WRITE_ERROR 0x00000002L |
| 86 | #define MH_INTERRUPT_MASK__MMU_PAGE_FAULT 0x00000004L |
| 87 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 88 | #define KGSL_MMU_INT_MASK \ |
| 89 | (MH_INTERRUPT_MASK__AXI_READ_ERROR | \ |
| 90 | MH_INTERRUPT_MASK__AXI_WRITE_ERROR | \ |
| 91 | MH_INTERRUPT_MASK__MMU_PAGE_FAULT) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 92 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 93 | enum kgsl_mmutype { |
| 94 | KGSL_MMU_TYPE_GPU = 0, |
| 95 | KGSL_MMU_TYPE_IOMMU, |
| 96 | KGSL_MMU_TYPE_NONE |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | struct kgsl_pagetable { |
| 100 | spinlock_t lock; |
| 101 | struct kref refcount; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | unsigned int max_entries; |
| 103 | struct gen_pool *pool; |
Shubhraprakash Das | 84fdb11 | 2012-04-04 12:49:31 -0600 | [diff] [blame] | 104 | struct gen_pool *kgsl_pool; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 105 | struct list_head list; |
| 106 | unsigned int name; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 107 | struct kobject *kobj; |
| 108 | |
| 109 | struct { |
| 110 | unsigned int entries; |
| 111 | unsigned int mapped; |
| 112 | unsigned int max_mapped; |
| 113 | unsigned int max_entries; |
| 114 | } stats; |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 115 | const struct kgsl_mmu_pt_ops *pt_ops; |
Shubhraprakash Das | f764e46 | 2012-04-26 15:38:09 -0600 | [diff] [blame] | 116 | unsigned int tlb_flags; |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 117 | void *priv; |
| 118 | }; |
| 119 | |
Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 120 | struct kgsl_mmu; |
| 121 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 122 | struct kgsl_mmu_ops { |
Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 123 | int (*mmu_init) (struct kgsl_mmu *mmu); |
| 124 | int (*mmu_close) (struct kgsl_mmu *mmu); |
| 125 | int (*mmu_start) (struct kgsl_mmu *mmu); |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 126 | void (*mmu_stop) (struct kgsl_mmu *mmu); |
Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 127 | void (*mmu_setstate) (struct kgsl_mmu *mmu, |
Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 128 | struct kgsl_pagetable *pagetable, |
| 129 | unsigned int context_id); |
Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 130 | void (*mmu_device_setstate) (struct kgsl_mmu *mmu, |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 131 | uint32_t flags); |
Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 132 | void (*mmu_pagefault) (struct kgsl_mmu *mmu); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 133 | unsigned int (*mmu_get_current_ptbase) |
Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 134 | (struct kgsl_mmu *mmu); |
Shubhraprakash Das | cb06807 | 2012-06-07 17:52:41 -0600 | [diff] [blame] | 135 | void (*mmu_disable_clk_on_ts) |
| 136 | (struct kgsl_mmu *mmu, uint32_t ts, bool ts_valid); |
Shubhraprakash Das | 9fb38ac | 2012-05-01 00:41:30 -0600 | [diff] [blame] | 137 | int (*mmu_enable_clk) |
| 138 | (struct kgsl_mmu *mmu, int ctx_id); |
Shubhraprakash Das | fce2736 | 2012-05-09 17:44:14 -0600 | [diff] [blame] | 139 | int (*mmu_get_pt_lsb)(struct kgsl_mmu *mmu, |
| 140 | unsigned int unit_id, |
| 141 | enum kgsl_iommu_context_id ctx_id); |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 142 | unsigned int (*mmu_get_reg_gpuaddr)(struct kgsl_mmu *mmu, |
| 143 | int iommu_unit_num, int ctx_id, int reg); |
| 144 | int (*mmu_get_num_iommu_units)(struct kgsl_mmu *mmu); |
| 145 | int (*mmu_pt_equal) (struct kgsl_mmu *mmu, |
| 146 | struct kgsl_pagetable *pt, |
| 147 | unsigned int pt_base); |
| 148 | unsigned int (*mmu_get_pt_base_addr) |
| 149 | (struct kgsl_mmu *mmu, |
| 150 | struct kgsl_pagetable *pt); |
Tarun Karra | 9c07082 | 2012-11-27 16:43:51 -0700 | [diff] [blame] | 151 | unsigned int (*mmu_sync_lock) |
| 152 | (struct kgsl_mmu *mmu, |
| 153 | unsigned int *cmds); |
| 154 | unsigned int (*mmu_sync_unlock) |
| 155 | (struct kgsl_mmu *mmu, |
| 156 | unsigned int *cmds); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | struct kgsl_mmu_pt_ops { |
| 160 | int (*mmu_map) (void *mmu_pt, |
| 161 | struct kgsl_memdesc *memdesc, |
Shubhraprakash Das | f764e46 | 2012-04-26 15:38:09 -0600 | [diff] [blame] | 162 | unsigned int protflags, |
| 163 | unsigned int *tlb_flags); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 164 | int (*mmu_unmap) (void *mmu_pt, |
Shubhraprakash Das | 0c81126 | 2012-06-06 23:22:19 -0600 | [diff] [blame] | 165 | struct kgsl_memdesc *memdesc, |
| 166 | unsigned int *tlb_flags); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 167 | void *(*mmu_create_pagetable) (void); |
| 168 | void (*mmu_destroy_pagetable) (void *pt); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 169 | }; |
| 170 | |
Tarun Karra | 9c07082 | 2012-11-27 16:43:51 -0700 | [diff] [blame] | 171 | #define KGSL_MMU_FLAGS_IOMMU_SYNC BIT(31) |
| 172 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 173 | struct kgsl_mmu { |
| 174 | unsigned int refcnt; |
| 175 | uint32_t flags; |
| 176 | struct kgsl_device *device; |
| 177 | unsigned int config; |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 178 | struct kgsl_memdesc setstate_memory; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 179 | /* current page table object being used by device mmu */ |
| 180 | struct kgsl_pagetable *defaultpagetable; |
Shubhraprakash Das | 19ca4a6 | 2012-05-18 12:11:20 -0600 | [diff] [blame] | 181 | /* pagetable object used for priv bank of IOMMU */ |
| 182 | struct kgsl_pagetable *priv_bank_table; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 183 | struct kgsl_pagetable *hwpagetable; |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 184 | const struct kgsl_mmu_ops *mmu_ops; |
| 185 | void *priv; |
Shubhraprakash Das | 2747cf6 | 2012-09-27 23:05:43 -0700 | [diff] [blame] | 186 | int fault; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 187 | }; |
| 188 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 189 | #include "kgsl_gpummu.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 190 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 191 | extern struct kgsl_mmu_ops iommu_ops; |
| 192 | extern struct kgsl_mmu_pt_ops iommu_pt_ops; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 193 | |
| 194 | struct kgsl_pagetable *kgsl_mmu_getpagetable(unsigned long name); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 195 | void kgsl_mmu_putpagetable(struct kgsl_pagetable *pagetable); |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 196 | void kgsl_mh_start(struct kgsl_device *device); |
| 197 | void kgsl_mh_intrcallback(struct kgsl_device *device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 198 | int kgsl_mmu_init(struct kgsl_device *device); |
| 199 | int kgsl_mmu_start(struct kgsl_device *device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 200 | int kgsl_mmu_close(struct kgsl_device *device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 201 | int kgsl_mmu_map(struct kgsl_pagetable *pagetable, |
| 202 | struct kgsl_memdesc *memdesc, |
| 203 | unsigned int protflags); |
| 204 | int kgsl_mmu_map_global(struct kgsl_pagetable *pagetable, |
| 205 | struct kgsl_memdesc *memdesc, unsigned int protflags); |
| 206 | int kgsl_mmu_unmap(struct kgsl_pagetable *pagetable, |
| 207 | struct kgsl_memdesc *memdesc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 208 | unsigned int kgsl_virtaddr_to_physaddr(void *virtaddr); |
Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 209 | void kgsl_setstate(struct kgsl_mmu *mmu, unsigned int context_id, |
| 210 | uint32_t flags); |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 211 | int kgsl_mmu_get_ptname_from_ptbase(struct kgsl_mmu *mmu, |
| 212 | unsigned int pt_base); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 213 | int kgsl_mmu_pt_get_flags(struct kgsl_pagetable *pt, |
| 214 | enum kgsl_deviceid id); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 215 | void kgsl_mmu_ptpool_destroy(void *ptpool); |
Jordan Crouse | 6d76c4d | 2012-03-26 09:50:43 -0600 | [diff] [blame] | 216 | void *kgsl_mmu_ptpool_init(int entries); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 217 | int kgsl_mmu_enabled(void); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 218 | void kgsl_mmu_set_mmutype(char *mmutype); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 219 | enum kgsl_mmutype kgsl_mmu_get_mmutype(void); |
Jordan Crouse | 6d76c4d | 2012-03-26 09:50:43 -0600 | [diff] [blame] | 220 | unsigned int kgsl_mmu_get_ptsize(void); |
Shubhraprakash Das | e7652cf | 2012-08-11 17:15:19 -0700 | [diff] [blame] | 221 | int kgsl_mmu_gpuaddr_in_range(unsigned int gpuaddr); |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 222 | |
| 223 | /* |
| 224 | * Static inline functions of MMU that simply call the SMMU specific |
| 225 | * function using a function pointer. These functions can be thought |
| 226 | * of as wrappers around the actual function |
| 227 | */ |
| 228 | |
| 229 | static inline unsigned int kgsl_mmu_get_current_ptbase(struct kgsl_mmu *mmu) |
| 230 | { |
| 231 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_get_current_ptbase) |
| 232 | return mmu->mmu_ops->mmu_get_current_ptbase(mmu); |
| 233 | else |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | static inline void kgsl_mmu_setstate(struct kgsl_mmu *mmu, |
Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 238 | struct kgsl_pagetable *pagetable, |
| 239 | unsigned int context_id) |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 240 | { |
| 241 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_setstate) |
Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 242 | mmu->mmu_ops->mmu_setstate(mmu, pagetable, context_id); |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static inline void kgsl_mmu_device_setstate(struct kgsl_mmu *mmu, |
| 246 | uint32_t flags) |
| 247 | { |
| 248 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_device_setstate) |
| 249 | mmu->mmu_ops->mmu_device_setstate(mmu, flags); |
| 250 | } |
| 251 | |
| 252 | static inline void kgsl_mmu_stop(struct kgsl_mmu *mmu) |
| 253 | { |
| 254 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_stop) |
| 255 | mmu->mmu_ops->mmu_stop(mmu); |
| 256 | } |
| 257 | |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 258 | static inline int kgsl_mmu_pt_equal(struct kgsl_mmu *mmu, |
| 259 | struct kgsl_pagetable *pt, |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 260 | unsigned int pt_base) |
| 261 | { |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 262 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_pt_equal) |
| 263 | return mmu->mmu_ops->mmu_pt_equal(mmu, pt, pt_base); |
| 264 | else |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 265 | return 1; |
Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 266 | } |
| 267 | |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 268 | static inline unsigned int kgsl_mmu_get_pt_base_addr(struct kgsl_mmu *mmu, |
| 269 | struct kgsl_pagetable *pt) |
Shubhraprakash Das | 5a610b5 | 2012-05-09 17:31:54 -0600 | [diff] [blame] | 270 | { |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 271 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_get_pt_base_addr) |
| 272 | return mmu->mmu_ops->mmu_get_pt_base_addr(mmu, pt); |
Shubhraprakash Das | a5b1db4 | 2012-05-09 18:02:34 -0600 | [diff] [blame] | 273 | else |
| 274 | return 0; |
| 275 | } |
| 276 | |
Shubhraprakash Das | eb6b854 | 2012-05-09 22:42:24 -0600 | [diff] [blame] | 277 | static inline int kgsl_mmu_get_pt_lsb(struct kgsl_mmu *mmu, |
| 278 | unsigned int unit_id, |
| 279 | enum kgsl_iommu_context_id ctx_id) |
| 280 | { |
| 281 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_get_pt_lsb) |
| 282 | return mmu->mmu_ops->mmu_get_pt_lsb(mmu, unit_id, ctx_id); |
| 283 | else |
| 284 | return 0; |
| 285 | } |
| 286 | |
Shubhraprakash Das | eb6b854 | 2012-05-09 22:42:24 -0600 | [diff] [blame] | 287 | static inline int kgsl_mmu_enable_clk(struct kgsl_mmu *mmu, |
| 288 | int ctx_id) |
| 289 | { |
| 290 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_enable_clk) |
| 291 | return mmu->mmu_ops->mmu_enable_clk(mmu, ctx_id); |
| 292 | else |
| 293 | return 0; |
| 294 | } |
| 295 | |
Shubhraprakash Das | cb06807 | 2012-06-07 17:52:41 -0600 | [diff] [blame] | 296 | static inline void kgsl_mmu_disable_clk_on_ts(struct kgsl_mmu *mmu, |
| 297 | unsigned int ts, bool ts_valid) |
Shubhraprakash Das | eb6b854 | 2012-05-09 22:42:24 -0600 | [diff] [blame] | 298 | { |
Shubhraprakash Das | cb06807 | 2012-06-07 17:52:41 -0600 | [diff] [blame] | 299 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_disable_clk_on_ts) |
| 300 | mmu->mmu_ops->mmu_disable_clk_on_ts(mmu, ts, ts_valid); |
Shubhraprakash Das | eb6b854 | 2012-05-09 22:42:24 -0600 | [diff] [blame] | 301 | } |
| 302 | |
Anoop Kumar Yerukala | 5479c9c | 2012-07-08 14:53:06 +0530 | [diff] [blame] | 303 | static inline unsigned int kgsl_mmu_get_int_mask(void) |
| 304 | { |
| 305 | /* Dont enable gpummu interrupts, if iommu is enabled */ |
| 306 | if (KGSL_MMU_TYPE_GPU == kgsl_mmu_get_mmutype()) |
| 307 | return KGSL_MMU_INT_MASK; |
| 308 | else |
| 309 | return (MH_INTERRUPT_MASK__AXI_READ_ERROR | |
| 310 | MH_INTERRUPT_MASK__AXI_WRITE_ERROR); |
| 311 | } |
| 312 | |
Shubhraprakash Das | 3cf33be | 2012-08-16 22:42:55 -0700 | [diff] [blame] | 313 | static inline unsigned int kgsl_mmu_get_reg_gpuaddr(struct kgsl_mmu *mmu, |
| 314 | int iommu_unit_num, |
| 315 | int ctx_id, int reg) |
| 316 | { |
| 317 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_get_reg_gpuaddr) |
| 318 | return mmu->mmu_ops->mmu_get_reg_gpuaddr(mmu, iommu_unit_num, |
| 319 | ctx_id, reg); |
| 320 | else |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | static inline int kgsl_mmu_get_num_iommu_units(struct kgsl_mmu *mmu) |
| 325 | { |
| 326 | if (mmu->mmu_ops && mmu->mmu_ops->mmu_get_num_iommu_units) |
| 327 | return mmu->mmu_ops->mmu_get_num_iommu_units(mmu); |
| 328 | else |
| 329 | return 0; |
| 330 | } |
| 331 | |
Tarun Karra | 9c07082 | 2012-11-27 16:43:51 -0700 | [diff] [blame] | 332 | static inline int kgsl_mmu_sync_lock(struct kgsl_mmu *mmu, |
| 333 | unsigned int *cmds) |
| 334 | { |
| 335 | if ((mmu->flags & KGSL_MMU_FLAGS_IOMMU_SYNC) && |
| 336 | mmu->mmu_ops && mmu->mmu_ops->mmu_sync_lock) |
| 337 | return mmu->mmu_ops->mmu_sync_lock(mmu, cmds); |
| 338 | else |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static inline int kgsl_mmu_sync_unlock(struct kgsl_mmu *mmu, |
| 343 | unsigned int *cmds) |
| 344 | { |
| 345 | if ((mmu->flags & KGSL_MMU_FLAGS_IOMMU_SYNC) && |
| 346 | mmu->mmu_ops && mmu->mmu_ops->mmu_sync_unlock) |
| 347 | return mmu->mmu_ops->mmu_sync_unlock(mmu, cmds); |
| 348 | else |
| 349 | return 0; |
| 350 | } |
| 351 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 352 | #endif /* __KGSL_MMU_H */ |