Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 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 | |
| 9 | #ifndef __ACPI_DEVICE_H |
| 10 | #define __ACPI_DEVICE_H |
| 11 | |
Simon Glass | 8965cc9 | 2020-07-07 13:11:40 -0600 | [diff] [blame^] | 12 | #include <linux/bitops.h> |
| 13 | |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 14 | struct udevice; |
| 15 | |
| 16 | /* Length of a full path to an ACPI device */ |
| 17 | #define ACPI_PATH_MAX 30 |
| 18 | |
Simon Glass | 8965cc9 | 2020-07-07 13:11:40 -0600 | [diff] [blame^] | 19 | /* Values that can be returned for ACPI device _STA method */ |
| 20 | enum acpi_dev_status { |
| 21 | ACPI_DSTATUS_PRESENT = BIT(0), |
| 22 | ACPI_DSTATUS_ENABLED = BIT(1), |
| 23 | ACPI_DSTATUS_SHOW_IN_UI = BIT(2), |
| 24 | ACPI_DSTATUS_OK = BIT(3), |
| 25 | ACPI_DSTATUS_HAS_BATTERY = BIT(4), |
| 26 | |
| 27 | ACPI_DSTATUS_ALL_OFF = 0, |
| 28 | ACPI_DSTATUS_HIDDEN_ON = ACPI_DSTATUS_PRESENT | ACPI_DSTATUS_ENABLED | |
| 29 | ACPI_DSTATUS_OK, |
| 30 | ACPI_DSTATUS_ALL_ON = ACPI_DSTATUS_HIDDEN_ON | |
| 31 | ACPI_DSTATUS_SHOW_IN_UI, |
| 32 | }; |
| 33 | |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 34 | /** |
| 35 | * acpi_device_path() - Get the full path to an ACPI device |
| 36 | * |
| 37 | * This gets the full path in the form XXXX.YYYY.ZZZZ where XXXX is the root |
| 38 | * and ZZZZ is the device. All parent devices are added to the path. |
| 39 | * |
| 40 | * @dev: Device to check |
| 41 | * @buf: Buffer to place the path in (should be ACPI_PATH_MAX long) |
| 42 | * @maxlen: Size of buffer (typically ACPI_PATH_MAX) |
| 43 | * @return 0 if OK, -ve on error |
| 44 | */ |
| 45 | int acpi_device_path(const struct udevice *dev, char *buf, int maxlen); |
| 46 | |
| 47 | /** |
| 48 | * acpi_device_scope() - Get the scope of an ACPI device |
| 49 | * |
| 50 | * This gets the scope which is the full path of the parent device, as per |
| 51 | * acpi_device_path(). |
| 52 | * |
| 53 | * @dev: Device to check |
| 54 | * @buf: Buffer to place the path in (should be ACPI_PATH_MAX long) |
| 55 | * @maxlen: Size of buffer (typically ACPI_PATH_MAX) |
| 56 | * @return 0 if OK, -EINVAL if the device has no parent, other -ve on other |
| 57 | * error |
| 58 | */ |
| 59 | int acpi_device_scope(const struct udevice *dev, char *scope, int maxlen); |
| 60 | |
Simon Glass | 8965cc9 | 2020-07-07 13:11:40 -0600 | [diff] [blame^] | 61 | /** |
| 62 | * acpi_device_status() - Get the status of a device |
| 63 | * |
| 64 | * This currently just returns ACPI_DSTATUS_ALL_ON. It does not support |
| 65 | * inactive or hidden devices. |
| 66 | * |
| 67 | * @dev: Device to check |
| 68 | * @return device status, as ACPI_DSTATUS_... |
| 69 | */ |
| 70 | enum acpi_dev_status acpi_device_status(const struct udevice *dev); |
| 71 | |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 72 | #endif |