cancel
Showing results for 
Search instead for 
Did you mean: 

PWM backlight not working.

Lmoio.1
Senior

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

10 REPLIES 10
Paul1
Lead

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

Lmoio.1
Senior

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.

PatrickF
ST Employee

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'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Lmoio.1
Senior

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:

  1. Backlight starts off, no matter what default-brightness-level I configure. I must manually do "echo 0 > /sys/class/backlight/panel-backlight/bl_power"
  2. When backlight is enabled, i don't see the image on the display (display becomes greyish but no image)

Thank you

Lmoio.1
Senior

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 = <&ltdc_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?

NPal.2
Senior

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.

Lmoio.1
Senior

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.

NPal.2
Senior

@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.

Lmoio.1
Senior

Try

echo 0 > /sys/class/backlight/backlight/bl_power