€•eüŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ,/translations/zh_CN/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/zh_TW/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/it_IT/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ja_JP/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ko_KR/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/pt_BR/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/sp_SP/driver-api/gpio/consumer”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒ"GPIO Descriptor Consumer Interface”h]”hŒ"GPIO Descriptor Consumer Interface”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒF/var/lib/git/docbuild/linux/Documentation/driver-api/gpio/consumer.rst”h´KubhŒ paragraph”“”)�”}”(hŒEThis document describes the consumer interface of the GPIO framework.”h]”hŒEThis document describes the consumer interface of the GPIO framework.”…”�”}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒGuidelines for GPIOs consumers”h]”hŒGuidelines for GPIOs consumers”…”�”}”(hhÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhÛh²hh³hÊh´K ubhÌ)�”}”(hŒãDrivers that can't work without standard GPIO calls should have Kconfig entries that depend on GPIOLIB or select GPIOLIB. The functions that allow a driver to obtain and use GPIOs are available by including the following file::”h]”hŒäDrivers that can’t work without standard GPIO calls should have Kconfig entries that depend on GPIOLIB or select GPIOLIB. The functions that allow a driver to obtain and use GPIOs are available by including the following file:”…”�”}”(hhìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hhÛh²hubhŒ literal_block”“”)�”}”(hŒ #include ”h]”hŒ #include ”…”�”}”hhüsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1húh³hÊh´KhhÛh²hubhÌ)�”}”(hŒÆThere are static inline stubs for all functions in the header file in the case where GPIOLIB is disabled. When these stubs are called they will emit warnings. These stubs are used for two use cases:”h]”hŒÆThere are static inline stubs for all functions in the header file in the case where GPIOLIB is disabled. When these stubs are called they will emit warnings. These stubs are used for two use cases:”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KhhÛh²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒ·Simple compile coverage with e.g. COMPILE_TEST - it does not matter that the current platform does not enable or select GPIOLIB because we are not going to execute the system anyway. ”h]”hÌ)�”}”(hŒ¶Simple compile coverage with e.g. COMPILE_TEST - it does not matter that the current platform does not enable or select GPIOLIB because we are not going to execute the system anyway.”h]”hŒ¶Simple compile coverage with e.g. COMPILE_TEST - it does not matter that the current platform does not enable or select GPIOLIB because we are not going to execute the system anyway.”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj!ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÊh´Nubj )�”}”(hX}Truly optional GPIOLIB support - where the driver does not really make use of the GPIOs on certain compile-time configurations for certain systems, but will use it under other compile-time configurations. In this case the consumer must make sure not to call into these functions, or the user will be met with console warnings that may be perceived as intimidating. Combining truly optional GPIOLIB usage with calls to ``[devm_]gpiod_get_optional()`` is a *bad idea*, and will result in weird error messages. Use the ordinary getter functions with optional GPIOLIB: some open coding of error handling should be expected when you do this. ”h]”hÌ)�”}”(hX|Truly optional GPIOLIB support - where the driver does not really make use of the GPIOs on certain compile-time configurations for certain systems, but will use it under other compile-time configurations. In this case the consumer must make sure not to call into these functions, or the user will be met with console warnings that may be perceived as intimidating. Combining truly optional GPIOLIB usage with calls to ``[devm_]gpiod_get_optional()`` is a *bad idea*, and will result in weird error messages. Use the ordinary getter functions with optional GPIOLIB: some open coding of error handling should be expected when you do this.”h]”(hX¢Truly optional GPIOLIB support - where the driver does not really make use of the GPIOs on certain compile-time configurations for certain systems, but will use it under other compile-time configurations. In this case the consumer must make sure not to call into these functions, or the user will be met with console warnings that may be perceived as intimidating. Combining truly optional GPIOLIB usage with calls to ”…”�”}”(hj=h²hh³Nh´NubhŒliteral”“”)�”}”(hŒ``[devm_]gpiod_get_optional()``”h]”hŒevm_]gpiod_get_optional()”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhj=ubhŒ is a ”…”�”}”(hj=h²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ *bad idea*”h]”hŒbad idea”…”�”}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj=ubhŒ«, and will result in weird error messages. Use the ordinary getter functions with optional GPIOLIB: some open coding of error handling should be expected when you do this.”…”�”}”(hj=h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj9ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jh³hÊh´KhhÛh²hubhÌ)�”}”(hXVAll the functions that work with the descriptor-based GPIO interface are prefixed with ``gpiod_``. The ``gpio_`` prefix is used for the legacy interface. No other function in the kernel should use these prefixes. The use of the legacy functions is strongly discouraged, new code should use and descriptors exclusively.”h]”(hŒWAll the functions that work with the descriptor-based GPIO interface are prefixed with ”…”�”}”(hj�h²hh³Nh´NubjF)�”}”(hŒ ``gpiod_``”h]”hŒgpiod_”…”�”}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhj�ubhŒ. The ”…”�”}”(hj�h²hh³Nh´NubjF)�”}”(hŒ ``gpio_``”h]”hŒgpio_”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhj�ubhŒæ prefix is used for the legacy interface. No other function in the kernel should use these prefixes. The use of the legacy functions is strongly discouraged, new code should use and descriptors exclusively.”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K#hhÛh²hubeh}”(h]”Œguidelines-for-gpios-consumers”ah ]”h"]”Œguidelines for gpios consumers”ah$]”h&]”uh1hµhh·h²hh³hÊh´K ubh¶)�”}”(hhh]”(h»)�”}”(hŒObtaining and Disposing GPIOs”h]”hŒObtaining and Disposing GPIOs”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj»h²hh³hÊh´K+ubhÌ)�”}”(hX=With the descriptor-based interface, GPIOs are identified with an opaque, non-forgeable handler that must be obtained through a call to one of the gpiod_get() functions. Like many other kernel subsystems, gpiod_get() takes the device that will use the GPIO and the function the requested GPIO is supposed to fulfill::”h]”hX<With the descriptor-based interface, GPIOs are identified with an opaque, non-forgeable handler that must be obtained through a call to one of the gpiod_get() functions. Like many other kernel subsystems, gpiod_get() takes the device that will use the GPIO and the function the requested GPIO is supposed to fulfill:”…”�”}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K-hj»h²hubhû)�”}”(hŒwstruct gpio_desc *gpiod_get(struct device *dev, const char *con_id, enum gpiod_flags flags)”h]”hŒwstruct gpio_desc *gpiod_get(struct device *dev, const char *con_id, enum gpiod_flags flags)”…”�”}”hjÚsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´K3hj»h²hubhÌ)�”}”(hŒ�If a function is implemented by using several GPIOs together (e.g. a simple LED device that displays digits), an additional index argument can be specified::”h]”hŒœIf a function is implemented by using several GPIOs together (e.g. a simple LED device that displays digits), an additional index argument can be specified:”…”�”}”(hjèh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K6hj»h²hubhû)�”}”(hŒ·struct gpio_desc *gpiod_get_index(struct device *dev, const char *con_id, unsigned int idx, enum gpiod_flags flags)”h]”hŒ·struct gpio_desc *gpiod_get_index(struct device *dev, const char *con_id, unsigned int idx, enum gpiod_flags flags)”…”�”}”hjösbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´K9hj»h²hubhÌ)�”}”(hŒzFor a more detailed description of the con_id parameter in the DeviceTree case see Documentation/driver-api/gpio/board.rst”h]”hŒzFor a more detailed description of the con_id parameter in the DeviceTree case see Documentation/driver-api/gpio/board.rst”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K=hj»h²hubhÌ)�”}”(hŒlThe flags parameter is used to optionally specify a direction and initial value for the GPIO. Values can be:”h]”hŒlThe flags parameter is used to optionally specify a direction and initial value for the GPIO. Values can be:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K@hj»h²hubj)�”}”(hhh]”(j )�”}”(hŒwGPIOD_ASIS or 0 to not initialize the GPIO at all. The direction must be set later with one of the dedicated functions.”h]”hÌ)�”}”(hŒwGPIOD_ASIS or 0 to not initialize the GPIO at all. The direction must be set later with one of the dedicated functions.”h]”hŒwGPIOD_ASIS or 0 to not initialize the GPIO at all. The direction must be set later with one of the dedicated functions.”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KChj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj h²hh³hÊh´Nubj )�”}”(hŒ)GPIOD_IN to initialize the GPIO as input.”h]”hÌ)�”}”(hj=h]”hŒ)GPIOD_IN to initialize the GPIO as input.”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KEhj;ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj h²hh³hÊh´Nubj )�”}”(hŒAGPIOD_OUT_LOW to initialize the GPIO as output with a value of 0.”h]”hÌ)�”}”(hjTh]”hŒAGPIOD_OUT_LOW to initialize the GPIO as output with a value of 0.”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KFhjRubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj h²hh³hÊh´Nubj )�”}”(hŒBGPIOD_OUT_HIGH to initialize the GPIO as output with a value of 1.”h]”hÌ)�”}”(hjkh]”hŒBGPIOD_OUT_HIGH to initialize the GPIO as output with a value of 1.”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KGhjiubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj h²hh³hÊh´Nubj )�”}”(hŒqGPIOD_OUT_LOW_OPEN_DRAIN same as GPIOD_OUT_LOW but also enforce the line to be electrically used with open drain.”h]”hÌ)�”}”(hŒqGPIOD_OUT_LOW_OPEN_DRAIN same as GPIOD_OUT_LOW but also enforce the line to be electrically used with open drain.”h]”hŒqGPIOD_OUT_LOW_OPEN_DRAIN same as GPIOD_OUT_LOW but also enforce the line to be electrically used with open drain.”…”�”}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KHhj€ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj h²hh³hÊh´Nubj )�”}”(hŒtGPIOD_OUT_HIGH_OPEN_DRAIN same as GPIOD_OUT_HIGH but also enforce the line to be electrically used with open drain. ”h]”hÌ)�”}”(hŒsGPIOD_OUT_HIGH_OPEN_DRAIN same as GPIOD_OUT_HIGH but also enforce the line to be electrically used with open drain.”h]”hŒsGPIOD_OUT_HIGH_OPEN_DRAIN same as GPIOD_OUT_HIGH but also enforce the line to be electrically used with open drain.”…”�”}”(hjœh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KJhj˜ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jŒ*”uh1jh³hÊh´KChj»h²hubhÌ)�”}”(hŒ«Note that the initial value is *logical* and the physical line level depends on whether the line is configured active high or active low (see :ref:`active_low_semantics`).”h]”(hŒNote that the initial value is ”…”�”}”(hj·h²hh³Nh´NubjZ)�”}”(hŒ *logical*”h]”hŒlogical”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj·ubhŒf and the physical line level depends on whether the line is configured active high or active low (see ”…”�”}”(hj·h²hh³Nh´Nubh)�”}”(hŒ:ref:`active_low_semantics`”h]”hŒinline”“”)�”}”(hjÓh]”hŒactive_low_semantics”…”�”}”(hj×h²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1jÕhjÑubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œdriver-api/gpio/consumer”Œ refdomain”jâŒreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆŒ reftarget”Œactive_low_semantics”uh1hh³hÊh´KMhj·ubhŒ).”…”�”}”(hj·h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KMhj»h²hubhÌ)�”}”(hX8The two last flags are used for use cases where open drain is mandatory, such as I2C: if the line is not already configured as open drain in the mappings (see board.rst), then open drain will be enforced anyway and a warning will be printed that the board configuration needs to be updated to match the use case.”h]”hX8The two last flags are used for use cases where open drain is mandatory, such as I2C: if the line is not already configured as open drain in the mappings (see board.rst), then open drain will be enforced anyway and a warning will be printed that the board configuration needs to be updated to match the use case.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KQhj»h²hubhÌ)�”}”(hXµBoth functions return either a valid GPIO descriptor, or an error code checkable with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned if and only if no GPIO has been assigned to the device/function/index triplet, other error codes are used for cases where a GPIO has been assigned but an error occurred while trying to acquire it. This is useful to discriminate between mere errors and an absence of GPIO for optional GPIO parameters. For the common pattern where a GPIO is optional, the gpiod_get_optional() and gpiod_get_index_optional() functions can be used. These functions return NULL instead of -ENOENT if no GPIO has been assigned to the requested function::”h]”hX´Both functions return either a valid GPIO descriptor, or an error code checkable with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned if and only if no GPIO has been assigned to the device/function/index triplet, other error codes are used for cases where a GPIO has been assigned but an error occurred while trying to acquire it. This is useful to discriminate between mere errors and an absence of GPIO for optional GPIO parameters. For the common pattern where a GPIO is optional, the gpiod_get_optional() and gpiod_get_index_optional() functions can be used. These functions return NULL instead of -ENOENT if no GPIO has been assigned to the requested function:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KVhj»h²hubhû)�”}”(hX¯struct gpio_desc *gpiod_get_optional(struct device *dev, const char *con_id, enum gpiod_flags flags) struct gpio_desc *gpiod_get_index_optional(struct device *dev, const char *con_id, unsigned int index, enum gpiod_flags flags)”h]”hX¯struct gpio_desc *gpiod_get_optional(struct device *dev, const char *con_id, enum gpiod_flags flags) struct gpio_desc *gpiod_get_index_optional(struct device *dev, const char *con_id, unsigned int index, enum gpiod_flags flags)”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´K`hj»h²hubhÌ)�”}”(hXRNote that gpio_get*_optional() functions (and their managed variants), unlike the rest of gpiolib API, also return NULL when gpiolib support is disabled. This is helpful to driver authors, since they do not need to special case -ENOSYS return codes. System integrators should however be careful to enable gpiolib on systems that need it.”h]”hXRNote that gpio_get*_optional() functions (and their managed variants), unlike the rest of gpiolib API, also return NULL when gpiolib support is disabled. This is helpful to driver authors, since they do not need to special case -ENOSYS return codes. System integrators should however be careful to enable gpiolib on systems that need it.”…”�”}”(hj*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kihj»h²hubhÌ)�”}”(hŒPFor a function using multiple GPIOs all of those can be obtained with one call::”h]”hŒOFor a function using multiple GPIOs all of those can be obtained with one call:”…”�”}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kohj»h²hubhû)�”}”(hŒ¨struct gpio_descs *gpiod_get_array(struct device *dev, const char *con_id, enum gpiod_flags flags)”h]”hŒ¨struct gpio_descs *gpiod_get_array(struct device *dev, const char *con_id, enum gpiod_flags flags)”…”�”}”hjFsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´Kqhj»h²hubhÌ)�”}”(hŒÜThis function returns a struct gpio_descs which contains an array of descriptors. It also contains a pointer to a gpiolib private structure which, if passed back to get/set array functions, may speed up I/O processing::”h]”hŒÛThis function returns a struct gpio_descs which contains an array of descriptors. It also contains a pointer to a gpiolib private structure which, if passed back to get/set array functions, may speed up I/O processing:”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kuhj»h²hubhû)�”}”(hŒustruct gpio_descs { struct gpio_array *info; unsigned int ndescs; struct gpio_desc *desc[]; }”h]”hŒustruct gpio_descs { struct gpio_array *info; unsigned int ndescs; struct gpio_desc *desc[]; }”…”�”}”hjbsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´Kyhj»h²hubhÌ)�”}”(hŒqThe following function returns NULL instead of -ENOENT if no GPIOs have been assigned to the requested function::”h]”hŒpThe following function returns NULL instead of -ENOENT if no GPIOs have been assigned to the requested function:”…”�”}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj»h²hubhû)�”}”(hŒÃstruct gpio_descs *gpiod_get_array_optional(struct device *dev, const char *con_id, enum gpiod_flags flags)”h]”hŒÃstruct gpio_descs *gpiod_get_array_optional(struct device *dev, const char *con_id, enum gpiod_flags flags)”…”�”}”hj~sbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´K‚hj»h²hubhÌ)�”}”(hŒ=Device-managed variants of these functions are also defined::”h]”hŒTo access such GPIOs, a different set of accessors is defined:”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K÷hjh²hubhû)�”}”(hŒ{int gpiod_get_value_cansleep(const struct gpio_desc *desc) void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)”h]”hŒ{int gpiod_get_value_cansleep(const struct gpio_desc *desc) void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)”…”�”}”hjdsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´Kùhjh²hubhÌ)�”}”(hŒÄAccessing such GPIOs requires a context which may sleep, for example a threaded IRQ handler, and those accessors must be used instead of spinlock-safe accessors without the cansleep() name suffix.”h]”hŒÄAccessing such GPIOs requires a context which may sleep, for example a threaded IRQ handler, and those accessors must be used instead of spinlock-safe accessors without the cansleep() name suffix.”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kühjh²hubhÌ)�”}”(hŒ¯Other than the fact that these accessors might sleep, and will work on GPIOs that can't be accessed from hardIRQ handlers, these calls act the same as the spinlock-safe calls.”h]”hŒ±Other than the fact that these accessors might sleep, and will work on GPIOs that can’t be accessed from hardIRQ handlers, these calls act the same as the spinlock-safe calls.”…”�”}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjh²hubhŒtarget”“”)�”}”(hŒ.. _active_low_semantics:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œactive-low-semantics”uh1jŽh´Mhjh²hh³hÊubeh}”(h]”Œgpio-access-that-may-sleep”ah ]”h"]”Œgpio access that may sleep”ah$]”h&]”uh1hµhjh²hh³hÊh´Kìubh¶)�”}”(hhh]”(h»)�”}”(hŒ'The active low and open drain semantics”h]”hŒ'The active low and open drain semantics”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¤h²hh³hÊh´MubhÌ)�”}”(hXŒAs a consumer should not have to care about the physical line level, all of the gpiod_set_value_xxx() or gpiod_set_array_value_xxx() functions operate with the *logical* value. With this they take the active low property into account. This means that they check whether the GPIO is configured to be active low, and if so, they manipulate the passed value before the physical line level is driven.”h]”(hŒ As a consumer should not have to care about the physical line level, all of the gpiod_set_value_xxx() or gpiod_set_array_value_xxx() functions operate with the ”…”�”}”(hjµh²hh³Nh´NubjZ)�”}”(hŒ *logical*”h]”hŒlogical”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjµubhŒã value. With this they take the active low property into account. This means that they check whether the GPIO is configured to be active low, and if so, they manipulate the passed value before the physical line level is driven.”…”�”}”(hjµh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hj¤h²hubhÌ)�”}”(hX%The same is applicable for open drain or open source output lines: those do not actively drive their output high (open drain) or low (open source), they just switch their output to a high impedance value. The consumer should not need to care. (For details read about open drain in driver.rst.)”h]”hX%The same is applicable for open drain or open source output lines: those do not actively drive their output high (open drain) or low (open source), they just switch their output to a high impedance value. The consumer should not need to care. (For details read about open drain in driver.rst.)”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¤h²hubhÌ)�”}”(hŒµWith this, all the gpiod_set_(array)_value_xxx() functions interpret the parameter "value" as "active" ("1") or "inactive" ("0"). The physical line level will be driven accordingly.”h]”hŒÉWith this, all the gpiod_set_(array)_value_xxx() functions interpret the parameter “valueâ€� as “activeâ€� (“1â€�) or “inactiveâ€� (“0â€�). The physical line level will be driven accordingly.”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¤h²hubhÌ)�”}”(hŒ¯As an example, if the active low property for a dedicated GPIO is set, and the gpiod_set_(array)_value_xxx() passes "active" ("1"), the physical line level will be driven low.”h]”hŒ·As an example, if the active low property for a dedicated GPIO is set, and the gpiod_set_(array)_value_xxx() passes “activeâ€� (“1â€�), the physical line level will be driven low.”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¤h²hubhÌ)�”}”(hŒTo summarize::”h]”hŒ To summarize:”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¤h²hubhû)�”}”(hXÍFunction (example) line property physical line gpiod_set_raw_value(desc, 0); don't care low gpiod_set_raw_value(desc, 1); don't care high gpiod_set_value(desc, 0); default (active high) low gpiod_set_value(desc, 1); default (active high) high gpiod_set_value(desc, 0); active low high gpiod_set_value(desc, 1); active low low gpiod_set_value(desc, 0); open drain low gpiod_set_value(desc, 1); open drain high impedance gpiod_set_value(desc, 0); open source high impedance gpiod_set_value(desc, 1); open source high”h]”hXÍFunction (example) line property physical line gpiod_set_raw_value(desc, 0); don't care low gpiod_set_raw_value(desc, 1); don't care high gpiod_set_value(desc, 0); default (active high) low gpiod_set_value(desc, 1); default (active high) high gpiod_set_value(desc, 0); active low high gpiod_set_value(desc, 1); active low low gpiod_set_value(desc, 0); open drain low gpiod_set_value(desc, 1); open drain high impedance gpiod_set_value(desc, 0); open source high impedance gpiod_set_value(desc, 1); open source high”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´Mhj¤h²hubhÌ)�”}”(hXIt is possible to override these semantics using the set_raw/get_raw functions but it should be avoided as much as possible, especially by system-agnostic drivers which should not need to care about the actual physical line level and worry about the logical value instead.”h]”hXIt is possible to override these semantics using the set_raw/get_raw functions but it should be avoided as much as possible, especially by system-agnostic drivers which should not need to care about the actual physical line level and worry about the logical value instead.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M+hj¤h²hubeh}”(h]”(Œ'the-active-low-and-open-drain-semantics”j›eh ]”h"]”(Œ'the active low and open drain semantics”Œactive_low_semantics”eh$]”h&]”uh1hµhjh²hh³hÊh´MŒexpect_referenced_by_name”}”j/j�sŒexpect_referenced_by_id”}”j›j�subh¶)�”}”(hhh]”(h»)�”}”(hŒAccessing raw GPIO values”h]”hŒAccessing raw GPIO values”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj6h²hh³hÊh´M2ubhÌ)�”}”(hŒªConsumers exist that need to manage the logical state of a GPIO line, i.e. the value their device will actually receive, no matter what lies between it and the GPIO line.”h]”hŒªConsumers exist that need to manage the logical state of a GPIO line, i.e. the value their device will actually receive, no matter what lies between it and the GPIO line.”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M3hj6h²hubhÌ)�”}”(hŒrThe following set of calls ignore the active-low or open drain property of a GPIO and work on the raw line value::”h]”hŒqThe following set of calls ignore the active-low or open drain property of a GPIO and work on the raw line value:”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M7hj6h²hubhû)�”}”(hX7int gpiod_get_raw_value(const struct gpio_desc *desc) void gpiod_set_raw_value(struct gpio_desc *desc, int value) int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value) int gpiod_direction_output_raw(struct gpio_desc *desc, int value)”h]”hX7int gpiod_get_raw_value(const struct gpio_desc *desc) void gpiod_set_raw_value(struct gpio_desc *desc, int value) int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value) int gpiod_direction_output_raw(struct gpio_desc *desc, int value)”…”�”}”hjcsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´M:hj6h²hubhÌ)�”}”(hŒZThe active low state of a GPIO can also be queried and toggled using the following calls::”h]”hŒYThe active low state of a GPIO can also be queried and toggled using the following calls:”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M@hj6h²hubhû)�”}”(hŒjint gpiod_is_active_low(const struct gpio_desc *desc) void gpiod_toggle_active_low(struct gpio_desc *desc)”h]”hŒjint gpiod_is_active_low(const struct gpio_desc *desc) void gpiod_toggle_active_low(struct gpio_desc *desc)”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´MChj6h²hubhÌ)�”}”(hŒœNote that these functions should only be used with great moderation; a driver should not have to care about the physical line level or open drain semantics.”h]”hŒœNote that these functions should only be used with great moderation; a driver should not have to care about the physical line level or open drain semantics.”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MFhj6h²hubeh}”(h]”Œaccessing-raw-gpio-values”ah ]”h"]”Œaccessing raw gpio values”ah$]”h&]”uh1hµhjh²hh³hÊh´M2ubh¶)�”}”(hhh]”(h»)�”}”(hŒ1Access multiple GPIOs with a single function call”h]”hŒ1Access multiple GPIOs with a single function call”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj£h²hh³hÊh´MKubhÌ)�”}”(hŒDThe following functions get or set the values of an array of GPIOs::”h]”hŒCThe following functions get or set the values of an array of GPIOs:”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MLhj£h²hubhû)�”}”(hX¨int gpiod_get_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_get_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_get_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_get_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_set_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap) int gpiod_set_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap) int gpiod_set_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap) int gpiod_set_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap)”h]”hX¨int gpiod_get_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_get_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_get_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_get_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap); int gpiod_set_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap) int gpiod_set_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap) int gpiod_set_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap) int gpiod_set_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, struct gpio_array *array_info, unsigned long *value_bitmap)”…”�”}”hjÂsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´MNhj£h²hubhÌ)�”}”(hXFThe array can be an arbitrary set of GPIOs. The functions will try to access GPIOs belonging to the same bank or chip simultaneously if supported by the corresponding chip driver. In that case a significantly improved performance can be expected. If simultaneous access is not possible the GPIOs will be accessed sequentially.”h]”hXFThe array can be an arbitrary set of GPIOs. The functions will try to access GPIOs belonging to the same bank or chip simultaneously if supported by the corresponding chip driver. In that case a significantly improved performance can be expected. If simultaneous access is not possible the GPIOs will be accessed sequentially.”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mphj£h²hubhÌ)�”}”(hŒ"The functions take four arguments:”h]”hŒ"The functions take four arguments:”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mvhj£h²hubhŒ block_quote”“”)�”}”(hX* array_size - the number of array elements * desc_array - an array of GPIO descriptors * array_info - optional information obtained from gpiod_get_array() * value_bitmap - a bitmap to store the GPIOs' values (get) or a bitmap of values to assign to the GPIOs (set) ”h]”j)�”}”(hhh]”(j )�”}”(hŒ,array_size - the number of array elements”h]”hÌ)�”}”(hj÷h]”hŒ,array_size - the number of array elements”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mxhjõubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjòubj )�”}”(hŒ,desc_array - an array of GPIO descriptors”h]”hÌ)�”}”(hjh]”hŒ,desc_array - an array of GPIO descriptors”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Myhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjòubj )�”}”(hŒDarray_info - optional information obtained from gpiod_get_array()”h]”hÌ)�”}”(hj%h]”hŒDarray_info - optional information obtained from gpiod_get_array()”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mzhj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjòubj )�”}”(hŒmvalue_bitmap - a bitmap to store the GPIOs' values (get) or a bitmap of values to assign to the GPIOs (set) ”h]”hÌ)�”}”(hŒlvalue_bitmap - a bitmap to store the GPIOs' values (get) or a bitmap of values to assign to the GPIOs (set)”h]”hŒnvalue_bitmap - a bitmap to store the GPIOs’ values (get) or a bitmap of values to assign to the GPIOs (set)”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M{hj:ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjòubeh}”(h]”h ]”h"]”h$]”h&]”jj¶uh1jh³hÊh´Mxhjîubah}”(h]”h ]”h"]”h$]”h&]”uh1jìh³hÊh´Mxhj£h²hubhÌ)�”}”(hXThe descriptor array can be obtained using the gpiod_get_array() function or one of its variants. If the group of descriptors returned by that function matches the desired group of GPIOs, those GPIOs can be accessed by simply using the struct gpio_descs returned by gpiod_get_array()::”h]”hXThe descriptor array can be obtained using the gpiod_get_array() function or one of its variants. If the group of descriptors returned by that function matches the desired group of GPIOs, those GPIOs can be accessed by simply using the struct gpio_descs returned by gpiod_get_array():”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M~hj£h²hubhû)�”}”(hŒ¼struct gpio_descs *my_gpio_descs = gpiod_get_array(...); gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc, my_gpio_descs->info, my_gpio_value_bitmap);”h]”hŒ¼struct gpio_descs *my_gpio_descs = gpiod_get_array(...); gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc, my_gpio_descs->info, my_gpio_value_bitmap);”…”�”}”hjlsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´Mƒhj£h²hubhÌ)�”}”(hXKIt is also possible to access a completely arbitrary array of descriptors. The descriptors may be obtained using any combination of gpiod_get() and gpiod_get_array(). Afterwards the array of descriptors has to be setup manually before it can be passed to one of the above functions. In that case, array_info should be set to NULL.”h]”hXKIt is also possible to access a completely arbitrary array of descriptors. The descriptors may be obtained using any combination of gpiod_get() and gpiod_get_array(). Afterwards the array of descriptors has to be setup manually before it can be passed to one of the above functions. In that case, array_info should be set to NULL.”…”�”}”(hjzh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M‡hj£h²hubhÌ)�”}”(hŒxNote that for optimal performance GPIOs belonging to the same chip should be contiguous within the array of descriptors.”h]”hŒxNote that for optimal performance GPIOs belonging to the same chip should be contiguous within the array of descriptors.”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M�hj£h²hubhÌ)�”}”(hX Still better performance may be achieved if array indexes of the descriptors match hardware pin numbers of a single chip. If an array passed to a get/set array function matches the one obtained from gpiod_get_array() and array_info associated with the array is also passed, the function may take a fast bitmap processing path, passing the value_bitmap argument directly to the respective .get/set_multiple() callback of the chip. That allows for utilization of GPIO banks as data I/O ports without much loss of performance.”h]”hX Still better performance may be achieved if array indexes of the descriptors match hardware pin numbers of a single chip. If an array passed to a get/set array function matches the one obtained from gpiod_get_array() and array_info associated with the array is also passed, the function may take a fast bitmap processing path, passing the value_bitmap argument directly to the respective .get/set_multiple() callback of the chip. That allows for utilization of GPIO banks as data I/O ports without much loss of performance.”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M�hj£h²hubhÌ)�”}”(hX3The return value of gpiod_get_array_value() and its variants is 0 on success or negative on error. Note the difference to gpiod_get_value(), which returns 0 or 1 on success to convey the GPIO value. With the array functions, the GPIO values are stored in value_array rather than passed back as return value.”h]”hX3The return value of gpiod_get_array_value() and its variants is 0 on success or negative on error. Note the difference to gpiod_get_value(), which returns 0 or 1 on success to convey the GPIO value. With the array functions, the GPIO values are stored in value_array rather than passed back as return value.”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M˜hj£h²hubeh}”(h]”Œ1access-multiple-gpios-with-a-single-function-call”ah ]”h"]”Œ1access multiple gpios with a single function call”ah$]”h&]”uh1hµhjh²hh³hÊh´MKubh¶)�”}”(hhh]”(h»)�”}”(hŒGPIOs mapped to IRQs”h]”hŒGPIOs mapped to IRQs”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjºh²hh³hÊh´MŸubhÌ)�”}”(hŒGPIO lines can quite often be used as IRQs. You can get the IRQ number corresponding to a given GPIO using the following call::”h]”hŒ~GPIO lines can quite often be used as IRQs. You can get the IRQ number corresponding to a given GPIO using the following call:”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjºh²hubhû)�”}”(hŒ.int gpiod_to_irq(const struct gpio_desc *desc)”h]”hŒ.int gpiod_to_irq(const struct gpio_desc *desc)”…”�”}”hjÙsbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´M£hjºh²hubhÌ)�”}”(hXkIt will return an IRQ number, or a negative errno code if the mapping can't be done (most likely because that particular GPIO cannot be used as IRQ). It is an unchecked error to use a GPIO that wasn't set up as an input using gpiod_direction_input(), or to use an IRQ number that didn't originally come from gpiod_to_irq(). gpiod_to_irq() is not allowed to sleep.”h]”hXqIt will return an IRQ number, or a negative errno code if the mapping can’t be done (most likely because that particular GPIO cannot be used as IRQ). It is an unchecked error to use a GPIO that wasn’t set up as an input using gpiod_direction_input(), or to use an IRQ number that didn’t originally come from gpiod_to_irq(). gpiod_to_irq() is not allowed to sleep.”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¥hjºh²hubhÌ)�”}”(hXDNon-error values returned from gpiod_to_irq() can be passed to request_irq() or free_irq(). They will often be stored into IRQ resources for platform devices, by the board-specific initialization code. Note that IRQ trigger options are part of the IRQ interface, e.g. IRQF_TRIGGER_FALLING, as are system wakeup capabilities.”h]”hXDNon-error values returned from gpiod_to_irq() can be passed to request_irq() or free_irq(). They will often be stored into IRQ resources for platform devices, by the board-specific initialization code. Note that IRQ trigger options are part of the IRQ interface, e.g. IRQF_TRIGGER_FALLING, as are system wakeup capabilities.”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M«hjºh²hubeh}”(h]”Œgpios-mapped-to-irqs”ah ]”h"]”Œgpios mapped to irqs”ah$]”h&]”uh1hµhjh²hh³hÊh´MŸubeh}”(h]”Œ using-gpios”ah ]”h"]”Œ using gpios”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kµubh¶)�”}”(hhh]”(h»)�”}”(hŒGPIOs and ACPI”h]”hŒGPIOs and ACPI”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´M³ubhÌ)�”}”(hŒÿOn ACPI systems, GPIOs are described by GpioIo()/GpioInt() resources listed by the _CRS configuration objects of devices. Those resources do not provide connection IDs (names) for GPIOs, so it is necessary to use an additional mechanism for this purpose.”h]”hŒÿOn ACPI systems, GPIOs are described by GpioIo()/GpioInt() resources listed by the _CRS configuration objects of devices. Those resources do not provide connection IDs (names) for GPIOs, so it is necessary to use an additional mechanism for this purpose.”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mµhjh²hubhÌ)�”}”(hXÀSystems compliant with ACPI 5.1 or newer may provide a _DSD configuration object which, among other things, may be used to provide connection IDs for specific GPIOs described by the GpioIo()/GpioInt() resources in _CRS. If that is the case, it will be handled by the GPIO subsystem automatically. However, if the _DSD is not present, the mappings between GpioIo()/GpioInt() resources and GPIO connection IDs need to be provided by device drivers.”h]”hXÀSystems compliant with ACPI 5.1 or newer may provide a _DSD configuration object which, among other things, may be used to provide connection IDs for specific GPIOs described by the GpioIo()/GpioInt() resources in _CRS. If that is the case, it will be handled by the GPIO subsystem automatically. However, if the _DSD is not present, the mappings between GpioIo()/GpioInt() resources and GPIO connection IDs need to be provided by device drivers.”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mºhjh²hubhÌ)�”}”(hŒJFor details refer to Documentation/firmware-guide/acpi/gpio-properties.rst”h]”hŒJFor details refer to Documentation/firmware-guide/acpi/gpio-properties.rst”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÁhjh²hubeh}”(h]”Œgpios-and-acpi”ah ]”h"]”Œgpios and acpi”ah$]”h&]”uh1hµhh·h²hh³hÊh´M³ubh¶)�”}”(hhh]”(h»)�”}”(hŒ*Interacting With the Legacy GPIO Subsystem”h]”hŒ*Interacting With the Legacy GPIO Subsystem”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjVh²hh³hÊh´MÅubhÌ)�”}”(hXGMany kernel subsystems and drivers still handle GPIOs using the legacy integer-based interface. It is strongly recommended to update these to the new gpiod interface. For cases where both interfaces need to be used, the following two functions allow to convert a GPIO descriptor into the GPIO integer namespace and vice-versa::”h]”hXFMany kernel subsystems and drivers still handle GPIOs using the legacy integer-based interface. It is strongly recommended to update these to the new gpiod interface. For cases where both interfaces need to be used, the following two functions allow to convert a GPIO descriptor into the GPIO integer namespace and vice-versa:”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÆhjVh²hubhû)�”}”(hŒ\int desc_to_gpio(const struct gpio_desc *desc) struct gpio_desc *gpio_to_desc(unsigned gpio)”h]”hŒ\int desc_to_gpio(const struct gpio_desc *desc) struct gpio_desc *gpio_to_desc(unsigned gpio)”…”�”}”hjusbah}”(h]”h ]”h"]”h$]”h&]”j j uh1húh³hÊh´MÌhjVh²hubhÌ)�”}”(hXƒThe GPIO number returned by desc_to_gpio() can safely be used as a parameter of the gpio\_*() functions for as long as the GPIO descriptor `desc` is not freed. All the same, a GPIO number passed to gpio_to_desc() must first be properly acquired using e.g. gpio_request_one(), and the returned GPIO descriptor is only considered valid until that GPIO number is released using gpio_free().”h]”(hŒ‹The GPIO number returned by desc_to_gpio() can safely be used as a parameter of the gpio_*() functions for as long as the GPIO descriptor ”…”�”}”(hjƒh²hh³Nh´NubhŒtitle_reference”“”)�”}”(hŒ`desc`”h]”hŒdesc”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j‹hjƒubhŒò is not freed. All the same, a GPIO number passed to gpio_to_desc() must first be properly acquired using e.g. gpio_request_one(), and the returned GPIO descriptor is only considered valid until that GPIO number is released using gpio_free().”…”�”}”(hjƒh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÏhjVh²hubhÌ)�”}”(hŒZFreeing a GPIO obtained by one API with the other API is forbidden and an unchecked error.”h]”hŒZFreeing a GPIO obtained by one API with the other API is forbidden and an unchecked error.”…”�”}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÕhjVh²hubeh}”(h]”Œ*interacting-with-the-legacy-gpio-subsystem”ah ]”h"]”Œ*interacting with the legacy gpio subsystem”ah$]”h&]”uh1hµhh·h²hh³hÊh´MÅubeh}”(h]”Œ"gpio-descriptor-consumer-interface”ah ]”h"]”Œ"gpio descriptor consumer interface”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jæŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”j›]”j�asŒnameids”}”(jÀj½j¸jµjj jj j¹j¶jjj¡jžj/j›j.j+j j�j·j´jjjSjPj¸jµuŒ nametypes”}”(jÀ‰j¸‰j‰j‰j¹‰j‰j¡‰j/ˆj.‰j ‰j·‰j‰jS‰j¸‰uh}”(j½h·jµhÛj j»j jj¶j#jj¼jžjj›j¤j+j¤j�j6j´j£jjºjPjjµjVuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”hŒsystem_message”“”)�”}”(hhh]”hÌ)�”}”(hhh]”hŒ:Hyperlink target "active-low-semantics" is not referenced.”…”�”}”hjP sbah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjM ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÊŒline”Muh1jK ubaŒ transformer”NŒ include_log”]”Œ decoration”Nh²hub.