acpi.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /*
  2. * acpi.h - ACPI Interface
  3. *
  4. * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  5. *
  6. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. */
  24. #ifndef _LINUX_ACPI_H
  25. #define _LINUX_ACPI_H
  26. #ifdef CONFIG_ACPI
  27. #ifndef _LINUX
  28. #define _LINUX
  29. #endif
  30. #include <linux/list.h>
  31. #include <acpi/acpi.h>
  32. #include <acpi/acpi_bus.h>
  33. #include <acpi/acpi_drivers.h>
  34. #include <asm/acpi.h>
  35. #ifdef CONFIG_ACPI_BOOT
  36. enum acpi_irq_model_id {
  37. ACPI_IRQ_MODEL_PIC = 0,
  38. ACPI_IRQ_MODEL_IOAPIC,
  39. ACPI_IRQ_MODEL_IOSAPIC,
  40. ACPI_IRQ_MODEL_COUNT
  41. };
  42. extern enum acpi_irq_model_id acpi_irq_model;
  43. /* Root System Description Pointer (RSDP) */
  44. struct acpi_table_rsdp {
  45. char signature[8];
  46. u8 checksum;
  47. char oem_id[6];
  48. u8 revision;
  49. u32 rsdt_address;
  50. } __attribute__ ((packed));
  51. struct acpi20_table_rsdp {
  52. char signature[8];
  53. u8 checksum;
  54. char oem_id[6];
  55. u8 revision;
  56. u32 rsdt_address;
  57. u32 length;
  58. u64 xsdt_address;
  59. u8 ext_checksum;
  60. u8 reserved[3];
  61. } __attribute__ ((packed));
  62. typedef struct {
  63. u8 type;
  64. u8 length;
  65. } __attribute__ ((packed)) acpi_table_entry_header;
  66. /* Root System Description Table (RSDT) */
  67. struct acpi_table_rsdt {
  68. struct acpi_table_header header;
  69. u32 entry[8];
  70. } __attribute__ ((packed));
  71. /* Extended System Description Table (XSDT) */
  72. struct acpi_table_xsdt {
  73. struct acpi_table_header header;
  74. u64 entry[1];
  75. } __attribute__ ((packed));
  76. /* Fixed ACPI Description Table (FADT) */
  77. struct acpi_table_fadt {
  78. struct acpi_table_header header;
  79. u32 facs_addr;
  80. u32 dsdt_addr;
  81. /* ... */
  82. } __attribute__ ((packed));
  83. /* Multiple APIC Description Table (MADT) */
  84. struct acpi_table_madt {
  85. struct acpi_table_header header;
  86. u32 lapic_address;
  87. struct {
  88. u32 pcat_compat:1;
  89. u32 reserved:31;
  90. } flags;
  91. } __attribute__ ((packed));
  92. enum acpi_madt_entry_id {
  93. ACPI_MADT_LAPIC = 0,
  94. ACPI_MADT_IOAPIC,
  95. ACPI_MADT_INT_SRC_OVR,
  96. ACPI_MADT_NMI_SRC,
  97. ACPI_MADT_LAPIC_NMI,
  98. ACPI_MADT_LAPIC_ADDR_OVR,
  99. ACPI_MADT_IOSAPIC,
  100. ACPI_MADT_LSAPIC,
  101. ACPI_MADT_PLAT_INT_SRC,
  102. ACPI_MADT_ENTRY_COUNT
  103. };
  104. typedef struct {
  105. u16 polarity:2;
  106. u16 trigger:2;
  107. u16 reserved:12;
  108. } __attribute__ ((packed)) acpi_interrupt_flags;
  109. struct acpi_table_lapic {
  110. acpi_table_entry_header header;
  111. u8 acpi_id;
  112. u8 id;
  113. struct {
  114. u32 enabled:1;
  115. u32 reserved:31;
  116. } flags;
  117. } __attribute__ ((packed));
  118. struct acpi_table_ioapic {
  119. acpi_table_entry_header header;
  120. u8 id;
  121. u8 reserved;
  122. u32 address;
  123. u32 global_irq_base;
  124. } __attribute__ ((packed));
  125. struct acpi_table_int_src_ovr {
  126. acpi_table_entry_header header;
  127. u8 bus;
  128. u8 bus_irq;
  129. u32 global_irq;
  130. acpi_interrupt_flags flags;
  131. } __attribute__ ((packed));
  132. struct acpi_table_nmi_src {
  133. acpi_table_entry_header header;
  134. acpi_interrupt_flags flags;
  135. u32 global_irq;
  136. } __attribute__ ((packed));
  137. struct acpi_table_lapic_nmi {
  138. acpi_table_entry_header header;
  139. u8 acpi_id;
  140. acpi_interrupt_flags flags;
  141. u8 lint;
  142. } __attribute__ ((packed));
  143. struct acpi_table_lapic_addr_ovr {
  144. acpi_table_entry_header header;
  145. u8 reserved[2];
  146. u64 address;
  147. } __attribute__ ((packed));
  148. struct acpi_table_iosapic {
  149. acpi_table_entry_header header;
  150. u8 id;
  151. u8 reserved;
  152. u32 global_irq_base;
  153. u64 address;
  154. } __attribute__ ((packed));
  155. struct acpi_table_lsapic {
  156. acpi_table_entry_header header;
  157. u8 acpi_id;
  158. u8 id;
  159. u8 eid;
  160. u8 reserved[3];
  161. struct {
  162. u32 enabled:1;
  163. u32 reserved:31;
  164. } flags;
  165. } __attribute__ ((packed));
  166. struct acpi_table_plat_int_src {
  167. acpi_table_entry_header header;
  168. acpi_interrupt_flags flags;
  169. u8 type; /* See acpi_interrupt_type */
  170. u8 id;
  171. u8 eid;
  172. u8 iosapic_vector;
  173. u32 global_irq;
  174. u32 reserved;
  175. } __attribute__ ((packed));
  176. enum acpi_interrupt_id {
  177. ACPI_INTERRUPT_PMI = 1,
  178. ACPI_INTERRUPT_INIT,
  179. ACPI_INTERRUPT_CPEI,
  180. ACPI_INTERRUPT_COUNT
  181. };
  182. #define ACPI_SPACE_MEM 0
  183. struct acpi_gen_regaddr {
  184. u8 space_id;
  185. u8 bit_width;
  186. u8 bit_offset;
  187. u8 resv;
  188. u32 addrl;
  189. u32 addrh;
  190. } __attribute__ ((packed));
  191. struct acpi_table_hpet {
  192. struct acpi_table_header header;
  193. u32 id;
  194. struct acpi_gen_regaddr addr;
  195. u8 number;
  196. u16 min_tick;
  197. u8 page_protect;
  198. } __attribute__ ((packed));
  199. /*
  200. * Simple Boot Flags
  201. * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
  202. */
  203. struct acpi_table_sbf
  204. {
  205. u8 sbf_signature[4];
  206. u32 sbf_len;
  207. u8 sbf_revision;
  208. u8 sbf_csum;
  209. u8 sbf_oemid[6];
  210. u8 sbf_oemtable[8];
  211. u8 sbf_revdata[4];
  212. u8 sbf_creator[4];
  213. u8 sbf_crearev[4];
  214. u8 sbf_cmos;
  215. u8 sbf_spare[3];
  216. } __attribute__ ((packed));
  217. /*
  218. * System Resource Affinity Table (SRAT)
  219. * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
  220. */
  221. struct acpi_table_srat {
  222. struct acpi_table_header header;
  223. u32 table_revision;
  224. u64 reserved;
  225. } __attribute__ ((packed));
  226. enum acpi_srat_entry_id {
  227. ACPI_SRAT_PROCESSOR_AFFINITY = 0,
  228. ACPI_SRAT_MEMORY_AFFINITY,
  229. ACPI_SRAT_ENTRY_COUNT
  230. };
  231. struct acpi_table_processor_affinity {
  232. acpi_table_entry_header header;
  233. u8 proximity_domain;
  234. u8 apic_id;
  235. struct {
  236. u32 enabled:1;
  237. u32 reserved:31;
  238. } flags;
  239. u8 lsapic_eid;
  240. u8 reserved[7];
  241. } __attribute__ ((packed));
  242. struct acpi_table_memory_affinity {
  243. acpi_table_entry_header header;
  244. u8 proximity_domain;
  245. u8 reserved1[5];
  246. u32 base_addr_lo;
  247. u32 base_addr_hi;
  248. u32 length_lo;
  249. u32 length_hi;
  250. u32 memory_type; /* See acpi_address_range_id */
  251. struct {
  252. u32 enabled:1;
  253. u32 hot_pluggable:1;
  254. u32 reserved:30;
  255. } flags;
  256. u64 reserved2;
  257. } __attribute__ ((packed));
  258. enum acpi_address_range_id {
  259. ACPI_ADDRESS_RANGE_MEMORY = 1,
  260. ACPI_ADDRESS_RANGE_RESERVED = 2,
  261. ACPI_ADDRESS_RANGE_ACPI = 3,
  262. ACPI_ADDRESS_RANGE_NVS = 4,
  263. ACPI_ADDRESS_RANGE_COUNT
  264. };
  265. /*
  266. * System Locality Information Table (SLIT)
  267. * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
  268. */
  269. struct acpi_table_slit {
  270. struct acpi_table_header header;
  271. u64 localities;
  272. u8 entry[1]; /* real size = localities^2 */
  273. } __attribute__ ((packed));
  274. /* Smart Battery Description Table (SBST) */
  275. struct acpi_table_sbst {
  276. struct acpi_table_header header;
  277. u32 warning; /* Warn user */
  278. u32 low; /* Critical sleep */
  279. u32 critical; /* Critical shutdown */
  280. } __attribute__ ((packed));
  281. /* Embedded Controller Boot Resources Table (ECDT) */
  282. struct acpi_table_ecdt {
  283. struct acpi_table_header header;
  284. struct acpi_generic_address ec_control;
  285. struct acpi_generic_address ec_data;
  286. u32 uid;
  287. u8 gpe_bit;
  288. char ec_id[0];
  289. } __attribute__ ((packed));
  290. /* PCI MMCONFIG */
  291. struct acpi_table_mcfg {
  292. struct acpi_table_header header;
  293. u8 reserved[8];
  294. u32 base_address;
  295. u32 base_reserved;
  296. } __attribute__ ((packed));
  297. /* Table Handlers */
  298. enum acpi_table_id {
  299. ACPI_TABLE_UNKNOWN = 0,
  300. ACPI_APIC,
  301. ACPI_BOOT,
  302. ACPI_DBGP,
  303. ACPI_DSDT,
  304. ACPI_ECDT,
  305. ACPI_ETDT,
  306. ACPI_FADT,
  307. ACPI_FACS,
  308. ACPI_OEMX,
  309. ACPI_PSDT,
  310. ACPI_SBST,
  311. ACPI_SLIT,
  312. ACPI_SPCR,
  313. ACPI_SRAT,
  314. ACPI_SSDT,
  315. ACPI_SPMI,
  316. ACPI_HPET,
  317. ACPI_MCFG,
  318. ACPI_TABLE_COUNT
  319. };
  320. typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
  321. extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
  322. typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
  323. char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
  324. unsigned long acpi_find_rsdp (void);
  325. int acpi_boot_init (void);
  326. int acpi_boot_table_init (void);
  327. int acpi_numa_init (void);
  328. int acpi_table_init (void);
  329. int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
  330. int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
  331. int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  332. int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  333. void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
  334. void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
  335. void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
  336. /* the following four functions are architecture-dependent */
  337. void acpi_numa_slit_init (struct acpi_table_slit *slit);
  338. void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
  339. void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
  340. void acpi_numa_arch_fixup(void);
  341. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  342. /* Arch dependent functions for cpu hotplug support */
  343. int acpi_map_lsapic(acpi_handle handle, int *pcpu);
  344. int acpi_unmap_lsapic(int cpu);
  345. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  346. extern int acpi_mp_config;
  347. extern u32 pci_mmcfg_base_addr;
  348. extern int sbf_port ;
  349. #else /*!CONFIG_ACPI_BOOT*/
  350. #define acpi_mp_config 0
  351. static inline int acpi_boot_init(void)
  352. {
  353. return 0;
  354. }
  355. static inline int acpi_boot_table_init(void)
  356. {
  357. return 0;
  358. }
  359. #endif /*!CONFIG_ACPI_BOOT*/
  360. unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low);
  361. int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
  362. /*
  363. * This function undoes the effect of one call to acpi_register_gsi().
  364. * If this matches the last registration, any IRQ resources for gsi
  365. * are freed.
  366. */
  367. #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
  368. void acpi_unregister_gsi (u32 gsi);
  369. #endif
  370. #ifdef CONFIG_ACPI_PCI
  371. struct acpi_prt_entry {
  372. struct list_head node;
  373. struct acpi_pci_id id;
  374. u8 pin;
  375. struct {
  376. acpi_handle handle;
  377. u32 index;
  378. } link;
  379. u32 irq;
  380. };
  381. struct acpi_prt_list {
  382. int count;
  383. struct list_head entries;
  384. };
  385. struct pci_dev;
  386. int acpi_pci_irq_enable (struct pci_dev *dev);
  387. void acpi_penalize_isa_irq(int irq);
  388. #ifdef CONFIG_ACPI_DEALLOCATE_IRQ
  389. void acpi_pci_irq_disable (struct pci_dev *dev);
  390. #endif
  391. struct acpi_pci_driver {
  392. struct acpi_pci_driver *next;
  393. int (*add)(acpi_handle handle);
  394. void (*remove)(acpi_handle handle);
  395. };
  396. int acpi_pci_register_driver(struct acpi_pci_driver *driver);
  397. void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
  398. #endif /*CONFIG_ACPI_PCI*/
  399. #ifdef CONFIG_ACPI_EC
  400. extern int ec_read(u8 addr, u8 *val);
  401. extern int ec_write(u8 addr, u8 val);
  402. #endif /*CONFIG_ACPI_EC*/
  403. #ifdef CONFIG_ACPI_INTERPRETER
  404. extern int acpi_blacklisted(void);
  405. extern void acpi_bios_year(char *s);
  406. #else /*!CONFIG_ACPI_INTERPRETER*/
  407. static inline int acpi_blacklisted(void)
  408. {
  409. return 0;
  410. }
  411. #endif /*!CONFIG_ACPI_INTERPRETER*/
  412. #define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
  413. #ifdef CONFIG_ACPI
  414. /*
  415. * Set highest legal C-state
  416. * 0: C0 okay, but not C1
  417. * 1: C1 okay, but not C2
  418. * 2: C2 okay, but not C3 etc.
  419. */
  420. extern unsigned int max_cstate;
  421. static inline unsigned int acpi_get_cstate_limit(void)
  422. {
  423. return max_cstate;
  424. }
  425. static inline void acpi_set_cstate_limit(unsigned int new_limit)
  426. {
  427. max_cstate = new_limit;
  428. return;
  429. }
  430. #else
  431. static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
  432. static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
  433. #endif
  434. #ifdef CONFIG_ACPI_NUMA
  435. int acpi_get_pxm(acpi_handle handle);
  436. #else
  437. static inline int acpi_get_pxm(acpi_handle handle)
  438. {
  439. return 0;
  440. }
  441. #endif
  442. extern int pnpacpi_disabled;
  443. #endif /* CONFIG_ACPI */
  444. #endif /*_LINUX_ACPI_H*/