Blame view

include/linux/pci_hotplug.h 7 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /*
   * PCI HotPlug Core Functions
   *
   * Copyright (C) 1995,2001 Compaq Computer Corporation
   * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
   * Copyright (C) 2001 IBM Corp.
   *
   * All rights reserved.
   *
   * 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, GOOD TITLE or
   * NON INFRINGEMENT.  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, write to the Free Software
   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   *
fb5f4d7a7   Kristen Carlson Accardi   change pci hotplu...
25
   * Send feedback to <kristen.c.accardi@intel.com>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
   *
   */
  #ifndef _PCI_HOTPLUG_H
  #define _PCI_HOTPLUG_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
31
32
33
34
35
36
37
38
39
40
41
  /* These values come from the PCI Express Spec */
  enum pcie_link_width {
  	PCIE_LNK_WIDTH_RESRV	= 0x00,
  	PCIE_LNK_X1		= 0x01,
  	PCIE_LNK_X2		= 0x02,
  	PCIE_LNK_X4		= 0x04,
  	PCIE_LNK_X8		= 0x08,
  	PCIE_LNK_X12		= 0x0C,
  	PCIE_LNK_X16		= 0x10,
  	PCIE_LNK_X32		= 0x20,
  	PCIE_LNK_WIDTH_UNKNOWN  = 0xFF,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
43
44
  /**
   * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
   * @owner: The module owner of this structure
c825bc94c   Kenji Kaneshige   PCI hotplug: crea...
45
   * @mod_name: The module name (KBUILD_MODNAME) of this structure
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
   * @enable_slot: Called when the user wants to enable a specific pci slot
   * @disable_slot: Called when the user wants to disable a specific pci slot
   * @set_attention_status: Called to set the specific slot's attention LED to
   * the specified value
   * @hardware_test: Called to run a specified hardware test on the specified
   * slot.
   * @get_power_status: Called to get the current power status of a slot.
   * 	If this field is NULL, the value passed in the struct hotplug_slot_info
   * 	will be used when this value is requested by a user.
   * @get_attention_status: Called to get the current attention status of a slot.
   *	If this field is NULL, the value passed in the struct hotplug_slot_info
   *	will be used when this value is requested by a user.
   * @get_latch_status: Called to get the current latch status of a slot.
   *	If this field is NULL, the value passed in the struct hotplug_slot_info
   *	will be used when this value is requested by a user.
   * @get_adapter_status: Called to get see if an adapter is present in the slot or not.
   *	If this field is NULL, the value passed in the struct hotplug_slot_info
   *	will be used when this value is requested by a user.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
65
66
67
68
69
70
71
   *
   * The table of function pointers that is passed to the hotplug pci core by a
   * hotplug pci driver.  These functions are called by the hotplug pci core when
   * the user wants to do something to a specific slot (query it for information,
   * set an LED, enable / disable power, etc.)
   */
  struct hotplug_slot_ops {
  	struct module *owner;
c825bc94c   Kenji Kaneshige   PCI hotplug: crea...
72
  	const char *mod_name;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
74
75
76
77
78
79
80
  	int (*enable_slot)		(struct hotplug_slot *slot);
  	int (*disable_slot)		(struct hotplug_slot *slot);
  	int (*set_attention_status)	(struct hotplug_slot *slot, u8 value);
  	int (*hardware_test)		(struct hotplug_slot *slot, u32 value);
  	int (*get_power_status)		(struct hotplug_slot *slot, u8 *value);
  	int (*get_attention_status)	(struct hotplug_slot *slot, u8 *value);
  	int (*get_latch_status)		(struct hotplug_slot *slot, u8 *value);
  	int (*get_adapter_status)	(struct hotplug_slot *slot, u8 *value);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
82
83
84
  };
  
  /**
   * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
3749c51ac   Matthew Wilcox   PCI: Make current...
85
   * @power_status: if power is enabled or not (1/0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
   * @attention_status: if the attention light is enabled or not (1/0)
   * @latch_status: if the latch (if any) is open or closed (1/0)
3749c51ac   Matthew Wilcox   PCI: Make current...
88
   * @adapter_status: if there is a pci board present in the slot or not (1/0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
90
91
92
93
94
95
96
   *
   * Used to notify the hotplug pci core of the status of a specific slot.
   */
  struct hotplug_slot_info {
  	u8	power_status;
  	u8	attention_status;
  	u8	latch_status;
  	u8	adapter_status;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
97
98
99
100
  };
  
  /**
   * struct hotplug_slot - used to register a physical slot with the hotplug pci core
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
   * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
eaae4b3a8   Steven Cole   [PATCH] PCI: Spel...
102
   * @info: pointer to the &struct hotplug_slot_info for the initial values for
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
103
104
105
106
107
108
109
   * this slot.
   * @release: called during pci_hp_deregister to free memory allocated in a
   * hotplug_slot structure.
   * @private: used by the hotplug pci controller driver to store whatever it
   * needs.
   */
  struct hotplug_slot {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
116
  	struct hotplug_slot_ops		*ops;
  	struct hotplug_slot_info	*info;
  	void (*release) (struct hotplug_slot *slot);
  	void				*private;
  
  	/* Variables below this are for use only by the hotplug pci core. */
  	struct list_head		slot_list;
f46753c5e   Alex Chiang   PCI: introduce pc...
117
  	struct pci_slot			*pci_slot;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
119
  };
  #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
0ad772ec4   Alex Chiang   PCI, PCI Hotplug:...
120
121
122
123
  static inline const char *hotplug_slot_name(const struct hotplug_slot *slot)
  {
  	return pci_slot_name(slot->pci_slot);
  }
c825bc94c   Kenji Kaneshige   PCI hotplug: crea...
124
125
126
  extern int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *pbus,
  			     int nr, const char *name,
  			     struct module *owner, const char *mod_name);
