Hello,
I would like to set GPIO gpiochip3 7 to HIGH on wakeup, and when suspending set it to low.
Currently i use systemd service with gpiod but it takes around 4 seconds to run after turning back screen which is painfully slow. I would like to have a more low level approach.
Sadly i’m not confident enough on DTO-s or kernel modifications but if you could provide me a simple modification i could do would be much appreciated.
We would like to order 80 panels for our project but it depends on how fast it can turn gpio on wakeup event.
Many thanks in advance
Hi, I’m the Toradex AI Assistant.
I might make mistakes or occasionally get you wrong. Our support team will step in if needed.
I’d be glad to help you optimize GPIO control during suspend/resume operations! To guide you properly, could you let me know which hardware platform and OS version you’re running? You can use the tdx-info command to get this information - details available at this link.
Low-Level GPIO Control During Suspend/Resume
For faster GPIO control during suspend/resume, you have several approaches that are more efficient than systemd services:
1. Device Tree Overlay Approach
You can create a device tree overlay to configure GPIO behavior during suspend/resume operations(1). This approach provides hardware-level control that’s much faster than userspace solutions.
2. GPIO Power Management Keys
The Linux kernel provides GPIO power management functionality that can be configured at the device tree level(2). You can declare a GPIO as an input device and assign key codes using the GPIO keyboard driver(2):
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpiokeys>;
power {
label = "Power-Key";
gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
linux,code = <KEY_POWER>;
debounce-interval = <10>;
};
};
3. Systemd Suspend/Resume Services (Optimized)
While you mentioned systemd is slow, you can create optimized suspend/resume services that execute closer to the kernel level(3). The documentation shows how to create customized suspend/resume services(3):
For actions before suspend:
[Unit]
Description=Sends signal USR1 to application signal_test before system entering in suspend mode.
Before=sleep.target
[Service]
Type=oneshot
ExecStart=killall -s SIGUSR1 signal_test
User=root
[Install]
RequiredBy=sleep.target
For actions after resume:
[Unit]
Description=Sends signal USR2 to application signal_test before system resumes.
After=sleep.target
[Service]
Type=oneshot
ExecStart=killall -s SIGUSR2 signal_test
User=root
4. Device Tree Overlay for GPIO Control
You can write a device tree overlay that configures the GPIO behavior during power state transitions(4). Device tree overlays allow you to modify hardware behavior without rebuilding the entire kernel(4).
Once you provide your hardware platform and OS version information, I can give you specific device tree overlay code and implementation details tailored to your exact setup.
Best regards, Toradex AI Assistant.
If I answered your question, please tick the “Solution” checkbox.
For follow-up questions to me, please use @ToradexAI in your post.