Hi,
I'm trying to enable PWM in the DTS of my KaRo TX25 module, with kernel 3.17.2, but it does not seem to work. I've created a PWM Backlight so I can control it through /sys/class/backlight, but when I change the brightness value, nothing happens, even though the value of actual_brightness is correctly updated.
Here are the relevant parts of my DTS:
backlight:
backlight: backlight5110 {
compatible = "pwm-backlight";
pwms = <&pwm1 0 500000>;
power-supply = <®_lcd_3v3>;
pwm-names = "backlight-5110";
brightness-levels = <
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
100
>;
default-brightness-level = <50>;
};
PWM:
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm1>;
#pwm-cells = <2>;
};
Pincontrol:
pinctrl_pwm1: pwmgrp {
fsl,pins = <
/* MX25_PAD_PWM__PWM 0x190 */
/* MX25_PAD_PWM__GPIO_1_26 0x190 */
MX25_PAD_PWM__GPIO_1_26 0x80000000
>;
};
When I export the pin as GPIO, it works fine. I'm able to control it through /sys/class/gpio and the display backlight is correctly lit on and off, but when I try to use PWM it doesn't change.
Solved! Go to Solution.
No, Fabio. The whole point was to try the PWM functionality, and the pwm-backlight seemed like an easy way to do it, but it has got a bit complicated :smileysilly:
Anyway, I've solved the problem. As with my troubles with SPI, the cause was the same: incorrect clock assignment in the DTSI (imx25.dtsi)
In the PWM declaration, there is this line
clocks = <&clks 105>, <&clks 36>;
First clock is all right, according to Documentation/devicetree/bindings/clock/imx25-clock.txt. Clock 105 is pwm1_ipg. But the second clock, 36, is per10. But to my surprise, there is a clock named pwm_ipg_per (52). As soon as I've changed it, PWM started working as a charm :smileyhappy:
So, clock assignment for all 4 PWMs need to be updated to the correct per clock. I have never sent a patch to the proper mailing list, but I'll try. If I don't succeed would you please send it for me?
Thanks for all your support
Looks like you missed to pass "status = "okay" in the pwm1 node.
Hi Fabio,
it looked promising, but no :smileysad:. I've tried it but that didn't work.
Thanks, anyway.
Hi Carlos,
Looking at other imx pwm examples I see that the brightness-levels range goes up to the 255.
Check arch/arm/boot/dts/imx6qdl-sabresd.dtsi for an example.
Can you try that instead?
OK, tried.
Actually, I've changed two things. First, I've changed pinctrl_pwm1 to use MX25_PAD_PWM__PWM, and second I've tried what you suggested.
What happens now is that at boot the display lights up 100%, but when I change the value of brightness, it doesn't do anything unless I put the value 0. Then, the display backlight turns off and does not recover unless there's a reboot, even if I send another value to brightness.
Carlos,
If 0 value works then it seems that the board you are using has an inverted pwm polarity: 0 % duty cycle turns it on , 100% duty cycle turns it off.
There have been patches posted in the pwm list to add support for the inverted PWM case. Take a look at this series from Lothar Waßmann from Karo:
http://patchwork.ozlabs.org/patch/398072/
You can try to ping these folks in the mailing list to see what is the status of this patch series.
I'm not very sure about that. If that was the case (polarity inverted), I should see a change in brightness even though it was "reversed". I can live with that :smileyhappy:. The issue seems to be that the PWM controller (or driver, or whatever...) is not working properly. At boot time, there's a fixed value for the output pin (1, in this case) and it only changes when I put a 0 in the "brightness" file in sysfs, and after that nothing. It's dead.
Fabio, have you tried the PWM with a recent kernel and a iMX25 board? Just to make sure it really works?
Anyway, I'll try contacting Lothar to see if there's any issues regarding the PWM driver.
I haven't tried pwm on mx25 with a recent kernel. Let me know if you make any progress with it, otherwise I will give it a try on a mx25pdk.
Carlos,
In case you only need to turn on/turn off the backlight: would it work if you use 'gpio-backlight'?
No, Fabio. The whole point was to try the PWM functionality, and the pwm-backlight seemed like an easy way to do it, but it has got a bit complicated :smileysilly:
Anyway, I've solved the problem. As with my troubles with SPI, the cause was the same: incorrect clock assignment in the DTSI (imx25.dtsi)
In the PWM declaration, there is this line
clocks = <&clks 105>, <&clks 36>;
First clock is all right, according to Documentation/devicetree/bindings/clock/imx25-clock.txt. Clock 105 is pwm1_ipg. But the second clock, 36, is per10. But to my surprise, there is a clock named pwm_ipg_per (52). As soon as I've changed it, PWM started working as a charm :smileyhappy:
So, clock assignment for all 4 PWMs need to be updated to the correct per clock. I have never sent a patch to the proper mailing list, but I'll try. If I don't succeed would you please send it for me?
Thanks for all your support
Good job on fixing it, Carlos!
If you have issues with the patch submission, just let me know and I can help you.
Hi Carlos,
I haven't seen your fix sent to the linux-arm-kernel mailing list yet.
Do you want me to submit this patch?
If so, please send me your email (it can be offline if you prefer), so that I can Cc you and also give you credit.
Regards,
Fabio Estevam
My bad, Fabio. I've been busy with another issue and I left this on queue.
Anyway, if you're so kind to send the patch... I'll send you my email by PM.
Thanks
Thanks, Carlos. Patch has been sent to the list.
Regards,
Fabio Estevam