-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a strict_gpiod option #6117
Conversation
Allowing GPIO state to persist allows the use of gpioset to control GPIO levels without having to use the --mode=wait feature. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad it's not just me that gets caught by the dtoverlaycheck failure :-)
gpio-ranges declares a relationship between pinctrl and GPIO controllers. It is required for "strict" mode to work. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Setting strict_gpiod to Y makes libgpiod and the gpiod utilities behave as documented, i.e. pins are returned to being GPIO inputs when they are released. drivers/pinctrl/bcm/pinctrl-bcm2835.c Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Setting strict_gpiod to Y makes libgpiod and the gpiod utilities behave as documented, i.e. pins are returned to being GPIO inputs when they are released. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Setting strict_gpiod disables the GPIO output persistence, such that pins are returned to being inputs when they are released. Note that this applies to the GPIO/pinctrl driver for the user-facing GPIOs, not the SoC GPIOs on Pi 5. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
There are enough dtparams now that not having them in alphabetical order makes them hard to find. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Describe the function of the strict_gpiod dtparam. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Patch for Mainline Kernel: |
See: raspberrypi/linux#6113 kernel: DRM: rp1: rp1-dsi: Fix escape clock divider and timeouts See: raspberrypi/linux#6120 kernel: vc4/hdmi: Ignore hotplug interrupt with force_hotplug See: raspberrypi/linux#6123 kernel: drivers: media: cfe: Add remap entries for mono formats See: raspberrypi/linux#6122 kernel: dw-axi-dmac-platform: Avoid trampling with zero length buffer See: raspberrypi/linux#6118 kernel: Add a strict_gpiod option See: raspberrypi/linux#6117 kernel: Unicam FS/FE timing GPIO See: raspberrypi/linux#6088
See: raspberrypi/linux#6113 kernel: DRM: rp1: rp1-dsi: Fix escape clock divider and timeouts See: raspberrypi/linux#6120 kernel: vc4/hdmi: Ignore hotplug interrupt with force_hotplug See: raspberrypi/linux#6123 kernel: drivers: media: cfe: Add remap entries for mono formats See: raspberrypi/linux#6122 kernel: dw-axi-dmac-platform: Avoid trampling with zero length buffer See: raspberrypi/linux#6118 kernel: Add a strict_gpiod option See: raspberrypi/linux#6117 kernel: Unicam FS/FE timing GPIO See: raspberrypi/linux#6088
Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: raspberrypi/linux#6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
The second version with parameter name Can we adapt to the mainline parameter name or is it too late and we need to handle both parameter names? |
Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: raspberrypi/linux#6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
The name change is easy enough - the abstraction through a dtparam helps. It's the inversion of the sense combined with the use of module parameters that is awkward/ugly, given that kernel updates are independent of changes to /etc/modprobe.d, etc. |
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: raspberrypi#6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: raspberrypi#6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Corresponding downstream changes can be found here: #6150 |
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
The upstream patch has been applied to 6.10-rc1, but there were comments after it has been applied: Does it makes sense to adjust the parameter persist_gpio_outputs via sysfs afterwards or should we make it readonly via sysfs? I need to know your opinion before i send follow-up patches. |
I think there are people who will want one value, and people who will want the other value, but likely nobody who wants a changeable global value (aside from the convenience of avoiding a reboot after it is set to the preferred value). Having said that, I have no problem with it being changeable at runtime. |
I don't have a strong preference here. But i value the benefits of a readonly sysfs entry:
So you actually don't have a problem with making this readonly? |
That's correct. In the past it was never strict in the downstream world, and now users have the option of making it strict - that's enough. |
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
commit 8ff0598 upstream. Until now after a bcm2835 pin was freed its pinmux was set to GPIO_IN. So in case it was configured as GPIO_OUT before the configured output level also get lost. As long as GPIO sysfs was used this wasn't actually a problem because the pins and their possible output level were kept by sysfs. Since more and more Raspberry Pi users start using libgpiod they are confused about this behavior. So make the pin freeing behavior of GPIO_OUT configurable via module parameter. In case pinctrl-bcm2835.persist_gpio_outputs is set to 1, the output level is kept. This patch based on the downstream work of Phil Elwell. Link: #6117 Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Message-ID: <20240503062745.11298-1-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Having accepted the upstream change to add the persist_gpio_outputs parameter, make it true by default. See: #6117 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This patch set addresses some of the comments on 022689f. The concern is that GPIOs should always be returned to being inputs when they are released so that, for example, a heater is switched off or a motor stops when the controlling application crashes. That is how the upstream pinctrl drivers work, but in the downstream RPi kernels this behaviour has been modified so that GPIO outputs remain as outputs with whatever drive they had, in order that changes from gpioset will persist without the need to keep gpioset as a background process.
Two of the patches add support for the
strict_gpiod
module parameter to the two pinctrl drivers. Another patch adds dtparams so that the change can be made in config.txt instead, and will apply to all models of Pi. The final patch adds agpio-ranges
property to Pi 5 - without it, the notification of a pin being released never reaches the pinctrl driver.