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/>.
26 #include "pcie_regs.h"
30 /* for attention and power indicator */
31 PCI_EXP_HP_IND_RESERVED
= PCI_EXP_SLTCTL_IND_RESERVED
,
32 PCI_EXP_HP_IND_ON
= PCI_EXP_SLTCTL_IND_ON
,
33 PCI_EXP_HP_IND_BLINK
= PCI_EXP_SLTCTL_IND_BLINK
,
34 PCI_EXP_HP_IND_OFF
= PCI_EXP_SLTCTL_IND_OFF
,
35 } PCIExpressIndicator
;
38 /* these bits must match the bits in Slot Control/Status registers.
39 * PCI_EXP_HP_EV_xxx = PCI_EXP_SLTCTL_xxxE = PCI_EXP_SLTSTA_xxx
41 * Not all the bits of slot control register match with the ones of
42 * slot status. Not some bits of slot status register is used to
43 * show status, not to report event occurence.
44 * So such bits must be masked out when checking the software
45 * notification condition.
47 PCI_EXP_HP_EV_ABP
= PCI_EXP_SLTCTL_ABPE
,
48 /* attention button pressed */
49 PCI_EXP_HP_EV_PDC
= PCI_EXP_SLTCTL_PDCE
,
50 /* presence detect changed */
51 PCI_EXP_HP_EV_CCI
= PCI_EXP_SLTCTL_CCIE
,
52 /* command completed */
54 PCI_EXP_HP_EV_SUPPORTED
= PCI_EXP_HP_EV_ABP
|
57 /* supported event mask */
59 /* events not listed aren't supported */
60 } PCIExpressHotPlugEvent
;
62 struct PCIExpressDevice
{
63 /* Offset of express capability in config space */
69 unsigned int hpev_intx
; /* INTx for hot plug event (0-3:INT[A-D]#)
70 * default is 0 = INTA#
71 * If the chip wants to use other interrupt
72 * line, initialize this member with the
74 * If the chip dynamically changes this member,
75 * also initialize it when loaded as
78 bool hpev_notified
; /* Logical AND of conditions for hot plug event.
80 Software Notification of Hot-Plug Events, an interrupt
81 is sent whenever the logical and of these conditions
82 transitions from false to true. */
87 unsigned int aer_intx
; /* INTx for error reporting
88 * default is 0 = INTA#
89 * If the chip wants to use other interrupt
90 * line, initialize this member with the
92 * If the chip dynamically changes this member,
93 * also initialize it when loaded as
98 /* PCI express capability helper functions */
99 int pcie_cap_init(PCIDevice
*dev
, uint8_t offset
, uint8_t type
, uint8_t port
);
100 void pcie_cap_exit(PCIDevice
*dev
);
101 uint8_t pcie_cap_get_type(const PCIDevice
*dev
);
102 void pcie_cap_flags_set_vector(PCIDevice
*dev
, uint8_t vector
);
103 uint8_t pcie_cap_flags_get_vector(PCIDevice
*dev
);
105 void pcie_cap_deverr_init(PCIDevice
*dev
);
106 void pcie_cap_deverr_reset(PCIDevice
*dev
);
108 void pcie_cap_slot_init(PCIDevice
*dev
, uint16_t slot
);
109 void pcie_cap_slot_reset(PCIDevice
*dev
);
110 void pcie_cap_slot_write_config(PCIDevice
*dev
,
111 uint32_t addr
, uint32_t val
, int len
);
112 int pcie_cap_slot_post_load(void *opaque
, int version_id
);
113 void pcie_cap_slot_push_attention_button(PCIDevice
*dev
);
115 void pcie_cap_root_init(PCIDevice
*dev
);
116 void pcie_cap_root_reset(PCIDevice
*dev
);
118 void pcie_cap_flr_init(PCIDevice
*dev
);
119 void pcie_cap_flr_write_config(PCIDevice
*dev
,
120 uint32_t addr
, uint32_t val
, int len
);
122 void pcie_cap_ari_init(PCIDevice
*dev
);
123 void pcie_cap_ari_reset(PCIDevice
*dev
);
124 bool pcie_cap_is_ari_enabled(const PCIDevice
*dev
);
126 /* PCI express extended capability helper functions */
127 uint16_t pcie_find_capability(PCIDevice
*dev
, uint16_t cap_id
);
128 void pcie_add_capability(PCIDevice
*dev
,
129 uint16_t cap_id
, uint8_t cap_ver
,
130 uint16_t offset
, uint16_t size
);
132 void pcie_ari_init(PCIDevice
*dev
, uint16_t offset
, uint16_t nextfn
);
134 #endif /* QEMU_PCIE_H */