#ifndef __ACPI_DEVICE_H
#define __ACPI_DEVICE_H
+#include <linux/bitops.h>
+
struct udevice;
/* Length of a full path to an ACPI device */
#define ACPI_PATH_MAX 30
+/* Values that can be returned for ACPI device _STA method */
+enum acpi_dev_status {
+ ACPI_DSTATUS_PRESENT = BIT(0),
+ ACPI_DSTATUS_ENABLED = BIT(1),
+ ACPI_DSTATUS_SHOW_IN_UI = BIT(2),
+ ACPI_DSTATUS_OK = BIT(3),
+ ACPI_DSTATUS_HAS_BATTERY = BIT(4),
+
+ ACPI_DSTATUS_ALL_OFF = 0,
+ ACPI_DSTATUS_HIDDEN_ON = ACPI_DSTATUS_PRESENT | ACPI_DSTATUS_ENABLED |
+ ACPI_DSTATUS_OK,
+ ACPI_DSTATUS_ALL_ON = ACPI_DSTATUS_HIDDEN_ON |
+ ACPI_DSTATUS_SHOW_IN_UI,
+};
+
/**
* acpi_device_path() - Get the full path to an ACPI device
*
*/
int acpi_device_scope(const struct udevice *dev, char *scope, int maxlen);
+/**
+ * acpi_device_status() - Get the status of a device
+ *
+ * This currently just returns ACPI_DSTATUS_ALL_ON. It does not support
+ * inactive or hidden devices.
+ *
+ * @dev: Device to check
+ * @return device status, as ACPI_DSTATUS_...
+ */
+enum acpi_dev_status acpi_device_status(const struct udevice *dev);
+
#endif
return 0;
}
DM_TEST(dm_test_acpi_device_path, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test acpi_device_status() */
+static int dm_test_acpi_device_status(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
+ ut_asserteq(ACPI_DSTATUS_ALL_ON, acpi_device_status(dev));
+
+ return 0;
+}
+DM_TEST(dm_test_acpi_device_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);