From patchwork Mon Nov 16 08:56:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 7622961 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A9364BF90C for ; Mon, 16 Nov 2015 09:09:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3B3820562 for ; Mon, 16 Nov 2015 09:09:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB4F820480 for ; Mon, 16 Nov 2015 09:09:22 +0000 (UTC) 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 1ZyFmr-00073N-V4; Mon, 16 Nov 2015 09:09:22 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyFbk-0002WV-QV; Mon, 16 Nov 2015 08:57:56 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 249A4420; Mon, 16 Nov 2015 09:57:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (AToulouse-657-1-1082-82.w92-146.abo.wanadoo.fr [92.146.160.82]) by mail.free-electrons.com (Postfix) with ESMTPSA id 9DB3E41B; Mon, 16 Nov 2015 09:56:56 +0100 (CET) From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org Subject: [PATCH v4 06/24] pwm: introduce default period and polarity concepts Date: Mon, 16 Nov 2015 09:56:29 +0100 Message-Id: <1447664207-24370-7-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447664207-24370-1-git-send-email-boris.brezillon@free-electrons.com> References: <1447664207-24370-1-git-send-email-boris.brezillon@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_005753_488231_DFA95361 X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -3.2 (---) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kamil Debski , Heiko Stuebner , Mike Turquette , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Alexandre Belloni , Lee Jones , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, Boris Brezillon , Robert Jarzmik , lm-sensors@lm-sensors.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Tomi Valkeinen , linux-input@vger.kernel.org, Jean-Christophe Plagniol-Villard , Guenter Roeck , Jean Delvare , Joachim Eastwood , Bryan Wu , Julia Lawall , Mark Brown , Jacek Anaszewski , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Jingoo Han , Dmitry Torokhov , Stephen Boyd , Liam Girdwood , Richard Purdie , Maxime Ripard MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When requested by a user, the PWM is assigned a default period and polarity extracted from the DT, the platform data or statically set by the driver. Those default values are currently stored in the period and polarity fields of the pwm_device struct, but they will be stored somewhere else once we have introduced the architecture allowing for hardware state retrieval. The pwm_set_default_polarity and pwm_set_default_period should only be used by PWM drivers or the PWM core infrastructure to specify the default period and polarity values. PWM users might call the pwm_get_default_period to query the default period value. There is currently no helper to query the default polarity, but it might be added later on if there is a need for it. Signed-off-by: Boris Brezillon Tested-by: Heiko Stuebner --- include/linux/pwm.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index cfc3ed4..8ba57fc 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -118,11 +118,22 @@ static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period) pwm->period = period; } +static inline void pwm_set_default_period(struct pwm_device *pwm, + unsigned int period) +{ + pwm_set_period(pwm, period); +} + static inline unsigned int pwm_get_period(const struct pwm_device *pwm) { return pwm ? pwm->period : 0; } +static inline unsigned int pwm_get_default_period(const struct pwm_device *pwm) +{ + return pwm_get_period(pwm); +} + static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) { if (pwm) @@ -139,6 +150,12 @@ static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm) */ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity); +static inline void pwm_set_default_polarity(struct pwm_device *pwm, + enum pwm_polarity polarity) +{ + pwm_set_polarity(pwm, polarity); +} + static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm) { return pwm ? pwm->polarity : PWM_POLARITY_NORMAL;