acpiphp.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * ACPI PCI Hot Plug Controller Driver
  3. *
  4. * Copyright (C) 1995,2001 Compaq Computer Corporation
  5. * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
  6. * Copyright (C) 2001 IBM Corp.
  7. * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
  8. * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
  9. * Copyright (C) 2002,2003 NEC Corporation
  10. * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com)
  11. * Copyright (C) 2003-2005 Hewlett Packard
  12. *
  13. * All rights reserved.
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or (at
  18. * your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful, but
  21. * WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  23. * NON INFRINGEMENT. See the GNU General Public License for more
  24. * details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. *
  30. * Send feedback to <gregkh@us.ibm.com>,
  31. * <t-kochi@bq.jp.nec.com>
  32. *
  33. */
  34. #ifndef _ACPIPHP_H
  35. #define _ACPIPHP_H
  36. #include <linux/acpi.h>
  37. #include <linux/kobject.h> /* for KOBJ_NAME_LEN */
  38. #include <linux/mutex.h>
  39. #include "pci_hotplug.h"
  40. #define dbg(format, arg...) \
  41. do { \
  42. if (acpiphp_debug) \
  43. printk(KERN_DEBUG "%s: " format, \
  44. MY_NAME , ## arg); \
  45. } while (0)
  46. #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
  47. #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
  48. #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
  49. /* name size which is used for entries in pcihpfs */
  50. #define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */
  51. struct acpiphp_bridge;
  52. struct acpiphp_slot;
  53. /*
  54. * struct slot - slot information for each *physical* slot
  55. */
  56. struct slot {
  57. struct hotplug_slot *hotplug_slot;
  58. struct acpiphp_slot *acpi_slot;
  59. };
  60. /**
  61. * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
  62. * @cache_line_size in DWORD
  63. * @latency_timer in PCI clock
  64. * @enable_SERR 0 or 1
  65. * @enable_PERR 0 or 1
  66. */
  67. struct hpp_param {
  68. u8 cache_line_size;
  69. u8 latency_timer;
  70. u8 enable_SERR;
  71. u8 enable_PERR;
  72. };
  73. /**
  74. * struct acpiphp_bridge - PCI bridge information
  75. *
  76. * for each bridge device in ACPI namespace
  77. */
  78. struct acpiphp_bridge {
  79. struct list_head list;
  80. acpi_handle handle;
  81. struct acpiphp_slot *slots;
  82. int type;
  83. int nr_slots;
  84. u32 flags;
  85. /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
  86. struct pci_bus *pci_bus;
  87. /* PCI-to-PCI bridge device */
  88. struct pci_dev *pci_dev;
  89. /* ACPI 2.0 _HPP parameters */
  90. struct hpp_param hpp;
  91. spinlock_t res_lock;
  92. };
  93. /**
  94. * struct acpiphp_slot - PCI slot information
  95. *
  96. * PCI slot information for each *physical* PCI slot
  97. */
  98. struct acpiphp_slot {
  99. struct acpiphp_slot *next;
  100. struct acpiphp_bridge *bridge; /* parent */
  101. struct list_head funcs; /* one slot may have different
  102. objects (i.e. for each function) */
  103. struct slot *slot;
  104. struct mutex crit_sect;
  105. u8 device; /* pci device# */
  106. u32 sun; /* ACPI _SUN (slot unique number) */
  107. u32 slotno; /* slot number relative to bridge */
  108. u32 flags; /* see below */
  109. };
  110. /**
  111. * struct acpiphp_func - PCI function information
  112. *
  113. * PCI function information for each object in ACPI namespace
  114. * typically 8 objects per slot (i.e. for each PCI function)
  115. */
  116. struct acpiphp_func {
  117. struct acpiphp_slot *slot; /* parent */
  118. struct list_head sibling;
  119. struct pci_dev *pci_dev;
  120. acpi_handle handle;
  121. u8 function; /* pci function# */
  122. u32 flags; /* see below */
  123. };
  124. /**
  125. * struct acpiphp_attention_info - device specific attention registration
  126. *
  127. * ACPI has no generic method of setting/getting attention status
  128. * this allows for device specific driver registration
  129. */
  130. struct acpiphp_attention_info
  131. {
  132. int (*set_attn)(struct hotplug_slot *slot, u8 status);
  133. int (*get_attn)(struct hotplug_slot *slot, u8 *status);
  134. struct module *owner;
  135. };
  136. struct dependent_device {
  137. struct list_head device_list;
  138. struct list_head pci_list;
  139. acpi_handle handle;
  140. struct acpiphp_func *func;
  141. };
  142. struct acpiphp_dock_station {
  143. acpi_handle handle;
  144. u32 last_dock_time;
  145. u32 flags;
  146. struct acpiphp_func *dock_bridge;
  147. struct list_head dependent_devices;
  148. struct list_head pci_dependent_devices;
  149. };
  150. /* PCI bus bridge HID */
  151. #define ACPI_PCI_HOST_HID "PNP0A03"
  152. /* PCI BRIDGE type */
  153. #define BRIDGE_TYPE_HOST 0
  154. #define BRIDGE_TYPE_P2P 1
  155. /* ACPI _STA method value (ignore bit 4; battery present) */
  156. #define ACPI_STA_PRESENT (0x00000001)
  157. #define ACPI_STA_ENABLED (0x00000002)
  158. #define ACPI_STA_SHOW_IN_UI (0x00000004)
  159. #define ACPI_STA_FUNCTIONING (0x00000008)
  160. #define ACPI_STA_ALL (0x0000000f)
  161. /* bridge flags */
  162. #define BRIDGE_HAS_STA (0x00000001)
  163. #define BRIDGE_HAS_EJ0 (0x00000002)
  164. #define BRIDGE_HAS_HPP (0x00000004)
  165. #define BRIDGE_HAS_PS0 (0x00000010)
  166. #define BRIDGE_HAS_PS1 (0x00000020)
  167. #define BRIDGE_HAS_PS2 (0x00000040)
  168. #define BRIDGE_HAS_PS3 (0x00000080)
  169. /* slot flags */
  170. #define SLOT_POWEREDON (0x00000001)
  171. #define SLOT_ENABLED (0x00000002)
  172. #define SLOT_MULTIFUNCTION (0x00000004)
  173. /* function flags */
  174. #define FUNC_HAS_STA (0x00000001)
  175. #define FUNC_HAS_EJ0 (0x00000002)
  176. #define FUNC_HAS_PS0 (0x00000010)
  177. #define FUNC_HAS_PS1 (0x00000020)
  178. #define FUNC_HAS_PS2 (0x00000040)
  179. #define FUNC_HAS_PS3 (0x00000080)
  180. #define FUNC_HAS_DCK (0x00000100)
  181. #define FUNC_IS_DD (0x00000200)
  182. /* dock station flags */
  183. #define DOCK_DOCKING (0x00000001)
  184. #define DOCK_HAS_BRIDGE (0x00000002)
  185. /* function prototypes */
  186. /* acpiphp_core.c */
  187. extern int acpiphp_register_attention(struct acpiphp_attention_info*info);
  188. extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
  189. extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot);
  190. extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
  191. /* acpiphp_glue.c */
  192. extern int acpiphp_glue_init (void);
  193. extern void acpiphp_glue_exit (void);
  194. extern int acpiphp_get_num_slots (void);
  195. typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
  196. void handle_hotplug_event_func(acpi_handle, u32, void*);
  197. extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
  198. extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
  199. extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
  200. extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
  201. extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
  202. extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
  203. extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
  204. /* acpiphp_dock.c */
  205. extern int find_dock_station(void);
  206. extern void remove_dock_station(void);
  207. extern void add_dependent_device(struct dependent_device *new_dd);
  208. extern void add_pci_dependent_device(struct dependent_device *new_dd);
  209. extern struct dependent_device *get_dependent_device(acpi_handle handle);
  210. extern int is_dependent_device(acpi_handle handle);
  211. extern int detect_dependent_devices(acpi_handle *bridge_handle);
  212. extern struct dependent_device *alloc_dependent_device(acpi_handle handle);
  213. /* variables */
  214. extern int acpiphp_debug;
  215. #endif /* _ACPIPHP_H */