gpio / ACPI: Add support for _DSD device properties
With release of ACPI 5.1 and _DSD method we can finally name GPIOs (and
other things as well) returned by _CRS. Previously we were only able to
use integer index to find the corresponding GPIO, which is pretty error
prone if the order changes.
With _DSD we can now query GPIOs using name instead of an integer index,
like the below example shows:
// Bluetooth device with reset and shutdown GPIOs
Device (BTH)
{
Name (_HID, ...)
Name (_CRS, ResourceTemplate ()
{
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {15}
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
})
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"reset-gpio", Package() {^BTH, 1, 1, 0 }},
Package () {"shutdown-gpio", Package() {^BTH, 0, 0, 0 }},
}
})
}
The format of the supported GPIO property is:
Package () { "name", Package () { ref, index, pin, active_low }}
ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
typically this is the device itself (BTH in our case).
index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
active_low - If 1 the GPIO is marked as active_low.
Since ACPI GpioIo() resource does not have field saying whether it is
active low or high, the "active_low" argument can be used here. Setting
it to 1 marks the GPIO as active low.
In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
resource, second pin in that resource with the GPIO number of 31.
This patch implements necessary support to gpiolib for extracting GPIOs
using _DSD device properties.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-10-29 22:41:01 +08:00
|
|
|
_DSD Device Properties Related to GPIO
|
|
|
|
--------------------------------------
|
|
|
|
|
2015-05-04 07:58:27 +08:00
|
|
|
With the release of ACPI 5.1, the _DSD configuration object finally
|
|
|
|
allows names to be given to GPIOs (and other things as well) returned
|
|
|
|
by _CRS. Previously, we were only able to use an integer index to find
|
gpio / ACPI: Add support for _DSD device properties
With release of ACPI 5.1 and _DSD method we can finally name GPIOs (and
other things as well) returned by _CRS. Previously we were only able to
use integer index to find the corresponding GPIO, which is pretty error
prone if the order changes.
With _DSD we can now query GPIOs using name instead of an integer index,
like the below example shows:
// Bluetooth device with reset and shutdown GPIOs
Device (BTH)
{
Name (_HID, ...)
Name (_CRS, ResourceTemplate ()
{
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {15}
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
})
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"reset-gpio", Package() {^BTH, 1, 1, 0 }},
Package () {"shutdown-gpio", Package() {^BTH, 0, 0, 0 }},
}
})
}
The format of the supported GPIO property is:
Package () { "name", Package () { ref, index, pin, active_low }}
ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
typically this is the device itself (BTH in our case).
index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
active_low - If 1 the GPIO is marked as active_low.
Since ACPI GpioIo() resource does not have field saying whether it is
active low or high, the "active_low" argument can be used here. Setting
it to 1 marks the GPIO as active low.
In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
resource, second pin in that resource with the GPIO number of 31.
This patch implements necessary support to gpiolib for extracting GPIOs
using _DSD device properties.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-10-29 22:41:01 +08:00
|
|
|
the corresponding GPIO, which is pretty error prone (it depends on
|
|
|
|
the _CRS output ordering, for example).
|
|
|
|
|
|
|
|
With _DSD we can now query GPIOs using a name instead of an integer
|
|
|
|
index, like the ASL example below shows:
|
|
|
|
|
|
|
|
// Bluetooth device with reset and shutdown GPIOs
|
|
|
|
Device (BTH)
|
|
|
|
{
|
|
|
|
Name (_HID, ...)
|
|
|
|
|
|
|
|
Name (_CRS, ResourceTemplate ()
|
|
|
|
{
|
|
|
|
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
|
|
|
|
"\\_SB.GPO0", 0, ResourceConsumer) {15}
|
|
|
|
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
|
|
|
|
"\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
|
|
|
|
})
|
|
|
|
|
|
|
|
Name (_DSD, Package ()
|
|
|
|
{
|
|
|
|
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
|
|
|
|
Package ()
|
|
|
|
{
|
2016-09-23 22:57:06 +08:00
|
|
|
Package () {"reset-gpios", Package() {^BTH, 1, 1, 0 }},
|
|
|
|
Package () {"shutdown-gpios", Package() {^BTH, 0, 0, 0 }},
|
gpio / ACPI: Add support for _DSD device properties
With release of ACPI 5.1 and _DSD method we can finally name GPIOs (and
other things as well) returned by _CRS. Previously we were only able to
use integer index to find the corresponding GPIO, which is pretty error
prone if the order changes.
With _DSD we can now query GPIOs using name instead of an integer index,
like the below example shows:
// Bluetooth device with reset and shutdown GPIOs
Device (BTH)
{
Name (_HID, ...)
Name (_CRS, ResourceTemplate ()
{
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {15}
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
})
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"reset-gpio", Package() {^BTH, 1, 1, 0 }},
Package () {"shutdown-gpio", Package() {^BTH, 0, 0, 0 }},
}
})
}
The format of the supported GPIO property is:
Package () { "name", Package () { ref, index, pin, active_low }}
ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
typically this is the device itself (BTH in our case).
index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
active_low - If 1 the GPIO is marked as active_low.
Since ACPI GpioIo() resource does not have field saying whether it is
active low or high, the "active_low" argument can be used here. Setting
it to 1 marks the GPIO as active low.
In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
resource, second pin in that resource with the GPIO number of 31.
This patch implements necessary support to gpiolib for extracting GPIOs
using _DSD device properties.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-10-29 22:41:01 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
The format of the supported GPIO property is:
|
|
|
|
|
|
|
|
Package () { "name", Package () { ref, index, pin, active_low }}
|
|
|
|
|
|
|
|
ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
|
|
|
|
typically this is the device itself (BTH in our case).
|
|
|
|
index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
|
|
|
|
pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
|
|
|
|
active_low - If 1 the GPIO is marked as active_low.
|
|
|
|
|
|
|
|
Since ACPI GpioIo() resource does not have a field saying whether it is
|
|
|
|
active low or high, the "active_low" argument can be used here. Setting
|
|
|
|
it to 1 marks the GPIO as active low.
|
|
|
|
|
2016-09-23 22:57:06 +08:00
|
|
|
In our Bluetooth example the "reset-gpios" refers to the second GpioIo()
|
gpio / ACPI: Add support for _DSD device properties
With release of ACPI 5.1 and _DSD method we can finally name GPIOs (and
other things as well) returned by _CRS. Previously we were only able to
use integer index to find the corresponding GPIO, which is pretty error
prone if the order changes.
With _DSD we can now query GPIOs using name instead of an integer index,
like the below example shows:
// Bluetooth device with reset and shutdown GPIOs
Device (BTH)
{
Name (_HID, ...)
Name (_CRS, ResourceTemplate ()
{
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {15}
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
"\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
})
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"reset-gpio", Package() {^BTH, 1, 1, 0 }},
Package () {"shutdown-gpio", Package() {^BTH, 0, 0, 0 }},
}
})
}
The format of the supported GPIO property is:
Package () { "name", Package () { ref, index, pin, active_low }}
ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
typically this is the device itself (BTH in our case).
index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
active_low - If 1 the GPIO is marked as active_low.
Since ACPI GpioIo() resource does not have field saying whether it is
active low or high, the "active_low" argument can be used here. Setting
it to 1 marks the GPIO as active low.
In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
resource, second pin in that resource with the GPIO number of 31.
This patch implements necessary support to gpiolib for extracting GPIOs
using _DSD device properties.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-10-29 22:41:01 +08:00
|
|
|
resource, second pin in that resource with the GPIO number of 31.
|
2014-11-04 06:39:57 +08:00
|
|
|
|
2016-10-21 22:21:29 +08:00
|
|
|
It is possible to leave holes in the array of GPIOs. This is useful in
|
|
|
|
cases like with SPI host controllers where some chip selects may be
|
|
|
|
implemented as GPIOs and some as native signals. For example a SPI host
|
|
|
|
controller can have chip selects 0 and 2 implemented as GPIOs and 1 as
|
|
|
|
native:
|
|
|
|
|
|
|
|
Package () {
|
|
|
|
"cs-gpios",
|
|
|
|
Package () {
|
|
|
|
^GPIO, 19, 0, 0, // chip select 0: GPIO
|
|
|
|
0, // chip select 1: native signal
|
|
|
|
^GPIO, 20, 0, 0, // chip select 2: GPIO
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-21 22:21:30 +08:00
|
|
|
Other supported properties
|
|
|
|
--------------------------
|
|
|
|
|
|
|
|
Following Device Tree compatible device properties are also supported by
|
|
|
|
_DSD device properties for GPIO controllers:
|
|
|
|
|
|
|
|
- gpio-hog
|
|
|
|
- output-high
|
|
|
|
- output-low
|
|
|
|
- input
|
|
|
|
- line-name
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Name (_DSD, Package () {
|
|
|
|
// _DSD Hierarchical Properties Extension UUID
|
|
|
|
ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
|
|
|
|
Package () {
|
|
|
|
Package () {"hog-gpio8", "G8PU"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
Name (G8PU, Package () {
|
|
|
|
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
|
|
|
|
Package () {
|
|
|
|
Package () {"gpio-hog", 1},
|
|
|
|
Package () {"gpios", Package () {8, 0}},
|
|
|
|
Package () {"output-high", 1},
|
|
|
|
Package () {"line-name", "gpio8-pullup"},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-10-21 22:21:32 +08:00
|
|
|
- gpio-line-names
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Package () {
|
|
|
|
"gpio-line-names",
|
|
|
|
Package () {
|
|
|
|
"SPI0_CS_N", "EXP2_INT", "MUX6_IO", "UART0_RXD", "MUX7_IO",
|
|
|
|
"LVL_C_A1", "MUX0_IO", "SPI1_MISO"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-21 22:21:30 +08:00
|
|
|
See Documentation/devicetree/bindings/gpio/gpio.txt for more information
|
|
|
|
about these properties.
|
|
|
|
|
2014-11-04 06:39:57 +08:00
|
|
|
ACPI GPIO Mappings Provided by Drivers
|
|
|
|
--------------------------------------
|
|
|
|
|
|
|
|
There are systems in which the ACPI tables do not contain _DSD but provide _CRS
|
|
|
|
with GpioIo()/GpioInt() resources and device drivers still need to work with
|
|
|
|
them.
|
|
|
|
|
|
|
|
In those cases ACPI device identification objects, _HID, _CID, _CLS, _SUB, _HRV,
|
|
|
|
available to the driver can be used to identify the device and that is supposed
|
|
|
|
to be sufficient to determine the meaning and purpose of all of the GPIO lines
|
|
|
|
listed by the GpioIo()/GpioInt() resources returned by _CRS. In other words,
|
|
|
|
the driver is supposed to know what to use the GpioIo()/GpioInt() resources for
|
|
|
|
once it has identified the device. Having done that, it can simply assign names
|
|
|
|
to the GPIO lines it is going to use and provide the GPIO subsystem with a
|
|
|
|
mapping between those names and the ACPI GPIO resources corresponding to them.
|
|
|
|
|
|
|
|
To do that, the driver needs to define a mapping table as a NULL-terminated
|
|
|
|
array of struct acpi_gpio_mapping objects that each contain a name, a pointer
|
|
|
|
to an array of line data (struct acpi_gpio_params) objects and the size of that
|
|
|
|
array. Each struct acpi_gpio_params object consists of three fields,
|
|
|
|
crs_entry_index, line_index, active_low, representing the index of the target
|
|
|
|
GpioIo()/GpioInt() resource in _CRS starting from zero, the index of the target
|
|
|
|
line in that resource starting from zero, and the active-low flag for that line,
|
|
|
|
respectively, in analogy with the _DSD GPIO property format specified above.
|
|
|
|
|
|
|
|
For the example Bluetooth device discussed previously the data structures in
|
|
|
|
question would look like this:
|
|
|
|
|
|
|
|
static const struct acpi_gpio_params reset_gpio = { 1, 1, false };
|
|
|
|
static const struct acpi_gpio_params shutdown_gpio = { 0, 0, false };
|
|
|
|
|
|
|
|
static const struct acpi_gpio_mapping bluetooth_acpi_gpios[] = {
|
2016-09-23 22:57:06 +08:00
|
|
|
{ "reset-gpios", &reset_gpio, 1 },
|
|
|
|
{ "shutdown-gpios", &shutdown_gpio, 1 },
|
2014-11-04 06:39:57 +08:00
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
|
|
|
Next, the mapping table needs to be passed as the second argument to
|
|
|
|
acpi_dev_add_driver_gpios() that will register it with the ACPI device object
|
|
|
|
pointed to by its first argument. That should be done in the driver's .probe()
|
|
|
|
routine. On removal, the driver should unregister its GPIO mapping table by
|
|
|
|
calling acpi_dev_remove_driver_gpios() on the ACPI device object where that
|
|
|
|
table was previously registered.
|