aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-11-03 17:39:57 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-11-04 15:58:24 -0500
commite36d453e98c57dda0f8ba68585676ac4ba36631e (patch)
treeee07de9e62c83b1c00dee07f7d953a2695659795
parent72daceb9a10af4614d4aee304f07904191962f07 (diff)
ACPI / GPIO: Document ACPI GPIO mappings API
Document the previously introduced method that can be used by device drivers to provide the GPIO subsystem with mappings between GPIO names (connection IDs) and GpioIo()/GpioInt() resources in _CRS. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r--Documentation/acpi/gpio-properties.txt44
-rw-r--r--Documentation/gpio/consumer.txt18
2 files changed, 62 insertions, 0 deletions
diff --git a/Documentation/acpi/gpio-properties.txt b/Documentation/acpi/gpio-properties.txt
index 3e45b8b7e4f2..ae36fcf86dc7 100644
--- a/Documentation/acpi/gpio-properties.txt
+++ b/Documentation/acpi/gpio-properties.txt
@@ -50,3 +50,47 @@ it to 1 marks the GPIO as active low.
50 50
51In our Bluetooth example the "reset-gpio" refers to the second GpioIo() 51In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
52resource, second pin in that resource with the GPIO number of 31. 52resource, second pin in that resource with the GPIO number of 31.
53
54ACPI GPIO Mappings Provided by Drivers
55--------------------------------------
56
57There are systems in which the ACPI tables do not contain _DSD but provide _CRS
58with GpioIo()/GpioInt() resources and device drivers still need to work with
59them.
60
61In those cases ACPI device identification objects, _HID, _CID, _CLS, _SUB, _HRV,
62available to the driver can be used to identify the device and that is supposed
63to be sufficient to determine the meaning and purpose of all of the GPIO lines
64listed by the GpioIo()/GpioInt() resources returned by _CRS. In other words,
65the driver is supposed to know what to use the GpioIo()/GpioInt() resources for
66once it has identified the device. Having done that, it can simply assign names
67to the GPIO lines it is going to use and provide the GPIO subsystem with a
68mapping between those names and the ACPI GPIO resources corresponding to them.
69
70To do that, the driver needs to define a mapping table as a NULL-terminated
71array of struct acpi_gpio_mapping objects that each contain a name, a pointer
72to an array of line data (struct acpi_gpio_params) objects and the size of that
73array. Each struct acpi_gpio_params object consists of three fields,
74crs_entry_index, line_index, active_low, representing the index of the target
75GpioIo()/GpioInt() resource in _CRS starting from zero, the index of the target
76line in that resource starting from zero, and the active-low flag for that line,
77respectively, in analogy with the _DSD GPIO property format specified above.
78
79For the example Bluetooth device discussed previously the data structures in
80question would look like this:
81
82static const struct acpi_gpio_params reset_gpio = { 1, 1, false };
83static const struct acpi_gpio_params shutdown_gpio = { 0, 0, false };
84
85static const struct acpi_gpio_mapping bluetooth_acpi_gpios[] = {
86 { "reset-gpio", &reset_gpio, 1 },
87 { "shutdown-gpio", &shutdown_gpio, 1 },
88 { },
89};
90
91Next, the mapping table needs to be passed as the second argument to
92acpi_dev_add_driver_gpios() that will register it with the ACPI device object
93pointed to by its first argument. That should be done in the driver's .probe()
94routine. On removal, the driver should unregister its GPIO mapping table by
95calling acpi_dev_remove_driver_gpios() on the ACPI device object where that
96table was previously registered.
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt
index 6ce544191ca6..859918db36b8 100644
--- a/Documentation/gpio/consumer.txt
+++ b/Documentation/gpio/consumer.txt
@@ -219,6 +219,24 @@ part of the IRQ interface, e.g. IRQF_TRIGGER_FALLING, as are system wakeup
219capabilities. 219capabilities.
220 220
221 221
222GPIOs and ACPI
223==============
224
225On ACPI systems, GPIOs are described by GpioIo()/GpioInt() resources listed by
226the _CRS configuration objects of devices. Those resources do not provide
227connection IDs (names) for GPIOs, so it is necessary to use an additional
228mechanism for this purpose.
229
230Systems compliant with ACPI 5.1 or newer may provide a _DSD configuration object
231which, among other things, may be used to provide connection IDs for specific
232GPIOs described by the GpioIo()/GpioInt() resources in _CRS. If that is the
233case, it will be handled by the GPIO subsystem automatically. However, if the
234_DSD is not present, the mappings between GpioIo()/GpioInt() resources and GPIO
235connection IDs need to be provided by device drivers.
236
237For details refer to Documentation/acpi/gpio-properties.txt
238
239
222Interacting With the Legacy GPIO Subsystem 240Interacting With the Legacy GPIO Subsystem
223========================================== 241==========================================
224Many kernel subsystems still handle GPIOs using the legacy integer-based 242Many kernel subsystems still handle GPIOs using the legacy integer-based