Firefly Open Source Community

   Login   |   Register   |
New_Topic

[Linux] PWM control

154

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
154
Posted at 10/25/2022 21:59:48     
  • Type: Official Firmware
  • Filename: ---
  • Download Address: -
  • Log: no log.zip
Problem description and steps to reproduce:
Hello.I try to use PWM to control backlight for LVDS LCD display:
/kernel/arch/arm64/boot/dts/rockchip/rk3568j-firefly-itxq-lvds_m10r800.dts

backlight:backlight {
        status = "okay";
        enable-gpios = <&pca9555 PCA_IO1_3 GPIO_ACTIVE_HIGH>;
        compatible = "pwm-backlight";
        pwms = <&pwm15 0 25000 1>;
lvds_panel: lvds-panel {
        enable-gpios = <&pca9555 PCA_IO1_2 GPIO_ACTIVE_HIGH>;
        backlight = <&backlight>;

}

How can i control this device backlight on pwm15 ?
I tryed:
cat /sys/kernel/debug/pwm
platform/fe700030.pwm, 1 PWM device
pwm-0   (backlight           ): requested enabled period: 25000 ns duty: 19625 ns polarity: inverse
platform/fe700020.pwm, 1 PWM device
pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: inverse
platform/fe6e0010.pwm, 1 PWM device
pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: inverse
platform/fe6e0000.pwm, 1 PWM device
pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: inverse


cd /sys/class/pwm/pwmchip0/
echo 0 > export
cd pwm0
echo 10000 > period
echo 5000 > duty_cycle
echo normal > polarity
echo 1 > enable

cat /sys/kernel/debug/pwm
platform/fe700030.pwm, 1 PWM device
pwm-0   (backlight           ): requested enabled period: 25000 ns duty: 19625 ns polarity: inverse
platform/fe700020.pwm, 1 PWM device
pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: inverse
platform/fe6e0010.pwm, 1 PWM device
pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: inverse
platform/fe6e0000.pwm, 1 PWM device
pwm-0   (sysfs               ): requested enabled period: 10000 ns duty: 5000 ns polarity: normal


Now i can control sysfs but not backlight.
How can i control backlight ?

no log.zip

22 Bytes, Down times: 1

Reply

Use props Report

486

Credits

20

Prestige

15

Contribution

intermediate

Rank: 3Rank: 3

Credits
486
Posted at 10/26/2022 10:06:29     
Try this: echo 100 > /sys/class/backlight/backlight/brightness
Reply

Use props Report

18

Credits

0

Prestige

0

Contribution

new registration

Rank: 1

Credits
18
Posted at 10/26/2022 10:09:42     
He has been used, you can not export.

cd /sys/class/backlight/backlight/
cat brightness                                                                                                                                                      
200
echo 50 > brightness
Reply

Use props Report

154

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
154
Posted at 10/26/2022 14:00:15     
时间的蝴蝶 Posted at 10/26/2022 10:06
Try this: echo 100 > /sys/class/backlight/backlight/brightness

Thank you a lot ! it works fine now !
Now i have another question - how can i control frequency (and polarity), not only brightness ?

Sure, i can try to change frequency in device tree file in pwms = <&pwm15 0 25000 1>:
/kernel/arch/arm64/boot/dts/rockchip/rk3568j-firefly-itxq-lvds_m10r800.dts

backlight:backlight {
        status = "okay";
        enable-gpios = <&pca9555 PCA_IO1_3 GPIO_ACTIVE_HIGH>;
        compatible = "pwm-backlight";
        pwms = <&pwm15 0 25000 1>;
}
Reply

Use props Report

154

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
154
Posted at 10/27/2022 13:31:53     
Yes Sure, i changed frequency (period) to 50000 ns in device tree file in pwms = <&pwm15 0 50000 1>:
/kernel/arch/arm64/boot/dts/rockchip/rk3568j-firefly-itxq-lvds_m10r800.dts
Then i built kernel and wrote firmware to SOM and everything works fine
Reply

Use props Report

You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list