2010-10-20 10:18:53 +02:00
|
|
|
/*
|
|
|
|
* ioh3420.c
|
|
|
|
* Intel X58 north bridge IOH
|
|
|
|
* PCI Express root port device id 3420
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
|
|
|
|
* VA Linux Systems Japan K.K.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:15 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/pci/pci_ids.h"
|
|
|
|
#include "hw/pci/msi.h"
|
|
|
|
#include "hw/pci/pcie.h"
|
2013-03-18 17:36:02 +01:00
|
|
|
#include "ioh3420.h"
|
2016-06-20 08:13:39 +02:00
|
|
|
#include "qapi/error.h"
|
2010-10-20 10:18:53 +02:00
|
|
|
|
|
|
|
#define PCI_DEVICE_ID_IOH_EPORT 0x3420 /* D0:F0 express mode */
|
|
|
|
#define PCI_DEVICE_ID_IOH_REV 0x2
|
|
|
|
#define IOH_EP_SSVID_OFFSET 0x40
|
|
|
|
#define IOH_EP_SSVID_SVID PCI_VENDOR_ID_INTEL
|
|
|
|
#define IOH_EP_SSVID_SSID 0
|
|
|
|
#define IOH_EP_MSI_OFFSET 0x60
|
|
|
|
#define IOH_EP_MSI_SUPPORTED_FLAGS PCI_MSI_FLAGS_MASKBIT
|
|
|
|
#define IOH_EP_MSI_NR_VECTOR 2
|
|
|
|
#define IOH_EP_EXP_OFFSET 0x90
|
|
|
|
#define IOH_EP_AER_OFFSET 0x100
|
|
|
|
|
2010-11-16 09:26:10 +01:00
|
|
|
/*
|
|
|
|
* If two MSI vector are allocated, Advanced Error Interrupt Message Number
|
|
|
|
* is 1. otherwise 0.
|
|
|
|
* 17.12.5.10 RPERRSTS, 32:27 bit Advanced Error Interrupt Message Number.
|
|
|
|
*/
|
|
|
|
static uint8_t ioh3420_aer_vector(const PCIDevice *d)
|
|
|
|
{
|
|
|
|
switch (msi_nr_vectors_allocated(d)) {
|
|
|
|
case 1:
|
|
|
|
return 0;
|
|
|
|
case 2:
|
|
|
|
return 1;
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
case 16:
|
|
|
|
case 32:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
abort();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:20:19 +01:00
|
|
|
static int ioh3420_interrupts_init(PCIDevice *d, Error **errp)
|
2010-11-16 09:26:10 +01:00
|
|
|
{
|
2010-10-20 10:18:53 +02:00
|
|
|
int rc;
|
2016-06-10 11:54:23 +02:00
|
|
|
|
2010-10-20 10:18:53 +02:00
|
|
|
rc = msi_init(d, IOH_EP_MSI_OFFSET, IOH_EP_MSI_NR_VECTOR,
|
|
|
|
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
|
2017-01-23 20:20:19 +01:00
|
|
|
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT,
|
2017-09-09 08:22:26 +02:00
|
|
|
errp);
|
2010-10-20 10:18:53 +02:00
|
|
|
if (rc < 0) {
|
2016-06-20 08:13:39 +02:00
|
|
|
assert(rc == -ENOTSUP);
|
2010-10-20 10:18:53 +02:00
|
|
|
}
|
2016-06-10 11:54:23 +02:00
|
|
|
|
2010-11-16 09:26:10 +01:00
|
|
|
return rc;
|
2010-10-20 10:18:53 +02:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:20:19 +01:00
|
|
|
static void ioh3420_interrupts_uninit(PCIDevice *d)
|
2010-10-20 10:18:53 +02:00
|
|
|
{
|
2010-11-16 09:26:10 +01:00
|
|
|
msi_uninit(d);
|
2010-10-20 10:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_ioh3420 = {
|
|
|
|
.name = "ioh-3240-express-root-port",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2010-10-25 07:46:47 +02:00
|
|
|
.post_load = pcie_cap_slot_post_load,
|
2010-10-20 10:18:53 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2016-12-14 20:58:29 +01:00
|
|
|
VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
|
2013-07-12 19:56:00 +02:00
|
|
|
VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
|
|
|
|
PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
|
2010-10-20 10:18:53 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void ioh3420_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
2017-01-23 20:20:19 +01:00
|
|
|
PCIERootPortClass *rpc = PCIE_ROOT_PORT_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
|
|
|
|
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
|
|
k->device_id = PCI_DEVICE_ID_IOH_EPORT;
|
|
|
|
k->revision = PCI_DEVICE_ID_IOH_REV;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->desc = "Intel IOH device id 3420 PCIE Root Port";
|
|
|
|
dc->vmsd = &vmstate_ioh3420;
|
2017-01-23 20:20:19 +01:00
|
|
|
rpc->aer_vector = ioh3420_aer_vector;
|
|
|
|
rpc->interrupts_init = ioh3420_interrupts_init;
|
|
|
|
rpc->interrupts_uninit = ioh3420_interrupts_uninit;
|
|
|
|
rpc->exp_offset = IOH_EP_EXP_OFFSET;
|
|
|
|
rpc->aer_offset = IOH_EP_AER_OFFSET;
|
|
|
|
rpc->ssvid_offset = IOH_EP_SSVID_OFFSET;
|
|
|
|
rpc->ssid = IOH_EP_SSVID_SSID;
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo ioh3420_info = {
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "ioh3420",
|
2017-01-23 20:20:19 +01:00
|
|
|
.parent = TYPE_PCIE_ROOT_PORT,
|
2011-12-08 04:34:16 +01:00
|
|
|
.class_init = ioh3420_class_init,
|
2010-10-20 10:18:53 +02:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void ioh3420_register_types(void)
|
2010-10-20 10:18:53 +02:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&ioh3420_info);
|
2010-10-20 10:18:53 +02:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(ioh3420_register_types)
|