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: 10161175 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 A6E3E60327 for ; Fri, 12 Jan 2018 14:42:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 977D12891C for ; Fri, 12 Jan 2018 14:42:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 961D1289EA; Fri, 12 Jan 2018 14:42:01 +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=unavailable 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 4A59E28A2A for ; Fri, 12 Jan 2018 14:42:01 +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=xFJ+rKNW/0TRcuK9iNNxGHBMdnE0oZoN0kO6i8jy41Y=; b=fYF1Toa77AaSe8 /YoMiTmHw29SOUA0Ewhgy9XKMUhMuaWf2YNfBNi8rVn6mKtoXZhUBLVmti46PIxRUQrVpsJx9oKeK IoLCnxwb3ZbOoS1XvN67dY6/vOBtQy8rC79DuBcwKEIjSWEIMDOiBZySdeylut8yODlZx7qCfxexi KwYizH9OkTdG75yR5SGSFj+YvCET7fWeqcn/O+wHouAOw7/3i6F70p2DomsDEq9AkG3wv2f9Jsxh6 /1eunqULCfRyaHPNfbP/FFdCF8P1rVgBcSbtn+tqEnMRLrFcDqbzTGoywn8iIWDD73GqWrLBL6qS1 yzbJtU9wkBW3Bp+V5Vew==; 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 1ea0Wt-0008Fs-Jd; Fri, 12 Jan 2018 14:41:59 +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-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, 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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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"; }