summaryrefslogtreecommitdiff
path: root/include/acpi/acpi_device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/acpi/acpi_device.h')
-rw-r--r--include/acpi/acpi_device.h93
1 files changed, 92 insertions, 1 deletions
diff --git a/include/acpi/acpi_device.h b/include/acpi/acpi_device.h
index 11461e168d..ed4acd912a 100644
--- a/include/acpi/acpi_device.h
+++ b/include/acpi/acpi_device.h
@@ -10,7 +10,9 @@
#define __ACPI_DEVICE_H
#include <i2c.h>
+#include <irq.h>
#include <spi.h>
+#include <asm-generic/gpio.h>
#include <linux/bitops.h>
struct acpi_ctx;
@@ -28,6 +30,9 @@ struct udevice;
/* Length of a full path to an ACPI device */
#define ACPI_PATH_MAX 30
+/* UUID for an I2C _DSM method */
+#define ACPI_DSM_I2C_HID_UUID "3cdff6f7-4267-4555-ad05-b30a3d8938de"
+
/* Values that can be returned for ACPI device _STA method */
enum acpi_dev_status {
ACPI_DSTATUS_PRESENT = BIT(0),
@@ -165,6 +170,28 @@ enum acpi_gpio_polarity {
* @io_shared; true if GPIO is shared
* @io_restrict: I/O restriction setting
* @polarity: GPIO polarity
+ *
+ * Note that GpioIo doesn't have any means of Active Low / High setting, so a
+ * _DSD must be provided to mitigate this.
+ *
+ * GpioIo doesn't properly communicate the initial state of the output pin,
+ * thus Linux assumes the simple rule:
+ *
+ * Pull Bias Polarity Requested...
+ *
+ * Implicit x AS IS (assumed firmware configured for us)
+ * Explicit x (no _DSD) as Pull Bias (Up == High, Down == Low),
+ * assuming non-active (Polarity = !Pull Bias)
+ *
+ * Down Low as low, assuming active
+ * Down High as high, assuming non-active
+ * Up Low as high, assuming non-active
+ * Up High as high, assuming active
+ *
+ * GpioIo() can be used as interrupt and in this case the IoRestriction mustn't
+ * be OutputOnly. It also requires active_low flag from _DSD in cases where it's
+ * needed (better to always provide than rely on above assumption made on OS
+ * level).
*/
struct acpi_gpio {
int pin_count;
@@ -233,6 +260,59 @@ struct acpi_spi {
};
/**
+ * struct acpi_i2c_priv - Information read from device tree
+ *
+ * This is used by devices which want to specify various pieces of ACPI
+ * information, including power control. It allows a generic function to
+ * generate the information for ACPI, based on device-tree properties.
+ *
+ * @disable_gpio_export_in_crs: Don't export GPIOs in the CRS
+ * @reset_gpio: GPIO used to assert reset to the device
+ * @enable_gpio: GPIO used to enable the device
+ * @stop_gpio: GPIO used to stop the device
+ * @irq_gpio: GPIO used for interrupt (if @irq is not used)
+ * @irq: IRQ used for interrupt (if @irq_gpio is not used)
+ * @hid: _HID value for device (required)
+ * @uid: _UID value for device
+ * @desc: _DDN value for device
+ * @wake: Wake event, e.g. GPE0_DW1_15; 0 if none
+ * @property_count: Number of other DSD properties (currently always 0)
+ * @probed: true set set 'linux,probed' property
+ * @compat_string: Device tree compatible string to report through ACPI
+ * @has_power_resource: true if this device has a power resource
+ * @reset_delay_ms: Delay after de-asserting reset, in ms
+ * @reset_off_delay_ms: Delay after asserting reset (during power off)
+ * @enable_delay_ms: Delay after asserting enable
+ * @enable_off_delay_ms: Delay after de-asserting enable (during power off)
+ * @stop_delay_ms: Delay after de-aserting stop
+ * @stop_off_delay_ms: Delay after asserting stop (during power off)
+ * @hid_desc_reg_offset: HID register offset (for Human Interface Devices)
+ */
+struct acpi_i2c_priv {
+ bool disable_gpio_export_in_crs;
+ struct gpio_desc reset_gpio;
+ struct gpio_desc enable_gpio;
+ struct gpio_desc irq_gpio;
+ struct gpio_desc stop_gpio;
+ struct irq irq;
+ const char *hid;
+ u32 uid;
+ const char *desc;
+ u32 wake;
+ u32 property_count;
+ bool probed;
+ const char *compat_string;
+ bool has_power_resource;
+ u32 reset_delay_ms;
+ u32 reset_off_delay_ms;
+ u32 enable_delay_ms;
+ u32 enable_off_delay_ms;
+ u32 stop_delay_ms;
+ u32 stop_off_delay_ms;
+ u32 hid_desc_reg_offset;
+};
+
+/**
* acpi_device_path() - Get the full path to an ACPI device
*
* This gets the full path in the form XXXX.YYYY.ZZZZ where XXXX is the root
@@ -320,9 +400,20 @@ int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx,
struct udevice *dev, const char *prop);
/**
+ * acpi_device_write_dsm_i2c_hid() - Write a device-specific method for HID
+ *
+ * This writes a DSM for an I2C Human-Interface Device based on the config
+ * provided
+ *
+ * @hid_desc_reg_offset: HID register offset
+ */
+int acpi_device_write_dsm_i2c_hid(struct acpi_ctx *ctx,
+ int hid_desc_reg_offset);
+
+/**
* acpi_device_write_i2c_dev() - Write an I2C device to ACPI
*
- * This creates a I2cSerialBus descriptor for an I2C device, including
+ * This creates a I2cSerialBusV2 descriptor for an I2C device, including
* information ACPI needs to use it.
*
* @ctx: ACPI context pointer