2021-06-02 02:12 AM
Similar question was asked here:
https://community.st.com/s/question/0D50X0000AvgWuG/how-to-use-timers2-as-pwmbacklight
But this does not work on v5.4 kernel anymore. So a working example would be nice as pwm-backlight device tree handling is not documented in the wiki. SoC is STM32MP157. Current code is:
panel_backlight: panel-backlight {
compatible = "pwm-backlight";
pwms = <&pwm12_pins_a 0 5000000>;
pwm-names = "backlight";
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
status = "okay";
};
&timers12 {
/delete-property/dmas;
/delete-property/dma-names;
status = "okay";
pwm12: pwm {
pinctrl-0 = <&pwm12_pins_a>;
pinctrl-1 = <&pwm12_sleep_pins_a>;
pinctrl-names = "default", "sleep";
#pwm-cells = <2>;
status = "okay";
};
timer@11 {
status = "okay";
};
};
Which leads to these errors:
[ 0.303501] pwm-backlight panel-backlight: panel-backlight supply power not found, using dummy regulator
[ 0.303628] OF: /panel-backlight: could not get #pwm-cells for /soc/pin-controller@50002000/pwm12-0
[ 0.303640] of_pwm_get(): can't parse "pwms" property
[ 0.303655] pwm-backlight panel-backlight: unable to request PWM
[ 0.303781] pwm-backlight: probe of panel-backlight failed with error -22
2021-06-03 02:57 AM
Hello,
Moving your dev from a LTS kernel version to another is never an obvious thing to do. A lot of thinks happen in the kernel during one year !!
It has to be done on purpose and you need to choose the right one (note ST released a first V3.0.0 vous kernel 5.10).
I will look at your issue. Maybe the bindings has changed a bit between the 2 versions.
2021-06-03 04:55 AM
Thanks @Bernard PUEL .
I had a little success, the display is now turned on during boot, as soon as enable-gpios is set.
But due to the fact that this pin is in use by the pinctrl, I cannot use enable-gpios and the pwm stuff does not work so far.
I found out that to get rid of the warning mentioned in the previous community question you have to put #pwm-cells = <2>; into the pwm12_pins_a node like so:
pwm12_pins_a: pwm12-0 {
#pwm-cells = <2>;
pins {
pinmux = <STM32_PINMUX('H', 6, AF2)>; /* TIM12_CH2 */
bias-pull-down;
drive-push-pull;
slew-rate = <0>;
};
};
pwm12_sleep_pins_a: pwm12-sleep-0 {
pins {
pinmux = <STM32_PINMUX('H', 6, ANALOG)>; /* TIM12_CH2 */
};
};
The problem is that as soon as I use the Timer 12 CH2 pin pwm12_pins_a in the pinctrl it does not work anymore.
Tracked it down to of_find_backlight_by_node() which does not find a pwm-backlight device.
So I guess the issue is somewhere between pwm12_pins_a and the pwms property.
2021-06-03 07:54 AM
from your first code extraction:
"pwms = <&pwm12_pins_a 0 5000000>;" should be replaced with "pwms = <&pwm12 0 5000000>;"
This makes the link between the 2 nodes. I don't know how it could work before on 4.19.
2021-06-03 08:01 AM
https://wiki.st.com/stm32mpu/wiki/TIM_device_tree_configuration#TIM_configured_in_PWM_mode is showing it.
2021-06-15 03:52 AM
&timers12 {
/delete-property/dmas;
/delete-property/dma-names;
status = "okay";
pwm12: pwm {
pinctrl-0 = <&pwm12_pins_a>;
pinctrl-1 = <&pwm12_sleep_pins_a>;
pinctrl-names = "default", "sleep";
#pwm-cells = <3>;
status = "okay";
};
};
pwm12_pins_a: pwm12-0 {
pins {
pinmux = <STM32_PINMUX('H', 9, AF2)>; /* TIM12_CH2 */
bias-pull-down;
drive-push-pull;
slew-rate = <0>;
};
};
pwm12_sleep_pins_a: pwm12-sleep-0 {
pins {
pinmux = <STM32_PINMUX('H', 9, ANALOG)>; /* TIM12_CH2 */
};
};
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm12 1 5000000 0>;
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
status = "okay";
};
That's the current setup but the signal coming out of H9 is always HIGH, no matter what value is in /sys/class/backlight/backlight/brightness.
Any ideas why @Bernard PUEL ?
2021-06-15 06:38 AM
Sorry, my link to the latest wiki page is based on latest delivery that is V3.0.0 so kernel 5.10.
Here is the right bindings for 5.4 Kernel (you can find in V2 wiki): https://github.com/STMicroelectronics/linux/blob/v5.4-stm32mp/Documentation/devicetree/bindings/pwm/pwm.txt
pwms has only 2 arguments, so you have to declare it: #pwm-cells = <2>; and use it like this: pwms = <&pwm12 1 5000000>; like you did in your first trial.
Hope it will help. If still not good, maybe check the pinctrl settings.
2021-06-15 06:55 AM
Unfortunately it doesn't. Is there maybe some kernel config missing, enabled is:
CONFIG_MFD_STM32_TIMERS
CONFIG_PWM_STM32
CONFIG_IIO_STM32_TIMER_TRIGGER
CONFIG_STM32_TIMER_CNT
2021-06-15 07:15 AM
2021-06-16 07:52 AM
you can check also https://wiki.st.com/stm32mpu-ecosystem-v2/wiki/PWM_overview chapters 4 and 5 to debug step by step.