acpi_bus.h 19 KB

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