18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_MMU_BOOK3E_H_
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_MMU_BOOK3E_H_
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * Freescale Book-E/Book-3e (ISA 2.06+) MMU support
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/* Book-3e defined page sizes */
98c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_1K	0
108c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_2K	1
118c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_4K	2
128c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_8K	3
138c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_16K	4
148c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_32K	5
158c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_64K	6
168c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_128K	7
178c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_256K	8
188c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_512K	9
198c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_1M	10
208c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_2M	11
218c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_4M	12
228c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_8M	13
238c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_16M	14
248c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_32M	15
258c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_64M	16
268c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_128M	17
278c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_256M	18
288c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_512M	19
298c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_1GB	20
308c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_2GB	21
318c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_4GB	22
328c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_8GB	23
338c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_16GB	24
348c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_32GB	25
358c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_64GB	26
368c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_128GB	27
378c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_256GB	28
388c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_512GB	29
398c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_1TB	30
408c2ecf20Sopenharmony_ci#define BOOK3E_PAGESZ_2TB	31
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* MAS registers bit definitions */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define MAS0_TLBSEL_MASK	0x30000000
458c2ecf20Sopenharmony_ci#define MAS0_TLBSEL_SHIFT	28
468c2ecf20Sopenharmony_ci#define MAS0_TLBSEL(x)		(((x) << MAS0_TLBSEL_SHIFT) & MAS0_TLBSEL_MASK)
478c2ecf20Sopenharmony_ci#define MAS0_GET_TLBSEL(mas0)	(((mas0) & MAS0_TLBSEL_MASK) >> \
488c2ecf20Sopenharmony_ci			MAS0_TLBSEL_SHIFT)
498c2ecf20Sopenharmony_ci#define MAS0_ESEL_MASK		0x0FFF0000
508c2ecf20Sopenharmony_ci#define MAS0_ESEL_SHIFT		16
518c2ecf20Sopenharmony_ci#define MAS0_ESEL(x)		(((x) << MAS0_ESEL_SHIFT) & MAS0_ESEL_MASK)
528c2ecf20Sopenharmony_ci#define MAS0_NV(x)		((x) & 0x00000FFF)
538c2ecf20Sopenharmony_ci#define MAS0_HES		0x00004000
548c2ecf20Sopenharmony_ci#define MAS0_WQ_ALLWAYS		0x00000000
558c2ecf20Sopenharmony_ci#define MAS0_WQ_COND		0x00001000
568c2ecf20Sopenharmony_ci#define MAS0_WQ_CLR_RSRV       	0x00002000
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define MAS1_VALID		0x80000000
598c2ecf20Sopenharmony_ci#define MAS1_IPROT		0x40000000
608c2ecf20Sopenharmony_ci#define MAS1_TID(x)		(((x) << 16) & 0x3FFF0000)
618c2ecf20Sopenharmony_ci#define MAS1_IND		0x00002000
628c2ecf20Sopenharmony_ci#define MAS1_TS			0x00001000
638c2ecf20Sopenharmony_ci#define MAS1_TSIZE_MASK		0x00000f80
648c2ecf20Sopenharmony_ci#define MAS1_TSIZE_SHIFT	7
658c2ecf20Sopenharmony_ci#define MAS1_TSIZE(x)		(((x) << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
668c2ecf20Sopenharmony_ci#define MAS1_GET_TSIZE(mas1)	(((mas1) & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define MAS2_EPN		(~0xFFFUL)
698c2ecf20Sopenharmony_ci#define MAS2_X0			0x00000040
708c2ecf20Sopenharmony_ci#define MAS2_X1			0x00000020
718c2ecf20Sopenharmony_ci#define MAS2_W			0x00000010
728c2ecf20Sopenharmony_ci#define MAS2_I			0x00000008
738c2ecf20Sopenharmony_ci#define MAS2_M			0x00000004
748c2ecf20Sopenharmony_ci#define MAS2_G			0x00000002
758c2ecf20Sopenharmony_ci#define MAS2_E			0x00000001
768c2ecf20Sopenharmony_ci#define MAS2_WIMGE_MASK		0x0000001f
778c2ecf20Sopenharmony_ci#define MAS2_EPN_MASK(size)		(~0 << (size + 10))
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define MAS3_RPN		0xFFFFF000
808c2ecf20Sopenharmony_ci#define MAS3_U0			0x00000200
818c2ecf20Sopenharmony_ci#define MAS3_U1			0x00000100
828c2ecf20Sopenharmony_ci#define MAS3_U2			0x00000080
838c2ecf20Sopenharmony_ci#define MAS3_U3			0x00000040
848c2ecf20Sopenharmony_ci#define MAS3_UX			0x00000020
858c2ecf20Sopenharmony_ci#define MAS3_SX			0x00000010
868c2ecf20Sopenharmony_ci#define MAS3_UW			0x00000008
878c2ecf20Sopenharmony_ci#define MAS3_SW			0x00000004
888c2ecf20Sopenharmony_ci#define MAS3_UR			0x00000002
898c2ecf20Sopenharmony_ci#define MAS3_SR			0x00000001
908c2ecf20Sopenharmony_ci#define MAS3_BAP_MASK		0x0000003f
918c2ecf20Sopenharmony_ci#define MAS3_SPSIZE		0x0000003e
928c2ecf20Sopenharmony_ci#define MAS3_SPSIZE_SHIFT	1
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define MAS4_TLBSEL_MASK	MAS0_TLBSEL_MASK
958c2ecf20Sopenharmony_ci#define MAS4_TLBSELD(x) 	MAS0_TLBSEL(x)
968c2ecf20Sopenharmony_ci#define MAS4_INDD		0x00008000	/* Default IND */
978c2ecf20Sopenharmony_ci#define MAS4_TSIZED(x)		MAS1_TSIZE(x)
988c2ecf20Sopenharmony_ci#define MAS4_X0D		0x00000040
998c2ecf20Sopenharmony_ci#define MAS4_X1D		0x00000020
1008c2ecf20Sopenharmony_ci#define MAS4_WD			0x00000010
1018c2ecf20Sopenharmony_ci#define MAS4_ID			0x00000008
1028c2ecf20Sopenharmony_ci#define MAS4_MD			0x00000004
1038c2ecf20Sopenharmony_ci#define MAS4_GD			0x00000002
1048c2ecf20Sopenharmony_ci#define MAS4_ED			0x00000001
1058c2ecf20Sopenharmony_ci#define MAS4_WIMGED_MASK	0x0000001f	/* Default WIMGE */
1068c2ecf20Sopenharmony_ci#define MAS4_WIMGED_SHIFT	0
1078c2ecf20Sopenharmony_ci#define MAS4_VLED		MAS4_X1D	/* Default VLE */
1088c2ecf20Sopenharmony_ci#define MAS4_ACMD		0x000000c0	/* Default ACM */
1098c2ecf20Sopenharmony_ci#define MAS4_ACMD_SHIFT		6
1108c2ecf20Sopenharmony_ci#define MAS4_TSIZED_MASK	0x00000f80	/* Default TSIZE */
1118c2ecf20Sopenharmony_ci#define MAS4_TSIZED_SHIFT	7
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#define MAS5_SGS		0x80000000
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define MAS6_SPID0		0x3FFF0000
1168c2ecf20Sopenharmony_ci#define MAS6_SPID1		0x00007FFE
1178c2ecf20Sopenharmony_ci#define MAS6_ISIZE(x)		MAS1_TSIZE(x)
1188c2ecf20Sopenharmony_ci#define MAS6_SAS		0x00000001
1198c2ecf20Sopenharmony_ci#define MAS6_SPID		MAS6_SPID0
1208c2ecf20Sopenharmony_ci#define MAS6_SIND 		0x00000002	/* Indirect page */
1218c2ecf20Sopenharmony_ci#define MAS6_SIND_SHIFT		1
1228c2ecf20Sopenharmony_ci#define MAS6_SPID_MASK		0x3fff0000
1238c2ecf20Sopenharmony_ci#define MAS6_SPID_SHIFT		16
1248c2ecf20Sopenharmony_ci#define MAS6_ISIZE_MASK		0x00000f80
1258c2ecf20Sopenharmony_ci#define MAS6_ISIZE_SHIFT	7
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define MAS7_RPN		0xFFFFFFFF
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define MAS8_TGS		0x80000000 /* Guest space */
1308c2ecf20Sopenharmony_ci#define MAS8_VF			0x40000000 /* Virtualization Fault */
1318c2ecf20Sopenharmony_ci#define MAS8_TLPID		0x000000ff
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci/* Bit definitions for MMUCFG */
1348c2ecf20Sopenharmony_ci#define MMUCFG_MAVN	0x00000003	/* MMU Architecture Version Number */
1358c2ecf20Sopenharmony_ci#define MMUCFG_MAVN_V1	0x00000000	/* v1.0 */
1368c2ecf20Sopenharmony_ci#define MMUCFG_MAVN_V2	0x00000001	/* v2.0 */
1378c2ecf20Sopenharmony_ci#define MMUCFG_NTLBS	0x0000000c	/* Number of TLBs */
1388c2ecf20Sopenharmony_ci#define MMUCFG_PIDSIZE	0x000007c0	/* PID Reg Size */
1398c2ecf20Sopenharmony_ci#define MMUCFG_TWC	0x00008000	/* TLB Write Conditional (v2.0) */
1408c2ecf20Sopenharmony_ci#define MMUCFG_LRAT	0x00010000	/* LRAT Supported (v2.0) */
1418c2ecf20Sopenharmony_ci#define MMUCFG_RASIZE	0x00fe0000	/* Real Addr Size */
1428c2ecf20Sopenharmony_ci#define MMUCFG_LPIDSIZE	0x0f000000	/* LPID Reg Size */
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* Bit definitions for MMUCSR0 */
1458c2ecf20Sopenharmony_ci#define MMUCSR0_TLB1FI	0x00000002	/* TLB1 Flash invalidate */
1468c2ecf20Sopenharmony_ci#define MMUCSR0_TLB0FI	0x00000004	/* TLB0 Flash invalidate */
1478c2ecf20Sopenharmony_ci#define MMUCSR0_TLB2FI	0x00000040	/* TLB2 Flash invalidate */
1488c2ecf20Sopenharmony_ci#define MMUCSR0_TLB3FI	0x00000020	/* TLB3 Flash invalidate */
1498c2ecf20Sopenharmony_ci#define MMUCSR0_TLBFI	(MMUCSR0_TLB0FI | MMUCSR0_TLB1FI | \
1508c2ecf20Sopenharmony_ci			 MMUCSR0_TLB2FI | MMUCSR0_TLB3FI)
1518c2ecf20Sopenharmony_ci#define MMUCSR0_TLB0PS	0x00000780	/* TLB0 Page Size */
1528c2ecf20Sopenharmony_ci#define MMUCSR0_TLB1PS	0x00007800	/* TLB1 Page Size */
1538c2ecf20Sopenharmony_ci#define MMUCSR0_TLB2PS	0x00078000	/* TLB2 Page Size */
1548c2ecf20Sopenharmony_ci#define MMUCSR0_TLB3PS	0x00780000	/* TLB3 Page Size */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci/* MMUCFG bits */
1578c2ecf20Sopenharmony_ci#define MMUCFG_MAVN_NASK	0x00000003
1588c2ecf20Sopenharmony_ci#define MMUCFG_MAVN_V1_0	0x00000000
1598c2ecf20Sopenharmony_ci#define MMUCFG_MAVN_V2_0	0x00000001
1608c2ecf20Sopenharmony_ci#define MMUCFG_NTLB_MASK	0x0000000c
1618c2ecf20Sopenharmony_ci#define MMUCFG_NTLB_SHIFT	2
1628c2ecf20Sopenharmony_ci#define MMUCFG_PIDSIZE_MASK	0x000007c0
1638c2ecf20Sopenharmony_ci#define MMUCFG_PIDSIZE_SHIFT	6
1648c2ecf20Sopenharmony_ci#define MMUCFG_TWC		0x00008000
1658c2ecf20Sopenharmony_ci#define MMUCFG_LRAT		0x00010000
1668c2ecf20Sopenharmony_ci#define MMUCFG_RASIZE_MASK	0x00fe0000
1678c2ecf20Sopenharmony_ci#define MMUCFG_RASIZE_SHIFT	17
1688c2ecf20Sopenharmony_ci#define MMUCFG_LPIDSIZE_MASK	0x0f000000
1698c2ecf20Sopenharmony_ci#define MMUCFG_LPIDSIZE_SHIFT	24
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/* TLBnCFG encoding */
1728c2ecf20Sopenharmony_ci#define TLBnCFG_N_ENTRY		0x00000fff	/* number of entries */
1738c2ecf20Sopenharmony_ci#define TLBnCFG_HES		0x00002000	/* HW select supported */
1748c2ecf20Sopenharmony_ci#define TLBnCFG_IPROT		0x00008000	/* IPROT supported */
1758c2ecf20Sopenharmony_ci#define TLBnCFG_GTWE		0x00010000	/* Guest can write */
1768c2ecf20Sopenharmony_ci#define TLBnCFG_IND		0x00020000	/* IND entries supported */
1778c2ecf20Sopenharmony_ci#define TLBnCFG_PT		0x00040000	/* Can load from page table */
1788c2ecf20Sopenharmony_ci#define TLBnCFG_MINSIZE		0x00f00000	/* Minimum Page Size (v1.0) */
1798c2ecf20Sopenharmony_ci#define TLBnCFG_MINSIZE_SHIFT	20
1808c2ecf20Sopenharmony_ci#define TLBnCFG_MAXSIZE		0x000f0000	/* Maximum Page Size (v1.0) */
1818c2ecf20Sopenharmony_ci#define TLBnCFG_MAXSIZE_SHIFT	16
1828c2ecf20Sopenharmony_ci#define TLBnCFG_ASSOC		0xff000000	/* Associativity */
1838c2ecf20Sopenharmony_ci#define TLBnCFG_ASSOC_SHIFT	24
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/* TLBnPS encoding */
1868c2ecf20Sopenharmony_ci#define TLBnPS_4K		0x00000004
1878c2ecf20Sopenharmony_ci#define TLBnPS_8K		0x00000008
1888c2ecf20Sopenharmony_ci#define TLBnPS_16K		0x00000010
1898c2ecf20Sopenharmony_ci#define TLBnPS_32K		0x00000020
1908c2ecf20Sopenharmony_ci#define TLBnPS_64K		0x00000040
1918c2ecf20Sopenharmony_ci#define TLBnPS_128K		0x00000080
1928c2ecf20Sopenharmony_ci#define TLBnPS_256K		0x00000100
1938c2ecf20Sopenharmony_ci#define TLBnPS_512K		0x00000200
1948c2ecf20Sopenharmony_ci#define TLBnPS_1M 		0x00000400
1958c2ecf20Sopenharmony_ci#define TLBnPS_2M 		0x00000800
1968c2ecf20Sopenharmony_ci#define TLBnPS_4M 		0x00001000
1978c2ecf20Sopenharmony_ci#define TLBnPS_8M 		0x00002000
1988c2ecf20Sopenharmony_ci#define TLBnPS_16M		0x00004000
1998c2ecf20Sopenharmony_ci#define TLBnPS_32M		0x00008000
2008c2ecf20Sopenharmony_ci#define TLBnPS_64M		0x00010000
2018c2ecf20Sopenharmony_ci#define TLBnPS_128M		0x00020000
2028c2ecf20Sopenharmony_ci#define TLBnPS_256M		0x00040000
2038c2ecf20Sopenharmony_ci#define TLBnPS_512M		0x00080000
2048c2ecf20Sopenharmony_ci#define TLBnPS_1G		0x00100000
2058c2ecf20Sopenharmony_ci#define TLBnPS_2G		0x00200000
2068c2ecf20Sopenharmony_ci#define TLBnPS_4G		0x00400000
2078c2ecf20Sopenharmony_ci#define TLBnPS_8G		0x00800000
2088c2ecf20Sopenharmony_ci#define TLBnPS_16G		0x01000000
2098c2ecf20Sopenharmony_ci#define TLBnPS_32G		0x02000000
2108c2ecf20Sopenharmony_ci#define TLBnPS_64G		0x04000000
2118c2ecf20Sopenharmony_ci#define TLBnPS_128G		0x08000000
2128c2ecf20Sopenharmony_ci#define TLBnPS_256G		0x10000000
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci/* tlbilx action encoding */
2158c2ecf20Sopenharmony_ci#define TLBILX_T_ALL			0
2168c2ecf20Sopenharmony_ci#define TLBILX_T_TID			1
2178c2ecf20Sopenharmony_ci#define TLBILX_T_FULLMATCH		3
2188c2ecf20Sopenharmony_ci#define TLBILX_T_CLASS0			4
2198c2ecf20Sopenharmony_ci#define TLBILX_T_CLASS1			5
2208c2ecf20Sopenharmony_ci#define TLBILX_T_CLASS2			6
2218c2ecf20Sopenharmony_ci#define TLBILX_T_CLASS3			7
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/*
2248c2ecf20Sopenharmony_ci * The mapping only needs to be cache-coherent on SMP, except on
2258c2ecf20Sopenharmony_ci * Freescale e500mc derivatives where it's also needed for coherent DMA.
2268c2ecf20Sopenharmony_ci */
2278c2ecf20Sopenharmony_ci#if defined(CONFIG_SMP) || defined(CONFIG_PPC_E500MC)
2288c2ecf20Sopenharmony_ci#define MAS2_M_IF_NEEDED	MAS2_M
2298c2ecf20Sopenharmony_ci#else
2308c2ecf20Sopenharmony_ci#define MAS2_M_IF_NEEDED	0
2318c2ecf20Sopenharmony_ci#endif
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
2348c2ecf20Sopenharmony_ci#include <asm/bug.h>
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ciextern unsigned int tlbcam_index;
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_citypedef struct {
2398c2ecf20Sopenharmony_ci	unsigned int	id;
2408c2ecf20Sopenharmony_ci	unsigned int	active;
2418c2ecf20Sopenharmony_ci	unsigned long	vdso_base;
2428c2ecf20Sopenharmony_ci} mm_context_t;
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci/* Page size definitions, common between 32 and 64-bit
2458c2ecf20Sopenharmony_ci *
2468c2ecf20Sopenharmony_ci *    shift : is the "PAGE_SHIFT" value for that page size
2478c2ecf20Sopenharmony_ci *    penc  : is the pte encoding mask
2488c2ecf20Sopenharmony_ci *
2498c2ecf20Sopenharmony_ci */
2508c2ecf20Sopenharmony_cistruct mmu_psize_def
2518c2ecf20Sopenharmony_ci{
2528c2ecf20Sopenharmony_ci	unsigned int	shift;	/* number of bits */
2538c2ecf20Sopenharmony_ci	unsigned int	enc;	/* PTE encoding */
2548c2ecf20Sopenharmony_ci	unsigned int    ind;    /* Corresponding indirect page size shift */
2558c2ecf20Sopenharmony_ci	unsigned int	flags;
2568c2ecf20Sopenharmony_ci#define MMU_PAGE_SIZE_DIRECT	0x1	/* Supported as a direct size */
2578c2ecf20Sopenharmony_ci#define MMU_PAGE_SIZE_INDIRECT	0x2	/* Supported as an indirect size */
2588c2ecf20Sopenharmony_ci};
2598c2ecf20Sopenharmony_ciextern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_cistatic inline int shift_to_mmu_psize(unsigned int shift)
2628c2ecf20Sopenharmony_ci{
2638c2ecf20Sopenharmony_ci	int psize;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	for (psize = 0; psize < MMU_PAGE_COUNT; ++psize)
2668c2ecf20Sopenharmony_ci		if (mmu_psize_defs[psize].shift == shift)
2678c2ecf20Sopenharmony_ci			return psize;
2688c2ecf20Sopenharmony_ci	return -1;
2698c2ecf20Sopenharmony_ci}
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_cistatic inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize)
2728c2ecf20Sopenharmony_ci{
2738c2ecf20Sopenharmony_ci	if (mmu_psize_defs[mmu_psize].shift)
2748c2ecf20Sopenharmony_ci		return mmu_psize_defs[mmu_psize].shift;
2758c2ecf20Sopenharmony_ci	BUG();
2768c2ecf20Sopenharmony_ci}
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci/* The page sizes use the same names as 64-bit hash but are
2798c2ecf20Sopenharmony_ci * constants
2808c2ecf20Sopenharmony_ci */
2818c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_4K_PAGES)
2828c2ecf20Sopenharmony_ci#define mmu_virtual_psize	MMU_PAGE_4K
2838c2ecf20Sopenharmony_ci#else
2848c2ecf20Sopenharmony_ci#error Unsupported page size
2858c2ecf20Sopenharmony_ci#endif
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ciextern int mmu_linear_psize;
2888c2ecf20Sopenharmony_ciextern int mmu_vmemmap_psize;
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistruct tlb_core_data {
2918c2ecf20Sopenharmony_ci	/*
2928c2ecf20Sopenharmony_ci	 * Per-core spinlock for e6500 TLB handlers (no tlbsrx.)
2938c2ecf20Sopenharmony_ci	 * Must be the first struct element.
2948c2ecf20Sopenharmony_ci	 */
2958c2ecf20Sopenharmony_ci	u8 lock;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	/* For software way selection, as on Freescale TLB1 */
2988c2ecf20Sopenharmony_ci	u8 esel_next, esel_max, esel_first;
2998c2ecf20Sopenharmony_ci};
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64
3028c2ecf20Sopenharmony_ciextern unsigned long linear_map_top;
3038c2ecf20Sopenharmony_ciextern int book3e_htw_mode;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci#define PPC_HTW_NONE	0
3068c2ecf20Sopenharmony_ci#define PPC_HTW_IBM	1
3078c2ecf20Sopenharmony_ci#define PPC_HTW_E6500	2
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/*
3108c2ecf20Sopenharmony_ci * 64-bit booke platforms don't load the tlb in the tlb miss handler code.
3118c2ecf20Sopenharmony_ci * HUGETLB_NEED_PRELOAD handles this - it causes huge_ptep_set_access_flags to
3128c2ecf20Sopenharmony_ci * return 1, indicating that the tlb requires preloading.
3138c2ecf20Sopenharmony_ci */
3148c2ecf20Sopenharmony_ci#define HUGETLB_NEED_PRELOAD
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci#define mmu_cleanup_all NULL
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci#define MAX_PHYSMEM_BITS        44
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci#endif
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_MMU_BOOK3E_H_ */
325