mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
pwm: Add table-based lookup for static mappings
In order to get rid of the global namespace for PWM devices, this commit provides an alternative method, similar to that of the regulator or clock frameworks, for registering a static mapping for PWM devices. This works by providing a table with a provider/consumer map in the board setup code. With the new pwm_get() and pwm_put() functions available, usage of pwm_request() and pwm_free() becomes deprecated. Reviewed-by: Shawn Guo <[email protected]> Reviewed-by: Mark Brown <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
This commit is contained in:
parent
62099abf67
commit
8138d2ddbc
3 changed files with 199 additions and 19 deletions
|
|
@ -12,14 +12,33 @@ this kind of flexibility the generic PWM API exists.
|
|||
Identifying PWMs
|
||||
----------------
|
||||
|
||||
Users of the legacy PWM API use unique IDs to refer to PWM devices. One
|
||||
goal of the new PWM framework is to get rid of this global namespace.
|
||||
Users of the legacy PWM API use unique IDs to refer to PWM devices.
|
||||
|
||||
Instead of referring to a PWM device via its unique ID, board setup code
|
||||
should instead register a static mapping that can be used to match PWM
|
||||
consumers to providers, as given in the following example:
|
||||
|
||||
static struct pwm_lookup board_pwm_lookup[] = {
|
||||
PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL),
|
||||
};
|
||||
|
||||
static void __init board_init(void)
|
||||
{
|
||||
...
|
||||
pwm_add_table(board_pwm_lookup, ARRAY_SIZE(board_pwm_lookup));
|
||||
...
|
||||
}
|
||||
|
||||
Using PWMs
|
||||
----------
|
||||
|
||||
A PWM can be requested using pwm_request() and freed after usage with
|
||||
pwm_free(). After being requested a PWM has to be configured using
|
||||
Legacy users can request a PWM device using pwm_request() and free it
|
||||
after usage with pwm_free().
|
||||
|
||||
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.
|
||||
|
||||
After being requested a PWM has to be configured using:
|
||||
|
||||
int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue