Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933589AbcJFGz2 (ORCPT ); Thu, 6 Oct 2016 02:55:28 -0400 Received: from 16.mo6.mail-out.ovh.net ([87.98.139.208]:38400 "EHLO 16.mo6.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752152AbcJFGz1 (ORCPT ); Thu, 6 Oct 2016 02:55:27 -0400 X-Greylist: delayed 306 seconds by postgrey-1.27 at vger.kernel.org; Thu, 06 Oct 2016 02:55:27 EDT From: Lukasz Majewski To: Bhuvanchandra DV , stefan@agner.ch Cc: , , mark.rutland@arm.com, linux-pwm@vger.kernel.org, l.majewski@samsung.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com, linux-arm-kernel@lists.infradead.org, Lothar Wassmann , Lukasz Majewski 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1356 Lines: 45 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; } -- 2.1.4