acpi_bus.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. */
  21. #ifndef __ACPI_BUS_H__
  22. #define __ACPI_BUS_H__
  23. #include <linux/device.h>
  24. #include <linux/property.h>
  25. /* TBD: Make dynamic */
  26. #define ACPI_MAX_HANDLES 10
  27. struct acpi_handle_list {
  28. u32 count;
  29. acpi_handle handles[ACPI_MAX_HANDLES];
  30. };
  31. /* acpi_utils.h */
  32. acpi_status
  33. acpi_extract_package(union acpi_object *package,
  34. struct acpi_buffer *format, struct acpi_buffer *buffer);
  35. acpi_status
  36. acpi_evaluate_integer(acpi_handle handle,
  37. acpi_string pathname,
  38. struct acpi_object_list *arguments, unsigned long long *data);
  39. acpi_status
  40. acpi_evaluate_reference(acpi_handle handle,
  41. acpi_string pathname,
  42. struct acpi_object_list *arguments,
  43. struct acpi_handle_list *list);
  44. acpi_status
  45. acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
  46. struct acpi_buffer *status_buf);
  47. acpi_status
  48. acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
  49. bool acpi_has_method(acpi_handle handle, char *name);
  50. acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
  51. u64 arg);
  52. acpi_status acpi_evaluate_ej0(acpi_handle handle);
  53. acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
  54. bool acpi_ata_match(acpi_handle handle);
  55. bool acpi_bay_match(acpi_handle handle);
  56. bool acpi_dock_match(acpi_handle handle);
  57. bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs);
  58. union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid,
  59. u64 rev, u64 func, union acpi_object *argv4);
  60. static inline union acpi_object *
  61. acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
  62. u64 func, union acpi_object *argv4,
  63. acpi_object_type type)
  64. {
  65. union acpi_object *obj;
  66. obj = acpi_evaluate_dsm(handle, guid, rev, func, argv4);
  67. if (obj && obj->type != type) {
  68. ACPI_FREE(obj);
  69. obj = NULL;
  70. }
  71. return obj;
  72. }
  73. #define ACPI_INIT_DSM_ARGV4(cnt, eles) \
  74. { \
  75. .package.type = ACPI_TYPE_PACKAGE, \
  76. .package.count = (cnt), \
  77. .package.elements = (eles) \
  78. }
  79. bool acpi_dev_found(const char *hid);
  80. bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
  81. const char *
  82. acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
  83. #ifdef CONFIG_ACPI
  84. #include <linux/proc_fs.h>
  85. #define ACPI_BUS_FILE_ROOT "acpi"
  86. extern struct proc_dir_entry *acpi_root_dir;
  87. enum acpi_bus_device_type {
  88. ACPI_BUS_TYPE_DEVICE = 0,
  89. ACPI_BUS_TYPE_POWER,
  90. ACPI_BUS_TYPE_PROCESSOR,
  91. ACPI_BUS_TYPE_THERMAL,
  92. ACPI_BUS_TYPE_POWER_BUTTON,
  93. ACPI_BUS_TYPE_SLEEP_BUTTON,
  94. ACPI_BUS_TYPE_ECDT_EC,
  95. ACPI_BUS_DEVICE_TYPE_COUNT
  96. };
  97. struct acpi_driver;
  98. struct acpi_device;
  99. /*
  100. * ACPI Scan Handler
  101. * -----------------
  102. */
  103. struct acpi_hotplug_profile {
  104. struct kobject kobj;
  105. int (*scan_dependent)(struct acpi_device *adev);
  106. void (*notify_online)(struct acpi_device *adev);
  107. bool enabled:1;
  108. bool demand_offline:1;
  109. };
  110. static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
  111. struct kobject *kobj)
  112. {
  113. return container_of(kobj, struct acpi_hotplug_profile, kobj);
  114. }
  115. struct acpi_scan_handler {
  116. const struct acpi_device_id *ids;
  117. struct list_head list_node;
  118. bool (*match)(const char *idstr, const struct acpi_device_id **matchid);
  119. int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
  120. void (*detach)(struct acpi_device *dev);
  121. void (*bind)(struct device *phys_dev);
  122. void (*unbind)(struct device *phys_dev);
  123. struct acpi_hotplug_profile hotplug;
  124. };
  125. /*
  126. * ACPI Hotplug Context
  127. * --------------------
  128. */
  129. struct acpi_hotplug_context {
  130. struct acpi_device *self;
  131. int (*notify)(struct acpi_device *, u32);
  132. void (*uevent)(struct acpi_device *, u32);
  133. void (*fixup)(struct acpi_device *);
  134. };
  135. /*
  136. * ACPI Driver
  137. * -----------
  138. */
  139. typedef int (*acpi_op_add) (struct acpi_device * device);
  140. typedef int (*acpi_op_remove) (struct acpi_device * device);
  141. typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
  142. struct acpi_device_ops {
  143. acpi_op_add add;
  144. acpi_op_remove remove;
  145. acpi_op_notify notify;
  146. };
  147. #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */
  148. struct acpi_driver {
  149. char name[80];
  150. char class[80];
  151. const struct acpi_device_id *ids; /* Supported Hardware IDs */
  152. unsigned int flags;
  153. struct acpi_device_ops ops;
  154. struct device_driver drv;
  155. struct module *owner;
  156. };
  157. /*
  158. * ACPI Device
  159. * -----------
  160. */
  161. /* Status (_STA) */
  162. struct acpi_device_status {
  163. u32 present:1;
  164. u32 enabled:1;
  165. u32 show_in_ui:1;
  166. u32 functional:1;
  167. u32 battery_present:1;
  168. u32 reserved:27;
  169. };
  170. /* Flags */
  171. struct acpi_device_flags {
  172. u32 dynamic_status:1;
  173. u32 removable:1;
  174. u32 ejectable:1;
  175. u32 power_manageable:1;
  176. u32 match_driver:1;
  177. u32 initialized:1;
  178. u32 visited:1;
  179. u32 hotplug_notify:1;
  180. u32 is_dock_station:1;
  181. u32 of_compatible_ok:1;
  182. u32 coherent_dma:1;
  183. u32 cca_seen:1;
  184. u32 enumeration_by_parent:1;
  185. u32 reserved:19;
  186. };
  187. /* File System */
  188. struct acpi_device_dir {
  189. struct proc_dir_entry *entry;
  190. };
  191. #define acpi_device_dir(d) ((d)->dir.entry)
  192. /* Plug and Play */
  193. typedef char acpi_bus_id[8];
  194. typedef unsigned long acpi_bus_address;
  195. typedef char acpi_device_name[40];
  196. typedef char acpi_device_class[20];
  197. struct acpi_hardware_id {
  198. struct list_head list;
  199. const char *id;
  200. };
  201. struct acpi_pnp_type {
  202. u32 hardware_id:1;
  203. u32 bus_address:1;
  204. u32 platform_id:1;
  205. u32 reserved:29;
  206. };
  207. struct acpi_device_pnp {
  208. acpi_bus_id bus_id; /* Object name */
  209. struct acpi_pnp_type type; /* ID type */
  210. acpi_bus_address bus_address; /* _ADR */
  211. char *unique_id; /* _UID */
  212. struct list_head ids; /* _HID and _CIDs */
  213. acpi_device_name device_name; /* Driver-determined */
  214. acpi_device_class device_class; /* " */
  215. union acpi_object *str_obj; /* unicode string for _STR method */
  216. };
  217. #define acpi_device_bid(d) ((d)->pnp.bus_id)
  218. #define acpi_device_adr(d) ((d)->pnp.bus_address)
  219. const char *acpi_device_hid(struct acpi_device *device);
  220. #define acpi_device_uid(d) ((d)->pnp.unique_id)
  221. #define acpi_device_name(d) ((d)->pnp.device_name)
  222. #define acpi_device_class(d) ((d)->pnp.device_class)
  223. /* Power Management */
  224. struct acpi_device_power_flags {
  225. u32 explicit_get:1; /* _PSC present? */
  226. u32 power_resources:1; /* Power resources */
  227. u32 inrush_current:1; /* Serialize Dx->D0 */
  228. u32 power_removed:1; /* Optimize Dx->D0 */
  229. u32 ignore_parent:1; /* Power is independent of parent power state */
  230. u32 dsw_present:1; /* _DSW present? */
  231. u32 reserved:26;
  232. };
  233. struct acpi_device_power_state {
  234. struct {
  235. u8 valid:1;
  236. u8 explicit_set:1; /* _PSx present? */
  237. u8 reserved:6;
  238. } flags;
  239. int power; /* % Power (compared to D0) */
  240. int latency; /* Dx->D0 time (microseconds) */
  241. struct list_head resources; /* Power resources referenced */
  242. };
  243. struct acpi_device_power {
  244. int state; /* Current state */
  245. struct acpi_device_power_flags flags;
  246. struct acpi_device_power_state states[ACPI_D_STATE_COUNT]; /* Power states (D0-D3Cold) */
  247. };
  248. /* Performance Management */
  249. struct acpi_device_perf_flags {
  250. u8 reserved:8;
  251. };
  252. struct acpi_device_perf_state {
  253. struct {
  254. u8 valid:1;
  255. u8 reserved:7;
  256. } flags;
  257. u8 power; /* % Power (compared to P0) */
  258. u8 performance; /* % Performance ( " ) */
  259. int latency; /* Px->P0 time (microseconds) */
  260. };
  261. struct acpi_device_perf {
  262. int state;
  263. struct acpi_device_perf_flags flags;
  264. int state_count;
  265. struct acpi_device_perf_state *states;
  266. };
  267. /* Wakeup Management */
  268. struct acpi_device_wakeup_flags {
  269. u8 valid:1; /* Can successfully enable wakeup? */
  270. u8 notifier_present:1; /* Wake-up notify handler has been installed */
  271. };
  272. struct acpi_device_wakeup_context {
  273. void (*func)(struct acpi_device_wakeup_context *context);
  274. struct device *dev;
  275. };
  276. struct acpi_device_wakeup {
  277. acpi_handle gpe_device;
  278. u64 gpe_number;
  279. u64 sleep_state;
  280. struct list_head resources;
  281. struct acpi_device_wakeup_flags flags;
  282. struct acpi_device_wakeup_context context;
  283. struct wakeup_source *ws;
  284. int prepare_count;
  285. int enable_count;
  286. };
  287. struct acpi_device_physical_node {
  288. unsigned int node_id;
  289. struct list_head node;
  290. struct device *dev;
  291. bool put_online:1;
  292. };
  293. struct acpi_device_properties {
  294. const guid_t *guid;
  295. const union acpi_object *properties;
  296. struct list_head list;
  297. };
  298. /* ACPI Device Specific Data (_DSD) */
  299. struct acpi_device_data {
  300. const union acpi_object *pointer;
  301. struct list_head properties;
  302. const union acpi_object *of_compatible;
  303. struct list_head subnodes;
  304. };
  305. struct acpi_gpio_mapping;
  306. /* Device */
  307. struct acpi_device {
  308. int device_type;
  309. acpi_handle handle; /* no handle for fixed hardware */
  310. struct fwnode_handle fwnode;
  311. struct acpi_device *parent;
  312. struct list_head children;
  313. struct list_head node;
  314. struct list_head wakeup_list;
  315. struct list_head del_list;
  316. struct acpi_device_status status;
  317. struct acpi_device_flags flags;
  318. struct acpi_device_pnp pnp;
  319. struct acpi_device_power power;
  320. struct acpi_device_wakeup wakeup;
  321. struct acpi_device_perf performance;
  322. struct acpi_device_dir dir;
  323. struct acpi_device_data data;
  324. struct acpi_scan_handler *handler;
  325. struct acpi_hotplug_context *hp;
  326. struct acpi_driver *driver;
  327. const struct acpi_gpio_mapping *driver_gpios;
  328. void *driver_data;
  329. struct device dev;
  330. unsigned int physical_node_count;
  331. unsigned int dep_unmet;
  332. struct list_head physical_node_list;
  333. struct mutex physical_node_lock;
  334. void (*remove)(struct acpi_device *);
  335. };
  336. /* Non-device subnode */
  337. struct acpi_data_node {
  338. const char *name;
  339. acpi_handle handle;
  340. struct fwnode_handle fwnode;
  341. struct fwnode_handle *parent;
  342. struct acpi_device_data data;
  343. struct list_head sibling;
  344. struct kobject kobj;
  345. struct completion kobj_done;
  346. };
  347. extern const struct fwnode_operations acpi_device_fwnode_ops;
  348. extern const struct fwnode_operations acpi_data_fwnode_ops;
  349. extern const struct fwnode_operations acpi_static_fwnode_ops;
  350. bool is_acpi_device_node(const struct fwnode_handle *fwnode);
  351. bool is_acpi_data_node(const struct fwnode_handle *fwnode);
  352. static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
  353. {
  354. return (is_acpi_device_node(fwnode) || is_acpi_data_node(fwnode));
  355. }
  356. #define to_acpi_device_node(__fwnode) \
  357. ({ \
  358. typeof(__fwnode) __to_acpi_device_node_fwnode = __fwnode; \
  359. \
  360. is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
  361. container_of(__to_acpi_device_node_fwnode, \
  362. struct acpi_device, fwnode) : \
  363. NULL; \
  364. })
  365. #define to_acpi_data_node(__fwnode) \
  366. ({ \
  367. typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \
  368. \
  369. is_acpi_data_node(__to_acpi_data_node_fwnode) ? \
  370. container_of(__to_acpi_data_node_fwnode, \
  371. struct acpi_data_node, fwnode) : \
  372. NULL; \
  373. })
  374. static inline bool is_acpi_static_node(const struct fwnode_handle *fwnode)
  375. {
  376. return !IS_ERR_OR_NULL(fwnode) &&
  377. fwnode->ops == &acpi_static_fwnode_ops;
  378. }
  379. static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
  380. const char *name)
  381. {
  382. return is_acpi_data_node(fwnode) ?
  383. (!strcmp(to_acpi_data_node(fwnode)->name, name)) : false;
  384. }
  385. static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
  386. {
  387. return &adev->fwnode;
  388. }
  389. static inline void *acpi_driver_data(struct acpi_device *d)
  390. {
  391. return d->driver_data;
  392. }
  393. #define to_acpi_device(d) container_of(d, struct acpi_device, dev)
  394. #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
  395. static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
  396. {
  397. *((u32 *)&adev->status) = sta;
  398. }
  399. static inline void acpi_set_hp_context(struct acpi_device *adev,
  400. struct acpi_hotplug_context *hp)
  401. {
  402. hp->self = adev;
  403. adev->hp = hp;
  404. }
  405. void acpi_initialize_hp_context(struct acpi_device *adev,
  406. struct acpi_hotplug_context *hp,
  407. int (*notify)(struct acpi_device *, u32),
  408. void (*uevent)(struct acpi_device *, u32));
  409. /* acpi_device.dev.bus == &acpi_bus_type */
  410. extern struct bus_type acpi_bus_type;
  411. /*
  412. * Events
  413. * ------
  414. */
  415. struct acpi_bus_event {
  416. struct list_head node;
  417. acpi_device_class device_class;
  418. acpi_bus_id bus_id;
  419. u32 type;
  420. u32 data;
  421. };
  422. extern struct kobject *acpi_kobj;
  423. extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
  424. void acpi_bus_private_data_handler(acpi_handle, void *);
  425. int acpi_bus_get_private_data(acpi_handle, void **);
  426. int acpi_bus_attach_private_data(acpi_handle, void *);
  427. void acpi_bus_detach_private_data(acpi_handle);
  428. extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
  429. extern int register_acpi_notifier(struct notifier_block *);
  430. extern int unregister_acpi_notifier(struct notifier_block *);
  431. /*
  432. * External Functions
  433. */
  434. int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
  435. struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
  436. void acpi_bus_put_acpi_device(struct acpi_device *adev);
  437. acpi_status acpi_bus_get_status_handle(acpi_handle handle,
  438. unsigned long long *sta);
  439. int acpi_bus_get_status(struct acpi_device *device);
  440. int acpi_bus_set_power(acpi_handle handle, int state);
  441. const char *acpi_power_state_string(int state);
  442. int acpi_device_get_power(struct acpi_device *device, int *state);
  443. int acpi_device_set_power(struct acpi_device *device, int state);
  444. int acpi_bus_init_power(struct acpi_device *device);
  445. int acpi_device_fix_up_power(struct acpi_device *device);
  446. int acpi_bus_update_power(acpi_handle handle, int *state_p);
  447. int acpi_device_update_power(struct acpi_device *device, int *state_p);
  448. bool acpi_bus_power_manageable(acpi_handle handle);
  449. #ifdef CONFIG_PM
  450. bool acpi_bus_can_wakeup(acpi_handle handle);
  451. #else
  452. static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; }
  453. #endif
  454. void acpi_scan_lock_acquire(void);
  455. void acpi_scan_lock_release(void);
  456. void acpi_lock_hp_context(void);
  457. void acpi_unlock_hp_context(void);
  458. int acpi_scan_add_handler(struct acpi_scan_handler *handler);
  459. int acpi_bus_register_driver(struct acpi_driver *driver);
  460. void acpi_bus_unregister_driver(struct acpi_driver *driver);
  461. int acpi_bus_scan(acpi_handle handle);
  462. void acpi_bus_trim(struct acpi_device *start);
  463. acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
  464. int acpi_match_device_ids(struct acpi_device *device,
  465. const struct acpi_device_id *ids);
  466. void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
  467. char *modalias, size_t len);
  468. int acpi_create_dir(struct acpi_device *);
  469. void acpi_remove_dir(struct acpi_device *);
  470. static inline bool acpi_device_enumerated(struct acpi_device *adev)
  471. {
  472. return adev && adev->flags.initialized && adev->flags.visited;
  473. }
  474. /**
  475. * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
  476. * @__acpi_driver: acpi_driver struct
  477. *
  478. * Helper macro for ACPI drivers which do not do anything special in module
  479. * init/exit. This eliminates a lot of boilerplate. Each module may only
  480. * use this macro once, and calling it replaces module_init() and module_exit()
  481. */
  482. #define module_acpi_driver(__acpi_driver) \
  483. module_driver(__acpi_driver, acpi_bus_register_driver, \
  484. acpi_bus_unregister_driver)
  485. /*
  486. * Bind physical devices with ACPI devices
  487. */
  488. struct acpi_bus_type {
  489. struct list_head list;
  490. const char *name;
  491. bool (*match)(struct device *dev);
  492. struct acpi_device * (*find_companion)(struct device *);
  493. void (*setup)(struct device *);
  494. void (*cleanup)(struct device *);
  495. };
  496. int register_acpi_bus_type(struct acpi_bus_type *);
  497. int unregister_acpi_bus_type(struct acpi_bus_type *);
  498. int acpi_bind_one(struct device *dev, struct acpi_device *adev);
  499. int acpi_unbind_one(struct device *dev);
  500. struct acpi_pci_root {
  501. struct acpi_device * device;
  502. struct pci_bus *bus;
  503. u16 segment;
  504. struct resource secondary; /* downstream bus range */
  505. u32 osc_support_set; /* _OSC state of support bits */
  506. u32 osc_control_set; /* _OSC state of control bits */
  507. phys_addr_t mcfg_addr;
  508. };
  509. /* helper */
  510. bool acpi_dma_supported(struct acpi_device *adev);
  511. enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
  512. int acpi_dma_get_range(struct device *dev, u64 *dma_addr, u64 *offset,
  513. u64 *size);
  514. int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr);
  515. struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
  516. u64 address, bool check_children);
  517. int acpi_is_root_bridge(acpi_handle);
  518. struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
  519. int acpi_enable_wakeup_device_power(struct acpi_device *dev, int state);
  520. int acpi_disable_wakeup_device_power(struct acpi_device *dev);
  521. #ifdef CONFIG_X86
  522. bool acpi_device_always_present(struct acpi_device *adev);
  523. #else
  524. static inline bool acpi_device_always_present(struct acpi_device *adev)
  525. {
  526. return false;
  527. }
  528. #endif
  529. #ifdef CONFIG_PM
  530. void acpi_pm_wakeup_event(struct device *dev);
  531. acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
  532. void (*func)(struct acpi_device_wakeup_context *context));
  533. acpi_status acpi_remove_pm_notifier(struct acpi_device *adev);
  534. bool acpi_pm_device_can_wakeup(struct device *dev);
  535. int acpi_pm_device_sleep_state(struct device *, int *, int);
  536. int acpi_pm_set_device_wakeup(struct device *dev, bool enable);
  537. int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable);
  538. #else
  539. static inline void acpi_pm_wakeup_event(struct device *dev)
  540. {
  541. }
  542. static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
  543. struct device *dev,
  544. void (*func)(struct acpi_device_wakeup_context *context))
  545. {
  546. return AE_SUPPORT;
  547. }
  548. static inline acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
  549. {
  550. return AE_SUPPORT;
  551. }
  552. static inline bool acpi_pm_device_can_wakeup(struct device *dev)
  553. {
  554. return false;
  555. }
  556. static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
  557. {
  558. if (p)
  559. *p = ACPI_STATE_D0;
  560. return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ?
  561. m : ACPI_STATE_D0;
  562. }
  563. static inline int acpi_pm_set_device_wakeup(struct device *dev, bool enable)
  564. {
  565. return -ENODEV;
  566. }
  567. static inline int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable)
  568. {
  569. return -ENODEV;
  570. }
  571. #endif
  572. #ifdef CONFIG_ACPI_SLEEP
  573. u32 acpi_target_system_state(void);
  574. #else
  575. static inline u32 acpi_target_system_state(void) { return ACPI_STATE_S0; }
  576. #endif
  577. static inline bool acpi_device_power_manageable(struct acpi_device *adev)
  578. {
  579. return adev->flags.power_manageable;
  580. }
  581. static inline bool acpi_device_can_wakeup(struct acpi_device *adev)
  582. {
  583. return adev->wakeup.flags.valid;
  584. }
  585. static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
  586. {
  587. return adev->power.states[ACPI_STATE_D3_COLD].flags.valid ||
  588. ((acpi_gbl_FADT.header.revision < 6) &&
  589. adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
  590. }
  591. #else /* CONFIG_ACPI */
  592. static inline int register_acpi_bus_type(void *bus) { return 0; }
  593. static inline int unregister_acpi_bus_type(void *bus) { return 0; }
  594. #endif /* CONFIG_ACPI */
  595. #endif /*__ACPI_BUS_H__*/