2 * PCI HotPlug Core Functions
4 * Copyright (c) 1995,2001 Compaq Computer Corporation
5 * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (c) 2001 IBM Corp.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Send feedback to <greg@kroah.com>
28 #ifndef _PCI_HOTPLUG_H
29 #define _PCI_HOTPLUG_H
32 /* These values come from the PCI Hotplug Spec */
34 PCI_SPEED_33MHz = 0x00,
35 PCI_SPEED_66MHz = 0x01,
36 PCI_SPEED_66MHz_PCIX = 0x02,
37 PCI_SPEED_100MHz_PCIX = 0x03,
38 PCI_SPEED_133MHz_PCIX = 0x04,
39 PCI_SPEED_66MHz_PCIX_266 = 0x09,
40 PCI_SPEED_100MHz_PCIX_266 = 0x0a,
41 PCI_SPEED_133MHz_PCIX_266 = 0x0b,
42 PCI_SPEED_66MHz_PCIX_533 = 0x11,
43 PCI_SPEED_100MHz_PCIX_533 = 0X12,
44 PCI_SPEED_133MHz_PCIX_533 = 0x13,
45 PCI_SPEED_UNKNOWN = 0xff,
49 struct hotplug_slot_core;
52 * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
53 * @owner: The module owner of this structure
54 * @enable_slot: Called when the user wants to enable a specific pci slot
55 * @disable_slot: Called when the user wants to disable a specific pci slot
56 * @set_attention_status: Called to set the specific slot's attention LED to
58 * @hardware_test: Called to run a specified hardware test on the specified
60 * @get_power_status: Called to get the current power status of a slot.
61 * If this field is NULL, the value passed in the struct hotplug_slot_info
62 * will be used when this value is requested by a user.
63 * @get_attention_status: Called to get the current attention status of a slot.
64 * If this field is NULL, the value passed in the struct hotplug_slot_info
65 * will be used when this value is requested by a user.
66 * @get_latch_status: Called to get the current latch status of a slot.
67 * If this field is NULL, the value passed in the struct hotplug_slot_info
68 * will be used when this value is requested by a user.
69 * @get_adapter_status: Called to get see if an adapter is present in the slot or not.
70 * If this field is NULL, the value passed in the struct hotplug_slot_info
71 * will be used when this value is requested by a user.
72 * @get_max_bus_speed: Called to get the max bus speed for a slot.
73 * If this field is NULL, the value passed in the struct hotplug_slot_info
74 * will be used when this value is requested by a user.
75 * @get_cur_bus_speed: Called to get the current bus speed for a slot.
76 * If this field is NULL, the value passed in the struct hotplug_slot_info
77 * will be used when this value is requested by a user.
79 * The table of function pointers that is passed to the hotplug pci core by a
80 * hotplug pci driver. These functions are called by the hotplug pci core when
81 * the user wants to do something to a specific slot (query it for information,
82 * set an LED, enable / disable power, etc.)
84 struct hotplug_slot_ops {
86 int (*enable_slot) (struct hotplug_slot *slot);
87 int (*disable_slot) (struct hotplug_slot *slot);
88 int (*set_attention_status) (struct hotplug_slot *slot, u8 value);
89 int (*hardware_test) (struct hotplug_slot *slot, u32 value);
90 int (*get_power_status) (struct hotplug_slot *slot, u8 *value);
91 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
92 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
93 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
94 int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value);
95 int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value);
99 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
100 * @power: if power is enabled or not (1/0)
101 * @attention_status: if the attention light is enabled or not (1/0)
102 * @latch_status: if the latch (if any) is open or closed (1/0)
103 * @adapter_present: if there is a pci board present in the slot or not (1/0)
105 * Used to notify the hotplug pci core of the status of a specific slot.
107 struct hotplug_slot_info {
112 enum pci_bus_speed max_bus_speed;
113 enum pci_bus_speed cur_bus_speed;
117 * struct hotplug_slot - used to register a physical slot with the hotplug pci core
118 * @name: the name of the slot being registered. This string must
119 * be unique amoung slots registered on this system.
120 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
121 * @info: pointer to the &struct hotplug_slot_info for the inital values for
123 * @private: used by the hotplug pci controller driver to store whatever it
126 struct hotplug_slot {
128 struct hotplug_slot_ops *ops;
129 struct hotplug_slot_info *info;
132 /* Variables below this are for use only by the hotplug pci core. */
133 struct list_head slot_list;
134 struct hotplug_slot_core *core_priv;
137 extern int pci_hp_register (struct hotplug_slot *slot);
138 extern int pci_hp_deregister (struct hotplug_slot *slot);
139 extern int pci_hp_change_slot_info (const char *name,
140 struct hotplug_slot_info *info);
142 struct pci_dev_wrapped {
147 struct pci_bus_wrapped {
153 int (* pre_visit_pci_bus) (struct pci_bus_wrapped *,
154 struct pci_dev_wrapped *);
155 int (* post_visit_pci_bus) (struct pci_bus_wrapped *,
156 struct pci_dev_wrapped *);
158 int (* pre_visit_pci_dev) (struct pci_dev_wrapped *,
159 struct pci_bus_wrapped *);
160 int (* visit_pci_dev) (struct pci_dev_wrapped *,
161 struct pci_bus_wrapped *);
162 int (* post_visit_pci_dev) (struct pci_dev_wrapped *,
163 struct pci_bus_wrapped *);
166 extern int pci_visit_dev (struct pci_visit *fn,
167 struct pci_dev_wrapped *wrapped_dev,
168 struct pci_bus_wrapped *wrapped_parent);
170 int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
171 int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
172 int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val);
173 int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 val);
174 int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 val);
175 int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val);
178 * Compatibility functions. Don't use these, use the
179 * pci_bus_*() functions above.
182 extern int pci_read_config_byte_nodev (struct pci_ops *ops, u8 bus, u8 device,
183 u8 function, int where, u8 *val);
184 extern int pci_read_config_word_nodev (struct pci_ops *ops, u8 bus, u8 device,
185 u8 function, int where, u16 *val);
186 extern int pci_read_config_dword_nodev (struct pci_ops *ops, u8 bus, u8 device,
187 u8 function, int where, u32 *val);
189 extern int pci_write_config_byte_nodev (struct pci_ops *ops, u8 bus, u8 device,
190 u8 function, int where, u8 val);
191 extern int pci_write_config_word_nodev (struct pci_ops *ops, u8 bus, u8 device,
192 u8 function, int where, u16 val);
193 extern int pci_write_config_dword_nodev (struct pci_ops *ops, u8 bus, u8 device,
194 u8 function, int where, u32 val);