PWM on iMX.25

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
7,580件の閲覧回数
csotoalonso
Contributor III

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 = <&reg_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.

ラベル(1)
0 件の賞賛
返信
1 解決策
5,624件の閲覧回数
csotoalonso
Contributor III

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

元の投稿で解決策を見る

0 件の賞賛
返信
13 返答(返信)
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

Looks like you missed to pass "status = "okay" in the pwm1 node.

0 件の賞賛
返信
5,623件の閲覧回数
csotoalonso
Contributor III

Hi Fabio,

it looked promising, but no :smileysad:. I've tried it but that didn't work.

Thanks, anyway.

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

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?

0 件の賞賛
返信
5,624件の閲覧回数
csotoalonso
Contributor III

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.

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

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.

0 件の賞賛
返信
5,624件の閲覧回数
csotoalonso
Contributor III

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.

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

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.

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

Carlos,

In case you only need to turn on/turn off the backlight: would it work if you use 'gpio-backlight'?

0 件の賞賛
返信
5,625件の閲覧回数
csotoalonso
Contributor III

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

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

Good job on fixing it, Carlos!

If you have issues with the patch submission, just let me know and I can help you.

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

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

0 件の賞賛
返信
5,624件の閲覧回数
csotoalonso
Contributor III

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

0 件の賞賛
返信
5,624件の閲覧回数
fabio_estevam
NXP Employee
NXP Employee

Thanks, Carlos. Patch has been sent to the list.

Regards,

Fabio Estevam

0 件の賞賛
返信