xref: /qemu/include/hw/pci-host/spapr.h (revision 2b7dc949e241ac2b069d2d6183c1346cad792662)
13384f95cSDavid Gibson /*
23384f95cSDavid Gibson  * QEMU SPAPR PCI BUS definitions
33384f95cSDavid Gibson  *
43384f95cSDavid Gibson  * Copyright (c) 2011 Alexey Kardashevskiy <aik@au1.ibm.com>
53384f95cSDavid Gibson  *
63384f95cSDavid Gibson  * This library is free software; you can redistribute it and/or
73384f95cSDavid Gibson  * modify it under the terms of the GNU Lesser General Public
83384f95cSDavid Gibson  * License as published by the Free Software Foundation; either
93384f95cSDavid Gibson  * version 2 of the License, or (at your option) any later version.
103384f95cSDavid Gibson  *
113384f95cSDavid Gibson  * This library is distributed in the hope that it will be useful,
123384f95cSDavid Gibson  * but WITHOUT ANY WARRANTY; without even the implied warranty of
133384f95cSDavid Gibson  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
143384f95cSDavid Gibson  * Lesser General Public License for more details.
153384f95cSDavid Gibson  *
163384f95cSDavid Gibson  * You should have received a copy of the GNU Lesser General Public
173384f95cSDavid Gibson  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
183384f95cSDavid Gibson  */
193384f95cSDavid Gibson #if !defined(__HW_SPAPR_H__)
203384f95cSDavid Gibson #error Please include spapr.h before this file!
213384f95cSDavid Gibson #endif
223384f95cSDavid Gibson 
233384f95cSDavid Gibson #if !defined(__HW_SPAPR_PCI_H__)
243384f95cSDavid Gibson #define __HW_SPAPR_PCI_H__
253384f95cSDavid Gibson 
26a2cb15b0SMichael S. Tsirkin #include "hw/pci/pci.h"
27a2cb15b0SMichael S. Tsirkin #include "hw/pci/pci_host.h"
280d09e41aSPaolo Bonzini #include "hw/ppc/xics.h"
293384f95cSDavid Gibson 
300ee2c058SAlexey Kardashevskiy #define SPAPR_MSIX_MAX_DEVS 32
310ee2c058SAlexey Kardashevskiy 
328c9f64dfSAndreas Färber #define TYPE_SPAPR_PCI_HOST_BRIDGE "spapr-pci-host-bridge"
338c9f64dfSAndreas Färber 
348c9f64dfSAndreas Färber #define SPAPR_PCI_HOST_BRIDGE(obj) \
358c9f64dfSAndreas Färber     OBJECT_CHECK(sPAPRPHBState, (obj), TYPE_SPAPR_PCI_HOST_BRIDGE)
368c9f64dfSAndreas Färber 
373384f95cSDavid Gibson typedef struct sPAPRPHBState {
3867c332fdSAndreas Färber     PCIHostState parent_obj;
393384f95cSDavid Gibson 
40caae58cbSDavid Gibson     int32_t index;
413384f95cSDavid Gibson     uint64_t buid;
42298a9710SDavid Gibson     char *dtbusname;
433384f95cSDavid Gibson 
443384f95cSDavid Gibson     MemoryRegion memspace, iospace;
45a8170e5eSAvi Kivity     hwaddr mem_win_addr, mem_win_size, io_win_addr, io_win_size;
46a8170e5eSAvi Kivity     hwaddr msi_win_addr;
47a3cfa18eSDavid Gibson     MemoryRegion memwindow, iowindow, msiwindow;
480ee2c058SAlexey Kardashevskiy 
495c4cbcf2SAlexey Kardashevskiy     uint32_t dma_liobn;
505c4cbcf2SAlexey Kardashevskiy     uint64_t dma_window_start;
515c4cbcf2SAlexey Kardashevskiy     uint64_t dma_window_size;
52*2b7dc949SPaolo Bonzini     sPAPRTCETable *tcet;
533384f95cSDavid Gibson 
543384f95cSDavid Gibson     struct {
55a307d594SAlexey Kardashevskiy         uint32_t irq;
567fb0bd34SDavid Gibson     } lsi_table[PCI_NUM_PINS];
573384f95cSDavid Gibson 
580ee2c058SAlexey Kardashevskiy     struct {
590ee2c058SAlexey Kardashevskiy         uint32_t config_addr;
600ee2c058SAlexey Kardashevskiy         uint32_t irq;
610ee2c058SAlexey Kardashevskiy         int nvec;
620ee2c058SAlexey Kardashevskiy     } msi_table[SPAPR_MSIX_MAX_DEVS];
630ee2c058SAlexey Kardashevskiy 
643384f95cSDavid Gibson     QLIST_ENTRY(sPAPRPHBState) list;
653384f95cSDavid Gibson } sPAPRPHBState;
663384f95cSDavid Gibson 
67caae58cbSDavid Gibson #define SPAPR_PCI_BASE_BUID          0x800000020000000ULL
68caae58cbSDavid Gibson 
69caae58cbSDavid Gibson #define SPAPR_PCI_WINDOW_BASE        0x10000000000ULL
70caae58cbSDavid Gibson #define SPAPR_PCI_WINDOW_SPACING     0x1000000000ULL
71caae58cbSDavid Gibson #define SPAPR_PCI_MMIO_WIN_OFF       0xA0000000
72caae58cbSDavid Gibson #define SPAPR_PCI_MMIO_WIN_SIZE      0x20000000
73caae58cbSDavid Gibson #define SPAPR_PCI_IO_WIN_OFF         0x80000000
74caae58cbSDavid Gibson #define SPAPR_PCI_IO_WIN_SIZE        0x10000
75caae58cbSDavid Gibson #define SPAPR_PCI_MSI_WIN_OFF        0x90000000
76caae58cbSDavid Gibson 
77caae58cbSDavid Gibson #define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL
78caae58cbSDavid Gibson 
79a307d594SAlexey Kardashevskiy static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)
80a307d594SAlexey Kardashevskiy {
81a307d594SAlexey Kardashevskiy     return xics_get_qirq(spapr->icp, phb->lsi_table[pin].irq);
82a307d594SAlexey Kardashevskiy }
83a307d594SAlexey Kardashevskiy 
8489dfd6e1SDavid Gibson PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index);
853384f95cSDavid Gibson 
86e0fdbd7cSAlexey Kardashevskiy int spapr_populate_pci_dt(sPAPRPHBState *phb,
873384f95cSDavid Gibson                           uint32_t xics_phandle,
883384f95cSDavid Gibson                           void *fdt);
893384f95cSDavid Gibson 
90fa28f71bSAlexey Kardashevskiy void spapr_pci_rtas_init(void);
91fa28f71bSAlexey Kardashevskiy 
923384f95cSDavid Gibson #endif /* __HW_SPAPR_PCI_H__ */
93