From patchwork Wed Feb 10 13:02:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 581409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8262B1402C9 for ; Thu, 11 Feb 2016 00:08:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=cjwtEcHy; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751391AbcBJNIf (ORCPT ); Wed, 10 Feb 2016 08:08:35 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:34747 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223AbcBJNEg (ORCPT ); Wed, 10 Feb 2016 08:04:36 -0500 Received: by mail-wm0-f44.google.com with SMTP id 128so25909047wmz.1 for ; Wed, 10 Feb 2016 05:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y9t0SNAQ7JZG+z5hooK+8NeKEiwCilNJCpp2dYaBSTY=; b=cjwtEcHydzW78//DJoAwhtMu8RgyCax44INoD94IlOIXa+cbNyREgSkXo6w2ImKPGu jhnNmHJjIT0tDM7mJAyk+hZWgDcsXzv56c8pAXgjVAE4fc0e2Fz2npOGsWN6h8lN3S6B ++EqXGb6VNhvukSjsQkDqOQSQk6aPTGq9ULjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y9t0SNAQ7JZG+z5hooK+8NeKEiwCilNJCpp2dYaBSTY=; b=HNA7I6dFzuaTDNAXwuPPLVlm3HcFbS/kFElqJTLnKmrg+b3qLPo2QlwiZFyv2pmLtP HsPdv2Anf+b+Iuid4RlXZmaMh7+Actd2XEQa2jlgGB/iwkRI57nyabmUbRZZxW9kTxvG Xd7ZvY9fZyy8HiYFeW0xO6Z9VuPLvkUO3JZbCx93AH4eagb3VlSUohxxeZg46JW2+LZH lWmV8SkjjG8rvVYM9GkR+t0hcFzf+/e1QKjs3N+Sief2NXdbhuzKfBE9h05YCc0nsBf5 uVfy+u5c7z1DAHghjTPSHdl/dA4jt9cHzJwMCD5odTLgY5DGFL5vJPvi1jiXN36x30Ab 5N+w== X-Gm-Message-State: AG10YOSe+C2K0m5xQ7RmYRpSancyicKoCjNBIwSRf4wHX03ngeFpQWPbzn0ZWcX428qTfw1J X-Received: by 10.28.90.67 with SMTP id o64mr10469057wmb.38.1455109475784; Wed, 10 Feb 2016 05:04:35 -0800 (PST) Received: from localhost.localdomain (host81-129-170-149.range81-129.btcentralplus.com. [81.129.170.149]) by smtp.gmail.com with ESMTPSA id q75sm22429319wmd.6.2016.02.10.05.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Feb 2016 05:04:34 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, thierry.reding@gmail.com, linux-pwm@vger.kernel.org, ajitpal.singh@st.com Cc: kernel@stlinux.com, maxime.coquelin@st.com, Lee Jones Subject: [PATCH 01/11] pwm: Add PWM Capture support Date: Wed, 10 Feb 2016 13:02:18 +0000 Message-Id: <1455109348-32767-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455109348-32767-1-git-send-email-lee.jones@linaro.org> References: <1455109348-32767-1-git-send-email-lee.jones@linaro.org> Sender: linux-pwm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pwm@vger.kernel.org Supply a PWM Capture call-back Op in order to pass back information obtained by running analysis on PWM a 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 --- drivers/pwm/core.c | 26 ++++++++++++++++++++++++++ include/linux/pwm.h | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index d24ca5f..8f4a8a9 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -494,6 +494,32 @@ unlock: EXPORT_SYMBOL_GPL(pwm_set_polarity); /** + * pwm_capture() - capture and report a PWM signal + * @pwm: PWM device + * @channel: PWM capture channel to use + * @buf: buffer to place output message into + * + * Returns: 0 on success or a negative error code on failure. + */ +int pwm_capture(struct pwm_device *pwm, int channel, char *buf) +{ + int err; + + if (!pwm || !pwm->chip->ops) + return -EINVAL; + + if (!pwm->chip->ops->capture) + return -ENOSYS; + + mutex_lock(&pwm->lock); + err = pwm->chip->ops->capture(pwm->chip, pwm, channel, buf); + mutex_unlock(&pwm->lock); + + return err; +} +EXPORT_SYMBOL_GPL(pwm_capture); + +/** * pwm_enable() - start a PWM output toggling * @pwm: PWM device * diff --git a/include/linux/pwm.h b/include/linux/pwm.h index cfc3ed4..7bcff6b 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -33,6 +33,11 @@ int pwm_enable(struct pwm_device *pwm); * pwm_disable - stop a PWM output toggling */ void pwm_disable(struct pwm_device *pwm); + +/* + * pwm_capture - capture and report a PWM signal + */ +int pwm_capture(struct pwm_device *pwm, int channel, char *buf); #else static inline struct pwm_device *pwm_request(int pwm_id, const char *label) { @@ -56,6 +61,11 @@ static inline int pwm_enable(struct pwm_device *pwm) static inline void pwm_disable(struct pwm_device *pwm) { } + +static inline int pwm_capture(struct pwm_device *pwm, int channel, char *buf) +{ + return -EINVAL; +} #endif struct pwm_chip; @@ -150,6 +160,7 @@ static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm) * @free: optional hook for freeing a PWM * @config: configure duty cycles and period length for this PWM * @set_polarity: configure the polarity of this PWM + * @capture: capture and report PWM signal * @enable: enable PWM output toggling * @disable: disable PWM output toggling * @dbg_show: optional routine to show contents in debugfs @@ -162,6 +173,8 @@ struct pwm_ops { int duty_ns, int period_ns); int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm, enum pwm_polarity polarity); + int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm, + int channel, char *buf); int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm); void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm); #ifdef CONFIG_DEBUG_FS