From patchwork Fri Jan 12 14:23:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10161173 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 000E960327 for ; Fri, 12 Jan 2018 14:41:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3FB628A2A for ; Fri, 12 Jan 2018 14:41:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8B6C28A29; Fri, 12 Jan 2018 14:41:59 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 5472F28876 for ; Fri, 12 Jan 2018 14:41:59 +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=6/0aeLB13bppCGciFfrMsc6bbSTLhpmGkYFyG1SKuv8=; b=LACbYfLGQJ6m04 w7XbRWXmUJ/e5gDlpYZIDS4iTS+aRQjbOyvpScW5T04R9aYKqznQdZV+LabLjVVycX4FVm+RKv0o1 fmDS3DbPbYpZUA+aRqyOnOhQVb9WB0eD7uZHLVnfu3wMBaAHu2MtgTFqLwA6xreD14CeXdjJ84I9T gR/BaV92bIM/kVcnlHkul+E5SSwl5cV+4Pm7Z/M4UieRSHTQdYr8McZ7iyYO/oL6rZpla6dUJJKeM vDGP6k7H23KPv8SPxFr8Z6aXev1Cclnga3Ffk4vJdpslm4Wm4nj3EHgs41jyEWoZ+E5ggrT7Wva8n U9pHkSA/Tuf+LTn4FPqw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ea0Wr-0008Dy-To; Fri, 12 Jan 2018 14:41:57 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ea0Wp-0005qc-Te; Fri, 12 Jan 2018 14:41:55 +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=iEdVZdm31mnK1EzGOD+Px1/oBvKTqb0it50yAs5y0Yo=; b=VSKdkZrQKCXJvWK/yrbkVerNy y2oMuNYRdPpWNwGvKdMX/0Xspqin/imD1qQDLI9N/nXCUsKi/XmAn2zD/9Zl0e+Pfc/6LTj1sVFwu /KBOEmw5oShJ74wtvoR4aLrv37FPoKN+zwWB4f4zl4l0XXd8WiObk/c7ammyN+nzXjo4Pr4GjtPG6 XnGNh8vji7Wish4FSIVaNUZssJG5IDZonYGlY5EK+CXfCGQFuNNmbqFN1Wky306Wpt32dCssXDrbf szunUVbT30CLp218nKP5RUGAPlBl+SLgZK1XXsTIoQQh2rCsrO10eX91ImITKfmUYRo1XtWkL6wa5 weTqO2Iag==; Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ea0G7-0001Qf-A8; Fri, 12 Jan 2018 14:24:42 +0000 X-IronPort-AV: E=Sophos;i="5.46,349,1511852400"; d="scan'208";a="10394904" Received: from exsmtp03.microchip.com (HELO email.microchip.com) ([198.175.253.49]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Jan 2018 07:24:23 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.76.4) by chn-sv-exch03.mchp-main.com (10.10.76.49) with Microsoft SMTP Server id 14.3.352.0; Fri, 12 Jan 2018 07:24:23 -0700 From: Claudiu Beznea To: , , , , , , , , , Subject: [PATCH v2 13/16] drivers: pwm: core: add push-pull mode support Date: Fri, 12 Jan 2018 16:23:00 +0200 Message-ID: <1515766983-15151-14-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515766983-15151-1-git-send-email-claudiu.beznea@microchip.com> References: <1515766983-15151-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-20180112_142439_662813_63F97E92 X-CRM114-Status: GOOD ( 10.69 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, Claudiu Beznea , linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add push-pull mode support in PWM code. In push-pull mode the channels outputs has same polarity and the edges are complementary delayed for one period. Signed-off-by: Claudiu Beznea --- drivers/pwm/sysfs.c | 2 ++ include/linux/pwm.h | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index 7d111ab17e43..5052bdec7ad6 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -249,6 +249,8 @@ static ssize_t mode_store(struct device *child, mode = PWM_MODE_NORMAL; else if (sysfs_streq(buf, pwm_get_mode_desc(PWM_MODE_COMPLEMENTARY))) mode = PWM_MODE_COMPLEMENTARY; + else if (sysfs_streq(buf, pwm_get_mode_desc(PWM_MODE_PUSH_PULL))) + mode = PWM_MODE_PUSH_PULL; else return -EINVAL; diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 2e8dfc3ea516..a4ad3b7a5317 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -29,13 +29,16 @@ enum pwm_polarity { * enum pwm_mode - PWM working modes * PWM_MODE_NORMAL: PWM has one output per channel * PWM_MODE_COMPLEMENTARY: PWM has 2 outputs per channel with opposite polarity + * PWM_MODE_PUSH_PULL: PWM has 2 outputs per channel with same polarity and + * the edges are complementary delayed for one period * PWM_MODE_MAX: Used to get the defined PWM modes mask (PWM_MODE_MAX - 1) * phase-shifted */ enum pwm_mode { PWM_MODE_NORMAL = BIT(0), PWM_MODE_COMPLEMENTARY = BIT(1), - PWM_MODE_MAX = BIT(2), + PWM_MODE_PUSH_PULL = BIT(2), + PWM_MODE_MAX = BIT(3), }; /** @@ -478,7 +481,9 @@ static inline void pwm_disable(struct pwm_device *pwm) static inline const char * const pwm_get_mode_desc(enum pwm_mode mode) { - static const char * const modes[] = { "normal", "complementary" }; + static const char * const modes[] = { + "normal", "complementary", "push-pull" + }; return mode ? modes[ffs(mode) - 1] : "invalid"; }