From patchwork Thu Oct 6 06:49:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 9363689 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 ACE0E600C8 for ; Thu, 6 Oct 2016 06:52:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3BD128E24 for ; Thu, 6 Oct 2016 06:52:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9762128E26; Thu, 6 Oct 2016 06:52:30 +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, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D51FD28E24 for ; Thu, 6 Oct 2016 06:52:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bs2Vz-0004g7-GW; Thu, 06 Oct 2016 06:50:47 +0000 Received: from 14.mo6.mail-out.ovh.net ([46.105.56.113]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bs2Vv-0004dl-LY for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2016 06:50:45 +0000 Received: from player738.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id 480A126DB4 for ; Thu, 6 Oct 2016 08:50:19 +0200 (CEST) Received: from localhost.localdomain (unknown [109.241.15.61]) (Authenticated sender: l.majewski@majess.pl) by player738.ha.ovh.net (Postfix) with ESMTPSA id 0C6B3A8C; Thu, 6 Oct 2016 08:50:05 +0200 (CEST) From: Lukasz Majewski To: Bhuvanchandra DV , stefan@agner.ch Subject: [PATCH] pwm: core: Use pwm->args.polarity to setup PWM_POLARITY_INVERSED Date: Thu, 6 Oct 2016 08:49:54 +0200 Message-Id: <1475736594-23028-1-git-send-email-l.majewski@majess.pl> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20161001101235.24598-3-bhuvanchandra.dv@toradex.com> References: <20161001101235.24598-3-bhuvanchandra.dv@toradex.com> X-Ovh-Tracer-Id: 17594156372331184801 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelvddrfedugdduudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161005_235043_891258_54FEA339 X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-pwm@vger.kernel.org, l.majewski@samsung.com, Lukasz Majewski , linux-kernel@vger.kernel.org, robh+dt@kernel.org, thierry.reding@gmail.com, kernel@pengutronix.de, fabio.estevam@nxp.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, Lothar Wassmann MIME-Version: 1.0 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 The pwm_set_polarity() function finally calls pwm_apply_state(), which in turn requires state->duty_cycle and state->period properly set. In the moment when polarity is set, the PWM is disabled and not configured. For that reason both above variables are set to 0 and the polarity is not set. To be sure that polarity is setup, one needs to set pwm->args.polarity, which controls MX3_PWMCR_POUTC bit setting at imx_pwm_config_v2(). Signed-off-by: Lukasz Majewski --- This patch should be applied on top of: "[v2,2/6] pwm: core: make the PWM_POLARITY flag in DTB optional" http://patchwork.ozlabs.org/patch/677330/ --- drivers/pwm/core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 1f62668..6cd6004 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -153,13 +153,11 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) return pwm; pwm->args.period = args->args[1]; + pwm->args.polarity = PWM_POLARITY_NORMAL; - if (args->args_count > 2) { + if (args->args_count > 2) if (args->args[2] & PWM_POLARITY_INVERTED) - pwm_set_polarity(pwm, PWM_POLARITY_INVERSED); - else - pwm_set_polarity(pwm, PWM_POLARITY_NORMAL); - } + pwm->args.polarity = PWM_POLARITY_INVERSED; return pwm; }