From patchwork Tue May 22 12:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10418615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25E9A6053B for ; Tue, 22 May 2018 12:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1465128BE2 for ; Tue, 22 May 2018 12:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0877A28BEA; Tue, 22 May 2018 12:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7C34E28BE2 for ; Tue, 22 May 2018 12:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O43o61bPVRey2kAruINcVpgWsT0lNKifiYBQHwjaPOo=; b=bkAitSj756NIno awPV8MZkf612BPRtP2TLWtVzDbPrfxQf52+3/ALP00/emYwXZ69qug6QOziCyZh3qXUSUzgzHpX21 D9sKz4XppqEctUuXIrvZ2pqZgRjbedqmKVvQvk+Y41PAptj8+qeC2Z9XAEzU6+/HqFl3u3VvVFVVf scCZAEFz+t/1XZ0+xxUQRAPH4NcaYg5jbS+/HJJpWFFszEdlqdSwimtg9EfafWL+Quplup+YVEL+q Bds07eXjTfNRLadFjsNRgq/aEJxylEN3yr07w9l2vmkT/ThKaGQjhW0mM7D/MzT5v1SSjZy5lmH/h qLwvwF/daOIPO6VJcOQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fL6fW-0007l3-TK; Tue, 22 May 2018 12:45:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fL6YL-000713-EI for linux-arm-kernel@bombadil.infradead.org; Tue, 22 May 2018 12:38:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+eiMnw5wPjCjjNCEiPDKYx1LO8A5FzYc1q6Eu4oyaFg=; b=oC/QqN1fB8kNMbsc77/cDiU6p kPWoJjfb5bwwdA9B2ghlkfIKrjuw4JRDIppCCQiFt6j8pbZff4sAoqNbKs7JlTdkbzTEm7mUm5bNE pmDSHLJnHwu80QILqRypPC4+g2E9aIpBqOb//0Sj7Ppfnp6R6b5a+/lkj9tV4ED2ynKtL9PlFgl+B WKHhjIEw73RnDm5A/eJoMxiZTw8Etosm439Qb8fQx4f6luoAKLH/AlnBOaVLphp7w7t1K97LTqqFK bQjfGRrURXwaDCyK9YdINpwHhOVksJDL3DLTk4MqJeZLM4dqjGBeSXjEoUikHHbH9yBwcV/Z5zMqj 2N1aK4CQA==; Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fL65r-00066H-6c for linux-arm-kernel@lists.infradead.org; Tue, 22 May 2018 12:08:50 +0000 X-IronPort-AV: E=Sophos;i="5.49,430,1520924400"; d="scan'208";a="14214841" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 May 2018 05:08:31 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Tue, 22 May 2018 05:08:30 -0700 From: Claudiu Beznea To: , , , , , , Subject: [PATCH v5 5/9] pwm: add PWM modes Date: Tue, 22 May 2018 15:07:09 +0300 Message-ID: <1526990833-30707-6-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526990833-30707-1-git-send-email-claudiu.beznea@microchip.com> References: <1526990833-30707-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180522_130843_671634_3DE6C5A8 X-CRM114-Status: GOOD ( 13.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add PWM normal and complementary modes. Signed-off-by: Claudiu Beznea --- Documentation/devicetree/bindings/pwm/pwm.txt | 9 +++++++-- Documentation/pwm.txt | 26 +++++++++++++++++++++++--- include/dt-bindings/pwm/pwm.h | 1 + 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/pwm/pwm.txt b/Documentation/devicetree/bindings/pwm/pwm.txt index 8556263b8502..7c8aaac43f92 100644 --- a/Documentation/devicetree/bindings/pwm/pwm.txt +++ b/Documentation/devicetree/bindings/pwm/pwm.txt @@ -46,11 +46,16 @@ period in nanoseconds. Optionally, the pwm-specifier can encode a number of flags (defined in ) in a third cell: - PWM_POLARITY_INVERTED: invert the PWM signal polarity +- PWM_MODE_COMPLEMENTARY: PWM complementary working mode (for PWM channels +with two outputs); if not specified, the default for PWM channel will be +used -Example with optional PWM specifier for inverse polarity +Example with optional PWM specifier for inverse polarity and complementary +mode: bl: backlight { - pwms = <&pwm 0 5000000 PWM_POLARITY_INVERTED>; + pwms = <&pwm 0 5000000 + (PWM_MODE_COMPLEMENTARY | PWM_POLARITY_INVERTED)>; pwm-names = "backlight"; }; diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt index 8fbf0aa3ba2d..912c43da8b48 100644 --- a/Documentation/pwm.txt +++ b/Documentation/pwm.txt @@ -61,9 +61,9 @@ In addition to the PWM state, the PWM API also exposes PWM arguments, which are the reference PWM config one should use on this PWM. PWM arguments are usually platform-specific and allows the PWM user to only care about dutycycle relatively to the full period (like, duty = 50% of the -period). struct pwm_args contains 2 fields (period and polarity) and should -be used to set the initial PWM config (usually done in the probe function -of the PWM user). PWM arguments are retrieved with pwm_get_args(). +period). struct pwm_args contains 3 fields (period, polarity and mode) and +should be used to set the initial PWM config (usually done in the probe +function of the PWM user). PWM arguments are retrieved with pwm_get_args(). Using PWMs with the sysfs interface ----------------------------------- @@ -110,6 +110,26 @@ channel that was exported. The following properties will then be available: - 0 - disabled - 1 - enabled + mode + Get/set PWM channel working mode. + + Normal mode - for PWM channels with one output; this should be the + default working mode for every PWM channel; output waveforms looks + like this: + __ __ __ __ + PWM __| |__| |__| |__| |__ + <--T--> + + Complementary mode - for PWM channels with two outputs; output waveforms + looks line this: + __ __ __ __ + PWMH1 __| |__| |__| |__| |__ + __ __ __ __ __ + PWML1 |__| |__| |__| |__| + <--T--> + + Where T is the signal period. + Implementing a PWM driver ------------------------- diff --git a/include/dt-bindings/pwm/pwm.h b/include/dt-bindings/pwm/pwm.h index ab9a077e3c7d..b82279cc1787 100644 --- a/include/dt-bindings/pwm/pwm.h +++ b/include/dt-bindings/pwm/pwm.h @@ -11,5 +11,6 @@ #define _DT_BINDINGS_PWM_PWM_H #define PWM_POLARITY_INVERTED (1 << 0) +#define PWM_MODE_COMPLEMENTARY (1 << 1) #endif