Blame view

include/linux/pci_hotplug.h 4.25 KB
736759ef5   Bjorn Helgaas   PCI: Add SPDX GPL...
1
  /* SPDX-License-Identifier: GPL-2.0+ */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
8
9
10
  /*
   * 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.
   *
fb5f4d7a7   Kristen Carlson Accardi   change pci hotplu...
11
   * Send feedback to <kristen.c.accardi@intel.com>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
14
15
   *
   */
  #ifndef _PCI_HOTPLUG_H
  #define _PCI_HOTPLUG_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
  /**
   * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
19
20
21
22
23
24
   * @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.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
   * @get_attention_status: Called to get the current attention status of a slot.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
   * @get_latch_status: Called to get the current latch status of a slot.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
   * @get_adapter_status: Called to get see if an adapter is present in the slot or not.
5c32b35b0   Alex Williamson   PCI: Add hotplug_...
28
29
30
   * @reset_slot: Optional interface to allow override of a bus reset for the
   *	slot for cases where a secondary bus reset can result in spurious
   *	hotplug events or where a slot can be reset independent of the bus.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
36
37
   *
   * 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 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
39
40
41
42
43
44
45
  	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);
5c32b35b0   Alex Williamson   PCI: Add hotplug_...
46
  	int (*reset_slot)		(struct hotplug_slot *slot, int probe);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
49
  };
  
  /**
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
   * struct hotplug_slot - used to register a physical slot with the hotplug pci core
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
   * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
81c4b5bf3   Lukas Wunner   PCI: hotplug: Con...
52
53
   * @owner: The module owner of this structure
   * @mod_name: The module name (KBUILD_MODNAME) of this structure
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
   */
  struct hotplug_slot {
81c4b5bf3   Lukas Wunner   PCI: hotplug: Con...
56
  	const struct hotplug_slot_ops	*ops;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
59
  
  	/* Variables below this are for use only by the hotplug pci core. */
  	struct list_head		slot_list;
f46753c5e   Alex Chiang   PCI: introduce pc...
60
  	struct pci_slot			*pci_slot;
81c4b5bf3   Lukas Wunner   PCI: hotplug: Con...
61
62
  	struct module			*owner;
  	const char			*mod_name;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64

0ad772ec4   Alex Chiang   PCI, PCI Hotplug:...
65
66
67
68
  static inline const char *hotplug_slot_name(const struct hotplug_slot *slot)
  {
  	return pci_slot_name(slot->pci_slot);
  }
f39d5b729   Bjorn Helgaas   PCI: Remove "exte...
69
70
71
  int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *pbus, int nr,
  		      const char *name, struct module *owner,
  		      const char *mod_name);
51bbf9bee   Lukas Wunner   PCI: hotplug: Dem...
72
73
74
75
76
77
78
79
  int __pci_hp_initialize(struct hotplug_slot *slot, struct pci_bus *bus, int nr,
  			const char *name, struct module *owner,
  			const char *mod_name);
  int pci_hp_add(struct hotplug_slot *slot);
  
  void pci_hp_del(struct hotplug_slot *slot);
  void pci_hp_destroy(struct hotplug_slot *slot);
  void pci_hp_deregister(struct hotplug_slot *slot);
eb5589a8f   Paul Gortmaker   include: convert ...
80
81
82
  /* use a define to avoid include chaining to get THIS_MODULE & friends */
  #define pci_hp_register(slot, pbus, devnr, name) \
  	__pci_hp_register(slot, pbus, devnr, name, THIS_MODULE, KBUILD_MODNAME)
51bbf9bee   Lukas Wunner   PCI: hotplug: Dem...
83
84
  #define pci_hp_initialize(slot, bus, nr, name) \
  	__pci_hp_initialize(slot, bus, nr, name, THIS_MODULE, KBUILD_MODNAME)
c825bc94c   Kenji Kaneshige   PCI hotplug: crea...
85

783c49fc5   Kristen Accardi   [PATCH] PCI Hotpl...
86
  #ifdef CONFIG_ACPI
8b48463f8   Lv Zheng   ACPI: Clean up in...
87
  #include <linux/acpi.h>
5352a44a5   Mika Westerberg   PCI: pciehp: Make...
88
  bool pciehp_is_native(struct pci_dev *bridge);
6f77fa494   Mika Westerberg   PCI: shpchp: Remo...
89
  int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge);
90cc0c3cc   Mika Westerberg   PCI: shpchp: Add ...
90
  bool shpchp_is_native(struct pci_dev *bridge);
e8c331e96   Kenji Kaneshige   PCI hotplug: intr...
91
  int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
7f5386693   Alex Chiang   PCI Hotplug: conv...
92
  int acpi_pci_detect_ejectable(acpi_handle handle);
8838400db   Bjorn Helgaas   PCI hotplug: add ...
93
  #else
96a621e01   Mika Westerberg   PCI: shpchp: Remo...
94
95
96
97
  static inline int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge)
  {
  	return 0;
  }
5352a44a5   Mika Westerberg   PCI: pciehp: Make...
98
  static inline bool pciehp_is_native(struct pci_dev *bridge) { return true; }
90cc0c3cc   Mika Westerberg   PCI: shpchp: Add ...
99
  static inline bool shpchp_is_native(struct pci_dev *bridge) { return true; }
783c49fc5   Kristen Accardi   [PATCH] PCI Hotpl...
100
  #endif
95d969ebb   Mika Westerberg   PCI: hotplug: Add...
101
102
103
104
105
  
  static inline bool hotplug_is_native(struct pci_dev *bridge)
  {
  	return pciehp_is_native(bridge) || shpchp_is_native(bridge);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
  #endif