Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * PCI HotPlug Core Functions
0004  *
0005  * Copyright (C) 1995,2001 Compaq Computer Corporation
0006  * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
0007  * Copyright (C) 2001 IBM Corp.
0008  *
0009  * All rights reserved.
0010  *
0011  * Send feedback to <kristen.c.accardi@intel.com>
0012  *
0013  */
0014 #ifndef _PCI_HOTPLUG_H
0015 #define _PCI_HOTPLUG_H
0016 
0017 /**
0018  * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
0019  * @enable_slot: Called when the user wants to enable a specific pci slot
0020  * @disable_slot: Called when the user wants to disable a specific pci slot
0021  * @set_attention_status: Called to set the specific slot's attention LED to
0022  * the specified value
0023  * @hardware_test: Called to run a specified hardware test on the specified
0024  * slot.
0025  * @get_power_status: Called to get the current power status of a slot.
0026  * @get_attention_status: Called to get the current attention status of a slot.
0027  * @get_latch_status: Called to get the current latch status of a slot.
0028  * @get_adapter_status: Called to get see if an adapter is present in the slot or not.
0029  * @reset_slot: Optional interface to allow override of a bus reset for the
0030  *  slot for cases where a secondary bus reset can result in spurious
0031  *  hotplug events or where a slot can be reset independent of the bus.
0032  *
0033  * The table of function pointers that is passed to the hotplug pci core by a
0034  * hotplug pci driver.  These functions are called by the hotplug pci core when
0035  * the user wants to do something to a specific slot (query it for information,
0036  * set an LED, enable / disable power, etc.)
0037  */
0038 struct hotplug_slot_ops {
0039     int (*enable_slot)      (struct hotplug_slot *slot);
0040     int (*disable_slot)     (struct hotplug_slot *slot);
0041     int (*set_attention_status) (struct hotplug_slot *slot, u8 value);
0042     int (*hardware_test)        (struct hotplug_slot *slot, u32 value);
0043     int (*get_power_status)     (struct hotplug_slot *slot, u8 *value);
0044     int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
0045     int (*get_latch_status)     (struct hotplug_slot *slot, u8 *value);
0046     int (*get_adapter_status)   (struct hotplug_slot *slot, u8 *value);
0047     int (*reset_slot)       (struct hotplug_slot *slot, bool probe);
0048 };
0049 
0050 /**
0051  * struct hotplug_slot - used to register a physical slot with the hotplug pci core
0052  * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
0053  * @slot_list: internal list used to track hotplug PCI slots
0054  * @pci_slot: represents a physical slot
0055  * @owner: The module owner of this structure
0056  * @mod_name: The module name (KBUILD_MODNAME) of this structure
0057  */
0058 struct hotplug_slot {
0059     const struct hotplug_slot_ops   *ops;
0060 
0061     /* Variables below this are for use only by the hotplug pci core. */
0062     struct list_head        slot_list;
0063     struct pci_slot         *pci_slot;
0064     struct module           *owner;
0065     const char          *mod_name;
0066 };
0067 
0068 static inline const char *hotplug_slot_name(const struct hotplug_slot *slot)
0069 {
0070     return pci_slot_name(slot->pci_slot);
0071 }
0072 
0073 int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *pbus, int nr,
0074               const char *name, struct module *owner,
0075               const char *mod_name);
0076 int __pci_hp_initialize(struct hotplug_slot *slot, struct pci_bus *bus, int nr,
0077             const char *name, struct module *owner,
0078             const char *mod_name);
0079 int pci_hp_add(struct hotplug_slot *slot);
0080 
0081 void pci_hp_del(struct hotplug_slot *slot);
0082 void pci_hp_destroy(struct hotplug_slot *slot);
0083 void pci_hp_deregister(struct hotplug_slot *slot);
0084 
0085 /* use a define to avoid include chaining to get THIS_MODULE & friends */
0086 #define pci_hp_register(slot, pbus, devnr, name) \
0087     __pci_hp_register(slot, pbus, devnr, name, THIS_MODULE, KBUILD_MODNAME)
0088 #define pci_hp_initialize(slot, bus, nr, name) \
0089     __pci_hp_initialize(slot, bus, nr, name, THIS_MODULE, KBUILD_MODNAME)
0090 
0091 #ifdef CONFIG_ACPI
0092 #include <linux/acpi.h>
0093 bool pciehp_is_native(struct pci_dev *bridge);
0094 int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge);
0095 bool shpchp_is_native(struct pci_dev *bridge);
0096 int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
0097 int acpi_pci_detect_ejectable(acpi_handle handle);
0098 #else
0099 static inline int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge)
0100 {
0101     return 0;
0102 }
0103 static inline bool pciehp_is_native(struct pci_dev *bridge) { return true; }
0104 static inline bool shpchp_is_native(struct pci_dev *bridge) { return true; }
0105 #endif
0106 
0107 static inline bool hotplug_is_native(struct pci_dev *bridge)
0108 {
0109     return pciehp_is_native(bridge) || shpchp_is_native(bridge);
0110 }
0111 #endif