f46753c5e   Alex Chiang   PCI: introduce pc...
127
  extern int pci_hp_deregister(struct hotplug_slot *slot);
660a0e8fd   Greg Kroah-Hartman   PCI Hotplug: fix ...
128
129
  extern int __must_check pci_hp_change_slot_info	(struct hotplug_slot *slot,
  						 struct hotplug_slot_info *info);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
130

c825bc94c   Kenji Kaneshige   PCI hotplug: crea...
131
132
133
134
135
136
137
  static inline int pci_hp_register(struct hotplug_slot *slot,
  				  struct pci_bus *pbus,
  				  int devnr, const char *name)
  {
  	return __pci_hp_register(slot, pbus, devnr, name,
  				 THIS_MODULE, KBUILD_MODNAME);
  }
e22b73501   Kenji Kaneshige   [PATCH] acpi_pcih...
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  /* PCI Setting Record (Type 0) */
  struct hpp_type0 {
  	u32 revision;
  	u8  cache_line_size;
  	u8  latency_timer;
  	u8  enable_serr;
  	u8  enable_perr;
  };
  
  /* PCI-X Setting Record (Type 1) */
  struct hpp_type1 {
  	u32 revision;
  	u8  max_mem_read;
  	u8  avg_max_split;
  	u16 tot_max_split;
  };
  
  /* PCI Express Setting Record (Type 2) */
  struct hpp_type2 {
  	u32 revision;
  	u32 unc_err_mask_and;
  	u32 unc_err_mask_or;
  	u32 unc_err_sever_and;
  	u32 unc_err_sever_or;
  	u32 cor_err_mask_and;
  	u32 cor_err_mask_or;
  	u32 adv_err_cap_and;
  	u32 adv_err_cap_or;
  	u16 pci_exp_devctl_and;
  	u16 pci_exp_devctl_or;
  	u16 pci_exp_lnkctl_and;
  	u16 pci_exp_lnkctl_or;
  	u32 sec_unc_err_sever_and;
  	u32 sec_unc_err_sever_or;
  	u32 sec_unc_err_mask_and;
  	u32 sec_unc_err_mask_or;
  };
783c49fc5   Kristen Accardi   [PATCH] PCI Hotpl...
175
  struct hotplug_params {
e22b73501   Kenji Kaneshige   [PATCH] acpi_pcih...
176
177
178
179
180
181
  	struct hpp_type0 *t0;		/* Type0: NULL if not available */
  	struct hpp_type1 *t1;		/* Type1: NULL if not available */
  	struct hpp_type2 *t2;		/* Type2: NULL if not available */
  	struct hpp_type0 type0_data;
  	struct hpp_type1 type1_data;
  	struct hpp_type2 type2_data;
783c49fc5   Kristen Accardi   [PATCH] PCI Hotpl...
182
183
184
185
186
  };
  
  #ifdef CONFIG_ACPI
  #include <acpi/acpi.h>
  #include <acpi/acpi_bus.h>
e81995bb1   Bjorn Helgaas   PCI hotplug: acpi...
187
  int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
ac9c052d1   Kenji Kaneshige   shpchp: check fir...
188
  int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
e8c331e96   Kenji Kaneshige   PCI hotplug: intr...
189
  int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
7f5386693   Alex Chiang   PCI Hotplug: conv...
190
  int acpi_pci_detect_ejectable(acpi_handle handle);
8838400db   Bjorn Helgaas   PCI hotplug: add ...
191
192
193
194
195
196
  #else
  static inline int pci_get_hp_params(struct pci_dev *dev,
  				    struct hotplug_params *hpp)
  {
  	return -ENODEV;
  }
783c49fc5   Kristen Accardi   [PATCH] PCI Hotpl...
197
  #endif
8838400db   Bjorn Helgaas   PCI hotplug: add ...
198
199
  
  void pci_configure_slot(struct pci_dev *dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
200
  #endif