3 * Intel X58 north bridge IOH
4 * PCI Express root port device id 3420
6 * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
7 * VA Linux Systems Japan K.K.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, see <http://www.gnu.org/licenses/>.
28 #define PCI_DEVICE_ID_IOH_EPORT 0x3420 /* D0:F0 express mode */
29 #define PCI_DEVICE_ID_IOH_REV 0x2
30 #define IOH_EP_SSVID_OFFSET 0x40
31 #define IOH_EP_SSVID_SVID PCI_VENDOR_ID_INTEL
32 #define IOH_EP_SSVID_SSID 0
33 #define IOH_EP_MSI_OFFSET 0x60
34 #define IOH_EP_MSI_SUPPORTED_FLAGS PCI_MSI_FLAGS_MASKBIT
35 #define IOH_EP_MSI_NR_VECTOR 2
36 #define IOH_EP_EXP_OFFSET 0x90
37 #define IOH_EP_AER_OFFSET 0x100
39 static void ioh3420_write_config(PCIDevice
*d
,
40 uint32_t address
, uint32_t val
, int len
)
43 pci_get_word(d
->config
+ d
->exp
.exp_cap
+ PCI_EXP_SLTCTL
);
45 pci_bridge_write_config(d
, address
, val
, len
);
46 msi_write_config(d
, address
, val
, len
);
47 pcie_cap_slot_write_config(d
, address
, val
, len
, sltctl
);
51 static void ioh3420_reset(DeviceState
*qdev
)
53 PCIDevice
*d
= DO_UPCAST(PCIDevice
, qdev
, qdev
);
55 pcie_cap_root_reset(d
);
56 pcie_cap_deverr_reset(d
);
57 pcie_cap_slot_reset(d
);
58 pci_bridge_reset(qdev
);
59 pci_bridge_disable_base_limit(d
);
63 static int ioh3420_initfn(PCIDevice
*d
)
65 PCIBridge
* br
= DO_UPCAST(PCIBridge
, dev
, d
);
66 PCIEPort
*p
= DO_UPCAST(PCIEPort
, br
, br
);
67 PCIESlot
*s
= DO_UPCAST(PCIESlot
, port
, p
);
70 rc
= pci_bridge_initfn(d
);
75 d
->config
[PCI_REVISION_ID
] = PCI_DEVICE_ID_IOH_REV
;
76 pcie_port_init_reg(d
);
78 pci_config_set_vendor_id(d
->config
, PCI_VENDOR_ID_INTEL
);
79 pci_config_set_device_id(d
->config
, PCI_DEVICE_ID_IOH_EPORT
);
81 rc
= pci_bridge_ssvid_init(d
, IOH_EP_SSVID_OFFSET
,
82 IOH_EP_SSVID_SVID
, IOH_EP_SSVID_SSID
);
86 rc
= msi_init(d
, IOH_EP_MSI_OFFSET
, IOH_EP_MSI_NR_VECTOR
,
87 IOH_EP_MSI_SUPPORTED_FLAGS
& PCI_MSI_FLAGS_64BIT
,
88 IOH_EP_MSI_SUPPORTED_FLAGS
& PCI_MSI_FLAGS_MASKBIT
);
92 rc
= pcie_cap_init(d
, IOH_EP_EXP_OFFSET
, PCI_EXP_TYPE_ROOT_PORT
, p
->port
);
96 pcie_cap_deverr_init(d
);
97 pcie_cap_slot_init(d
, s
->slot
);
98 pcie_chassis_create(s
->chassis
);
99 rc
= pcie_chassis_add_slot(s
);
103 pcie_cap_root_init(d
);
108 static int ioh3420_exitfn(PCIDevice
*d
)
113 return pci_bridge_exitfn(d
);
116 PCIESlot
*ioh3420_init(PCIBus
*bus
, int devfn
, bool multifunction
,
117 const char *bus_name
, pci_map_irq_fn map_irq
,
118 uint8_t port
, uint8_t chassis
, uint16_t slot
)
124 d
= pci_create_multifunction(bus
, devfn
, multifunction
, "ioh3420");
128 br
= DO_UPCAST(PCIBridge
, dev
, d
);
130 qdev
= &br
->dev
.qdev
;
131 pci_bridge_map_irq(br
, bus_name
, map_irq
);
132 qdev_prop_set_uint8(qdev
, "port", port
);
133 qdev_prop_set_uint8(qdev
, "chassis", chassis
);
134 qdev_prop_set_uint16(qdev
, "slot", slot
);
135 qdev_init_nofail(qdev
);
137 return DO_UPCAST(PCIESlot
, port
, DO_UPCAST(PCIEPort
, br
, br
));
140 static const VMStateDescription vmstate_ioh3420
= {
141 .name
= "ioh-3240-express-root-port",
143 .minimum_version_id
= 1,
144 .minimum_version_id_old
= 1,
145 .fields
= (VMStateField
[]) {
146 VMSTATE_PCIE_DEVICE(port
.br
.dev
, PCIESlot
),
148 VMSTATE_END_OF_LIST()
152 static PCIDeviceInfo ioh3420_info
= {
153 .qdev
.name
= "ioh3420",
154 .qdev
.desc
= "Intel IOH device id 3420 PCIE Root Port",
155 .qdev
.size
= sizeof(PCIESlot
),
156 .qdev
.reset
= ioh3420_reset
,
157 .qdev
.vmsd
= &vmstate_ioh3420
,
161 .config_write
= ioh3420_write_config
,
162 .init
= ioh3420_initfn
,
163 .exit
= ioh3420_exitfn
,
165 .qdev
.props
= (Property
[]) {
166 DEFINE_PROP_UINT8("port", PCIESlot
, port
.port
, 0),
167 DEFINE_PROP_UINT8("chassis", PCIESlot
, chassis
, 0),
168 DEFINE_PROP_UINT16("slot", PCIESlot
, slot
, 0),
170 DEFINE_PROP_END_OF_LIST(),
174 static void ioh3420_register(void)
176 pci_qdev_register(&ioh3420_info
);
179 device_init(ioh3420_register
);
186 * indent-tab-mode: nil