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: 859952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pwm-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zJ4m66NNSz9s7g for ; Sat, 13 Jan 2018 01:25:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933935AbeALOY0 (ORCPT ); Fri, 12 Jan 2018 09:24:26 -0500 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:45440 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933687AbeALOYZ (ORCPT ); Fri, 12 Jan 2018 09:24:25 -0500 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: , , , , , , , , , CC: , , , , , , , Claudiu Beznea 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 Sender: linux-pwm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pwm@vger.kernel.org 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"; }