cancel
Showing results for 
Search instead for 
Did you mean: 

pwm2 prevents system to go in suspend mode

GCici
Associate II

Hi,

I've set up 3 pwmleds on my board, 1 led ("led1") on pwm2 (TIM2_CH4 on PA3) and the other 2 ("led2" and "led3") on pwm8 (TIM8_CH1 on PH13 and TIM8_CH2 on PH14). If I put the system in suspend mode it doesn't work. The system gives me the following message:

"

stm32-pwm 40000000.timer:pwm: PWM 3 still in use by consumer led1

PM: dpm_run_callback(): platform_pm_suspend+0x0/0x48 returns -16

stm32-pwm 40000000.timer:pwm: PM: failed to suspend: error -16

PM: Some devices failed to suspend, or early wake event detected"

"

If I disable the led1 in the devicetree and leave only the other 2 leds (led2 and led3) on pwm8 the suspend works as expected.

Any idea?

9 REPLIES 9
PatrickF
ST Employee

Hi @GCici​ ,

I'm not Linux expert, but it might sound normal that you cannot go in suspend if some peripheral activity is running.

Maybe your 'led' driver is not intended to be automatically stopped under Linux request (it could make sense for e.g. motor control, etc... ) and need to be stopped manually (e.g. by the app who started it) before going to suspend.

If LED are only for status, maybe there is better ways to control them than using PWM.

Regards.

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.

Hi,

Pwmleds belong to kernel driver, and if you read what is written ​it's the same for all the 3 LEDs. The driver has pm management, in fact with pwm8 it works as expected. The problem is with pwm2. So, thank you for your reply but I think I need the help of a Linux expert ;)

Cheers ​

GCici
Associate II

Still no answer?

BTW I've found a workaround, but that must not be the solution: I can get sleep working by force-removal of pwm-stm32 kernel module.

I'd appreciate some help guys

Kevin HUBER
ST Employee

Hello @GCici​ ,

Please can you provide me the DTS file of your board and if possible also the complete DTB.

I will have a look at it and if I do not find something, I will try to reproduce the issue on my board.

Which ecosystem are you using? Is it the v4.1 ? https://wiki.st.com/stm32mpu/wiki/STM32_MPU_OpenSTLinux_release_note_-_v4.1.0#Linux-C2-AE_kernel

Best Regards,

Kevin

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.

Here are the relevant fragments:

/ {
	pwmleds {
		compatible = "pwm-leds";
 
 		led1{
			label = "led1";
			pwms = <&pwm2 3 500000 0>;
			max-brightness = <255>;
			linux,default-trigger = "heartbeat";
		};
 
		led2 {
			label = "led2";
			pwms = <&pwm8 1 500000 1>;
			max-brightness = <255>;
			linux,default-trigger = "default-off";
			default-state = "off";
		};
 
		led3 {
			label = "led3";
			pwms = <&pwm8 0 500000 1>;
			max-brightness = <127>;
			linux,default-trigger = "default-off";
			default-state = "off";
		};
	};
};
 
&pinctrl {
	pwm8_pins_b: pwm8-1 {
		pins {
			pinmux = <STM32_PINMUX('H', 13, AF3)>, /* TIM8_CH1 */
				 <STM32_PINMUX('H', 14, AF3)>, /* TIM8_CH2 */
			bias-pull-down;
			drive-push-pull;
			slew-rate = <0>;
		};
	};
 
	pwm8_sleep_pins_b: pwm8-sleep-1 {
		pins {
			pinmux = <STM32_PINMUX('H', 13, ANALOG)>, /* TIM8_CH1 */
				 <STM32_PINMUX('H', 14, ANALOG)>, /* TIM8_CH2 */
		};
	};
};
 
&timers2 {
	/delete-property/dmas;
	/delete-property/dma-names;
	status = "okay";
 
	pwm2: pwm {
		pinctrl-0 = <&pwm2_pins_a>;
		pinctrl-1 = <&pwm2_sleep_pins_a>;
		pinctrl-names = "default", "sleep";
		status = "okay";
	};
 
	timer@1 {
		status = "okay";
	};
};
 
&timers8 {
	/delete-property/dmas;
	/delete-property/dma-names;
	status = "okay";
 
	pwm8: pwm {
		pinctrl-0 = <&pwm8_pins_b>;
		pinctrl-1 = <&pwm8_sleep_pins_b>;
		pinctrl-names = "default", "sleep";
		status = "okay";
	};
 
	timer@7 {
		status = "okay";
	};
};

And yes, I'm using the latest v4.1 ecosystem

It's a custom board based on stm32mp153dac so I think the complete dtb would be useless for you

Kevin HUBER
ST Employee

Hello @GCici​ ,

Your DTS looks correct, so I tried to reproduce the problem on my board. I modified the DT configuration of my STM32MP157F-EV1 board to use the same pin than you for pwm2 and pwm8.

If I verify the pins used by doing "cat /sys/kernel/debug/pinctrl/soc:pinctrl@50002000/pinmux-pins", I can see:

pin 125 (PH13): device 44001000.timer:pwm function af3 group PH13
pin 126 (PH14): device 44001000.timer:pwm function af3 group PH14
 
 
pin 3 (PA3): device 40000000.timer:pwm function af1 group PA3

So it looks good.

Then if I follow the debug chapter of the wiki page: https://wiki.st.com/stm32mpu/wiki/PWM_overview#How_to_monitor_with_debugfs

 
_legacyfs_online_stmicro_images_0693W00000dJpI0QAK.pngI can see that led1,2 and 3 are well configured.

But unlike you, I'm able to go in low power mode by calling "echo mem > /sys/power/state". As explained in the wiki: https://wiki.st.com/stm32mpu/wiki/Power_overview#API_description


_legacyfs_online_stmicro_images_0693W00000dJpFPQA0.pngI also tried on a DK2 board and I got the same result.

So right now, I'm not able to reproduce the problem on my side.

---

Please can you share the complete boot log of your board until you reproduce the problem.

I would like to have all the traces and the commands that you use to try to understand what can causes such an issue?

Even if it is not the same board, I would like also to have the complete DTB.

The goal is not to apply it directly on my board, but to uncompiled it with a tool named "dtc". Then I will be able to see if your configuration is not overwritten by another device tree or another configuration somewhere else.

Best Regards,

Kevin

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.
GCici
Associate II

Hi, 

finally I've found the time to investigate. In the meanwhile i moved to the latest ecosystem (v5) and now all works well, except when I use "active-low;" option in one of the 3 leds definiton. I have one of the 3 gpios connected to a p-mos, so I need to use that directive in order to set the correct brightness. how to move on?

PatrickF
ST Employee

Hi @GCici ,

regarding the active-low for PWM, have you tried something like this in Device Tree:

pwms = <&pwm2 3 500000 PWM_POLARITY_INVERTED>;

or in sysfs

echo "inversed" > pwm2/polarity

See also
https://github.com/STMicroelectronics/linux/blob/master/Documentation/devicetree/bindings/pwm/pwm.txt#L48

Regards.

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.

Yes, but it doesnt change the behavior when manually setting brightness. If i want to put the led off i have to set brightness to 255 and not 0