aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-25 13:40:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-25 13:40:15 -0400
commitecc5fbd5ef472a4c659dc56a5739b3f041c0530c (patch)
treeeec1c3ddd6082e6391d7d27ae78d813a8f6c216c /Documentation
parent1f93d2abf488c6a41bdd5e6caf80b559493eea8d (diff)
parent18c588786c08458f5d965d8735ab48f9e51e0b4b (diff)
Merge tag 'pwm/for-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "This set of changes introduces an atomic API to the PWM subsystem. This is influenced by the DRM atomic API that was introduced a while back, though it is obviously a lot simpler. The fundamental idea remains the same, though: drivers provide a single callback to implement the atomic configuration of a PWM channel. As a side-effect the PWM subsystem gains the ability for initial state retrieval, so that the logical state mirrors that of the hardware. Many use-cases don't care about this, but for others it is essential. These new features require changes in all users, which these patches take care of. The core is transitioned to use the atomic callback if available and provides a fallback mechanism for other drivers. Changes to transition users and drivers to the atomic API are postponed to v4.8" * tag 'pwm/for-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (30 commits) pwm: Add information about polarity, duty cycle and period to debugfs pwm: Switch to the atomic API pwm: Update documentation pwm: Add core infrastructure to allow atomic updates pwm: Add hardware readout infrastructure pwm: Move the enabled/disabled info into pwm_state pwm: Introduce the pwm_state concept pwm: Keep PWM state in sync with hardware state ARM: Explicitly apply PWM config extracted from pwm_args drm: i915: Explicitly apply PWM config extracted from pwm_args input: misc: pwm-beeper: Explicitly apply PWM config extracted from pwm_args input: misc: max8997: Explicitly apply PWM config extracted from pwm_args backlight: lm3630a: explicitly apply PWM config extracted from pwm_args backlight: lp855x: Explicitly apply PWM config extracted from pwm_args backlight: lp8788: Explicitly apply PWM config extracted from pwm_args backlight: pwm_bl: Use pwm_get_args() where appropriate fbdev: ssd1307fb: Use pwm_get_args() where appropriate regulator: pwm: Use pwm_get_args() where appropriate leds: pwm: Use pwm_get_args() where appropriate input: misc: max77693: Use pwm_get_args() where appropriate ...
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