1d2fd9612SCédric Le Goater /* 2d2fd9612SCédric Le Goater * QEMU PowerPC PowerNV CPU Core model 3d2fd9612SCédric Le Goater * 4d2fd9612SCédric Le Goater * Copyright (c) 2016, IBM Corporation. 5d2fd9612SCédric Le Goater * 6d2fd9612SCédric Le Goater * This library is free software; you can redistribute it and/or 7d2fd9612SCédric Le Goater * modify it under the terms of the GNU Lesser General Public License 8f70c5966SChetan Pant * as published by the Free Software Foundation; either version 2.1 of 9d2fd9612SCédric Le Goater * the License, or (at your option) any later version. 10d2fd9612SCédric Le Goater * 11d2fd9612SCédric Le Goater * This library is distributed in the hope that it will be useful, but 12d2fd9612SCédric Le Goater * WITHOUT ANY WARRANTY; without even the implied warranty of 13d2fd9612SCédric Le Goater * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14d2fd9612SCédric Le Goater * Lesser General Public License for more details. 15d2fd9612SCédric Le Goater * 16d2fd9612SCédric Le Goater * You should have received a copy of the GNU Lesser General Public 17d2fd9612SCédric Le Goater * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18d2fd9612SCédric Le Goater */ 19a8b991b5SMarkus Armbruster 20a8b991b5SMarkus Armbruster #ifndef PPC_PNV_CORE_H 21a8b991b5SMarkus Armbruster #define PPC_PNV_CORE_H 22d2fd9612SCédric Le Goater 23d2fd9612SCédric Le Goater #include "hw/cpu/core.h" 24ec150c7eSMarkus Armbruster #include "target/ppc/cpu.h" 25b6c80037SMarkus Armbruster #include "hw/ppc/pnv.h" 26db1015e9SEduardo Habkost #include "qom/object.h" 27d2fd9612SCédric Le Goater 280ca94b2fSNicholas Piggin /* Per-core ChipTOD / TimeBase state */ 290ca94b2fSNicholas Piggin typedef struct PnvCoreTODState { 3078be3218SNicholas Piggin /* 3178be3218SNicholas Piggin * POWER10 DD2.0 - big core TFMR drives the state machine on the even 3278be3218SNicholas Piggin * small core. Skiboot has a workaround that targets the even small core 3378be3218SNicholas Piggin * for CHIPTOD_TO_TB ops. 3478be3218SNicholas Piggin */ 3578be3218SNicholas Piggin bool big_core_quirk; 3678be3218SNicholas Piggin 370ca94b2fSNicholas Piggin int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ 380ca94b2fSNicholas Piggin int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ 390ca94b2fSNicholas Piggin 400ca94b2fSNicholas Piggin /* 410ca94b2fSNicholas Piggin * "Timers" for async TBST events are simulated by mfTFAC because TFAC 420ca94b2fSNicholas Piggin * is polled for such events. These are just used to ensure firmware 430ca94b2fSNicholas Piggin * performs the polling at least a few times. 440ca94b2fSNicholas Piggin */ 450ca94b2fSNicholas Piggin int tb_state_timer; 460ca94b2fSNicholas Piggin int tb_sync_pulse_timer; 470ca94b2fSNicholas Piggin } PnvCoreTODState; 480ca94b2fSNicholas Piggin 49d2fd9612SCédric Le Goater #define TYPE_PNV_CORE "powernv-cpu-core" 50c821774aSEduardo Habkost OBJECT_DECLARE_TYPE(PnvCore, PnvCoreClass, 5130b5707cSEduardo Habkost PNV_CORE) 52d2fd9612SCédric Le Goater 53db1015e9SEduardo Habkost struct PnvCore { 54d2fd9612SCédric Le Goater /*< private >*/ 55d2fd9612SCédric Le Goater CPUCore parent_obj; 56d2fd9612SCédric Le Goater 57d2fd9612SCédric Le Goater /*< public >*/ 5808304a86SDavid Gibson PowerPCCPU **threads; 59c26504afSNicholas Piggin bool big_core; 60*3b5ea01eSNicholas Piggin bool lpar_per_core; 61d2fd9612SCédric Le Goater uint32_t pir; 629940412aSCaleb Schlossin uint32_t hwid; 6308c3f3a7SCédric Le Goater uint64_t hrmor; 640ca94b2fSNicholas Piggin 6560d30cffSNicholas Piggin target_ulong scratch[8]; /* SPRC/SPRD indirect SCRATCH registers */ 660ca94b2fSNicholas Piggin PnvCoreTODState tod_state; 670ca94b2fSNicholas Piggin 68aa5ac64bSCédric Le Goater PnvChip *chip; 6924ece072SCédric Le Goater 7024ece072SCédric Le Goater MemoryRegion xscom_regs; 71db1015e9SEduardo Habkost }; 72d2fd9612SCédric Le Goater 73db1015e9SEduardo Habkost struct PnvCoreClass { 74d2fd9612SCédric Le Goater DeviceClass parent_class; 7590ef386cSCédric Le Goater 7690ef386cSCédric Le Goater const MemoryRegionOps *xscom_ops; 77aa2addf9SNicholas Piggin uint64_t xscom_size; 78db1015e9SEduardo Habkost }; 79d2fd9612SCédric Le Goater 807fd544d8SIgor Mammedov #define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE 817fd544d8SIgor Mammedov #define PNV_CORE_TYPE_NAME(cpu_model) cpu_model PNV_CORE_TYPE_SUFFIX 82d2fd9612SCédric Le Goater 838907fc25SCédric Le Goater typedef struct PnvCPUState { 84060e6143SNicholas Piggin PnvCore *pnv_core; 85956b8f46SCédric Le Goater Object *intc; 868907fc25SCédric Le Goater } PnvCPUState; 878907fc25SCédric Le Goater pnv_cpu_state(PowerPCCPU * cpu)888907fc25SCédric Le Goaterstatic inline PnvCPUState *pnv_cpu_state(PowerPCCPU *cpu) 898907fc25SCédric Le Goater { 908907fc25SCédric Le Goater return (PnvCPUState *)cpu->machine_data; 918907fc25SCédric Le Goater } 928907fc25SCédric Le Goater 93fdc2b46aSJoel Stanley struct PnvQuadClass { 94fdc2b46aSJoel Stanley DeviceClass parent_class; 95fdc2b46aSJoel Stanley 96fdc2b46aSJoel Stanley const MemoryRegionOps *xscom_ops; 97fdc2b46aSJoel Stanley uint64_t xscom_size; 98bdb97596SJoel Stanley 99bdb97596SJoel Stanley const MemoryRegionOps *xscom_qme_ops; 100bdb97596SJoel Stanley uint64_t xscom_qme_size; 101fdc2b46aSJoel Stanley }; 102fdc2b46aSJoel Stanley 1035dad902cSCédric Le Goater #define TYPE_PNV_QUAD "powernv-cpu-quad" 104fdc2b46aSJoel Stanley 105fdc2b46aSJoel Stanley #define PNV_QUAD_TYPE_SUFFIX "-" TYPE_PNV_QUAD 106fdc2b46aSJoel Stanley #define PNV_QUAD_TYPE_NAME(cpu_model) cpu_model PNV_QUAD_TYPE_SUFFIX 107fdc2b46aSJoel Stanley 108fdc2b46aSJoel Stanley OBJECT_DECLARE_TYPE(PnvQuad, PnvQuadClass, PNV_QUAD) 1095dad902cSCédric Le Goater 110db1015e9SEduardo Habkost struct PnvQuad { 1115dad902cSCédric Le Goater DeviceState parent_obj; 1125dad902cSCédric Le Goater 113c8891955SNicholas Piggin bool special_wakeup_done; 114c8891955SNicholas Piggin bool special_wakeup[4]; 115c8891955SNicholas Piggin 11692612f15SCédric Le Goater uint32_t quad_id; 1175dad902cSCédric Le Goater MemoryRegion xscom_regs; 118bdb97596SJoel Stanley MemoryRegion xscom_qme_regs; 119db1015e9SEduardo Habkost }; 120a8b991b5SMarkus Armbruster #endif /* PPC_PNV_CORE_H */ 121