From patchwork Thu Jul 11 14:37:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2826429 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1BAA19F7D6 for ; Thu, 11 Jul 2013 14:40:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97F7C20299 for ; Thu, 11 Jul 2013 14:40:15 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74F5F20295 for ; Thu, 11 Jul 2013 14:40:13 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UxI0o-0005dn-OC; Thu, 11 Jul 2013 14:38:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UxI0R-0002Eh-VK; Thu, 11 Jul 2013 14:38:03 +0000 Received: from perceval.ideasonboard.com ([95.142.166.194]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UxI0O-0002D8-QG for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2013 14:38:01 +0000 Received: from localhost.localdomain (unknown [193.120.41.118]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 23EF335A4B; Thu, 11 Jul 2013 16:37:04 +0200 (CEST) From: Laurent Pinchart To: Thierry Reding Subject: [PATCH 2/2] pwm: Add PWM polarity flag macros for DT Date: Thu, 11 Jul 2013 16:37:48 +0200 Message-Id: <1373553468-6564-3-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1373553468-6564-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1373553468-6564-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130711_103801_111660_B72258AF X-CRM114-Status: GOOD ( 14.05 ) X-Spam-Score: -2.2 (--) Cc: linux-pwm@vger.kernel.org, Shawn Guo , Tomasz Figa , linux-omap@vger.kernel.org, Philip Avinash , Boris BREZILLON , Steffen Trumtrar , devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define PWM_POLARITY_NORMAL and PWM_POLARITY_INVERTED macros in include/dt-bindings/pwm/pwm.h to be used by device tree sources. Signed-off-by: Laurent Pinchart --- Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt | 6 +++--- Documentation/devicetree/bindings/pwm/pwm-samsung.txt | 5 +++-- Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt | 5 +++-- Documentation/devicetree/bindings/pwm/pwm.txt | 8 +++++--- Documentation/devicetree/bindings/pwm/vt8500-pwm.txt | 5 +++-- arch/arm/boot/dts/am335x-evm.dts | 3 ++- arch/arm/boot/dts/am335x-evmsk.dts | 3 ++- arch/arm/boot/dts/wm8850-w70v2.dts | 3 ++- include/dt-bindings/pwm/pwm.h | 15 +++++++++++++++ include/linux/pwm.h | 4 ++-- 10 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 include/dt-bindings/pwm/pwm.h diff --git a/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt b/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt index de0eaed..be09be4 100644 --- a/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt +++ b/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt @@ -4,9 +4,9 @@ Required properties: - compatible: should be "atmel,tcb-pwm" - #pwm-cells: Should be 3. The first cell specifies the per-chip index of the PWM to use, the second cell is the period in nanoseconds and - bit 0 in the third cell is used to encode the polarity of PWM output. - Set bit 0 of the third cell in PWM specifier to 1 for inverse polarity & - set to 0 for normal polarity. + the third cell is used to encode the polarity of PWM output. Set the + PWM_POLARITY_NORMAL flag for normal polarity or the PWM_POLARITY_INVERSED + flag for inverted polarity. PWM flags are defined in . - tc-block: The Timer Counter block to use as a PWM chip. Example: diff --git a/Documentation/devicetree/bindings/pwm/pwm-samsung.txt b/Documentation/devicetree/bindings/pwm/pwm-samsung.txt index ac67c68..bece18b 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-samsung.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-samsung.txt @@ -24,8 +24,9 @@ Required properties: - phandle to PWM controller node - index of PWM channel (from 0 to 4) - PWM signal period in nanoseconds - - bitmask of optional PWM flags: - 0x1 - invert PWM signal + - bitmask of optional PWM flags as defined in : + PWM_POLARITY_NORMAL - normal polarity + PWM_POLARITY_INVERSED - inverted polarity Optional properties: - samsung,pwm-outputs: list of PWM channels used as PWM outputs on particular diff --git a/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt b/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt index 337c6fc..9007d92 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt @@ -7,8 +7,9 @@ Required properties: - #pwm-cells: Should be 3. Number of cells being used to specify PWM property. First cell specifies the per-chip index of the PWM to use, the second cell is the period in nanoseconds and bit 0 in the third cell is used to - encode the polarity of PWM output. Set bit 0 of the third in PWM specifier - to 1 for inverse polarity & set to 0 for normal polarity. + encode the polarity of PWM output. Set the PWM_POLARITY_NORMAL flag for + normal polarity or the PWM_POLARITY_INVERSED flag for inverted polarity. + PWM flags are defined in . - reg: physical base address and size of the registers map. Optional properties: diff --git a/Documentation/devicetree/bindings/pwm/pwm.txt b/Documentation/devicetree/bindings/pwm/pwm.txt index 06e6724..38c357a 100644 --- a/Documentation/devicetree/bindings/pwm/pwm.txt +++ b/Documentation/devicetree/bindings/pwm/pwm.txt @@ -43,13 +43,15 @@ because the name "backlight" would be used as fallback anyway. pwm-specifier typically encodes the chip-relative PWM number and the PWM period in nanoseconds. -Optionally, the pwm-specifier can encode a number of flags in a third cell: -- bit 0: PWM signal polarity (0: normal polarity, 1: inverse polarity) +Optionally, the pwm-specifier can encode a number of flags (defined in +) in a third cell: +- PWM_POLARITY_NORMAL: use the normal PWM signal polarity +- PWM_POLARITY_INVERSED: invert the PWM signal polarity Example with optional PWM specifier for inverse polarity bl: backlight { - pwms = <&pwm 0 5000000 1>; + pwms = <&pwm 0 5000000 PWM_POLARITY_INVERSED>; pwm-names = "backlight"; }; diff --git a/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt b/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt index d21d82d..5b1b21f 100644 --- a/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt +++ b/Documentation/devicetree/bindings/pwm/vt8500-pwm.txt @@ -6,8 +6,9 @@ Required properties: - #pwm-cells: Should be 3. Number of cells being used to specify PWM property. First cell specifies the per-chip index of the PWM to use, the second cell is the period in nanoseconds and bit 0 in the third cell is used to - encode the polarity of PWM output. Set bit 0 of the third in PWM specifier - to 1 for inverse polarity & set to 0 for normal polarity. + encode the polarity of PWM output. Set the PWM_POLARITY_NORMAL flag for + normal polarity or the PWM_POLARITY_INVERSED flag for inverted polarity. + PWM flags are defined in . - clocks: phandle to the PWM source clock Example: diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index 3aee1a4..c9da673 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -8,6 +8,7 @@ /dts-v1/; #include "am33xx.dtsi" +#include / { model = "TI AM335x EVM"; @@ -370,7 +371,7 @@ backlight { compatible = "pwm-backlight"; - pwms = <&ecap0 0 50000 0>; + pwms = <&ecap0 0 50000 PWM_POLARITY_NORMAL>; brightness-levels = <0 51 53 56 62 75 101 152 255>; default-brightness-level = <8>; }; diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index 0c8ad17..5d4ec91 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts @@ -14,6 +14,7 @@ /dts-v1/; #include "am33xx.dtsi" +#include / { model = "TI AM335x EVM-SK"; @@ -298,7 +299,7 @@ backlight { compatible = "pwm-backlight"; - pwms = <&ecap2 0 50000 1>; + pwms = <&ecap2 0 50000 PWM_POLARITY_INVERSED>; brightness-levels = <0 58 61 66 75 90 125 170 255>; default-brightness-level = <8>; }; diff --git a/arch/arm/boot/dts/wm8850-w70v2.dts b/arch/arm/boot/dts/wm8850-w70v2.dts index 90e913f..171930a 100644 --- a/arch/arm/boot/dts/wm8850-w70v2.dts +++ b/arch/arm/boot/dts/wm8850-w70v2.dts @@ -11,13 +11,14 @@ /dts-v1/; /include/ "wm8850.dtsi" +#include / { model = "Wondermedia WM8850-W70v2 Tablet"; backlight { compatible = "pwm-backlight"; - pwms = <&pwm 0 50000 1>; /* duty inverted */ + pwms = <&pwm 0 50000 PWM_POLARITY_INVERSED>; brightness-levels = <0 40 60 80 100 130 190 255>; default-brightness-level = <5>; diff --git a/include/dt-bindings/pwm/pwm.h b/include/dt-bindings/pwm/pwm.h new file mode 100644 index 0000000..f82be30 --- /dev/null +++ b/include/dt-bindings/pwm/pwm.h @@ -0,0 +1,15 @@ +/* + * This header provides constants for most PWM bindings. + * + * Most PWM bindings can include a flags cell as part of the PWM specifier. + * In most cases, the format of the flags cell uses the standard values + * defined in this header. + */ + +#ifndef _DT_BINDINGS_PWM_PWM_H +#define _DT_BINDINGS_PWM_PWM_H + +#define PWM_POLARITY_NORMAL (0 << 0) +#define PWM_POLARITY_INVERSED (1 << 0) + +#endif diff --git a/include/linux/pwm.h b/include/linux/pwm.h index f0feafd..ffde99b 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -69,8 +69,8 @@ struct pwm_chip; * period */ enum pwm_polarity { - PWM_POLARITY_NORMAL, - PWM_POLARITY_INVERSED, + PWM_POLARITY_NORMAL = 0, + PWM_POLARITY_INVERSED = 1, }; enum {