2005-04-16 15:20:36 -07:00
/*
* ACPI PCI Hot Plug Controller Driver
*
* Copyright ( C ) 1995 , 2001 Compaq Computer Corporation
* Copyright ( C ) 2001 Greg Kroah - Hartman ( greg @ kroah . com )
* Copyright ( C ) 2001 IBM Corp .
* Copyright ( C ) 2002 Hiroshi Aono ( h - aono @ ap . jp . nec . com )
* Copyright ( C ) 2002 , 2003 Takayoshi Kochi ( t - kochi @ bq . jp . nec . com )
* Copyright ( C ) 2002 , 2003 NEC Corporation
2005-04-28 00:25:53 -07:00
* Copyright ( C ) 2003 - 2005 Matthew Wilcox ( matthew . wilcox @ hp . com )
* Copyright ( C ) 2003 - 2005 Hewlett Packard
2005-04-16 15:20:36 -07:00
*
* 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 0213 9 , USA .
*
* Send feedback to < gregkh @ us . ibm . com > ,
* < t - kochi @ bq . jp . nec . com >
*
*/
# ifndef _ACPIPHP_H
# define _ACPIPHP_H
# include <linux/acpi.h>
2006-01-13 16:02:15 +01:00
# include <linux/mutex.h>
2006-10-13 20:05:19 -07:00
# include <linux/pci_hotplug.h>
2005-04-16 15:20:36 -07:00
2013-07-13 23:27:24 +02:00
struct acpiphp_context ;
2005-04-16 15:20:36 -07:00
struct acpiphp_bridge ;
struct acpiphp_slot ;
/*
* struct slot - slot information for each * physical * slot
*/
struct slot {
struct hotplug_slot * hotplug_slot ;
struct acpiphp_slot * acpi_slot ;
2006-11-13 15:12:45 -08:00
struct hotplug_slot_info info ;
2013-07-13 23:27:25 +02:00
unsigned int sun ; /* ACPI _SUN (Slot User Number) value */
2005-04-16 15:20:36 -07:00
} ;
2008-10-20 17:41:12 -06:00
static inline const char * slot_name ( struct slot * slot )
{
return hotplug_slot_name ( slot - > hotplug_slot ) ;
}
2007-11-28 09:04:30 -08:00
/*
2005-04-16 15:20:36 -07:00
* struct acpiphp_bridge - PCI bridge information
*
* for each bridge device in ACPI namespace
*/
struct acpiphp_bridge {
struct list_head list ;
2013-04-12 05:44:27 +00:00
struct list_head slots ;
2013-04-12 05:44:28 +00:00
struct kref ref ;
2006-03-22 14:49:20 +09:00
2013-07-13 23:27:24 +02:00
struct acpiphp_context * context ;
2006-03-22 14:49:20 +09:00
2005-04-16 15:20:36 -07:00
int nr_slots ;
/* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
struct pci_bus * pci_bus ;
/* PCI-to-PCI bridge device */
struct pci_dev * pci_dev ;
2014-01-10 15:24:41 +01:00
bool is_going_away ;
2005-04-16 15:20:36 -07:00
} ;
2007-11-28 09:04:30 -08:00
/*
2005-04-16 15:20:36 -07:00
* struct acpiphp_slot - PCI slot information
*
* PCI slot information for each * physical * PCI slot
*/
struct acpiphp_slot {
2013-04-12 05:44:27 +00:00
struct list_head node ;
2013-07-13 23:27:25 +02:00
struct pci_bus * bus ;
2005-04-16 15:20:36 -07:00
struct list_head funcs ; /* one slot may have different
objects ( i . e . for each function ) */
2006-02-23 17:56:08 -08:00
struct slot * slot ;
2005-04-16 15:20:36 -07:00
u8 device ; /* pci device# */
u32 flags ; /* see below */
} ;
2007-11-28 09:04:30 -08:00
/*
2005-04-16 15:20:36 -07:00
* struct acpiphp_func - PCI function information
*
* PCI function information for each object in ACPI namespace
* typically 8 objects per slot ( i . e . for each PCI function )
*/
struct acpiphp_func {
2013-07-13 23:27:25 +02:00
struct acpiphp_bridge * parent ;
struct acpiphp_slot * slot ;
2005-04-16 15:20:36 -07:00
struct list_head sibling ;
u8 function ; /* pci function# */
u32 flags ; /* see below */
} ;
2013-07-13 23:27:24 +02:00
struct acpiphp_context {
2014-02-06 17:31:37 +01:00
struct acpi_hotplug_context hp ;
2013-07-13 23:27:25 +02:00
struct acpiphp_func func ;
2013-07-13 23:27:24 +02:00
struct acpiphp_bridge * bridge ;
unsigned int refcount ;
} ;
2014-02-06 17:31:37 +01:00
static inline struct acpiphp_context * to_acpiphp_context ( struct acpi_hotplug_context * hp )
{
return container_of ( hp , struct acpiphp_context , hp ) ;
}
2013-07-13 23:27:25 +02:00
static inline struct acpiphp_context * func_to_context ( struct acpiphp_func * func )
{
return container_of ( func , struct acpiphp_context , func ) ;
}
2014-02-04 00:39:33 +01:00
static inline struct acpi_device * func_to_acpi_device ( struct acpiphp_func * func )
{
2014-02-06 17:31:37 +01:00
return func_to_context ( func ) - > hp . self ;
2014-02-04 00:39:33 +01:00
}
2013-07-13 23:27:25 +02:00
static inline acpi_handle func_to_handle ( struct acpiphp_func * func )
{
2014-02-04 00:39:33 +01:00
return func_to_acpi_device ( func ) - > handle ;
2013-07-13 23:27:25 +02:00
}
2014-06-10 22:46:35 +02:00
struct acpiphp_root_context {
struct acpi_hotplug_context hp ;
struct acpiphp_bridge * root_bridge ;
} ;
static inline struct acpiphp_root_context * to_acpiphp_root_context ( struct acpi_hotplug_context * hp )
{
return container_of ( hp , struct acpiphp_root_context , hp ) ;
}
2007-11-28 09:04:30 -08:00
/*
2005-04-16 15:20:36 -07:00
* struct acpiphp_attention_info - device specific attention registration
*
* ACPI has no generic method of setting / getting attention status
* this allows for device specific driver registration
*/
struct acpiphp_attention_info
{
int ( * set_attn ) ( struct hotplug_slot * slot , u8 status ) ;
int ( * get_attn ) ( struct hotplug_slot * slot , u8 * status ) ;
struct module * owner ;
} ;
/* ACPI _STA method value (ignore bit 4; battery present) */
# define ACPI_STA_ALL (0x0000000f)
/* slot flags */
2013-07-13 23:27:26 +02:00
# define SLOT_ENABLED (0x00000001)
2014-01-10 15:24:41 +01:00
# define SLOT_IS_GOING_AWAY (0x00000002)
2005-04-16 15:20:36 -07:00
/* function flags */
# define FUNC_HAS_STA (0x00000001)
# define FUNC_HAS_EJ0 (0x00000002)
/* function prototypes */
/* acpiphp_core.c */
2015-12-27 13:21:11 -08:00
int acpiphp_register_attention ( struct acpiphp_attention_info * info ) ;
2013-04-12 12:02:59 -06:00
int acpiphp_unregister_attention ( struct acpiphp_attention_info * info ) ;
2013-07-13 23:27:25 +02:00
int acpiphp_register_hotplug_slot ( struct acpiphp_slot * slot , unsigned int sun ) ;
2013-04-12 12:02:59 -06:00
void acpiphp_unregister_hotplug_slot ( struct acpiphp_slot * slot ) ;
2005-04-16 15:20:36 -07:00
/* acpiphp_glue.c */
typedef int ( * acpiphp_callback ) ( struct acpiphp_slot * slot , void * data ) ;
2013-04-12 12:02:59 -06:00
int acpiphp_enable_slot ( struct acpiphp_slot * slot ) ;
2014-01-10 15:24:41 +01:00
int acpiphp_disable_slot ( struct acpiphp_slot * slot ) ;
2013-04-12 12:02:59 -06:00
u8 acpiphp_get_power_status ( struct acpiphp_slot * slot ) ;
u8 acpiphp_get_attention_status ( struct acpiphp_slot * slot ) ;
u8 acpiphp_get_latch_status ( struct acpiphp_slot * slot ) ;
u8 acpiphp_get_adapter_status ( struct acpiphp_slot * slot ) ;
2005-04-16 15:20:36 -07:00
/* variables */
2013-04-12 05:44:25 +00:00
extern bool acpiphp_disabled ;
2005-04-16 15:20:36 -07:00
# endif /* _ACPIPHP_H */