€•lƒŒ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/userspace-api/gpio/sysfs”Œ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/userspace-api/gpio/sysfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/it_IT/userspace-api/gpio/sysfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ja_JP/userspace-api/gpio/sysfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ko_KR/userspace-api/gpio/sysfs”Œ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/userspace-api/gpio/sysfs”Œ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/userspace-api/gpio/sysfs”Œ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 Sysfs Interface for Userspace”h]”hŒ"GPIO Sysfs Interface for Userspace”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒF/var/lib/git/docbuild/linux/Documentation/userspace-api/gpio/sysfs.rst”h´KubhŒwarning”“”)”}”(hXšThis API is obsoleted by the chardev.rst and the ABI documentation has been moved to Documentation/ABI/obsolete/sysfs-gpio. New developments should use the chardev.rst, and existing developments are encouraged to migrate as soon as possible, as this API will be removed in the future. This interface will continue to be maintained for the migration period, but new features will only be added to the new API.”h]”(hŒ paragraph”“”)”}”(hŒ{This API is obsoleted by the chardev.rst and the ABI documentation has been moved to Documentation/ABI/obsolete/sysfs-gpio.”h]”hŒ{This API is obsoleted by the chardev.rst and the ABI documentation has been moved to Documentation/ABI/obsolete/sysfs-gpio.”…””}”(hhÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KhhÍubhÒ)”}”(hŒ New developments should use the chardev.rst, and existing developments are encouraged to migrate as soon as possible, as this API will be removed in the future.”h]”hŒ New developments should use the chardev.rst, and existing developments are encouraged to migrate as soon as possible, as this API will be removed in the future.”…””}”(hháh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KhhÍubhÒ)”}”(hŒ{This interface will continue to be maintained for the migration period, but new features will only be added to the new API.”h]”hŒ{This interface will continue to be maintained for the migration period, but new features will only be added to the new API.”…””}”(hhïh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K hhÍubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËhh·h²hh³hÊh´Nubh¶)”}”(hhh]”(h»)”}”(hŒThe obsolete sysfs ABI”h]”hŒThe obsolete sysfs ABI”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KubhÒ)”}”(hXPPlatforms which use the "gpiolib" implementors framework may choose to configure a sysfs user interface to GPIOs. This is different from the debugfs interface, since it provides control over GPIO direction and value instead of just showing a gpio state summary. Plus, it could be present on production systems without debugging support.”h]”hXTPlatforms which use the “gpiolib†implementors framework may choose to configure a sysfs user interface to GPIOs. This is different from the debugfs interface, since it provides control over GPIO direction and value instead of just showing a gpio state summary. Plus, it could be present on production systems without debugging support.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khjh²hubhÒ)”}”(hXãGiven appropriate hardware documentation for the system, userspace could know for example that GPIO #23 controls the write protect line used to protect boot loader segments in flash memory. System upgrade procedures may need to temporarily remove that protection, first importing a GPIO, then changing its output state, then updating the code before re-enabling the write protection. In normal use, GPIO #23 would never be touched, and the kernel would have no need to know about it.”h]”hXãGiven appropriate hardware documentation for the system, userspace could know for example that GPIO #23 controls the write protect line used to protect boot loader segments in flash memory. System upgrade procedures may need to temporarily remove that protection, first importing a GPIO, then changing its output state, then updating the code before re-enabling the write protection. In normal use, GPIO #23 would never be touched, and the kernel would have no need to know about it.”…””}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khjh²hubhÒ)”}”(hX Again depending on appropriate hardware documentation, on some systems userspace GPIO can be used to determine system configuration data that standard kernels won't know about. And for some tasks, simple userspace GPIO drivers could be all that the system really needs.”h]”hXAgain depending on appropriate hardware documentation, on some systems userspace GPIO can be used to determine system configuration data that standard kernels won’t know about. And for some tasks, simple userspace GPIO drivers could be all that the system really needs.”…””}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khjh²hubhŒnote”“”)”}”(hŒÉDo NOT abuse sysfs to control hardware that has proper kernel drivers. Please read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing kernel wheels in userspace. I MEAN IT. REALLY.”h]”(hÒ)”}”(hŒµDo NOT abuse sysfs to control hardware that has proper kernel drivers. Please read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing kernel wheels in userspace.”h]”hŒµDo NOT abuse sysfs to control hardware that has proper kernel drivers. Please read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing kernel wheels in userspace.”…””}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K%hj@ubhÒ)”}”(hŒI MEAN IT. REALLY.”h]”hŒI MEAN IT. REALLY.”…””}”(hjRh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K)hj@ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j>hjh²hh³hÊh´Nubeh}”(h]”Œthe-obsolete-sysfs-abi”ah ]”h"]”Œthe obsolete sysfs abi”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒPaths in Sysfs”h]”hŒPaths in Sysfs”…””}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjnh²hh³hÊh´K,ubhÒ)”}”(hŒ4There are three kinds of entries in /sys/class/gpio:”h]”hŒ4There are three kinds of entries in /sys/class/gpio:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K-hjnh²hubhŒ block_quote”“”)”}”(hŒŽ- Control interfaces used to get userspace control over GPIOs; - GPIOs themselves; and - GPIO controllers ("gpio_chip" instances). ”h]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ=Control interfaces used to get userspace control over GPIOs; ”h]”hÒ)”}”(hŒ export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code. "unexport" ... Reverses the effect of exporting to userspace. Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file. ”h]”(hÒ)”}”(hŒ/sys/class/gpio/”h]”hŒ/sys/class/gpio/”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K9hj ubjŽ)”}”(hX¼"export" ... Userspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file. Example: "echo 19 > export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code. "unexport" ... Reverses the effect of exporting to userspace. Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file. ”h]”hŒdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hŒç"export" ... Userspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file. Example: "echo 19 > export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code. ”h]”(hŒterm”“”)”}”(hŒ "export" ...”h]”hŒ“export†...”…””}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´K@hj)ubhŒ definition”“”)”}”(hhh]”(hÒ)”}”(hŒiUserspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file.”h]”hŒiUserspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file.”…””}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code.”h]”hŒxExample: “echo 19 > export†will create a “gpio19†node for GPIO #19, if that’s not requested by kernel code.”…””}”(hjPh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K?hj?ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j=hj)ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´K@hj$ubj()”}”(hŒœ"unexport" ... Reverses the effect of exporting to userspace. Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file. ”h]”(j.)”}”(hŒ"unexport" ...”h]”hŒ“unexport†...”…””}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´KFhjjubj>)”}”(hhh]”(hÒ)”}”(hŒ.Reverses the effect of exporting to userspace.”h]”hŒ.Reverses the effect of exporting to userspace.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KChj|ubhÒ)”}”(hŒ\Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file.”h]”hŒhExample: “echo 19 > unexport†will remove a “gpio19†node exported using the “export†file.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KEhj|ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j=hjjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´KFhj$ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j"hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´K;hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´K9hjnh²hubhÒ)”}”(hŒqGPIO signals have paths like /sys/class/gpio/gpio42/ (for GPIO #42) and have the following read/write attributes:”h]”hŒqGPIO signals have paths like /sys/class/gpio/gpio42/ (for GPIO #42) and have the following read/write attributes:”…””}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KHhjnh²hubjŽ)”}”(hX”/sys/class/gpio/gpioN/ "direction" ... reads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value. Note that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction. "value" ... reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active. If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value. "edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return. This file exists only if the pin can be configured as an interrupt generating input pin. "active_low" ... reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting. ”h]”(hÒ)”}”(hŒ/sys/class/gpio/gpioN/”h]”hŒ/sys/class/gpio/gpioN/”…””}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KKhjÇubjŽ)”}”(hXè"direction" ... reads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value. Note that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction. "value" ... reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active. If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value. "edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return. This file exists only if the pin can be configured as an interrupt generating input pin. "active_low" ... reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting. ”h]”j#)”}”(hhh]”(j()”}”(hXí"direction" ... reads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value. Note that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction. ”h]”(j.)”}”(hŒ"direction" ...”h]”hŒ“direction†...”…””}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´KWhjàubj>)”}”(hhh]”(hÒ)”}”(hXreads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value.”h]”hXreads as either “in†or “outâ€. This value may normally be written. Writing as “out†defaults to initializing the value as low. To ensure glitch free operation, values “low†and “high†may be written to configure the GPIO as an output with that initial value.”…””}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KNhjòubhÒ)”}”(hŒØNote that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction.”h]”(hŒNote that this attribute ”…””}”(hjh²hh³Nh´NubhŒemphasis”“”)”}”(hŒ*will not exist*”h]”hŒwill not exist”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubhŒµ if the kernel doesn’t support changing the direction of a GPIO, or it was exported by kernel code that didn’t explicitly allow userspace to reconfigure this GPIO’s direction.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KThjòubeh}”(h]”h ]”h"]”h$]”h&]”uh1j=hjàubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´KWhjÝubj()”}”(hXÛ"value" ... reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active. If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value. ”h]”(j.)”}”(hŒ "value" ...”h]”hŒ“value†...”…””}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´Kghj1ubj>)”}”(hhh]”(hÒ)”}”(hŒ–reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active.”h]”hŒ–reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active.”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KZhjCubhÒ)”}”(hX6If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value.”h]”hX:If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of “edgeâ€), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value.”…””}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K^hjCubeh}”(h]”h ]”h"]”h$]”h&]”uh1j=hj1ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´KghjÝubj()”}”(hX"edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return. This file exists only if the pin can be configured as an interrupt generating input pin. ”h]”(j.)”}”(hŒ "edge" ...”h]”hŒ“edge†...”…””}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´Kohjnubj>)”}”(hhh]”(hÒ)”}”(hŒ›reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return.”h]”hŒ¯reads as either “noneâ€, “risingâ€, “fallingâ€, or “bothâ€. Write these strings to select the signal edge(s) that will make poll(2) on the “value†file return.”…””}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Kjhj€ubhÒ)”}”(hŒXThis file exists only if the pin can be configured as an interrupt generating input pin.”h]”hŒXThis file exists only if the pin can be configured as an interrupt generating input pin.”…””}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Knhj€ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j=hjnubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´KohjÝubj()”}”(hX"active_low" ... reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting. ”h]”(j.)”}”(hŒ"active_low" ...”h]”hŒ“active_low†...”…””}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´Kwhj«ubj>)”}”(hhh]”hÒ)”}”(hXreads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting.”h]”hX reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for “rising†and “falling†edges will follow this setting.”…””}”(hjÀh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Krhj½ubah}”(h]”h ]”h"]”h$]”h&]”uh1j=hj«ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´KwhjÝubeh}”(h]”h ]”h"]”h$]”h&]”uh1j"hjÙubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´KMhjÇubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´KKhjnh²hubhÒ)”}”(hŒ¡GPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the controller implementing GPIOs starting at #42) and have the following read-only attributes:”h]”hŒ¡GPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the controller implementing GPIOs starting at #42) and have the following read-only attributes:”…””}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Kyhjnh²hubjŽ)”}”(hŒþ/sys/class/gpio/gpiochipN/ "base" ... same as N, the first GPIO managed by this chip "label" ... provided for diagnostics (not always unique) "ngpio" ... how many GPIOs this manages (N to N + ngpio - 1) ”h]”(hÒ)”}”(hŒ/sys/class/gpio/gpiochipN/”h]”hŒ/sys/class/gpio/gpiochipN/”…””}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K}hjúubjŽ)”}”(hŒÊ"base" ... same as N, the first GPIO managed by this chip "label" ... provided for diagnostics (not always unique) "ngpio" ... how many GPIOs this manages (N to N + ngpio - 1) ”h]”j#)”}”(hhh]”(j()”}”(hŒ:"base" ... same as N, the first GPIO managed by this chip ”h]”(j.)”}”(hŒ "base" ...”h]”hŒ“base†...”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´K€hjubj>)”}”(hhh]”hÒ)”}”(hŒ.same as N, the first GPIO managed by this chip”h]”hŒ.same as N, the first GPIO managed by this chip”…””}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K€hj%ubah}”(h]”h ]”h"]”h$]”h&]”uh1j=hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´K€hjubj()”}”(hŒ9"label" ... provided for diagnostics (not always unique) ”h]”(j.)”}”(hŒ "label" ...”h]”hŒ“label†...”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´KƒhjBubj>)”}”(hhh]”hÒ)”}”(hŒ,provided for diagnostics (not always unique)”h]”hŒ,provided for diagnostics (not always unique)”…””}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KƒhjTubah}”(h]”h ]”h"]”h$]”h&]”uh1j=hjBubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´Kƒhjubj()”}”(hŒ="ngpio" ... how many GPIOs this manages (N to N + ngpio - 1) ”h]”(j.)”}”(hŒ "ngpio" ...”h]”hŒ“ngpio†...”…””}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j-h³hÊh´K†hjqubj>)”}”(hhh]”hÒ)”}”(hŒ0how many GPIOs this manages (N to N + ngpio - 1)”h]”hŒ0how many GPIOs this manages (N to N + ngpio - 1)”…””}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K†hjƒubah}”(h]”h ]”h"]”h$]”h&]”uh1j=hjqubeh}”(h]”h ]”h"]”h$]”h&]”uh1j'h³hÊh´K†hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j"hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´Khjúubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´K}hjnh²hubhÒ)”}”(hX“Board documentation should in most cases cover what GPIOs are used for what purposes. However, those numbers are not always stable; GPIOs on a daughtercard might be different depending on the base board being used, or other cards in the stack. In such cases, you may need to use the gpiochip nodes (possibly in conjunction with schematics) to determine the correct GPIO number to use for a given signal.”h]”hX“Board documentation should in most cases cover what GPIOs are used for what purposes. However, those numbers are not always stable; GPIOs on a daughtercard might be different depending on the base board being used, or other cards in the stack. In such cases, you may need to use the gpiochip nodes (possibly in conjunction with schematics) to determine the correct GPIO number to use for a given signal.”…””}”(hj²h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Kˆhjnh²hubeh}”(h]”Œpaths-in-sysfs”ah ]”h"]”Œpaths in sysfs”ah$]”h&]”uh1hµhh·h²hh³hÊh´K,ubh¶)”}”(hhh]”(h»)”}”(hŒExporting from Kernel code”h]”hŒExporting from Kernel code”…””}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÈh²hh³hÊh´K‘ubhÒ)”}”(hŒkKernel code can explicitly manage exports of GPIOs which have already been requested using gpio_request()::”h]”hŒjKernel code can explicitly manage exports of GPIOs which have already been requested using gpio_request():”…””}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K’hjÈh²hubhŒ literal_block”“”)”}”(hXI/* export the GPIO to userspace */ int gpiod_export(struct gpio_desc *desc, bool direction_may_change); /* reverse gpiod_export() */ void gpiod_unexport(struct gpio_desc *desc); /* create a sysfs link to an exported GPIO node */ int gpiod_export_link(struct device *dev, const char *name, struct gpio_desc *desc);”h]”hXI/* export the GPIO to userspace */ int gpiod_export(struct gpio_desc *desc, bool direction_may_change); /* reverse gpiod_export() */ void gpiod_unexport(struct gpio_desc *desc); /* create a sysfs link to an exported GPIO node */ int gpiod_export_link(struct device *dev, const char *name, struct gpio_desc *desc);”…””}”hjésbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jçh³hÊh´K•hjÈh²hubhÒ)”}”(hX After a kernel driver requests a GPIO, it may only be made available in the sysfs interface by gpiod_export(). The driver can control whether the signal direction may change. This helps drivers prevent userspace code from accidentally clobbering important system state.”h]”hX After a kernel driver requests a GPIO, it may only be made available in the sysfs interface by gpiod_export(). The driver can control whether the signal direction may change. This helps drivers prevent userspace code from accidentally clobbering important system state.”…””}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KŸhjÈh²hubhÒ)”}”(hŒÊThis explicit exporting can help with debugging (by making some kinds of experiments easier), or can provide an always-there interface that's suitable for documenting as part of a board support package.”h]”hŒÌThis explicit exporting can help with debugging (by making some kinds of experiments easier), or can provide an always-there interface that’s suitable for documenting as part of a board support package.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K¤hjÈh²hubhÒ)”}”(hŒåAfter the GPIO has been exported, gpiod_export_link() allows creating symlinks from elsewhere in sysfs to the GPIO sysfs node. Drivers can use this to provide the interface under their own device in sysfs with a descriptive name.”h]”hŒåAfter the GPIO has been exported, gpiod_export_link() allows creating symlinks from elsewhere in sysfs to the GPIO sysfs node. Drivers can use this to provide the interface under their own device in sysfs with a descriptive name.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K¨hjÈh²hubeh}”(h]”Œexporting-from-kernel-code”ah ]”h"]”Œexporting from kernel code”ah$]”h&]”uh1hµhh·h²hh³hÊh´K‘ubeh}”(h]”Œ"gpio-sysfs-interface-for-userspace”ah ]”h"]”Œ"gpio sysfs interface for userspace”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”jVŒ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”}”Œnameids”}”(j0j-jkjhjÅjÂj(j%uŒ nametypes”}”(j0‰jk‰jʼnj(‰uh}”(j-h·jhjjÂjnj%jÈuŒ 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”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.