18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2013 Freescale Semiconductor, Inc. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __FSL_PAMU_H 88c2ecf20Sopenharmony_ci#define __FSL_PAMU_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/iommu.h> 118c2ecf20Sopenharmony_ci#include <linux/pci.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/fsl_pamu_stash.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* Bit Field macros 168c2ecf20Sopenharmony_ci * v = bit field variable; m = mask, m##_SHIFT = shift, x = value to load 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#define set_bf(v, m, x) (v = ((v) & ~(m)) | (((x) << m##_SHIFT) & (m))) 198c2ecf20Sopenharmony_ci#define get_bf(v, m) (((v) & (m)) >> m##_SHIFT) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* PAMU CCSR space */ 228c2ecf20Sopenharmony_ci#define PAMU_PGC 0x00000000 /* Allows all peripheral accesses */ 238c2ecf20Sopenharmony_ci#define PAMU_PE 0x40000000 /* enable PAMU */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* PAMU_OFFSET to the next pamu space in ccsr */ 268c2ecf20Sopenharmony_ci#define PAMU_OFFSET 0x1000 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define PAMU_MMAP_REGS_BASE 0 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct pamu_mmap_regs { 318c2ecf20Sopenharmony_ci u32 ppbah; 328c2ecf20Sopenharmony_ci u32 ppbal; 338c2ecf20Sopenharmony_ci u32 pplah; 348c2ecf20Sopenharmony_ci u32 pplal; 358c2ecf20Sopenharmony_ci u32 spbah; 368c2ecf20Sopenharmony_ci u32 spbal; 378c2ecf20Sopenharmony_ci u32 splah; 388c2ecf20Sopenharmony_ci u32 splal; 398c2ecf20Sopenharmony_ci u32 obah; 408c2ecf20Sopenharmony_ci u32 obal; 418c2ecf20Sopenharmony_ci u32 olah; 428c2ecf20Sopenharmony_ci u32 olal; 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* PAMU Error Registers */ 468c2ecf20Sopenharmony_ci#define PAMU_POES1 0x0040 478c2ecf20Sopenharmony_ci#define PAMU_POES2 0x0044 488c2ecf20Sopenharmony_ci#define PAMU_POEAH 0x0048 498c2ecf20Sopenharmony_ci#define PAMU_POEAL 0x004C 508c2ecf20Sopenharmony_ci#define PAMU_AVS1 0x0050 518c2ecf20Sopenharmony_ci#define PAMU_AVS1_AV 0x1 528c2ecf20Sopenharmony_ci#define PAMU_AVS1_OTV 0x6 538c2ecf20Sopenharmony_ci#define PAMU_AVS1_APV 0x78 548c2ecf20Sopenharmony_ci#define PAMU_AVS1_WAV 0x380 558c2ecf20Sopenharmony_ci#define PAMU_AVS1_LAV 0x1c00 568c2ecf20Sopenharmony_ci#define PAMU_AVS1_GCV 0x2000 578c2ecf20Sopenharmony_ci#define PAMU_AVS1_PDV 0x4000 588c2ecf20Sopenharmony_ci#define PAMU_AV_MASK (PAMU_AVS1_AV | PAMU_AVS1_OTV | PAMU_AVS1_APV | PAMU_AVS1_WAV \ 598c2ecf20Sopenharmony_ci | PAMU_AVS1_LAV | PAMU_AVS1_GCV | PAMU_AVS1_PDV) 608c2ecf20Sopenharmony_ci#define PAMU_AVS1_LIODN_SHIFT 16 618c2ecf20Sopenharmony_ci#define PAMU_LAV_LIODN_NOT_IN_PPAACT 0x400 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define PAMU_AVS2 0x0054 648c2ecf20Sopenharmony_ci#define PAMU_AVAH 0x0058 658c2ecf20Sopenharmony_ci#define PAMU_AVAL 0x005C 668c2ecf20Sopenharmony_ci#define PAMU_EECTL 0x0060 678c2ecf20Sopenharmony_ci#define PAMU_EEDIS 0x0064 688c2ecf20Sopenharmony_ci#define PAMU_EEINTEN 0x0068 698c2ecf20Sopenharmony_ci#define PAMU_EEDET 0x006C 708c2ecf20Sopenharmony_ci#define PAMU_EEATTR 0x0070 718c2ecf20Sopenharmony_ci#define PAMU_EEAHI 0x0074 728c2ecf20Sopenharmony_ci#define PAMU_EEALO 0x0078 738c2ecf20Sopenharmony_ci#define PAMU_EEDHI 0X007C 748c2ecf20Sopenharmony_ci#define PAMU_EEDLO 0x0080 758c2ecf20Sopenharmony_ci#define PAMU_EECC 0x0084 768c2ecf20Sopenharmony_ci#define PAMU_UDAD 0x0090 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* PAMU Revision Registers */ 798c2ecf20Sopenharmony_ci#define PAMU_PR1 0x0BF8 808c2ecf20Sopenharmony_ci#define PAMU_PR2 0x0BFC 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* PAMU version mask */ 838c2ecf20Sopenharmony_ci#define PAMU_PR1_MASK 0xffff 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* PAMU Capabilities Registers */ 868c2ecf20Sopenharmony_ci#define PAMU_PC1 0x0C00 878c2ecf20Sopenharmony_ci#define PAMU_PC2 0x0C04 888c2ecf20Sopenharmony_ci#define PAMU_PC3 0x0C08 898c2ecf20Sopenharmony_ci#define PAMU_PC4 0x0C0C 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* PAMU Control Register */ 928c2ecf20Sopenharmony_ci#define PAMU_PC 0x0C10 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* PAMU control defs */ 958c2ecf20Sopenharmony_ci#define PAMU_CONTROL 0x0C10 968c2ecf20Sopenharmony_ci#define PAMU_PC_PGC 0x80000000 /* PAMU gate closed bit */ 978c2ecf20Sopenharmony_ci#define PAMU_PC_PE 0x40000000 /* PAMU enable bit */ 988c2ecf20Sopenharmony_ci#define PAMU_PC_SPCC 0x00000010 /* sPAACE cache enable */ 998c2ecf20Sopenharmony_ci#define PAMU_PC_PPCC 0x00000001 /* pPAACE cache enable */ 1008c2ecf20Sopenharmony_ci#define PAMU_PC_OCE 0x00001000 /* OMT cache enable */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define PAMU_PFA1 0x0C14 1038c2ecf20Sopenharmony_ci#define PAMU_PFA2 0x0C18 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#define PAMU_PC2_MLIODN(X) ((X) >> 16) 1068c2ecf20Sopenharmony_ci#define PAMU_PC3_MWCE(X) (((X) >> 21) & 0xf) 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci/* PAMU Interrupt control and Status Register */ 1098c2ecf20Sopenharmony_ci#define PAMU_PICS 0x0C1C 1108c2ecf20Sopenharmony_ci#define PAMU_ACCESS_VIOLATION_STAT 0x8 1118c2ecf20Sopenharmony_ci#define PAMU_ACCESS_VIOLATION_ENABLE 0x4 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/* PAMU Debug Registers */ 1148c2ecf20Sopenharmony_ci#define PAMU_PD1 0x0F00 1158c2ecf20Sopenharmony_ci#define PAMU_PD2 0x0F04 1168c2ecf20Sopenharmony_ci#define PAMU_PD3 0x0F08 1178c2ecf20Sopenharmony_ci#define PAMU_PD4 0x0F0C 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define PAACE_AP_PERMS_DENIED 0x0 1208c2ecf20Sopenharmony_ci#define PAACE_AP_PERMS_QUERY 0x1 1218c2ecf20Sopenharmony_ci#define PAACE_AP_PERMS_UPDATE 0x2 1228c2ecf20Sopenharmony_ci#define PAACE_AP_PERMS_ALL 0x3 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define PAACE_DD_TO_HOST 0x0 1258c2ecf20Sopenharmony_ci#define PAACE_DD_TO_IO 0x1 1268c2ecf20Sopenharmony_ci#define PAACE_PT_PRIMARY 0x0 1278c2ecf20Sopenharmony_ci#define PAACE_PT_SECONDARY 0x1 1288c2ecf20Sopenharmony_ci#define PAACE_V_INVALID 0x0 1298c2ecf20Sopenharmony_ci#define PAACE_V_VALID 0x1 1308c2ecf20Sopenharmony_ci#define PAACE_MW_SUBWINDOWS 0x1 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define PAACE_WSE_4K 0xB 1338c2ecf20Sopenharmony_ci#define PAACE_WSE_8K 0xC 1348c2ecf20Sopenharmony_ci#define PAACE_WSE_16K 0xD 1358c2ecf20Sopenharmony_ci#define PAACE_WSE_32K 0xE 1368c2ecf20Sopenharmony_ci#define PAACE_WSE_64K 0xF 1378c2ecf20Sopenharmony_ci#define PAACE_WSE_128K 0x10 1388c2ecf20Sopenharmony_ci#define PAACE_WSE_256K 0x11 1398c2ecf20Sopenharmony_ci#define PAACE_WSE_512K 0x12 1408c2ecf20Sopenharmony_ci#define PAACE_WSE_1M 0x13 1418c2ecf20Sopenharmony_ci#define PAACE_WSE_2M 0x14 1428c2ecf20Sopenharmony_ci#define PAACE_WSE_4M 0x15 1438c2ecf20Sopenharmony_ci#define PAACE_WSE_8M 0x16 1448c2ecf20Sopenharmony_ci#define PAACE_WSE_16M 0x17 1458c2ecf20Sopenharmony_ci#define PAACE_WSE_32M 0x18 1468c2ecf20Sopenharmony_ci#define PAACE_WSE_64M 0x19 1478c2ecf20Sopenharmony_ci#define PAACE_WSE_128M 0x1A 1488c2ecf20Sopenharmony_ci#define PAACE_WSE_256M 0x1B 1498c2ecf20Sopenharmony_ci#define PAACE_WSE_512M 0x1C 1508c2ecf20Sopenharmony_ci#define PAACE_WSE_1G 0x1D 1518c2ecf20Sopenharmony_ci#define PAACE_WSE_2G 0x1E 1528c2ecf20Sopenharmony_ci#define PAACE_WSE_4G 0x1F 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define PAACE_DID_PCI_EXPRESS_1 0x00 1558c2ecf20Sopenharmony_ci#define PAACE_DID_PCI_EXPRESS_2 0x01 1568c2ecf20Sopenharmony_ci#define PAACE_DID_PCI_EXPRESS_3 0x02 1578c2ecf20Sopenharmony_ci#define PAACE_DID_PCI_EXPRESS_4 0x03 1588c2ecf20Sopenharmony_ci#define PAACE_DID_LOCAL_BUS 0x04 1598c2ecf20Sopenharmony_ci#define PAACE_DID_SRIO 0x0C 1608c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_1 0x10 1618c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_2 0x11 1628c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_3 0x12 1638c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_4 0x13 1648c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_1_2 0x14 1658c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_3_4 0x15 1668c2ecf20Sopenharmony_ci#define PAACE_DID_MEM_1_4 0x16 1678c2ecf20Sopenharmony_ci#define PAACE_DID_BM_SW_PORTAL 0x18 1688c2ecf20Sopenharmony_ci#define PAACE_DID_PAMU 0x1C 1698c2ecf20Sopenharmony_ci#define PAACE_DID_CAAM 0x21 1708c2ecf20Sopenharmony_ci#define PAACE_DID_QM_SW_PORTAL 0x3C 1718c2ecf20Sopenharmony_ci#define PAACE_DID_CORE0_INST 0x80 1728c2ecf20Sopenharmony_ci#define PAACE_DID_CORE0_DATA 0x81 1738c2ecf20Sopenharmony_ci#define PAACE_DID_CORE1_INST 0x82 1748c2ecf20Sopenharmony_ci#define PAACE_DID_CORE1_DATA 0x83 1758c2ecf20Sopenharmony_ci#define PAACE_DID_CORE2_INST 0x84 1768c2ecf20Sopenharmony_ci#define PAACE_DID_CORE2_DATA 0x85 1778c2ecf20Sopenharmony_ci#define PAACE_DID_CORE3_INST 0x86 1788c2ecf20Sopenharmony_ci#define PAACE_DID_CORE3_DATA 0x87 1798c2ecf20Sopenharmony_ci#define PAACE_DID_CORE4_INST 0x88 1808c2ecf20Sopenharmony_ci#define PAACE_DID_CORE4_DATA 0x89 1818c2ecf20Sopenharmony_ci#define PAACE_DID_CORE5_INST 0x8A 1828c2ecf20Sopenharmony_ci#define PAACE_DID_CORE5_DATA 0x8B 1838c2ecf20Sopenharmony_ci#define PAACE_DID_CORE6_INST 0x8C 1848c2ecf20Sopenharmony_ci#define PAACE_DID_CORE6_DATA 0x8D 1858c2ecf20Sopenharmony_ci#define PAACE_DID_CORE7_INST 0x8E 1868c2ecf20Sopenharmony_ci#define PAACE_DID_CORE7_DATA 0x8F 1878c2ecf20Sopenharmony_ci#define PAACE_DID_BROADCAST 0xFF 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci#define PAACE_ATM_NO_XLATE 0x00 1908c2ecf20Sopenharmony_ci#define PAACE_ATM_WINDOW_XLATE 0x01 1918c2ecf20Sopenharmony_ci#define PAACE_ATM_PAGE_XLATE 0x02 1928c2ecf20Sopenharmony_ci#define PAACE_ATM_WIN_PG_XLATE (PAACE_ATM_WINDOW_XLATE | PAACE_ATM_PAGE_XLATE) 1938c2ecf20Sopenharmony_ci#define PAACE_OTM_NO_XLATE 0x00 1948c2ecf20Sopenharmony_ci#define PAACE_OTM_IMMEDIATE 0x01 1958c2ecf20Sopenharmony_ci#define PAACE_OTM_INDEXED 0x02 1968c2ecf20Sopenharmony_ci#define PAACE_OTM_RESERVED 0x03 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#define PAACE_M_COHERENCE_REQ 0x01 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define PAACE_PID_0 0x0 2018c2ecf20Sopenharmony_ci#define PAACE_PID_1 0x1 2028c2ecf20Sopenharmony_ci#define PAACE_PID_2 0x2 2038c2ecf20Sopenharmony_ci#define PAACE_PID_3 0x3 2048c2ecf20Sopenharmony_ci#define PAACE_PID_4 0x4 2058c2ecf20Sopenharmony_ci#define PAACE_PID_5 0x5 2068c2ecf20Sopenharmony_ci#define PAACE_PID_6 0x6 2078c2ecf20Sopenharmony_ci#define PAACE_PID_7 0x7 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci#define PAACE_TCEF_FORMAT0_8B 0x00 2108c2ecf20Sopenharmony_ci#define PAACE_TCEF_FORMAT1_RSVD 0x01 2118c2ecf20Sopenharmony_ci/* 2128c2ecf20Sopenharmony_ci * Hard coded value for the PAACT size to accommodate 2138c2ecf20Sopenharmony_ci * maximum LIODN value generated by u-boot. 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ci#define PAACE_NUMBER_ENTRIES 0x500 2168c2ecf20Sopenharmony_ci/* Hard coded value for the SPAACT size */ 2178c2ecf20Sopenharmony_ci#define SPAACE_NUMBER_ENTRIES 0x800 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci#define OME_NUMBER_ENTRIES 16 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci/* PAACE Bit Field Defines */ 2228c2ecf20Sopenharmony_ci#define PPAACE_AF_WBAL 0xfffff000 2238c2ecf20Sopenharmony_ci#define PPAACE_AF_WBAL_SHIFT 12 2248c2ecf20Sopenharmony_ci#define PPAACE_AF_WSE 0x00000fc0 2258c2ecf20Sopenharmony_ci#define PPAACE_AF_WSE_SHIFT 6 2268c2ecf20Sopenharmony_ci#define PPAACE_AF_MW 0x00000020 2278c2ecf20Sopenharmony_ci#define PPAACE_AF_MW_SHIFT 5 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci#define SPAACE_AF_LIODN 0xffff0000 2308c2ecf20Sopenharmony_ci#define SPAACE_AF_LIODN_SHIFT 16 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci#define PAACE_AF_AP 0x00000018 2338c2ecf20Sopenharmony_ci#define PAACE_AF_AP_SHIFT 3 2348c2ecf20Sopenharmony_ci#define PAACE_AF_DD 0x00000004 2358c2ecf20Sopenharmony_ci#define PAACE_AF_DD_SHIFT 2 2368c2ecf20Sopenharmony_ci#define PAACE_AF_PT 0x00000002 2378c2ecf20Sopenharmony_ci#define PAACE_AF_PT_SHIFT 1 2388c2ecf20Sopenharmony_ci#define PAACE_AF_V 0x00000001 2398c2ecf20Sopenharmony_ci#define PAACE_AF_V_SHIFT 0 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci#define PAACE_DA_HOST_CR 0x80 2428c2ecf20Sopenharmony_ci#define PAACE_DA_HOST_CR_SHIFT 7 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci#define PAACE_IA_CID 0x00FF0000 2458c2ecf20Sopenharmony_ci#define PAACE_IA_CID_SHIFT 16 2468c2ecf20Sopenharmony_ci#define PAACE_IA_WCE 0x000000F0 2478c2ecf20Sopenharmony_ci#define PAACE_IA_WCE_SHIFT 4 2488c2ecf20Sopenharmony_ci#define PAACE_IA_ATM 0x0000000C 2498c2ecf20Sopenharmony_ci#define PAACE_IA_ATM_SHIFT 2 2508c2ecf20Sopenharmony_ci#define PAACE_IA_OTM 0x00000003 2518c2ecf20Sopenharmony_ci#define PAACE_IA_OTM_SHIFT 0 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci#define PAACE_WIN_TWBAL 0xfffff000 2548c2ecf20Sopenharmony_ci#define PAACE_WIN_TWBAL_SHIFT 12 2558c2ecf20Sopenharmony_ci#define PAACE_WIN_SWSE 0x00000fc0 2568c2ecf20Sopenharmony_ci#define PAACE_WIN_SWSE_SHIFT 6 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* PAMU Data Structures */ 2598c2ecf20Sopenharmony_ci/* primary / secondary paact structure */ 2608c2ecf20Sopenharmony_cistruct paace { 2618c2ecf20Sopenharmony_ci /* PAACE Offset 0x00 */ 2628c2ecf20Sopenharmony_ci u32 wbah; /* only valid for Primary PAACE */ 2638c2ecf20Sopenharmony_ci u32 addr_bitfields; /* See P/S PAACE_AF_* */ 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci /* PAACE Offset 0x08 */ 2668c2ecf20Sopenharmony_ci /* Interpretation of first 32 bits dependent on DD above */ 2678c2ecf20Sopenharmony_ci union { 2688c2ecf20Sopenharmony_ci struct { 2698c2ecf20Sopenharmony_ci /* Destination ID, see PAACE_DID_* defines */ 2708c2ecf20Sopenharmony_ci u8 did; 2718c2ecf20Sopenharmony_ci /* Partition ID */ 2728c2ecf20Sopenharmony_ci u8 pid; 2738c2ecf20Sopenharmony_ci /* Snoop ID */ 2748c2ecf20Sopenharmony_ci u8 snpid; 2758c2ecf20Sopenharmony_ci /* coherency_required : 1 reserved : 7 */ 2768c2ecf20Sopenharmony_ci u8 coherency_required; /* See PAACE_DA_* */ 2778c2ecf20Sopenharmony_ci } to_host; 2788c2ecf20Sopenharmony_ci struct { 2798c2ecf20Sopenharmony_ci /* Destination ID, see PAACE_DID_* defines */ 2808c2ecf20Sopenharmony_ci u8 did; 2818c2ecf20Sopenharmony_ci u8 reserved1; 2828c2ecf20Sopenharmony_ci u16 reserved2; 2838c2ecf20Sopenharmony_ci } to_io; 2848c2ecf20Sopenharmony_ci } domain_attr; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /* Implementation attributes + window count + address & operation translation modes */ 2878c2ecf20Sopenharmony_ci u32 impl_attr; /* See PAACE_IA_* */ 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci /* PAACE Offset 0x10 */ 2908c2ecf20Sopenharmony_ci /* Translated window base address */ 2918c2ecf20Sopenharmony_ci u32 twbah; 2928c2ecf20Sopenharmony_ci u32 win_bitfields; /* See PAACE_WIN_* */ 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci /* PAACE Offset 0x18 */ 2958c2ecf20Sopenharmony_ci /* first secondary paace entry */ 2968c2ecf20Sopenharmony_ci u32 fspi; /* only valid for Primary PAACE */ 2978c2ecf20Sopenharmony_ci union { 2988c2ecf20Sopenharmony_ci struct { 2998c2ecf20Sopenharmony_ci u8 ioea; 3008c2ecf20Sopenharmony_ci u8 moea; 3018c2ecf20Sopenharmony_ci u8 ioeb; 3028c2ecf20Sopenharmony_ci u8 moeb; 3038c2ecf20Sopenharmony_ci } immed_ot; 3048c2ecf20Sopenharmony_ci struct { 3058c2ecf20Sopenharmony_ci u16 reserved; 3068c2ecf20Sopenharmony_ci u16 omi; 3078c2ecf20Sopenharmony_ci } index_ot; 3088c2ecf20Sopenharmony_ci } op_encode; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci /* PAACE Offsets 0x20-0x38 */ 3118c2ecf20Sopenharmony_ci u32 reserved[8]; /* not currently implemented */ 3128c2ecf20Sopenharmony_ci}; 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci/* OME : Operation mapping entry 3158c2ecf20Sopenharmony_ci * MOE : Mapped Operation Encodings 3168c2ecf20Sopenharmony_ci * The operation mapping table is table containing operation mapping entries (OME). 3178c2ecf20Sopenharmony_ci * The index of a particular OME is programmed in the PAACE entry for translation 3188c2ecf20Sopenharmony_ci * in bound I/O operations corresponding to an LIODN. The OMT is used for translation 3198c2ecf20Sopenharmony_ci * specifically in case of the indexed translation mode. Each OME contains a 128 3208c2ecf20Sopenharmony_ci * byte mapped operation encoding (MOE), where each byte represents an MOE. 3218c2ecf20Sopenharmony_ci */ 3228c2ecf20Sopenharmony_ci#define NUM_MOE 128 3238c2ecf20Sopenharmony_cistruct ome { 3248c2ecf20Sopenharmony_ci u8 moe[NUM_MOE]; 3258c2ecf20Sopenharmony_ci} __packed; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci#define PAACT_SIZE (sizeof(struct paace) * PAACE_NUMBER_ENTRIES) 3288c2ecf20Sopenharmony_ci#define SPAACT_SIZE (sizeof(struct paace) * SPAACE_NUMBER_ENTRIES) 3298c2ecf20Sopenharmony_ci#define OMT_SIZE (sizeof(struct ome) * OME_NUMBER_ENTRIES) 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci#define PAMU_PAGE_SHIFT 12 3328c2ecf20Sopenharmony_ci#define PAMU_PAGE_SIZE 4096ULL 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci#define IOE_READ 0x00 3358c2ecf20Sopenharmony_ci#define IOE_READ_IDX 0x00 3368c2ecf20Sopenharmony_ci#define IOE_WRITE 0x81 3378c2ecf20Sopenharmony_ci#define IOE_WRITE_IDX 0x01 3388c2ecf20Sopenharmony_ci#define IOE_EREAD0 0x82 /* Enhanced read type 0 */ 3398c2ecf20Sopenharmony_ci#define IOE_EREAD0_IDX 0x02 /* Enhanced read type 0 */ 3408c2ecf20Sopenharmony_ci#define IOE_EWRITE0 0x83 /* Enhanced write type 0 */ 3418c2ecf20Sopenharmony_ci#define IOE_EWRITE0_IDX 0x03 /* Enhanced write type 0 */ 3428c2ecf20Sopenharmony_ci#define IOE_DIRECT0 0x84 /* Directive type 0 */ 3438c2ecf20Sopenharmony_ci#define IOE_DIRECT0_IDX 0x04 /* Directive type 0 */ 3448c2ecf20Sopenharmony_ci#define IOE_EREAD1 0x85 /* Enhanced read type 1 */ 3458c2ecf20Sopenharmony_ci#define IOE_EREAD1_IDX 0x05 /* Enhanced read type 1 */ 3468c2ecf20Sopenharmony_ci#define IOE_EWRITE1 0x86 /* Enhanced write type 1 */ 3478c2ecf20Sopenharmony_ci#define IOE_EWRITE1_IDX 0x06 /* Enhanced write type 1 */ 3488c2ecf20Sopenharmony_ci#define IOE_DIRECT1 0x87 /* Directive type 1 */ 3498c2ecf20Sopenharmony_ci#define IOE_DIRECT1_IDX 0x07 /* Directive type 1 */ 3508c2ecf20Sopenharmony_ci#define IOE_RAC 0x8c /* Read with Atomic clear */ 3518c2ecf20Sopenharmony_ci#define IOE_RAC_IDX 0x0c /* Read with Atomic clear */ 3528c2ecf20Sopenharmony_ci#define IOE_RAS 0x8d /* Read with Atomic set */ 3538c2ecf20Sopenharmony_ci#define IOE_RAS_IDX 0x0d /* Read with Atomic set */ 3548c2ecf20Sopenharmony_ci#define IOE_RAD 0x8e /* Read with Atomic decrement */ 3558c2ecf20Sopenharmony_ci#define IOE_RAD_IDX 0x0e /* Read with Atomic decrement */ 3568c2ecf20Sopenharmony_ci#define IOE_RAI 0x8f /* Read with Atomic increment */ 3578c2ecf20Sopenharmony_ci#define IOE_RAI_IDX 0x0f /* Read with Atomic increment */ 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci#define EOE_READ 0x00 3608c2ecf20Sopenharmony_ci#define EOE_WRITE 0x01 3618c2ecf20Sopenharmony_ci#define EOE_RAC 0x0c /* Read with Atomic clear */ 3628c2ecf20Sopenharmony_ci#define EOE_RAS 0x0d /* Read with Atomic set */ 3638c2ecf20Sopenharmony_ci#define EOE_RAD 0x0e /* Read with Atomic decrement */ 3648c2ecf20Sopenharmony_ci#define EOE_RAI 0x0f /* Read with Atomic increment */ 3658c2ecf20Sopenharmony_ci#define EOE_LDEC 0x10 /* Load external cache */ 3668c2ecf20Sopenharmony_ci#define EOE_LDECL 0x11 /* Load external cache with stash lock */ 3678c2ecf20Sopenharmony_ci#define EOE_LDECPE 0x12 /* Load external cache with preferred exclusive */ 3688c2ecf20Sopenharmony_ci#define EOE_LDECPEL 0x13 /* Load external cache with preferred exclusive and lock */ 3698c2ecf20Sopenharmony_ci#define EOE_LDECFE 0x14 /* Load external cache with forced exclusive */ 3708c2ecf20Sopenharmony_ci#define EOE_LDECFEL 0x15 /* Load external cache with forced exclusive and lock */ 3718c2ecf20Sopenharmony_ci#define EOE_RSA 0x16 /* Read with stash allocate */ 3728c2ecf20Sopenharmony_ci#define EOE_RSAU 0x17 /* Read with stash allocate and unlock */ 3738c2ecf20Sopenharmony_ci#define EOE_READI 0x18 /* Read with invalidate */ 3748c2ecf20Sopenharmony_ci#define EOE_RWNITC 0x19 /* Read with no intention to cache */ 3758c2ecf20Sopenharmony_ci#define EOE_WCI 0x1a /* Write cache inhibited */ 3768c2ecf20Sopenharmony_ci#define EOE_WWSA 0x1b /* Write with stash allocate */ 3778c2ecf20Sopenharmony_ci#define EOE_WWSAL 0x1c /* Write with stash allocate and lock */ 3788c2ecf20Sopenharmony_ci#define EOE_WWSAO 0x1d /* Write with stash allocate only */ 3798c2ecf20Sopenharmony_ci#define EOE_WWSAOL 0x1e /* Write with stash allocate only and lock */ 3808c2ecf20Sopenharmony_ci#define EOE_VALID 0x80 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/* Function prototypes */ 3838c2ecf20Sopenharmony_ciint pamu_domain_init(void); 3848c2ecf20Sopenharmony_ciint pamu_enable_liodn(int liodn); 3858c2ecf20Sopenharmony_ciint pamu_disable_liodn(int liodn); 3868c2ecf20Sopenharmony_civoid pamu_free_subwins(int liodn); 3878c2ecf20Sopenharmony_ciint pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size, 3888c2ecf20Sopenharmony_ci u32 omi, unsigned long rpn, u32 snoopid, uint32_t stashid, 3898c2ecf20Sopenharmony_ci u32 subwin_cnt, int prot); 3908c2ecf20Sopenharmony_ciint pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin_addr, 3918c2ecf20Sopenharmony_ci phys_addr_t subwin_size, u32 omi, unsigned long rpn, 3928c2ecf20Sopenharmony_ci uint32_t snoopid, u32 stashid, int enable, int prot); 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ciu32 get_stash_id(u32 stash_dest_hint, u32 vcpu); 3958c2ecf20Sopenharmony_civoid get_ome_index(u32 *omi_index, struct device *dev); 3968c2ecf20Sopenharmony_ciint pamu_update_paace_stash(int liodn, u32 subwin, u32 value); 3978c2ecf20Sopenharmony_ciint pamu_disable_spaace(int liodn, u32 subwin); 3988c2ecf20Sopenharmony_ciu32 pamu_get_max_subwin_cnt(void); 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci#endif /* __FSL_PAMU_H */ 401