sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget7/translations/zh_CN/firmware-guide/acpi/gpio-propertiesmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/zh_TW/firmware-guide/acpi/gpio-propertiesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/it_IT/firmware-guide/acpi/gpio-propertiesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/ja_JP/firmware-guide/acpi/gpio-propertiesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/ko_KR/firmware-guide/acpi/gpio-propertiesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/sp_SP/firmware-guide/acpi/gpio-propertiesmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhQ/var/lib/git/docbuild/linux/Documentation/firmware-guide/acpi/gpio-properties.rsthKubhsection)}(hhh](htitle)}(h&_DSD Device Properties Related to GPIOh]h&_DSD Device Properties Related to GPIO}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hX<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 the corresponding GPIO, which is pretty error prone (it depends on the _CRS output ordering, for example).h]hX<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 the corresponding GPIO, which is pretty error prone (it depends on the _CRS output ordering, for example).}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hmWith _DSD we can now query GPIOs using a name instead of an integer index, like the ASL example below shows::h]hlWith _DSD we can now query GPIOs using a name instead of an integer index, like the ASL example below shows:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh literal_block)}(hX// Bluetooth device with reset and shutdown GPIOs Device (BTH) { Name (_HID, ...) Name (_CRS, ResourceTemplate () { GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly, "\\_SB.GPO0", 0, ResourceConsumer) { 15 } GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly, "\\_SB.GPO0", 0, ResourceConsumer) { 27, 31 } }) Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () { "reset-gpios", Package () { ^BTH, 1, 1, 0 } }, Package () { "shutdown-gpios", Package () { ^BTH, 0, 0, 0 } }, } }) }h]hX// Bluetooth device with reset and shutdown GPIOs Device (BTH) { Name (_HID, ...) Name (_CRS, ResourceTemplate () { GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly, "\\_SB.GPO0", 0, ResourceConsumer) { 15 } GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly, "\\_SB.GPO0", 0, ResourceConsumer) { 27, 31 } }) Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () { "reset-gpios", Package () { ^BTH, 1, 1, 0 } }, Package () { "shutdown-gpios", Package () { ^BTH, 0, 0, 0 } }, } }) }}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhhhhubh)}(h.The format of the supported GPIO property is::h]h-The format of the supported GPIO property is:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hhhhubh)}(h@Package () { "name", Package () { ref, index, pin, active_low }}h]h@Package () { "name", Package () { ref, index, pin, active_low }}}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhK*hhhhubhdefinition_list)}(hhh](hdefinition_list_item)}(h|ref The device that has _CRS containing GpioIo()/GpioInt() resources, typically this is the device itself (BTH in our case).h](hterm)}(hrefh]href}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK-hjubh definition)}(hhh]h)}(hxThe device that has _CRS containing GpioIo()/GpioInt() resources, typically this is the device itself (BTH in our case).h]hxThe device that has _CRS containing GpioIo()/GpioInt() resources, typically this is the device itself (BTH in our case).}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hj0ubah}(h]h ]h"]h$]h&]uh1j.hjubeh}(h]h ]h"]h$]h&]uh1jhhhK-hjubj)}(hJindex Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.h](j)}(hindexh]hindex}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK/hjMubj/)}(hhh]h)}(hDIndex of the GpioIo()/GpioInt() resource in _CRS starting from zero.h]hDIndex of the GpioIo()/GpioInt() resource in _CRS starting from zero.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hj_ubah}(h]h ]h"]h$]h&]uh1j.hjMubeh}(h]h ]h"]h$]h&]uh1jhhhK/hjhhubj)}(hCpin Pin in the GpioIo()/GpioInt() resource. Typically this is zero.h](j)}(hpinh]hpin}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK1hj|ubj/)}(hhh]h)}(h?Pin in the GpioIo()/GpioInt() resource. Typically this is zero.h]h?Pin in the GpioIo()/GpioInt() resource. Typically this is zero.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjubah}(h]h ]h"]h$]h&]uh1j.hj|ubeh}(h]h ]h"]h$]h&]uh1jhhhK1hjhhubj)}(h3active_low If 1, the GPIO is marked as active_low. h](j)}(h active_lowh]h active_low}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK4hjubj/)}(hhh]h)}(h'If 1, the GPIO is marked as active_low.h]h'If 1, the GPIO is marked as active_low.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK4hjubah}(h]h ]h"]h$]h&]uh1j.hjubeh}(h]h ]h"]h$]h&]uh1jhhhK4hjhhubeh}(h]h ]h"]h$]h&]uh1jhhhhhhhNubh)}(hSince 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.h]hSince 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hhhhubh)}(hNote, active_low in _DSD does not make sense for GpioInt() resource and must be 0. GpioInt() resource has its own means of defining it.h]hNote, active_low in _DSD does not make sense for GpioInt() resource and must be 0. GpioInt() resource has its own means of defining it.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:hhhhubh)}(hIn our Bluetooth example the "reset-gpios" refers to the second GpioIo() resource, second pin in that resource with the GPIO number of 31.h]hIn our Bluetooth example the “reset-gpios” refers to the second GpioIo() resource, second pin in that resource with the GPIO number of 31.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK=hhhhubh)}(hThe GpioIo() resource unfortunately doesn't explicitly provide an initial state of the output pin which driver should use during its initialization.h]hThe GpioIo() resource unfortunately doesn’t explicitly provide an initial state of the output pin which driver should use during its initialization.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hhhhubh)}(hLinux tries to use common sense here and derives the state from the bias and polarity settings. The table below shows the expectations:h]hLinux tries to use common sense here and derives the state from the bias and polarity settings. The table below shows the expectations:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKChhhhubhtable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthK uh1j0hj-ubj1)}(hhh]h}(h]h ]h"]h$]h&]colwidthK uh1j0hj-ubj1)}(hhh]h}(h]h ]h"]h$]h&]colwidthK/uh1j0hj-ubhthead)}(hhh]hrow)}(hhh](hentry)}(hhh]h)}(h Pull Biash]h Pull Bias}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhj\ubah}(h]h ]h"]h$]h&]uh1jZhjWubj[)}(hhh]h)}(hPolarityh]hPolarity}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjsubah}(h]h ]h"]h$]h&]uh1jZhjWubj[)}(hhh]h)}(h Requested...h]h Requested...}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjubah}(h]h ]h"]h$]h&]uh1jZhjWubeh}(h]h ]h"]h$]h&]uh1jUhjRubah}(h]h ]h"]h$]h&]uh1jPhj-ubhtbody)}(hhh](jV)}(hhh]j[)}(hhh]h)}(hImplicith]hImplicit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhjubah}(h]h ]h"]h$]h&]morecolsKuh1jZhjubah}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh](j[)}(hhh]h)}(h **Default**h]hstrong)}(hjh]hDefault}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKKhjubah}(h]h ]h"]h$]h&]uh1jZhjubj[)}(hhh]h)}(hxh]hx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjubah}(h]h ]h"]h$]h&]uh1jZhjubj[)}(hhh]h)}(h-AS IS (assumed firmware configured it for us)h]h-AS IS (assumed firmware configured it for us)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjubah}(h]h ]h"]h$]h&]uh1jZhjubeh}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh]j[)}(hhh]h)}(hExplicith]hExplicit}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhj/ubah}(h]h ]h"]h$]h&]morecolsKuh1jZhj,ubah}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh](j[)}(hhh]h)}(h**None**h]j)}(hjUh]hNone}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjSubah}(h]h ]h"]h$]h&]uh1hhhhKOhjPubah}(h]h ]h"]h$]h&]uh1jZhjMubj[)}(hhh]h)}(hjh]hx}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjpubah}(h]h ]h"]h$]h&]uh1jZhjMubj[)}(hhh]h)}(h?AS IS (assumed firmware configured it for us) with no Pull Biash]h?AS IS (assumed firmware configured it for us) with no Pull Bias}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjubah}(h]h ]h"]h$]h&]uh1jZhjMubeh}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh](j[)}(hhh]h)}(h**Up**h]j)}(hjh]hUp}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKRhjubah}(h]h ]h"]h$]h&]morerowsKuh1jZhjubj[)}(hhh]h)}(h x (no _DSD)h]h x (no _DSD)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhjubah}(h]h ]h"]h$]h&]uh1jZhjubj[)}(hhh]h)}(has high, assuming non-activeh]has high, assuming non-active}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKShjubah}(h]h ]h"]h$]h&]morerowsKuh1jZhjubeh}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh]j[)}(hhh]h)}(hLowh]hLow}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKThjubah}(h]h ]h"]h$]h&]uh1jZhjubah}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh](j[)}(hhh]h)}(hHighh]hHigh}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhjubah}(h]h ]h"]h$]h&]uh1jZhjubj[)}(hhh]h)}(has high, assuming activeh]has high, assuming active}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhj6ubah}(h]h ]h"]h$]h&]uh1jZhjubeh}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh](j[)}(hhh]h)}(h**Down**h]j)}(hj[h]hDown}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjYubah}(h]h ]h"]h$]h&]uh1hhhhKXhjVubah}(h]h ]h"]h$]h&]morerowsKuh1jZhjSubj[)}(hhh]h)}(h x (no _DSD)h]h x (no _DSD)}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjwubah}(h]h ]h"]h$]h&]uh1jZhjSubj[)}(hhh]h)}(has low, assuming non-activeh]has low, assuming non-active}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubah}(h]h ]h"]h$]h&]morerowsKuh1jZhjSubeh}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh]j[)}(hhh]h)}(hHighh]hHigh}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhjubah}(h]h ]h"]h$]h&]uh1jZhjubah}(h]h ]h"]h$]h&]uh1jUhjubjV)}(hhh](j[)}(hhh]h)}(hLowh]hLow}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jZhjubj[)}(hhh]h)}(has low, assuming activeh]has low, assuming active}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jZhjubeh}(h]h ]h"]h$]h&]uh1jUhjubeh}(h]h ]h"]h$]h&]uh1jhj-ubeh}(h]h ]h"]h$]h&]colsKuh1j+hj(ubah}(h]h ]h"]h$]h&]uh1j&hhhhhhhNubh)}(hThat said, for our above example the both GPIOs, since the bias setting is explicit and _DSD is present, will be treated as active with a high polarity and Linux will configure the pins in this state until a driver reprograms them differently.h]hThat said, for our above example the both GPIOs, since the bias setting is explicit and _DSD is present, will be treated as active with a high polarity and Linux will configure the pins in this state until a driver reprograms them differently.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hhhhubh)}(hX"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::h]hX!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:}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhhhhubh)}(hPackage () { "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 } }h]hPackage () { "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 } }}hj2sbah}(h]h ]h"]h$]h&]hhuh1hhhhKjhhhhubh)}(hXhNote, that historically ACPI has no means of the GPIO polarity and thus the SPISerialBus() resource defines it on the per-chip basis. In order to avoid a chain of negations, the GPIO polarity is considered being Active High. Even for the cases when _DSD() is involved (see the example above) the GPIO CS polarity must be defined Active High to avoid ambiguity.h]hXhNote, that historically ACPI has no means of the GPIO polarity and thus the SPISerialBus() resource defines it on the per-chip basis. In order to avoid a chain of negations, the GPIO polarity is considered being Active High. Even for the cases when _DSD() is involved (see the example above) the GPIO CS polarity must be defined Active High to avoid ambiguity.}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKshhhhubh)}(hhh](h)}(hOther supported propertiesh]hOther supported properties}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjNhhhhhKzubh)}(huFollowing Device Tree compatible device properties are also supported by _DSD device properties for GPIO controllers:h]huFollowing Device Tree compatible device properties are also supported by _DSD device properties for GPIO controllers:}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK|hjNhhubh bullet_list)}(hhh](h list_item)}(hgpio-hogh]h)}(hjvh]hgpio-hog}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjtubah}(h]h ]h"]h$]h&]uh1jrhjohhhhhNubjs)}(h output-highh]h)}(hjh]h output-high}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhhhNubjs)}(h output-lowh]h)}(hjh]h output-low}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhhhNubjs)}(hinputh]h)}(hjh]hinput}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhhhNubjs)}(h line-name h]h)}(h line-nameh]h line-name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjohhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jmhhhKhjNhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjNhhubh)}(hXName (_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" }, } })h]hXName (_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" }, } })}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjNhhubjn)}(hhh]js)}(hgpio-line-names h]h)}(hgpio-line-namesh]hgpio-line-names}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhj hhhhhNubah}(h]h ]h"]h$]h&]jjuh1jmhhhKhjNhhubh)}(hX`The ``gpio-line-names`` declaration is a list of strings ("names"), which describes each line/pin of a GPIO controller/expander. This list, contained in a package, must be inserted inside the GPIO controller declaration of an ACPI table (typically inside the DSDT). The ``gpio-line-names`` list must respect the following rules (see also the examples):h](hThe }(hj-hhhNhNubhliteral)}(h``gpio-line-names``h]hgpio-line-names}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1j5hj-ubh declaration is a list of strings (“names”), which describes each line/pin of a GPIO controller/expander. This list, contained in a package, must be inserted inside the GPIO controller declaration of an ACPI table (typically inside the DSDT). The }(hj-hhhNhNubj6)}(h``gpio-line-names``h]hgpio-line-names}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1j5hj-ubh? list must respect the following rules (see also the examples):}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjNhhubh block_quote)}(hX- the first name in the list corresponds with the first line/pin of the GPIO controller/expander - the names inside the list must be consecutive (no "holes" are permitted) - the list can be incomplete and can end before the last GPIO line: in other words, it is not mandatory to fill all the GPIO lines - empty names are allowed (two quotation marks ``""`` correspond to an empty name) - names inside one GPIO controller/expander must be unique h]jn)}(hhh](js)}(h^the first name in the list corresponds with the first line/pin of the GPIO controller/expanderh]h)}(h^the first name in the list corresponds with the first line/pin of the GPIO controller/expanderh]h^the first name in the list corresponds with the first line/pin of the GPIO controller/expander}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjjubah}(h]h ]h"]h$]h&]uh1jrhjgubjs)}(hHthe names inside the list must be consecutive (no "holes" are permitted)h]h)}(hjh]hLthe names inside the list must be consecutive (no “holes” are permitted)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjgubjs)}(hthe list can be incomplete and can end before the last GPIO line: in other words, it is not mandatory to fill all the GPIO linesh]h)}(hthe list can be incomplete and can end before the last GPIO line: in other words, it is not mandatory to fill all the GPIO linesh]hthe list can be incomplete and can end before the last GPIO line: in other words, it is not mandatory to fill all the GPIO lines}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjgubjs)}(hPempty names are allowed (two quotation marks ``""`` correspond to an empty name)h]h)}(hPempty names are allowed (two quotation marks ``""`` correspond to an empty name)h](h-empty names are allowed (two quotation marks }(hjhhhNhNubj6)}(h``""``h]h""}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j5hjubh correspond to an empty name)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjgubjs)}(h9names inside one GPIO controller/expander must be unique h]h)}(h8names inside one GPIO controller/expander must be uniqueh]h8names inside one GPIO controller/expander must be unique}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jrhjgubeh}(h]h ]h"]h$]h&]jjuh1jmhhhKhjcubah}(h]h ]h"]h$]h&]uh1jahhhKhjNhhubh)}(hXExample of a GPIO controller of 16 lines, with an incomplete list with two empty names::h]hWExample of a GPIO controller of 16 lines, with an incomplete list with two empty names:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjNhhubh)}(hPackage () { "gpio-line-names", Package () { "pin_0", "pin_1", "", "", "pin_3", "pin_4_push_button", } }h]hPackage () { "gpio-line-names", Package () { "pin_0", "pin_1", "", "", "pin_3", "pin_4_push_button", } }}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjNhhubh)}(h^At runtime, the above declaration produces the following result (using the "libgpiod" tools)::h]haAt runtime, the above declaration produces the following result (using the “libgpiod” tools):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjNhhubh)}(hXroot@debian:~# gpioinfo gpiochip4 gpiochip4 - 16 lines: line 0: "pin_0" unused input active-high line 1: "pin_1" unused input active-high line 2: unnamed unused input active-high line 3: unnamed unused input active-high line 4: "pin_3" unused input active-high line 5: "pin_4_push_button" unused input active-high line 6: unnamed unused input active-high line 7 unnamed unused input active-high line 8: unnamed unused input active-high line 9: unnamed unused input active-high line 10: unnamed unused input active-high line 11: unnamed unused input active-high line 12: unnamed unused input active-high line 13: unnamed unused input active-high line 14: unnamed unused input active-high line 15: unnamed unused input active-high root@debian:~# gpiofind pin_4_push_button gpiochip4 5 root@debian:~#h]hXroot@debian:~# gpioinfo gpiochip4 gpiochip4 - 16 lines: line 0: "pin_0" unused input active-high line 1: "pin_1" unused input active-high line 2: unnamed unused input active-high line 3: unnamed unused input active-high line 4: "pin_3" unused input active-high line 5: "pin_4_push_button" unused input active-high line 6: unnamed unused input active-high line 7 unnamed unused input active-high line 8: unnamed unused input active-high line 9: unnamed unused input active-high line 10: unnamed unused input active-high line 11: unnamed unused input active-high line 12: unnamed unused input active-high line 13: unnamed unused input active-high line 14: unnamed unused input active-high line 15: unnamed unused input active-high root@debian:~# gpiofind pin_4_push_button gpiochip4 5 root@debian:~#}hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjNhhubh)}(hAnother example::h]hAnother example:}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjNhhubh)}(hPackage () { "gpio-line-names", Package () { "SPI0_CS_N", "EXP2_INT", "MUX6_IO", "UART0_RXD", "MUX7_IO", "LVL_C_A1", "MUX0_IO", "SPI1_MISO", } }h]hPackage () { "gpio-line-names", Package () { "SPI0_CS_N", "EXP2_INT", "MUX6_IO", "UART0_RXD", "MUX7_IO", "LVL_C_A1", "MUX0_IO", "SPI1_MISO", } }}hjEsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjNhhubh)}(h`See Documentation/devicetree/bindings/gpio/gpio.txt for more information about these properties.h]h`See Documentation/devicetree/bindings/gpio/gpio.txt for more information about these properties.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjNhhubeh}(h]other-supported-propertiesah ]h"]other supported propertiesah$]h&]uh1hhhhhhhhKzubh)}(hhh](h)}(h&ACPI GPIO Mappings Provided by Driversh]h&ACPI GPIO Mappings Provided by Drivers}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjihhhhhKubh)}(hThere 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.h]hThere 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.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hXxIn 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.h]hXxIn 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hXlTo do that, the driver needs to define a mapping table as a NULL-terminated array of struct acpi_gpio_mapping objects that each contains 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.h]hXlTo do that, the driver needs to define a mapping table as a NULL-terminated array of struct acpi_gpio_mapping objects that each contains 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hlFor the example Bluetooth device discussed previously the data structures in question would look like this::h]hkFor the example Bluetooth device discussed previously the data structures in question would look like this:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hX#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[] = { { "reset-gpios", &reset_gpio, 1 }, { "shutdown-gpios", &shutdown_gpio, 1 }, { } };h]hX#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[] = { { "reset-gpios", &reset_gpio, 1 }, { "shutdown-gpios", &shutdown_gpio, 1 }, { } };}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjihhubh)}(hXNext, the mapping table needs to be passed as the second argument to acpi_dev_add_driver_gpios() or its managed analogue 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.h]hXNext, the mapping table needs to be passed as the second argument to acpi_dev_add_driver_gpios() or its managed analogue 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjihhubeh}(h]&acpi-gpio-mappings-provided-by-driversah ]h"]&acpi gpio mappings provided by driversah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hUsing the _CRS fallbackh]hUsing the _CRS fallback}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM ubh)}(hIf a device does not have _DSD or the driver does not create ACPI GPIO mapping, the Linux GPIO framework refuses to return any GPIOs. This is because the driver does not know what it actually gets. For example if we have a device like below::h]hIf a device does not have _DSD or the driver does not create ACPI GPIO mapping, the Linux GPIO framework refuses to return any GPIOs. This is because the driver does not know what it actually gets. For example if we have a device like below:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hXCDevice (BTH) { Name (_HID, ...) Name (_CRS, ResourceTemplate () { GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone, "\\_SB.GPO0", 0, ResourceConsumer) { 15 } GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone, "\\_SB.GPO0", 0, ResourceConsumer) { 27 } }) }h]hXCDevice (BTH) { Name (_HID, ...) Name (_CRS, ResourceTemplate () { GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone, "\\_SB.GPO0", 0, ResourceConsumer) { 15 } GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone, "\\_SB.GPO0", 0, ResourceConsumer) { 27 } }) }}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjhhubh)}(hThere are two main approaches to get GPIO resource from ACPI::h]h=There are two main approaches to get GPIO resource from ACPI:}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM4hjQhhubh)}(hfdesc = gpiod_get(dev, connection_id, flags); desc = gpiod_get_index(dev, connection_id, index, flags);h]hfdesc = gpiod_get(dev, connection_id, flags); desc = gpiod_get_index(dev, connection_id, index, flags);}hjpsbah}(h]h ]h"]h$]h&]hhuh1hhhhM6hjQhhubh)}(h\We may consider two different cases here, i.e. when connection ID is provided and otherwise.h]h\We may consider two different cases here, i.e. when connection ID is provided and otherwise.}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hjQhhubh)}(hCase 1::h]hCase 1:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hjQhhubh)}(h|desc = gpiod_get(dev, "non-null-connection-id", flags); desc = gpiod_get_index(dev, "non-null-connection-id", index, flags);h]h|desc = gpiod_get(dev, "non-null-connection-id", flags); desc = gpiod_get_index(dev, "non-null-connection-id", index, flags);}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhM>hjQhhubh)}(hCase 2::h]hCase 2:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMAhjQhhubh)}(hTdesc = gpiod_get(dev, NULL, flags); desc = gpiod_get_index(dev, NULL, index, flags);h]hTdesc = gpiod_get(dev, NULL, flags); desc = gpiod_get_index(dev, NULL, index, flags);}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMChjQhhubh)}(hCase 1 assumes that corresponding ACPI device description must have defined device properties and will prevent to getting any GPIO resources otherwise.h]hCase 1 assumes that corresponding ACPI device description must have defined device properties and will prevent to getting any GPIO resources otherwise.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhjQhhubh)}(h@Case 2 explicitly tells GPIO core to look for resources in _CRS.h]h@Case 2 explicitly tells GPIO core to look for resources in _CRS.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhjQhhubh)}(hX#Be aware that gpiod_get_index() in cases 1 and 2, assuming that there are two versions of ACPI device description provided and no mapping is present in the driver, will return different resources. That's why a certain driver has to handle them carefully as explained in the previous chapter.h]hX%Be aware that gpiod_get_index() in cases 1 and 2, assuming that there are two versions of ACPI device description provided and no mapping is present in the driver, will return different resources. That’s why a certain driver has to handle them carefully as explained in the previous chapter.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMLhjQhhubeh}(h]getting-gpio-descriptorah ]h"]getting gpio descriptorah$]h&]uh1hhhhhhhhM2ubeh}(h]%dsd-device-properties-related-to-gpioah ]h"]&_dsd device properties related to gpioah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksjZfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjfjcjjjNjKjju nametypes}(jjfjjNjuh}(jhjcjNjjijKjjjQu footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.