PWM backlight not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-02 3:06 AM - last edited on ‎2024-11-06 12:39 AM by Andrew Neil
Can you please check my device tree configuration?
Backlight as a GPIO is working correctly, but when i try to use it as pwm, the pin line is always fixed to low.
Inside my .dts:
This is my panel definition:
panel { compatible = "newkoro,display","simple-panel"; //enable-gpios = <&gpioe 12 GPIO_ACTIVE_HIGH>; //reset-gpios = <&gpioe 11 GPIO_ACTIVE_HIGH>; backlight = <&backlight>; power-supply = <&vdd>; status = "okay"; port@0{ //reg = <0>; panel_in: endpoint { remote-endpoint = <<dc_ep0_out>; }; }; };
This is backlight as simple gpio (working)
//backlight: panel-backlight { // compatible = "gpio-backlight"; // gpios = <&gpioe 4 GPIO_ACTIVE_HIGH>; //default-off; //};
This is backlight as pwm (not working)
backlight: panel-backlight { compatible = "pwm-backlight"; pwms = <&backlight_pwm 0 100000 0>; brightness-levels = <0 31 63 95 127 159 191 223 255>; default-brightness-level = <8>; status = "okay"; //power-supply = <®_5v2>; /* 3V3_BACKLIGHT */ };
and this is timer defs:
&timers15 { status = "okay"; backlight_pwm: pwm { pinctrl-names = "default", "sleep"; pinctrl-0 = <&pwm15_pins_a>; pinctrl-1 = <&pwm15_sleep_pins_a>; status = "okay"; //#pwm-cells = <2>; }; };
inside pinctrl i have:
pwm15_pins_a: pwm15-0 { pins { pinmux = <STM32_PINMUX('E', 4, AF4)>; /* TIM15_CH1N */ bias-disable; drive-push-pull; slew-rate = <0>; }; }; pwm15_sleep_pins_a: pwm15-sleep-0 { pins { pinmux = <STM32_PINMUX('E', 4, ANALOG)>; /* TIM15_CH1N */ }; };
thank you
- Labels:
-
STM32MP15 Lines
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-02 5:36 AM
People likely to ask:
- What STM part number?
- How is clock source for PWM configured?
I use MX to configure. I have an STM32L476 Nucleo sample project with PWM output working if you'd like a zip. You could dig through and see the MX generated PWM setup code, and my use of it.
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-02 5:44 AM
Hi Paul,
thank you for answering.
I'm working with STM32MP157c.
I need .dts configuration, MX output files are mostly incomplete, so i don't think it would help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-08 12:28 AM
Hi,
(it seems you are also in direct contact with regional FAE for same topic, so you might receive answer by other channels)
In our DT examples (for DK2 and EV1 board), I confirm timer15 is used for CSI/HSI oscillator regular calibration.
So it cannot be used for other purposes.
Please try commenting the related lines in your DT:
&rcc {
/* st,hsi-cal; */
/* st,csi-cal; */
/* st,cal-sec = <60>; */
...
};
...
&timers15 {
/* secure-status = "okay"; */
/* st,hsi-cal-input = <7>; */
/* st,csi-cal-input = <8>; */
};
But as this will stop the CSI/HSI calibration, it might not fit some of your clock constrains if non-calibrated accuracy is not enough.
Alternatively, to free timer15 and still use calibration, timer12 could be used for CSI/HSI calibration.
e.g.
&timers12 {
secure-status = "okay";
st,hsi-cal-input = <1>;
st,csi-cal-input = <2>;
};
Regards.
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-08 2:25 AM
Hi @PatrickF​
You were correct, I modified tf-a dts removing calibration on timer15 and now I can controll pwm as expected.
However, I still have doubts about the pwm-backlight driver:
- Backlight starts off, no matter what default-brightness-level I configure. I must manually do "echo 0 > /sys/class/backlight/panel-backlight/bl_power"
- When backlight is enabled, i don't see the image on the display (display becomes greyish but no image)
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-08 2:38 AM
UPDATE:
If I remove backlight property from the display:
panel {
compatible = "newkoro,display","simple-panel";
//enable-gpios = <&gpioe 12 GPIO_ACTIVE_HIGH>;
//reset-gpios = <&gpioe 11 GPIO_ACTIVE_HIGH>;
//backlight = <&backlight>;
power-supply = <&vdd>;
status = "okay";
port@0{
//reg = <0>;
panel_in: endpoint {
remote-endpoint = <<dc_ep0_out>;
};
};
Backlight starts on, i can see the image on the display and regolate pwm duty.
I was wondering, is panel-simple.c driver able of using backlight as pwm?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-24 7:35 AM
Hi @Lmoio.1​ , thanks for putting up this query. I am running into exact similar issue. Its just that I am using stm32mp157a and timer4 channel 4 as pwm out.
Getting some new error when I performed grep in demsg :
pwm-backlight: probe of backlight failed with error -22
@PatrickF​ and all the members in the chain requesting for the input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-24 7:48 AM
Hi,
can you leave only timer configuration [&timers4 in your case] and verify pwm is working? (check under /sys/class/pwm)..
I'll attach STM workshop about pwms. Hope it's usefull.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-29 6:27 AM
@Lmoio.1​ Thanks for suggestions. PWM is working perfectly. Driver also picked up correctly now. But there is not variation of backlight happening even though changing brightness levels.
Here is the device tree working (for atleast binding to driver) :
backlight: backlight {
u-boot,dm-pre-reloc;
compatible = "pwm-backlight";
pwms = <&bl_pwm 0 500000 PWM_POLARITY_INVERTED>;
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <2>;
power-supply = <&vdd>;
enable-gpios = <&gpioc 2 GPIO_ACTIVE_HIGH>;
status = "okay";
};
It comes up as : /sys/class/backlight/backlight in sysfs interface.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-29 6:31 AM
Try
echo 0 > /sys/class/backlight/backlight/bl_power
