aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/pwm.txt30
1 files changed, 28 insertions, 2 deletions
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index ca895fd211e4..789b27c6ec99 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -42,9 +42,26 @@ variants of these functions, devm_pwm_get() and devm_pwm_put(), also exist.
42 42
43After being requested, a PWM has to be configured using: 43After being requested, a PWM has to be configured using:
44 44
45int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns); 45int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state);
46 46
47To start/stop toggling the PWM output use pwm_enable()/pwm_disable(). 47This API controls both the PWM period/duty_cycle config and the
48enable/disable state.
49
50The pwm_config(), pwm_enable() and pwm_disable() functions are just wrappers
51around pwm_apply_state() and should not be used if the user wants to change
52several parameter at once. For example, if you see pwm_config() and
53pwm_{enable,disable}() calls in the same function, this probably means you
54should switch to pwm_apply_state().
55
56The PWM user API also allows one to query the PWM state with pwm_get_state().
57
58In addition to the PWM state, the PWM API also exposes PWM arguments, which
59are the reference PWM config one should use on this PWM.
60PWM arguments are usually platform-specific and allows the PWM user to only
61care about dutycycle relatively to the full period (like, duty = 50% of the
62period). struct pwm_args contains 2 fields (period and polarity) and should
63be used to set the initial PWM config (usually done in the probe function
64of the PWM user). PWM arguments are retrieved with pwm_get_args().
48 65
49Using PWMs with the sysfs interface 66Using PWMs with the sysfs interface
50----------------------------------- 67-----------------------------------
@@ -105,6 +122,15 @@ goes low for the remainder of the period. Conversely, a signal with inversed
105polarity starts low for the duration of the duty cycle and goes high for the 122polarity starts low for the duration of the duty cycle and goes high for the
106remainder of the period. 123remainder of the period.
107 124
125Drivers are encouraged to implement ->apply() instead of the legacy
126->enable(), ->disable() and ->config() methods. Doing that should provide
127atomicity in the PWM config workflow, which is required when the PWM controls
128a critical device (like a regulator).
129
130The implementation of ->get_state() (a method used to retrieve initial PWM
131state) is also encouraged for the same reason: letting the PWM user know
132about the current PWM state would allow him to avoid glitches.
133
108Locking 134Locking
109------- 135-------
110 136