aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2016-06-08 05:21:23 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-06-10 10:01:35 -0400
commit3a3d1a4e32ab47323d7b8c8b7631a8d36a3098b2 (patch)
treea79165beca06b134c36ac6dd6ebbcd82e36d3206 /drivers/pwm
parent1a695a905c18548062509178b98bc91e67510864 (diff)
pwm: Add PWM capture support
Supply a PWM capture callback op in order to pass back information obtained by running analysis on a PWM signal. This would normally (at least during testing) be called from the sysfs routines with a view to printing out PWM capture data which has been encoded into a string. Signed-off-by: Lee Jones <lee.jones@linaro.org> [thierry.reding@gmail.com: make capture data unsigned int for symmetry] Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/core.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index dba3843c53b8..8f40604046d6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -525,6 +525,33 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
525EXPORT_SYMBOL_GPL(pwm_apply_state); 525EXPORT_SYMBOL_GPL(pwm_apply_state);
526 526
527/** 527/**
528 * pwm_capture() - capture and report a PWM signal
529 * @pwm: PWM device
530 * @result: structure to fill with capture result
531 * @timeout: time to wait, in milliseconds, before giving up on capture
532 *
533 * Returns: 0 on success or a negative error code on failure.
534 */
535int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
536 unsigned long timeout)
537{
538 int err;
539
540 if (!pwm || !pwm->chip->ops)
541 return -EINVAL;
542
543 if (!pwm->chip->ops->capture)
544 return -ENOSYS;
545
546 mutex_lock(&pwm_lock);
547 err = pwm->chip->ops->capture(pwm->chip, pwm, result, timeout);
548 mutex_unlock(&pwm_lock);
549
550 return err;
551}
552EXPORT_SYMBOL_GPL(pwm_capture);
553
554/**
528 * pwm_adjust_config() - adjust the current PWM config to the PWM arguments 555 * pwm_adjust_config() - adjust the current PWM config to the PWM arguments
529 * @pwm: PWM device 556 * @pwm: PWM device
530 * 557 *