Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * ACPI PCI Hot Plug Controller Driver
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  * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
0009  * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
0010  * Copyright (C) 2002,2003 NEC Corporation
0011  * Copyright (C) 2003-2005 Matthew Wilcox (willy@infradead.org)
0012  * Copyright (C) 2003-2005 Hewlett Packard
0013  *
0014  * All rights reserved.
0015  *
0016  * Send feedback to <gregkh@us.ibm.com>,
0017  *          <t-kochi@bq.jp.nec.com>
0018  *
0019  */
0020 
0021 #ifndef _ACPIPHP_H
0022 #define _ACPIPHP_H
0023 
0024 #include <linux/acpi.h>
0025 #include <linux/mutex.h>
0026 #include <linux/pci_hotplug.h>
0027 
0028 struct acpiphp_context;
0029 struct acpiphp_bridge;
0030 struct acpiphp_slot;
0031 
0032 /*
0033  * struct slot - slot information for each *physical* slot
0034  */
0035 struct slot {
0036     struct hotplug_slot hotplug_slot;
0037     struct acpiphp_slot *acpi_slot;
0038     unsigned int sun;   /* ACPI _SUN (Slot User Number) value */
0039 };
0040 
0041 static inline const char *slot_name(struct slot *slot)
0042 {
0043     return hotplug_slot_name(&slot->hotplug_slot);
0044 }
0045 
0046 static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
0047 {
0048     return container_of(hotplug_slot, struct slot, hotplug_slot);
0049 }
0050 
0051 /*
0052  * struct acpiphp_bridge - PCI bridge information
0053  *
0054  * for each bridge device in ACPI namespace
0055  */
0056 struct acpiphp_bridge {
0057     struct list_head list;
0058     struct list_head slots;
0059     struct kref ref;
0060 
0061     struct acpiphp_context *context;
0062 
0063     int nr_slots;
0064 
0065     /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
0066     struct pci_bus *pci_bus;
0067 
0068     /* PCI-to-PCI bridge device */
0069     struct pci_dev *pci_dev;
0070 
0071     bool is_going_away;
0072 };
0073 
0074 
0075 /*
0076  * struct acpiphp_slot - PCI slot information
0077  *
0078  * PCI slot information for each *physical* PCI slot
0079  */
0080 struct acpiphp_slot {
0081     struct list_head node;
0082     struct pci_bus *bus;
0083     struct list_head funcs;     /* one slot may have different
0084                        objects (i.e. for each function) */
0085     struct slot *slot;
0086 
0087     u8      device;     /* pci device# */
0088     u32     flags;      /* see below */
0089 };
0090 
0091 
0092 /*
0093  * struct acpiphp_func - PCI function information
0094  *
0095  * PCI function information for each object in ACPI namespace
0096  * typically 8 objects per slot (i.e. for each PCI function)
0097  */
0098 struct acpiphp_func {
0099     struct acpiphp_bridge *parent;
0100     struct acpiphp_slot *slot;
0101 
0102     struct list_head sibling;
0103 
0104     u8      function;   /* pci function# */
0105     u32     flags;      /* see below */
0106 };
0107 
0108 struct acpiphp_context {
0109     struct acpi_hotplug_context hp;
0110     struct acpiphp_func func;
0111     struct acpiphp_bridge *bridge;
0112     unsigned int refcount;
0113 };
0114 
0115 static inline struct acpiphp_context *to_acpiphp_context(struct acpi_hotplug_context *hp)
0116 {
0117     return container_of(hp, struct acpiphp_context, hp);
0118 }
0119 
0120 static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
0121 {
0122     return container_of(func, struct acpiphp_context, func);
0123 }
0124 
0125 static inline struct acpi_device *func_to_acpi_device(struct acpiphp_func *func)
0126 {
0127     return func_to_context(func)->hp.self;
0128 }
0129 
0130 static inline acpi_handle func_to_handle(struct acpiphp_func *func)
0131 {
0132     return func_to_acpi_device(func)->handle;
0133 }
0134 
0135 struct acpiphp_root_context {
0136     struct acpi_hotplug_context hp;
0137     struct acpiphp_bridge *root_bridge;
0138 };
0139 
0140 static inline struct acpiphp_root_context *to_acpiphp_root_context(struct acpi_hotplug_context *hp)
0141 {
0142     return container_of(hp, struct acpiphp_root_context, hp);
0143 }
0144 
0145 /*
0146  * struct acpiphp_attention_info - device specific attention registration
0147  *
0148  * ACPI has no generic method of setting/getting attention status
0149  * this allows for device specific driver registration
0150  */
0151 struct acpiphp_attention_info {
0152     int (*set_attn)(struct hotplug_slot *slot, u8 status);
0153     int (*get_attn)(struct hotplug_slot *slot, u8 *status);
0154     struct module *owner;
0155 };
0156 
0157 /* ACPI _STA method value (ignore bit 4; battery present) */
0158 #define ACPI_STA_ALL            (0x0000000f)
0159 
0160 /* slot flags */
0161 
0162 #define SLOT_ENABLED        (0x00000001)
0163 #define SLOT_IS_GOING_AWAY  (0x00000002)
0164 
0165 /* function flags */
0166 
0167 #define FUNC_HAS_STA        (0x00000001)
0168 #define FUNC_HAS_EJ0        (0x00000002)
0169 
0170 /* function prototypes */
0171 
0172 /* acpiphp_core.c */
0173 int acpiphp_register_attention(struct acpiphp_attention_info *info);
0174 int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
0175 int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
0176 void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
0177 
0178 int acpiphp_enable_slot(struct acpiphp_slot *slot);
0179 int acpiphp_disable_slot(struct acpiphp_slot *slot);
0180 u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
0181 u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
0182 u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
0183 u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot);
0184 
0185 /* variables */
0186 extern bool acpiphp_disabled;
0187 
0188 #endif /* _ACPIPHP_H */