I want to try to use PWM in linux kernel module for my Rasperry Pi. I've successfully enabled PWM via SYSFS interface. For usage of pwm in kernel modules documentation states:
New users should use the pwm_get() function and pass to it the consumer device or a consumer name. pwm_put() is used to free the PWM device. Managed variants of these functions, devm_pwm_get() and devm_pwm_put(), also exist.
pwm_get function looks like this:
/**
* pwm_get() - look up and request a PWM device
* @dev: device for PWM consumer
* @con_id: consumer name
....
*/
struct pwm_device *pwm_get(struct device *dev, const char *con_id)
Where I can find dev and con_id? I suspect that they should be defined in device tree, but it is only a suspicion.
pwm-beeper
is another example ofpwm_get()
.A corresponding entry in the device tree is present here.