diff options
author | Thierry Reding <thierry.reding@avionic-design.de> | 2012-03-26 08:42:48 +0200 |
---|---|---|
committer | Thierry Reding <thierry.reding@avionic-design.de> | 2012-06-15 12:56:53 +0200 |
commit | 8138d2ddbcca2a100482dac390133f83c5a60f94 (patch) | |
tree | 814645a7608376af451f9721dd3da585a87bbdd6 /Documentation/pwm.txt | |
parent | 62099abf67a20cfb98d4c031fb1925e10a78ee1b (diff) | |
download | lwn-8138d2ddbcca2a100482dac390133f83c5a60f94.tar.gz lwn-8138d2ddbcca2a100482dac390133f83c5a60f94.zip |
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 <shawn.guo@linaro.org>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Diffstat (limited to 'Documentation/pwm.txt')
-rw-r--r-- | Documentation/pwm.txt | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt index 48f598acdd16..554290ebab94 100644 --- a/Documentation/pwm.txt +++ b/Documentation/pwm.txt @@ -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); |