The hardware: Apalis IMX6Q 1Gb V1.1Y on Ixora 1.1A.
The software: Toradex BSP 6.4.0 devel.
The backlight of the TFT is controlled by PWM1 in my program via /sys/class/pwm/pwmchip0/ sysfs functions. It works fine.
The problem is that at system boot the corresponding pin is set by the loading kernel to a default that is inverted respect of what expected by the display firmware.
If I don’t connect the the pin wire, at boot I see no backlight for around 1/2 second, then the backlight goes ON and I see the system booting messages, then the wayland/weston service launches my application that begins to handle the pwm/brightness via sysfs.
If I connect the wire I see no backlight until the application is up and running.
I want to invert the default pin HIGH/LOW setting to have the backlight ON when booting.
Or better I want to enable the pwm handling at boot.
To acheive this I can patch the device tree overlay (on that I ask the Lucas Akira help, see: Patch device Tree to disable PCIe)
or to me will be enough to pass a command as soon as possible during boot process.
Please note that the final product devices will be very few in number so I can customize each on by editing some file on the already deployed system files, I don’t need to strictly operate at Yocto level.
(that correspond to GPIO1, pin 13 on X27 connector of Ixora board, gpio 36 in Linux) I’ve succesfully set high the pin at boot. I’ve connected a led and it lights. Then I’ve created a simple program that switch on and off the gpio in Linux. And it works.
But the pin I want to be high at boot is the one of PWM1, that is the pin 33 of X27, that corresponds to GPIO1_IO09. But inputting:
$> fw_setenv bootcmd "gpio set GPIO1_9;… "
nothing changes on pin, it remains low at boot. And when my program, that configure and uses the PWM1, opens, I can see the signal going high and low on oscilloscope.
Why? It’s because the kernel device tree has that pin configured as pwm so I cannot pilot it as gpio with bootcmd parameter? If so, can you suggest the device tree patch to have it configured as pwm but set the pin high as default?
Or better, a patch that already set the PWM1 frequency, duty-cycle and enable it as I do in my program?
I just tested manipulating both pins (GPIO1_9 and GPIO2_4) from U-Boot and it worked for me.
Here is my setup:
Apalis iMX6D 512MB V1.1B
Toradex Reference Minimal Image from BSP 6.4.0
Ixora V1.1A
To test them, I connected one LED to each pin (X27.13 and X27.33).
What I did: I stopped the boot in U-Boot and performed the following:
Apalis iMX6 # gpio set GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 1
Warning: value of pin is still 0
Apalis iMX6 # gpio clear GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 0
Apalis iMX6 # gpio set GPIO2_4
gpio: pin GPIO2_4 (gpio 36) value is 1
Apalis iMX6 # gpio clear GPIO2_4
gpio: pin GPIO2_4 (gpio 36) value is 0
Apalis iMX6 # gpio set GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 1
Warning: value of pin is still 0
Apalis iMX6 # gpio clear GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 0
Apalis iMX6 # gpio toggle GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 1
Warning: value of pin is still 0
Apalis iMX6 # gpio toggle GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 1
Warning: value of pin is still 0
Apalis iMX6 # gpio toggle GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 1
Warning: value of pin is still 0
Apalis iMX6 # gpio clear GPIO1_9
gpio: pin GPIO1_9 (gpio 9) value is 0
The toggle doesn’t make GPIO1_9 go down, but clear works every time.
For GPIO2_4, set, clear and toggle works all the time.
This is not entirely true from what I can see on my side.
During U-boot, GPIO1_9 is high. But when the Linux Kernel starts, it goes low.
If you would like to have it low (or high) when Linux Kernel comes up, you can use GPIO hog:
OK, good to be able to set/clear some gpios at U-boot level.
One secondary question: why one cannot set GPIO1_9 with U-boot? It is not configured as gpio in U-boot?
Anyway I want to have it set to high during kernel loading and I can have it low during U-boot.
I have to patch the kernel device tree… and I don’t know how to do.
Can you provide a complete tutorial? (as Lucas did in the post Patch device Tree to disable PCIe).
I mean that I’m not able to identify the .bb where that gpio is set as part of pwm1 pins. Then, reproducing something similar to the tutorial of Lucas, I suppose I can set it high creating a custom .bbappend.
I’ve seen already, but a question: this is not the PWM4 shared pin? I have to use PWM1 pin
Actually, this is exactly what I did and shared here in my previous message.
We have already a great set of documentation regarding device trees: Device Tree Documentation Overview | Toradex Developer Center. The Technical Marketing team at Toradex invested already an impressive amount of time to put together this documentation. If you need help with the device tree, I recommend you consume those articles and follow the steps in there, so you can have a better understanding of how to deal with device trees.
After consuming the information from there, if you still have specific questions, please share them with us, so we can further help you
I am not sure I understood this part…
I shared the pwm-backlight, which is a generic driver that you can “attach” to a PWM, so it is managed by Linux as a backlight for a display. I didn’t intend to target any specific PWM interface.
You are right! I recently found the documentation and I have to admit that is very well done.
In my case I “attempted” an out-of-the-box solution gift from you but now I realize that is important to have a better knowledge of Yocto/recipes/device-tree manners, for our future projects. I will invest some time on.
As for the Linux backlight web page on Toradex developer site I intended that “pwm-backlight” was an alias for PWM4 pin: “On the Apalis Standard, two dedicated pins are used for backlight control, BKL1_ON, and BKL1_PWM. Note that so far all Apalis modules use the same PWM instance on the pins PWM4 and BKL1_PWM, hence PWM4 can not be used independently when BKL1_PWM is in use.”