110a83cb9SPrem Mallappa /* 210a83cb9SPrem Mallappa * Copyright (C) 2014-2016 Broadcom Corporation 310a83cb9SPrem Mallappa * Copyright (c) 2017 Red Hat, Inc. 410a83cb9SPrem Mallappa * Written by Prem Mallappa, Eric Auger 510a83cb9SPrem Mallappa * 610a83cb9SPrem Mallappa * This program is free software; you can redistribute it and/or modify 710a83cb9SPrem Mallappa * it under the terms of the GNU General Public License version 2 as 810a83cb9SPrem Mallappa * published by the Free Software Foundation. 910a83cb9SPrem Mallappa * 1010a83cb9SPrem Mallappa * This program is distributed in the hope that it will be useful, 1110a83cb9SPrem Mallappa * but WITHOUT ANY WARRANTY; without even the implied warranty of 1210a83cb9SPrem Mallappa * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1310a83cb9SPrem Mallappa * GNU General Public License for more details. 1410a83cb9SPrem Mallappa * 1510a83cb9SPrem Mallappa * You should have received a copy of the GNU General Public License along 1610a83cb9SPrem Mallappa * with this program; if not, see <http://www.gnu.org/licenses/>. 1710a83cb9SPrem Mallappa */ 1810a83cb9SPrem Mallappa 1910a83cb9SPrem Mallappa #ifndef HW_ARM_SMMUV3_H 2010a83cb9SPrem Mallappa #define HW_ARM_SMMUV3_H 2110a83cb9SPrem Mallappa 2210a83cb9SPrem Mallappa #include "hw/arm/smmu-common.h" 23db1015e9SEduardo Habkost #include "qom/object.h" 2410a83cb9SPrem Mallappa 2510a83cb9SPrem Mallappa #define TYPE_SMMUV3_IOMMU_MEMORY_REGION "smmuv3-iommu-memory-region" 2610a83cb9SPrem Mallappa 2710a83cb9SPrem Mallappa typedef struct SMMUQueue { 2810a83cb9SPrem Mallappa uint64_t base; /* base register */ 2910a83cb9SPrem Mallappa uint32_t prod; 3010a83cb9SPrem Mallappa uint32_t cons; 3110a83cb9SPrem Mallappa uint8_t entry_size; 3210a83cb9SPrem Mallappa uint8_t log2size; 3310a83cb9SPrem Mallappa } SMMUQueue; 3410a83cb9SPrem Mallappa 35db1015e9SEduardo Habkost struct SMMUv3State { 3610a83cb9SPrem Mallappa SMMUState smmu_state; 3710a83cb9SPrem Mallappa 3810a83cb9SPrem Mallappa uint32_t features; 3910a83cb9SPrem Mallappa uint8_t sid_size; 4010a83cb9SPrem Mallappa uint8_t sid_split; 4110a83cb9SPrem Mallappa 4210a83cb9SPrem Mallappa uint32_t idr[6]; 4310a83cb9SPrem Mallappa uint32_t iidr; 445888f0adSEric Auger uint32_t aidr; 4510a83cb9SPrem Mallappa uint32_t cr[3]; 4610a83cb9SPrem Mallappa uint32_t cr0ack; 4710a83cb9SPrem Mallappa uint32_t statusr; 48c2ecb424SMostafa Saleh uint32_t gbpa; 4910a83cb9SPrem Mallappa uint32_t irq_ctrl; 5010a83cb9SPrem Mallappa uint32_t gerror; 5110a83cb9SPrem Mallappa uint32_t gerrorn; 5210a83cb9SPrem Mallappa uint64_t gerror_irq_cfg0; 5310a83cb9SPrem Mallappa uint32_t gerror_irq_cfg1; 5410a83cb9SPrem Mallappa uint32_t gerror_irq_cfg2; 5510a83cb9SPrem Mallappa uint64_t strtab_base; 5610a83cb9SPrem Mallappa uint32_t strtab_base_cfg; 5710a83cb9SPrem Mallappa uint64_t eventq_irq_cfg0; 5810a83cb9SPrem Mallappa uint32_t eventq_irq_cfg1; 5910a83cb9SPrem Mallappa uint32_t eventq_irq_cfg2; 6010a83cb9SPrem Mallappa 6110a83cb9SPrem Mallappa SMMUQueue eventq, cmdq; 6210a83cb9SPrem Mallappa 6310a83cb9SPrem Mallappa qemu_irq irq[4]; 6432cfd7f3SEric Auger QemuMutex mutex; 65*8cefcc3bSMostafa Saleh char *stage; 66db1015e9SEduardo Habkost }; 6710a83cb9SPrem Mallappa 6810a83cb9SPrem Mallappa typedef enum { 6910a83cb9SPrem Mallappa SMMU_IRQ_EVTQ, 7010a83cb9SPrem Mallappa SMMU_IRQ_PRIQ, 7110a83cb9SPrem Mallappa SMMU_IRQ_CMD_SYNC, 7210a83cb9SPrem Mallappa SMMU_IRQ_GERROR, 7310a83cb9SPrem Mallappa } SMMUIrq; 7410a83cb9SPrem Mallappa 75db1015e9SEduardo Habkost struct SMMUv3Class { 7610a83cb9SPrem Mallappa /*< private >*/ 7710a83cb9SPrem Mallappa SMMUBaseClass smmu_base_class; 7810a83cb9SPrem Mallappa /*< public >*/ 7910a83cb9SPrem Mallappa 8010a83cb9SPrem Mallappa DeviceRealize parent_realize; 81503819a3SPeter Maydell ResettablePhases parent_phases; 82db1015e9SEduardo Habkost }; 8310a83cb9SPrem Mallappa 8410a83cb9SPrem Mallappa #define TYPE_ARM_SMMUV3 "arm-smmuv3" 85a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(SMMUv3State, SMMUv3Class, ARM_SMMUV3) 8610a83cb9SPrem Mallappa 8721eb5b5cSMostafa Saleh #define STAGE1_SUPPORTED(s) FIELD_EX32(s->idr[0], IDR0, S1P) 8821eb5b5cSMostafa Saleh #define STAGE2_SUPPORTED(s) FIELD_EX32(s->idr[0], IDR0, S2P) 8921eb5b5cSMostafa Saleh 9010a83cb9SPrem Mallappa #endif 91