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: 61653 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2630777lbl; Wed, 10 Feb 2016 05:06:08 -0800 (PST) X-Received: by 10.98.9.219 with SMTP id 88mr53804058pfj.0.1455109568174; Wed, 10 Feb 2016 05:06:08 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 3si4991091pfo.227.2016.02.10.05.06.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2016 05:06:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTUSF-0006Sq-Ue; Wed, 10 Feb 2016 13:05:11 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTUS1-0005vR-4q for linux-arm-kernel@lists.infradead.org; Wed, 10 Feb 2016 13:04:58 +0000 Received: by mail-wm0-x22a.google.com with SMTP id p63so27517126wmp.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=MCCqp2HhYUal/2IZIQUfB30dWS64W3HDj4X3HMHuKDWOaq1TDtvkfg9gMWyXaapYax VoL3oJX9MKBs/sW7CDNssdKmxeyddmy9h2Ocly7BxEfckneff3LcGK3pJasr7Gz+MBQk AvKLwPTV9Vu5froNMWDblHfArPDsVrIymDKwzFGvqixX92tE8pAVgLXJgH9gvjg2fmsi n/E8YbcwILEJi8cXi9uBlUnsri8dr8EkPAb6od8ibcknhfxLyXX3CnEmWEeeoaRgEd/W QNDCD2BHiUDsZDoKcqYEmkivmKrLWavGed5Ra9JRuBues6kxPrnACLANd+cFnRAtu5bB GubQ== X-Gm-Message-State: AG10YORLnmhboTorvY2LiZTHqXoQQLRjuV5sNoVXvnyuZ2re55FxkGCNW6UYXMnRsQKyJjnq 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160210_050457_441247_E72E00A5 X-CRM114-Status: GOOD ( 12.81 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lee Jones , kernel@stlinux.com, maxime.coquelin@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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(+) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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