1a3980bf5SBenjamin Herrenschmidt /* 2a3980bf5SBenjamin Herrenschmidt * QEMU PowerPC PowerNV LPC controller 3a3980bf5SBenjamin Herrenschmidt * 4c05aa140SCédric Le Goater * Copyright (c) 2016-2022, IBM Corporation. 5a3980bf5SBenjamin Herrenschmidt * 6a3980bf5SBenjamin Herrenschmidt * This library is free software; you can redistribute it and/or 7a3980bf5SBenjamin Herrenschmidt * modify it under the terms of the GNU Lesser General Public 8a3980bf5SBenjamin Herrenschmidt * License as published by the Free Software Foundation; either 9f70c5966SChetan Pant * version 2.1 of the License, or (at your option) any later version. 10a3980bf5SBenjamin Herrenschmidt * 11a3980bf5SBenjamin Herrenschmidt * This library is distributed in the hope that it will be useful, 12a3980bf5SBenjamin Herrenschmidt * but WITHOUT ANY WARRANTY; without even the implied warranty of 13a3980bf5SBenjamin Herrenschmidt * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14a3980bf5SBenjamin Herrenschmidt * Lesser General Public License for more details. 15a3980bf5SBenjamin Herrenschmidt * 16a3980bf5SBenjamin Herrenschmidt * You should have received a copy of the GNU Lesser General Public 17a3980bf5SBenjamin Herrenschmidt * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18a3980bf5SBenjamin Herrenschmidt */ 19a8b991b5SMarkus Armbruster 20a8b991b5SMarkus Armbruster #ifndef PPC_PNV_LPC_H 21a8b991b5SMarkus Armbruster #define PPC_PNV_LPC_H 22a3980bf5SBenjamin Herrenschmidt 23*8be545baSRichard Henderson #include "system/memory.h" 24b6c80037SMarkus Armbruster #include "hw/ppc/pnv.h" 2514f11a20SMarkus Armbruster #include "hw/qdev-core.h" 2624c3caffSNicholas Piggin #include "hw/isa/isa.h" /* For ISA_NUM_IRQS */ 27eaf87a39SDavid Gibson 28a3980bf5SBenjamin Herrenschmidt #define TYPE_PNV_LPC "pnv-lpc" 29db1015e9SEduardo Habkost typedef struct PnvLpcClass PnvLpcClass; 30db1015e9SEduardo Habkost typedef struct PnvLpcController PnvLpcController; 318110fa1dSEduardo Habkost DECLARE_OBJ_CHECKERS(PnvLpcController, PnvLpcClass, 328110fa1dSEduardo Habkost PNV_LPC, TYPE_PNV_LPC) 3382514be2SCédric Le Goater #define TYPE_PNV8_LPC TYPE_PNV_LPC "-POWER8" 348110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(PnvLpcController, PNV8_LPC, 358110fa1dSEduardo Habkost TYPE_PNV8_LPC) 36a3980bf5SBenjamin Herrenschmidt 3715376c66SCédric Le Goater #define TYPE_PNV9_LPC TYPE_PNV_LPC "-POWER9" 388110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(PnvLpcController, PNV9_LPC, 398110fa1dSEduardo Habkost TYPE_PNV9_LPC) 4015376c66SCédric Le Goater 412661f6abSCédric Le Goater #define TYPE_PNV10_LPC TYPE_PNV_LPC "-POWER10" 428110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(PnvLpcController, PNV10_LPC, 438110fa1dSEduardo Habkost TYPE_PNV10_LPC) 442661f6abSCédric Le Goater 45db1015e9SEduardo Habkost struct PnvLpcController { 46a3980bf5SBenjamin Herrenschmidt DeviceState parent; 47a3980bf5SBenjamin Herrenschmidt 48a3980bf5SBenjamin Herrenschmidt uint64_t eccb_stat_reg; 49a3980bf5SBenjamin Herrenschmidt uint32_t eccb_data_reg; 50a3980bf5SBenjamin Herrenschmidt 51a3980bf5SBenjamin Herrenschmidt /* OPB bus */ 52a3980bf5SBenjamin Herrenschmidt MemoryRegion opb_mr; 53a3980bf5SBenjamin Herrenschmidt AddressSpace opb_as; 54a3980bf5SBenjamin Herrenschmidt 55a3980bf5SBenjamin Herrenschmidt /* ISA IO and Memory space */ 56a3980bf5SBenjamin Herrenschmidt MemoryRegion isa_io; 57a3980bf5SBenjamin Herrenschmidt MemoryRegion isa_mem; 58d61c2857SCédric Le Goater MemoryRegion isa_fw; 59a3980bf5SBenjamin Herrenschmidt 60a3980bf5SBenjamin Herrenschmidt /* Windows from OPB to ISA (aliases) */ 61a3980bf5SBenjamin Herrenschmidt MemoryRegion opb_isa_io; 62a3980bf5SBenjamin Herrenschmidt MemoryRegion opb_isa_mem; 63a3980bf5SBenjamin Herrenschmidt MemoryRegion opb_isa_fw; 64a3980bf5SBenjamin Herrenschmidt 65a3980bf5SBenjamin Herrenschmidt /* Registers */ 66a3980bf5SBenjamin Herrenschmidt MemoryRegion lpc_hc_regs; 67a3980bf5SBenjamin Herrenschmidt MemoryRegion opb_master_regs; 68a3980bf5SBenjamin Herrenschmidt 69a3980bf5SBenjamin Herrenschmidt /* OPB Master LS registers */ 708207b906SCédric Le Goater uint32_t opb_irq_route0; 718207b906SCédric Le Goater uint32_t opb_irq_route1; 72a3980bf5SBenjamin Herrenschmidt uint32_t opb_irq_stat; 73a3980bf5SBenjamin Herrenschmidt uint32_t opb_irq_mask; 74a3980bf5SBenjamin Herrenschmidt uint32_t opb_irq_pol; 75a3980bf5SBenjamin Herrenschmidt uint32_t opb_irq_input; 76a3980bf5SBenjamin Herrenschmidt 77c6e07f03SGlenn Miles /* LPC device IRQ state */ 78c6e07f03SGlenn Miles uint32_t lpc_hc_irq_inputs; 79c6e07f03SGlenn Miles 80a3980bf5SBenjamin Herrenschmidt /* LPC HC registers */ 81a3980bf5SBenjamin Herrenschmidt uint32_t lpc_hc_fw_seg_idsel; 82a3980bf5SBenjamin Herrenschmidt uint32_t lpc_hc_fw_rd_acc_size; 83a3980bf5SBenjamin Herrenschmidt uint32_t lpc_hc_irqser_ctrl; 84a3980bf5SBenjamin Herrenschmidt uint32_t lpc_hc_irqmask; 85a3980bf5SBenjamin Herrenschmidt uint32_t lpc_hc_irqstat; 86a3980bf5SBenjamin Herrenschmidt uint32_t lpc_hc_error_addr; 87a3980bf5SBenjamin Herrenschmidt 88a3980bf5SBenjamin Herrenschmidt /* XSCOM registers */ 89a3980bf5SBenjamin Herrenschmidt MemoryRegion xscom_regs; 904d1df88bSBenjamin Herrenschmidt 9124c3caffSNicholas Piggin /* 9224c3caffSNicholas Piggin * In P8, ISA irqs are combined with internal sources to drive the 9324c3caffSNicholas Piggin * LPCHC interrupt output. P9 ISA irqs raise one of 4 lines that 9424c3caffSNicholas Piggin * drive PSI SERIRQ irqs, routing according to OPB routing registers. 9524c3caffSNicholas Piggin */ 9624c3caffSNicholas Piggin bool psi_has_serirq; 9724c3caffSNicholas Piggin 984d1df88bSBenjamin Herrenschmidt /* PSI to generate interrupts */ 9924c3caffSNicholas Piggin qemu_irq psi_irq_lpchc; 10024c3caffSNicholas Piggin 10124c3caffSNicholas Piggin /* P9 serirq lines and irq routing table */ 10224c3caffSNicholas Piggin qemu_irq psi_irq_serirq[4]; 10324c3caffSNicholas Piggin int irq_to_serirq_route[ISA_NUM_IRQS]; 104db1015e9SEduardo Habkost }; 105a3980bf5SBenjamin Herrenschmidt 106db1015e9SEduardo Habkost struct PnvLpcClass { 10782514be2SCédric Le Goater DeviceClass parent_class; 10882514be2SCédric Le Goater 10982514be2SCédric Le Goater DeviceRealize parent_realize; 110db1015e9SEduardo Habkost }; 11182514be2SCédric Le Goater 11224bd283bSNicholas Piggin bool pnv_lpc_opb_read(PnvLpcController *lpc, uint32_t addr, 11324bd283bSNicholas Piggin uint8_t *data, int sz); 11424bd283bSNicholas Piggin bool pnv_lpc_opb_write(PnvLpcController *lpc, uint32_t addr, 11524bd283bSNicholas Piggin uint8_t *data, int sz); 11624bd283bSNicholas Piggin 11704026890SCédric Le Goater ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp); 118b6c80037SMarkus Armbruster int pnv_dt_lpc(PnvChip *chip, void *fdt, int root_offset, 1192661f6abSCédric Le Goater uint64_t lpcm_addr, uint64_t lpcm_size); 1204d1df88bSBenjamin Herrenschmidt 121a8b991b5SMarkus Armbruster #endif /* PPC_PNV_LPC_H */ 122