4 * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
5 * VA Linux Systems Japan K.K.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "pcie_port.h"
23 void pcie_port_init_reg(PCIDevice
*d
)
26 66MHz and fast back to back don't apply to pci express port. */
27 pci_set_word(d
->config
+ PCI_STATUS
, 0);
28 pci_set_word(d
->config
+ PCI_SEC_STATUS
, 0);
30 /* Unlike conventional pci bridge, some bits are hardwired to 0. */
31 pci_set_word(d
->wmask
+ PCI_BRIDGE_CONTROL
,
32 PCI_BRIDGE_CTL_PARITY
|
36 PCI_BRIDGE_CTL_BUS_RESET
);
39 /**************************************************************************
40 * (chassis number, pcie physical slot number) -> pcie slot conversion
45 QLIST_HEAD(, PCIESlot
) slots
;
46 QLIST_ENTRY(PCIEChassis
) next
;
49 static QLIST_HEAD(, PCIEChassis
) chassis
= QLIST_HEAD_INITIALIZER(chassis
);
51 static struct PCIEChassis
*pcie_chassis_find(uint8_t chassis_number
)
53 struct PCIEChassis
*c
;
54 QLIST_FOREACH(c
, &chassis
, next
) {
55 if (c
->number
== chassis_number
) {
62 void pcie_chassis_create(uint8_t chassis_number
)
64 struct PCIEChassis
*c
;
65 c
= pcie_chassis_find(chassis_number
);
69 c
= g_malloc0(sizeof(*c
));
70 c
->number
= chassis_number
;
71 QLIST_INIT(&c
->slots
);
72 QLIST_INSERT_HEAD(&chassis
, c
, next
);
75 static PCIESlot
*pcie_chassis_find_slot_with_chassis(struct PCIEChassis
*c
,
79 QLIST_FOREACH(s
, &c
->slots
, next
) {
80 if (s
->slot
== slot
) {
87 PCIESlot
*pcie_chassis_find_slot(uint8_t chassis_number
, uint16_t slot
)
89 struct PCIEChassis
*c
;
90 c
= pcie_chassis_find(chassis_number
);
94 return pcie_chassis_find_slot_with_chassis(c
, slot
);
97 int pcie_chassis_add_slot(struct PCIESlot
*slot
)
99 struct PCIEChassis
*c
;
100 c
= pcie_chassis_find(slot
->chassis
);
104 if (pcie_chassis_find_slot_with_chassis(c
, slot
->slot
)) {
107 QLIST_INSERT_HEAD(&c
->slots
, slot
, next
);
111 void pcie_chassis_del_slot(PCIESlot
*s
)
113 QLIST_REMOVE(s
, next
);