From patchwork Wed Mar 2 15:32:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 63394 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2449075lbc; Wed, 2 Mar 2016 07:36:20 -0800 (PST) X-Received: by 10.98.16.210 with SMTP id 79mr29325867pfq.69.1456932980469; Wed, 02 Mar 2016 07:36:20 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id o70si27677233pfj.105.2016.03.02.07.36.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 07:36:20 -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 1ab8nv-0005B8-3M; Wed, 02 Mar 2016 15:35:11 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ab8nN-0004KW-My for linux-arm-kernel@lists.infradead.org; Wed, 02 Mar 2016 15:34:39 +0000 Received: by mail-wm0-x231.google.com with SMTP id p65so83143652wmp.0 for ; Wed, 02 Mar 2016 07:34:17 -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=cyI57F19pIhwZcq5ccrYrB+HUgtxU3ItyRp6MeQ2xbE=; b=WSCgCzvj7vFHnaCVuw4iPhr977KCcwRZ1S58xJjcJcfnvMk5N8tbZ0AaEHoxQ42IW+ qhI2Qwggpq9lb2GyV06n2JAW65R4f7k9iWY5n5VlveaCnTSSCI+9vhnmNLt+r2DNeMaf EYgq7lkatcfsXHy+SAIetg3Y0UhTxqM7Igb8k= 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=cyI57F19pIhwZcq5ccrYrB+HUgtxU3ItyRp6MeQ2xbE=; b=IrXT6TEP4agLwBdg5aBz+Uk7lZeT83Hvjx3gMKdSLb04PvkzFiAfCzNY5Y90NbkFcu hl+rRoAD0ZXXfDylD6M2zozmvC647QcGJarNasu2UlHqNjT34FzPOKhZ5vZhuouX4s08 BCpheaLjtfMCDnjKQ3KY8Z5wDZvYtRA0aVUvMETbL/150fEvb18ex0a0FdHIbSQnAteb tmUkBBWyWzbtlO5s+LXDo/Ckqj7UdIpLwq8h+SJrhFVhApjVljY+F/t79K3wAsjTmQLw ysnKF1bkaLBytSRj5v7xzWtAUbSEV985gjvLOxoBg66AUsmXWQseVSKJHCf1klEaqGKy mKCw== X-Gm-Message-State: AD7BkJIy++UnYfCtia3cBwN2+3i0rsNgL78sW+bRChX+Pdm02G/3QyZKLG59n9WVDJVsJK// X-Received: by 10.194.205.8 with SMTP id lc8mr25795675wjc.177.1456932856051; Wed, 02 Mar 2016 07:34:16 -0800 (PST) Received: from localhost.localdomain (host81-154-142-245.range81-154.btcentralplus.com. [81.154.142.245]) by smtp.gmail.com with ESMTPSA id da6sm26941407wjb.24.2016.03.02.07.34.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 07:34:15 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RESEND 02/11] pwm: sysfs: Add PWM Capture support Date: Wed, 2 Mar 2016 15:32:00 +0000 Message-Id: <1456932729-9667-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456932729-9667-1-git-send-email-lee.jones@linaro.org> References: <1456932729-9667-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160302_073438_148334_329938C4 X-CRM114-Status: GOOD ( 11.46 ) 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:231 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: linux-pwm@vger.kernel.org, kernel@stlinux.com, ajitpal.singh@st.com, thierry.reding@gmail.com, Lee Jones , maxime.coquelin@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Allow a user to read PWM Capture results from /sysfs. First, the user must tell PWM Capture which channel they wish to read from: $ echo 2 > $PWMCHIP/capture To start a capture and read the result, simply read the file: $ cat $PWMCHIP/capture The output format is left to the device. Signed-off-by: Lee Jones --- drivers/pwm/sysfs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 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/sysfs.c b/drivers/pwm/sysfs.c index 9c90886..3572ef4 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -23,6 +23,8 @@ #include #include +static int capture_channel; + struct pwm_export { struct device child; struct pwm_device *pwm; @@ -167,16 +169,42 @@ static ssize_t polarity_store(struct device *child, return ret ? : size; } +static ssize_t capture_show(struct device *child, + struct device_attribute *attr, + char *buf) +{ + struct pwm_device *pwm = child_to_pwm_device(child); + + return pwm_capture(pwm, capture_channel, buf); +} + +static ssize_t capture_store(struct device *child, + struct device_attribute *attr, + const char *buf, size_t size) +{ + int val, ret; + + ret = kstrtoint(buf, 0, &val); + if (ret) + return ret; + + capture_channel = val; + + return size; +} + static DEVICE_ATTR_RW(period); static DEVICE_ATTR_RW(duty_cycle); static DEVICE_ATTR_RW(enable); static DEVICE_ATTR_RW(polarity); +static DEVICE_ATTR_RW(capture); static struct attribute *pwm_attrs[] = { &dev_attr_period.attr, &dev_attr_duty_cycle.attr, &dev_attr_enable.attr, &dev_attr_polarity.attr, + &dev_attr_capture.attr, NULL }; ATTRIBUTE_GROUPS(pwm);