2019-06-07 09:39 AM
HI, I needs use timers2 to enable the pwm function. Then it will used as pwm-backlight for LCD. I wasn't known how to write the dts file. Could you show me some example code on this function?
Solved! Go to Solution.
2019-06-13 12:49 AM
Could you please try this declaration and use &pwm2 phandle in your pwms declaration ( pwms = <&pwm2 0 5000000>;):
503 &timers2 {
504 status = "okay";
505 /* spare dmas for other usage */
506 /delete-property/dmas;
507 /delete-property/dma-names;
508 - pwm {
+ pwm2: pwm {
509 pinctrl-0 = <&pwm2_pins_a>;
510 pinctrl-1 = <&pwm2_sleep_pins_a>;
511 pinctrl-names = "default", "sleep";
512 #pwm-cells = <2>;
513 status = "okay";
514 };
515 - timer@1 {
516 - status = "disabled";
517 - };
518 };
2019-06-09 11:54 PM
You could find some details in https://wiki.st.com/stm32mpu/wiki/TIM_device_tree_configuration and https://wiki.st.com/stm32mpu/wiki/PWM_overview
2019-06-11 09:18 AM
Hi PatrickF Thanks. I got this error message.
Warning (pwms_property): /panel-backlight: Missing property '#pwm-cells' in node /soc/timer@40000000 or bad phandle (referred from pwms[0])
Here is my backlight dts code
187 panel_backlight: panel-backlight {
188 compatible = "pwm-backlight";
189 pwms = <&timers2 0 5000000>;
190 brightness-levels = <0 4 8 16 32 64 128 255>;
191 default-brightness-level = <6>;
192 status = "okay";
193 };
It seems my "pwms" value was wrong.
2019-06-12 08:32 AM
You have first to configure your pinctrl of your pwm output like described in this article (remove the trigger source part):
Then you will need to use your &pwm1_pins_a phandle defined instead of &timers2 above. see:
As you will use in your backlight declaration 2 arguments (pwms = <&pwm1_pins_a 0 5000000>;), you will need to add this property in your pwm node:
#pwm-cells = <2>;
Hoping it is clear.
2019-06-13 12:28 AM
503 &timers2 {
504 status = "okay";
505 /* spare dmas for other usage */
506 /delete-property/dmas;
507 /delete-property/dma-names;
508 pwm {
509 pinctrl-0 = <&pwm2_pins_a>;
510 pinctrl-1 = <&pwm2_sleep_pins_a>;
511 pinctrl-names = "default", "sleep";
512 #pwm-cells = <2>;
513 status = "okay";
514 };
515 timer@1 {
516 status = "disabled";
517 };
518 };
187 panel_backlight: panel-backlight {
188 compatible = "pwm-backlight";
189 pwms = <&pwm2_pins_a 0 5000000>;
190 brightness-levels = <0 4 8 16 32 64 128 255>;
191 default-brightness-level = <6>;
192 status = "okay";
193 };
I add the "pwm-cell" attribute to timers2 block. Then I use pwm2_pins_a also has the warning info.
Warning (pwms_property): /panel-backlight: Missing property '#pwm-cells' in node /soc/pin-controller@50002000/pwm2-0 or bad phandle (referred from pwms[0])
2019-06-13 12:49 AM
Could you please try this declaration and use &pwm2 phandle in your pwms declaration ( pwms = <&pwm2 0 5000000>;):
503 &timers2 {
504 status = "okay";
505 /* spare dmas for other usage */
506 /delete-property/dmas;
507 /delete-property/dma-names;
508 - pwm {
+ pwm2: pwm {
509 pinctrl-0 = <&pwm2_pins_a>;
510 pinctrl-1 = <&pwm2_sleep_pins_a>;
511 pinctrl-names = "default", "sleep";
512 #pwm-cells = <2>;
513 status = "okay";
514 };
515 - timer@1 {
516 - status = "disabled";
517 - };
518 };
2019-06-13 01:19 AM
Thanks for your help. It is working for my case.
2019-06-13 01:28 AM
ok that's great. We will update the wiki for better clarity.