18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_NOHASH_32_PTE_FSL_BOOKE_H
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_NOHASH_32_PTE_FSL_BOOKE_H
48c2ecf20Sopenharmony_ci#ifdef __KERNEL__
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/* PTE bit definitions for Freescale BookE SW loaded TLB MMU based
78c2ecf20Sopenharmony_ci * processors
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci   MMU Assist Register 3:
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci   32 33 34 35 36  ... 50 51 52 53 54 55 56 57 58 59 60 61 62 63
128c2ecf20Sopenharmony_ci   RPN......................  0  0 U0 U1 U2 U3 UX SX UW SW UR SR
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci   - PRESENT *must* be in the bottom three bits because swap cache
158c2ecf20Sopenharmony_ci     entries use the top 29 bits.
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci*/
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/* Definitions for FSL Book-E Cores */
208c2ecf20Sopenharmony_ci#define _PAGE_PRESENT	0x00001	/* S: PTE contains a translation */
218c2ecf20Sopenharmony_ci#define _PAGE_USER	0x00002	/* S: User page (maps to UR) */
228c2ecf20Sopenharmony_ci#define _PAGE_RW	0x00004	/* S: Write permission (SW) */
238c2ecf20Sopenharmony_ci#define _PAGE_DIRTY	0x00008	/* S: Page dirty */
248c2ecf20Sopenharmony_ci#define _PAGE_EXEC	0x00010	/* H: SX permission */
258c2ecf20Sopenharmony_ci#define _PAGE_ACCESSED	0x00020	/* S: Page referenced */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define _PAGE_ENDIAN	0x00040	/* H: E bit */
288c2ecf20Sopenharmony_ci#define _PAGE_GUARDED	0x00080	/* H: G bit */
298c2ecf20Sopenharmony_ci#define _PAGE_COHERENT	0x00100	/* H: M bit */
308c2ecf20Sopenharmony_ci#define _PAGE_NO_CACHE	0x00200	/* H: I bit */
318c2ecf20Sopenharmony_ci#define _PAGE_WRITETHRU	0x00400	/* H: W bit */
328c2ecf20Sopenharmony_ci#define _PAGE_SPECIAL	0x00800 /* S: Special page */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define _PAGE_KERNEL_RO		0
358c2ecf20Sopenharmony_ci#define _PAGE_KERNEL_ROX	_PAGE_EXEC
368c2ecf20Sopenharmony_ci#define _PAGE_KERNEL_RW		(_PAGE_DIRTY | _PAGE_RW)
378c2ecf20Sopenharmony_ci#define _PAGE_KERNEL_RWX	(_PAGE_DIRTY | _PAGE_RW | _PAGE_EXEC)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* No page size encoding in the linux PTE */
408c2ecf20Sopenharmony_ci#define _PAGE_PSIZE		0
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define _PMD_PRESENT	0
438c2ecf20Sopenharmony_ci#define _PMD_PRESENT_MASK (PAGE_MASK)
448c2ecf20Sopenharmony_ci#define _PMD_BAD	(~PAGE_MASK)
458c2ecf20Sopenharmony_ci#define _PMD_USER	0
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define _PTE_NONE_MASK	0
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define PTE_WIMGE_SHIFT (6)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/*
528c2ecf20Sopenharmony_ci * We define 2 sets of base prot bits, one for basic pages (ie,
538c2ecf20Sopenharmony_ci * cacheable kernel and user pages) and one for non cacheable
548c2ecf20Sopenharmony_ci * pages. We always set _PAGE_COHERENT when SMP is enabled or
558c2ecf20Sopenharmony_ci * the processor might need it for DMA coherency.
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci#define _PAGE_BASE_NC	(_PAGE_PRESENT | _PAGE_ACCESSED)
588c2ecf20Sopenharmony_ci#if defined(CONFIG_SMP) || defined(CONFIG_PPC_E500MC)
598c2ecf20Sopenharmony_ci#define _PAGE_BASE	(_PAGE_BASE_NC | _PAGE_COHERENT)
608c2ecf20Sopenharmony_ci#else
618c2ecf20Sopenharmony_ci#define _PAGE_BASE	(_PAGE_BASE_NC)
628c2ecf20Sopenharmony_ci#endif
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/* Permission masks used to generate the __P and __S table */
658c2ecf20Sopenharmony_ci#define PAGE_NONE	__pgprot(_PAGE_BASE)
668c2ecf20Sopenharmony_ci#define PAGE_SHARED	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
678c2ecf20Sopenharmony_ci#define PAGE_SHARED_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
688c2ecf20Sopenharmony_ci#define PAGE_COPY	__pgprot(_PAGE_BASE | _PAGE_USER)
698c2ecf20Sopenharmony_ci#define PAGE_COPY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
708c2ecf20Sopenharmony_ci#define PAGE_READONLY	__pgprot(_PAGE_BASE | _PAGE_USER)
718c2ecf20Sopenharmony_ci#define PAGE_READONLY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
748c2ecf20Sopenharmony_ci#endif /*  _ASM_POWERPC_NOHASH_32_PTE_FSL_BOOKE_H */
75