acpiphp.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. *
  11. * All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or (at
  16. * your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful, but
  19. * WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21. * NON INFRINGEMENT. See the GNU General Public License for more
  22. * details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. *
  28. * Send feedback to <gregkh@us.ibm.com>,
  29. * <t-kochi@bq.jp.nec.com>
  30. *
  31. */
  32. #ifndef _ACPIPHP_H
  33. #define _ACPIPHP_H
  34. #include <linux/acpi.h>
  35. #include <linux/kobject.h> /* for KOBJ_NAME_LEN */
  36. #include "pci_hotplug.h"
  37. #define dbg(format, arg...) \
  38. do { \
  39. if (acpiphp_debug) \
  40. printk(KERN_DEBUG "%s: " format, \
  41. MY_NAME , ## arg); \
  42. } while (0)
  43. #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
  44. #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
  45. #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
  46. /* name size which is used for entries in pcihpfs */
  47. #define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */
  48. struct acpiphp_bridge;
  49. struct acpiphp_slot;
  50. struct pci_resource;
  51. /*
  52. * struct slot - slot information for each *physical* slot
  53. */
  54. struct slot {
  55. u8 number;
  56. struct hotplug_slot *hotplug_slot;
  57. struct list_head slot_list;
  58. struct acpiphp_slot *acpi_slot;
  59. };
  60. /*
  61. * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
  62. */
  63. struct pci_resource {
  64. struct pci_resource * next;
  65. u64 base;
  66. u32 length;
  67. };
  68. /**
  69. * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
  70. * @cache_line_size in DWORD
  71. * @latency_timer in PCI clock
  72. * @enable_SERR 0 or 1
  73. * @enable_PERR 0 or 1
  74. */
  75. struct hpp_param {
  76. u8 cache_line_size;
  77. u8 latency_timer;
  78. u8 enable_SERR;
  79. u8 enable_PERR;
  80. };
  81. /**
  82. * struct acpiphp_bridge - PCI bridge information
  83. *
  84. * for each bridge device in ACPI namespace
  85. */
  86. struct acpiphp_bridge {
  87. struct list_head list;
  88. acpi_handle handle;
  89. struct acpiphp_slot *slots;
  90. int type;
  91. int nr_slots;
  92. u8 seg;
  93. u8 bus;
  94. u8 sub;
  95. u32 flags;
  96. /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
  97. struct pci_bus *pci_bus;
  98. /* PCI-to-PCI bridge device */
  99. struct pci_dev *pci_dev;
  100. /* ACPI 2.0 _HPP parameters */
  101. struct hpp_param hpp;
  102. spinlock_t res_lock;
  103. /* available resources on this bus */
  104. struct pci_resource *mem_head;
  105. struct pci_resource *p_mem_head;
  106. struct pci_resource *io_head;
  107. struct pci_resource *bus_head;
  108. };
  109. /**
  110. * struct acpiphp_slot - PCI slot information
  111. *
  112. * PCI slot information for each *physical* PCI slot
  113. */
  114. struct acpiphp_slot {
  115. struct acpiphp_slot *next;
  116. struct acpiphp_bridge *bridge; /* parent */
  117. struct list_head funcs; /* one slot may have different
  118. objects (i.e. for each function) */
  119. struct semaphore crit_sect;
  120. u32 id; /* slot id (serial #) for hotplug core */
  121. u8 device; /* pci device# */
  122. u32 sun; /* ACPI _SUN (slot unique number) */
  123. u32 slotno; /* slot number relative to bridge */
  124. u32 flags; /* see below */
  125. };
  126. /**
  127. * struct acpiphp_func - PCI function information
  128. *
  129. * PCI function information for each object in ACPI namespace
  130. * typically 8 objects per slot (i.e. for each PCI function)
  131. */
  132. struct acpiphp_func {
  133. struct acpiphp_slot *slot; /* parent */
  134. struct list_head sibling;
  135. struct pci_dev *pci_dev;
  136. acpi_handle handle;
  137. u8 function; /* pci function# */
  138. u32 flags; /* see below */
  139. /* resources used for this function */
  140. struct pci_resource *mem_head;
  141. struct pci_resource *p_mem_head;
  142. struct pci_resource *io_head;
  143. struct pci_resource *bus_head;
  144. };
  145. /**
  146. * struct acpiphp_attention_info - device specific attention registration
  147. *
  148. * ACPI has no generic method of setting/getting attention status
  149. * this allows for device specific driver registration
  150. */
  151. struct acpiphp_attention_info
  152. {
  153. int (*set_attn)(struct hotplug_slot *slot, u8 status);
  154. int (*get_attn)(struct hotplug_slot *slot, u8 *status);
  155. struct module *owner;
  156. };
  157. /* PCI bus bridge HID */
  158. #define ACPI_PCI_HOST_HID "PNP0A03"
  159. /* PCI BRIDGE type */
  160. #define BRIDGE_TYPE_HOST 0
  161. #define BRIDGE_TYPE_P2P 1
  162. /* ACPI _STA method value (ignore bit 4; battery present) */
  163. #define ACPI_STA_PRESENT (0x00000001)
  164. #define ACPI_STA_ENABLED (0x00000002)
  165. #define ACPI_STA_SHOW_IN_UI (0x00000004)
  166. #define ACPI_STA_FUNCTIONING (0x00000008)
  167. #define ACPI_STA_ALL (0x0000000f)
  168. /* bridge flags */
  169. #define BRIDGE_HAS_STA (0x00000001)
  170. #define BRIDGE_HAS_EJ0 (0x00000002)
  171. #define BRIDGE_HAS_HPP (0x00000004)
  172. #define BRIDGE_HAS_PS0 (0x00000010)
  173. #define BRIDGE_HAS_PS1 (0x00000020)
  174. #define BRIDGE_HAS_PS2 (0x00000040)
  175. #define BRIDGE_HAS_PS3 (0x00000080)
  176. /* slot flags */
  177. #define SLOT_POWEREDON (0x00000001)
  178. #define SLOT_ENABLED (0x00000002)
  179. #define SLOT_MULTIFUNCTION (0x00000004)
  180. /* function flags */
  181. #define FUNC_HAS_STA (0x00000001)
  182. #define FUNC_HAS_EJ0 (0x00000002)
  183. #define FUNC_HAS_PS0 (0x00000010)
  184. #define FUNC_HAS_PS1 (0x00000020)
  185. #define FUNC_HAS_PS2 (0x00000040)
  186. #define FUNC_HAS_PS3 (0x00000080)
  187. /* function prototypes */
  188. /* acpiphp_core.c */
  189. extern int acpiphp_register_attention(struct acpiphp_attention_info*info);
  190. extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
  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. extern struct acpiphp_slot *get_slot_from_id (int id);
  196. typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
  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_pci.c */
  205. extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
  206. extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
  207. extern int acpiphp_configure_function (struct acpiphp_func *func);
  208. extern void acpiphp_unconfigure_function (struct acpiphp_func *func);
  209. extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
  210. extern int acpiphp_init_func_resource (struct acpiphp_func *func);
  211. /* acpiphp_res.c */
  212. extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
  213. extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
  214. extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
  215. extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
  216. extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
  217. extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
  218. extern void acpiphp_free_resource (struct pci_resource **res);
  219. extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
  220. extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
  221. /* variables */
  222. extern int acpiphp_debug;
  223. #endif /* _ACPIPHP_H */