acpi_device.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Generation of tables for particular device types
  4. *
  5. * Copyright 2019 Google LLC
  6. * Mostly taken from coreboot file of the same name
  7. */
  8. #ifndef __ACPI_DEVICE_H
  9. #define __ACPI_DEVICE_H
  10. #include <linux/bitops.h>
  11. struct udevice;
  12. /* Length of a full path to an ACPI device */
  13. #define ACPI_PATH_MAX 30
  14. /* Values that can be returned for ACPI device _STA method */
  15. enum acpi_dev_status {
  16. ACPI_DSTATUS_PRESENT = BIT(0),
  17. ACPI_DSTATUS_ENABLED = BIT(1),
  18. ACPI_DSTATUS_SHOW_IN_UI = BIT(2),
  19. ACPI_DSTATUS_OK = BIT(3),
  20. ACPI_DSTATUS_HAS_BATTERY = BIT(4),
  21. ACPI_DSTATUS_ALL_OFF = 0,
  22. ACPI_DSTATUS_HIDDEN_ON = ACPI_DSTATUS_PRESENT | ACPI_DSTATUS_ENABLED |
  23. ACPI_DSTATUS_OK,
  24. ACPI_DSTATUS_ALL_ON = ACPI_DSTATUS_HIDDEN_ON |
  25. ACPI_DSTATUS_SHOW_IN_UI,
  26. };
  27. /**
  28. * acpi_device_path() - Get the full path to an ACPI device
  29. *
  30. * This gets the full path in the form XXXX.YYYY.ZZZZ where XXXX is the root
  31. * and ZZZZ is the device. All parent devices are added to the path.
  32. *
  33. * @dev: Device to check
  34. * @buf: Buffer to place the path in (should be ACPI_PATH_MAX long)
  35. * @maxlen: Size of buffer (typically ACPI_PATH_MAX)
  36. * @return 0 if OK, -ve on error
  37. */
  38. int acpi_device_path(const struct udevice *dev, char *buf, int maxlen);
  39. /**
  40. * acpi_device_scope() - Get the scope of an ACPI device
  41. *
  42. * This gets the scope which is the full path of the parent device, as per
  43. * acpi_device_path().
  44. *
  45. * @dev: Device to check
  46. * @buf: Buffer to place the path in (should be ACPI_PATH_MAX long)
  47. * @maxlen: Size of buffer (typically ACPI_PATH_MAX)
  48. * @return 0 if OK, -EINVAL if the device has no parent, other -ve on other
  49. * error
  50. */
  51. int acpi_device_scope(const struct udevice *dev, char *scope, int maxlen);
  52. /**
  53. * acpi_device_status() - Get the status of a device
  54. *
  55. * This currently just returns ACPI_DSTATUS_ALL_ON. It does not support
  56. * inactive or hidden devices.
  57. *
  58. * @dev: Device to check
  59. * @return device status, as ACPI_DSTATUS_...
  60. */
  61. enum acpi_dev_status acpi_device_status(const struct udevice *dev);
  62. #endif