Thanks to Phil’s post in viewtopic.php?t=359251 I understand where I went wrong and have test a fix but that fix of hardcoding the correct global PWM device index can’t be the proper way.
On older Pi’s (tested on < 3s) there is only one PWM chip and PWM0 is always the first entry in the global PWM device index. But on the Pi5, as Phil notes in the above thead, that can not be assumed.
With the “dtoverlay=pwm,pin=12,func=4” the PWM device I need to use is first on the second chip (the 3rd in the global index). Using that the driver or the sysfs interface works. But my guess is can not be depended on.
I am used pwm_request() as it is simple but it is deprecated and we should use one of the pwm_get() functions. But the questions becomes what is the correct way to find either the correct device or consumer name to pass to pwm_get().
The other improvement to the driver I would to add is a check that the overlay has been loaded and pin 12 is now set to alt func 4.
Please let me know the best practice for either of these.
On older Pi’s (tested on < 3s) there is only one PWM chip and PWM0 is always the first entry in the global PWM device index. But on the Pi5, as Phil notes in the above thead, that can not be assumed.
With the “dtoverlay=pwm,pin=12,func=4” the PWM device I need to use is first on the second chip (the 3rd in the global index). Using that the driver or the sysfs interface works. But my guess is can not be depended on.
I am used pwm_request() as it is simple but it is deprecated and we should use one of the pwm_get() functions. But the questions becomes what is the correct way to find either the correct device or consumer name to pass to pwm_get().
Code:
struct pwm_device * pwm_get (struct device * dev, const char * con_id);Argumentsdev=device for PWM consumercon_id=consumer nameDescriptionLookup is first attempted using DT. If the device was not instantiated from a device tree, a PWM chip and a relative index is looked up via a table supplied by board setup code (see pwm_add_table). Once a PWM chip has been found the specified PWM device will be requested and is ready to be used.ReturnsA pointer to the requested PWM device or an ERR_PTR-encoded error code on failure.
Please let me know the best practice for either of these.
Statistics: Posted by wkeeling — Wed Mar 06, 2024 4:43 pm