Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4455

Advanced users • Can't get PWM backlight to work on P4

$
0
0
I have an HDMI display that doesn't support backlight control via the HDMI port, so I'm trying to do it using some spare GPIO pin, using a device tree overlay. Here's my overlay:

Code:

/dts-v1/;/plugin/;/ {        compatible = "brcm,bcm2835";        fragment@0 {                target = <&gpio>;                __overlay__ {                        pwm_pins: pwm_pins {                                brcm,pins = <18 19>;                                brcm,function = <2>;                                brcm,pull = <0>;                        };                };        };        fragment@1 {                target = <&pwm>;                __overlay__ {                        pinctrl-names = "default";                        pinctrl-0 = <&pwm_pins>;                        status = "okay";                };        };        fragment@2 {                target-path = "/";                __overlay__  {                        backlight: backlight {                                compatible = "pwm-backlight";                                pwms = <&pwm 0 200000>;                                brightness-levels = <0 255>;                                num-interpolated-steps = <255>;                                default-brightness-level = <255>;                                enable-gpios = <&gpio 27 1>;                        };                };        };};
The overlay compiles and loads fine.

`sudo cat /sys/kernel/debug/pwm` shows:

Code:

platform/fe20c000.pwm, 2 PWM devices pwm-0   (backlight           ): requested period: 200000 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
`pinctrl get 18-19,27` shows:

Code:

18: a5    pn | lo // GPIO18 = PWM0_019: a5    pn | lo // GPIO19 = PWM0_127: op -- pd | hi // GPIO27 = output
/boot/config.txt is stock with only the following modifications:

Code:

dtparam=audio=offdtoverlay=pwm-backlight
`pwm-backlight` is the overlay displayed above.

`ls /sys/class/backlight/backlight`

Code:

actual_brightness  bl_power  brightness  device  max_brightness  power  scale  subsystem  type  uevent
`actual_brightness` is 255, and `brightness` is also 255. I see no errors in the logs, so everything appears to be loading as expected. However, I get no PWM signal on GPIO 18; it remains low. I also tried setting `brightness` to 128, but while it succeeded without error, the signal on GPIO 18 remains low.

What am I doing wrong?

`uname -a` is:

Code:

Linux raspberrypi 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux

Statistics: Posted by JinShil — Tue Jan 16, 2024 11:59 pm — Replies 1 — Views 303



Viewing all articles
Browse latest Browse all 4455

Trending Articles