123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
- #ifndef __ARCH_ARM_MACH_MSM_IOMMU_HW_8XXX_H
- #define __ARCH_ARM_MACH_MSM_IOMMU_HW_8XXX_H
- #define CTX_SHIFT 12
- #define GET_GLOBAL_REG(reg, base) (readl((base) + (reg)))
- #define GET_CTX_REG(reg, base, ctx) \
- (readl((base) + (reg) + ((ctx) << CTX_SHIFT)))
- #define SET_GLOBAL_REG(reg, base, val) writel((val), ((base) + (reg)))
- #define SET_CTX_REG(reg, base, ctx, val) \
- writel((val), ((base) + (reg) + ((ctx) << CTX_SHIFT)))
- /* Wrappers for numbered registers */
- #define SET_GLOBAL_REG_N(b, n, r, v) SET_GLOBAL_REG(b, ((r) + (n << 2)), (v))
- #define GET_GLOBAL_REG_N(b, n, r) GET_GLOBAL_REG(b, ((r) + (n << 2)))
- /* Field wrappers */
- #define GET_GLOBAL_FIELD(b, r, F) GET_FIELD(((b) + (r)), F##_MASK, F##_SHIFT)
- #define GET_CONTEXT_FIELD(b, c, r, F) \
- GET_FIELD(((b) + (r) + ((c) << CTX_SHIFT)), F##_MASK, F##_SHIFT)
- #define SET_GLOBAL_FIELD(b, r, F, v) \
- SET_FIELD(((b) + (r)), F##_MASK, F##_SHIFT, (v))
- #define SET_CONTEXT_FIELD(b, c, r, F, v) \
- SET_FIELD(((b) + (r) + ((c) << CTX_SHIFT)), F##_MASK, F##_SHIFT, (v))
- #define GET_FIELD(addr, mask, shift) ((readl(addr) >> (shift)) & (mask))
- #define SET_FIELD(addr, mask, shift, v) \
- do { \
- int t = readl(addr); \
- writel((t & ~((mask) << (shift))) + (((v) & (mask)) << (shift)), addr);\
- } while (0)
- #define NUM_FL_PTE 4096
- #define NUM_SL_PTE 256
- #define NUM_TEX_CLASS 8
- /* First-level page table bits */
- #define FL_BASE_MASK 0xFFFFFC00
- #define FL_TYPE_TABLE (1 << 0)
- #define FL_TYPE_SECT (2 << 0)
- #define FL_SUPERSECTION (1 << 18)
- #define FL_AP_WRITE (1 << 10)
- #define FL_AP_READ (1 << 11)
- #define FL_SHARED (1 << 16)
- #define FL_BUFFERABLE (1 << 2)
- #define FL_CACHEABLE (1 << 3)
- #define FL_TEX0 (1 << 12)
- #define FL_OFFSET(va) (((va) & 0xFFF00000) >> 20)
- #define FL_NG (1 << 17)
- /* Second-level page table bits */
- #define SL_BASE_MASK_LARGE 0xFFFF0000
- #define SL_BASE_MASK_SMALL 0xFFFFF000
- #define SL_TYPE_LARGE (1 << 0)
- #define SL_TYPE_SMALL (2 << 0)
- #define SL_AP0 (1 << 4)
- #define SL_AP1 (2 << 4)
- #define SL_SHARED (1 << 10)
- #define SL_BUFFERABLE (1 << 2)
- #define SL_CACHEABLE (1 << 3)
- #define SL_TEX0 (1 << 6)
- #define SL_OFFSET(va) (((va) & 0xFF000) >> 12)
- #define SL_NG (1 << 11)
- /* Memory type and cache policy attributes */
- #define MT_SO 0
- #define MT_DEV 1
- #define MT_NORMAL 2
- #define CP_NONCACHED 0
- #define CP_WB_WA 1
- #define CP_WT 2
- #define CP_WB_NWA 3
- /* Global register setters / getters */
- #define SET_M2VCBR_N(b, N, v) SET_GLOBAL_REG_N(M2VCBR_N, N, (b), (v))
- #define SET_CBACR_N(b, N, v) SET_GLOBAL_REG_N(CBACR_N, N, (b), (v))
- #define SET_TLBRSW(b, v) SET_GLOBAL_REG(TLBRSW, (b), (v))
- #define SET_TLBTR0(b, v) SET_GLOBAL_REG(TLBTR0, (b), (v))
- #define SET_TLBTR1(b, v) SET_GLOBAL_REG(TLBTR1, (b), (v))
- #define SET_TLBTR2(b, v) SET_GLOBAL_REG(TLBTR2, (b), (v))
- #define SET_TESTBUSCR(b, v) SET_GLOBAL_REG(TESTBUSCR, (b), (v))
- #define SET_GLOBAL_TLBIALL(b, v) SET_GLOBAL_REG(GLOBAL_TLBIALL, (b), (v))
- #define SET_TLBIVMID(b, v) SET_GLOBAL_REG(TLBIVMID, (b), (v))
- #define SET_CR(b, v) SET_GLOBAL_REG(CR, (b), (v))
- #define SET_EAR(b, v) SET_GLOBAL_REG(EAR, (b), (v))
- #define SET_ESR(b, v) SET_GLOBAL_REG(ESR, (b), (v))
- #define SET_ESRRESTORE(b, v) SET_GLOBAL_REG(ESRRESTORE, (b), (v))
- #define SET_ESYNR0(b, v) SET_GLOBAL_REG(ESYNR0, (b), (v))
- #define SET_ESYNR1(b, v) SET_GLOBAL_REG(ESYNR1, (b), (v))
- #define SET_RPU_ACR(b, v) SET_GLOBAL_REG(RPU_ACR, (b), (v))
- #define GET_M2VCBR_N(b, N) GET_GLOBAL_REG_N(M2VCBR_N, N, (b))
- #define GET_CBACR_N(b, N) GET_GLOBAL_REG_N(CBACR_N, N, (b))
- #define GET_TLBTR0(b) GET_GLOBAL_REG(TLBTR0, (b))
- #define GET_TLBTR1(b) GET_GLOBAL_REG(TLBTR1, (b))
- #define GET_TLBTR2(b) GET_GLOBAL_REG(TLBTR2, (b))
- #define GET_TESTBUSCR(b) GET_GLOBAL_REG(TESTBUSCR, (b))
- #define GET_GLOBAL_TLBIALL(b) GET_GLOBAL_REG(GLOBAL_TLBIALL, (b))
- #define GET_TLBIVMID(b) GET_GLOBAL_REG(TLBIVMID, (b))
- #define GET_CR(b) GET_GLOBAL_REG(CR, (b))
- #define GET_EAR(b) GET_GLOBAL_REG(EAR, (b))
- #define GET_ESR(b) GET_GLOBAL_REG(ESR, (b))
- #define GET_ESRRESTORE(b) GET_GLOBAL_REG(ESRRESTORE, (b))
- #define GET_ESYNR0(b) GET_GLOBAL_REG(ESYNR0, (b))
- #define GET_ESYNR1(b) GET_GLOBAL_REG(ESYNR1, (b))
- #define GET_REV(b) GET_GLOBAL_REG(REV, (b))
- #define GET_IDR(b) GET_GLOBAL_REG(IDR, (b))
- #define GET_RPU_ACR(b) GET_GLOBAL_REG(RPU_ACR, (b))
- /* Context register setters/getters */
- #define SET_SCTLR(b, c, v) SET_CTX_REG(SCTLR, (b), (c), (v))
- #define SET_ACTLR(b, c, v) SET_CTX_REG(ACTLR, (b), (c), (v))
- #define SET_CONTEXTIDR(b, c, v) SET_CTX_REG(CONTEXTIDR, (b), (c), (v))
- #define SET_TTBR0(b, c, v) SET_CTX_REG(TTBR0, (b), (c), (v))
- #define SET_TTBR1(b, c, v) SET_CTX_REG(TTBR1, (b), (c), (v))
- #define SET_TTBCR(b, c, v) SET_CTX_REG(TTBCR, (b), (c), (v))
- #define SET_PAR(b, c, v) SET_CTX_REG(PAR, (b), (c), (v))
- #define SET_FSR(b, c, v) SET_CTX_REG(FSR, (b), (c), (v))
- #define SET_FSRRESTORE(b, c, v) SET_CTX_REG(FSRRESTORE, (b), (c), (v))
- #define SET_FAR(b, c, v) SET_CTX_REG(FAR, (b), (c), (v))
- #define SET_FSYNR0(b, c, v) SET_CTX_REG(FSYNR0, (b), (c), (v))
- #define SET_FSYNR1(b, c, v) SET_CTX_REG(FSYNR1, (b), (c), (v))
- #define SET_PRRR(b, c, v) SET_CTX_REG(PRRR, (b), (c), (v))
- #define SET_NMRR(b, c, v) SET_CTX_REG(NMRR, (b), (c), (v))
- #define SET_TLBLKCR(b, c, v) SET_CTX_REG(TLBLCKR, (b), (c), (v))
- #define SET_V2PSR(b, c, v) SET_CTX_REG(V2PSR, (b), (c), (v))
- #define SET_TLBFLPTER(b, c, v) SET_CTX_REG(TLBFLPTER, (b), (c), (v))
- #define SET_TLBSLPTER(b, c, v) SET_CTX_REG(TLBSLPTER, (b), (c), (v))
- #define SET_BFBCR(b, c, v) SET_CTX_REG(BFBCR, (b), (c), (v))
- #define SET_CTX_TLBIALL(b, c, v) SET_CTX_REG(CTX_TLBIALL, (b), (c), (v))
- #define SET_TLBIASID(b, c, v) SET_CTX_REG(TLBIASID, (b), (c), (v))
- #define SET_TLBIVA(b, c, v) SET_CTX_REG(TLBIVA, (b), (c), (v))
- #define SET_TLBIVAA(b, c, v) SET_CTX_REG(TLBIVAA, (b), (c), (v))
- #define SET_V2PPR(b, c, v) SET_CTX_REG(V2PPR, (b), (c), (v))
- #define SET_V2PPW(b, c, v) SET_CTX_REG(V2PPW, (b), (c), (v))
- #define SET_V2PUR(b, c, v) SET_CTX_REG(V2PUR, (b), (c), (v))
- #define SET_V2PUW(b, c, v) SET_CTX_REG(V2PUW, (b), (c), (v))
- #define SET_RESUME(b, c, v) SET_CTX_REG(RESUME, (b), (c), (v))
- #define GET_SCTLR(b, c) GET_CTX_REG(SCTLR, (b), (c))
- #define GET_ACTLR(b, c) GET_CTX_REG(ACTLR, (b), (c))
- #define GET_CONTEXTIDR(b, c) GET_CTX_REG(CONTEXTIDR, (b), (c))
- #define GET_TTBR0(b, c) GET_CTX_REG(TTBR0, (b), (c))
- #define GET_TTBR1(b, c) GET_CTX_REG(TTBR1, (b), (c))
- #define GET_TTBCR(b, c) GET_CTX_REG(TTBCR, (b), (c))
- #define GET_PAR(b, c) GET_CTX_REG(PAR, (b), (c))
- #define GET_FSR(b, c) GET_CTX_REG(FSR, (b), (c))
- #define GET_FSRRESTORE(b, c) GET_CTX_REG(FSRRESTORE, (b), (c))
- #define GET_FAR(b, c) GET_CTX_REG(FAR, (b), (c))
- #define GET_FSYNR0(b, c) GET_CTX_REG(FSYNR0, (b), (c))
- #define GET_FSYNR1(b, c) GET_CTX_REG(FSYNR1, (b), (c))
- #define GET_PRRR(b, c) GET_CTX_REG(PRRR, (b), (c))
- #define GET_NMRR(b, c) GET_CTX_REG(NMRR, (b), (c))
- #define GET_TLBLCKR(b, c) GET_CTX_REG(TLBLCKR, (b), (c))
- #define GET_V2PSR(b, c) GET_CTX_REG(V2PSR, (b), (c))
- #define GET_TLBFLPTER(b, c) GET_CTX_REG(TLBFLPTER, (b), (c))
- #define GET_TLBSLPTER(b, c) GET_CTX_REG(TLBSLPTER, (b), (c))
- #define GET_BFBCR(b, c) GET_CTX_REG(BFBCR, (b), (c))
|