cancel
Showing results for 
Search instead for 
Did you mean: 

PWM Kernel Driver API

NPal.2
Senior

Hi all,

I wish to perform PWM for certain leds connected to STM32MP1 pins.

I wish to do it from the user space application.

I got it working via sysfs interface , but I am more interested in controlling it via a user space application based on some logic. How can I do this ?

Is there API documentation for it?

TIA

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

I'm not SW expert, but for me the pwm_device content is retrieved (mostly from DT I guess) by some available pwm kernel functions.

See https://www.kernel.org/doc/html/latest/driver-api/miscellaneous.html#c.pwm_get

This is not related to ST drivers, but supported by kernel, I think the example for Rockchip you pointed is probably working on STM32MP1 without much issues.

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.

View solution in original post

6 REPLIES 6
PatrickF
ST Employee

Hi,

Did you already found this wiki https://wiki.st.com/stm32mpu/wiki/PWM_overview#Example_of_PWM_usage_with_kernel_PWM_API ?

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 @PatrickF​ ,

Thanks for the response.

I did went through it but it just mentions data for device tree configuration. There is no help around how can I use the driver in custom application.

Can you please help me get more details around this ? I really appreciate the help.

Hi,

Have you seen this 'C' example links on that wiki page ?

Several in-kernel drivers use kernel PWM API. Below a few examples:

API is documented here : https://www.kernel.org/doc/html/latest/driver-api/pwm.html

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 @PatrickF​ : Thanks for the response. I can see how the API is used in the pwm-beeper.c but my concern is again at the ground level as to what data is passed into the struct pwm_device which is used in beeper.

I am looking for an example which somewhat guides to use STM32MP1 PWM like this. Also there isn't much documentation as to how to populate that structure with correct value though API interface seems clean.

Hi,

I'm not SW expert, but for me the pwm_device content is retrieved (mostly from DT I guess) by some available pwm kernel functions.

See https://www.kernel.org/doc/html/latest/driver-api/miscellaneous.html#c.pwm_get

This is not related to ST drivers, but supported by kernel, I think the example for Rockchip you pointed is probably working on STM32MP1 without much issues.

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.

Hi @PatrickF​ : Thank you so much for response will take a look.