linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@majess.pl>
To: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>, stefan@agner.ch
Cc: mark.rutland@arm.com, linux-pwm@vger.kernel.org,
	l.majewski@samsung.com, Lukasz Majewski <l.majewski@majess.pl>,
	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 <LW@KARO-electronics.de>
Subject: [PATCH] pwm: core: Use pwm->args.polarity to setup PWM_POLARITY_INVERSED
Date: Thu,  6 Oct 2016 08:49:54 +0200	[thread overview]
Message-ID: <1475736594-23028-1-git-send-email-l.majewski@majess.pl> (raw)
In-Reply-To: <20161001101235.24598-3-bhuvanchandra.dv@toradex.com>

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 <l.majewski@majess.pl>
---
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

  parent reply	other threads:[~2016-10-06  6:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-01 10:12 [PATCH v2 0/6] Support PWM polarity control Bhuvanchandra DV
2016-10-01 10:12 ` [PATCH v2 1/6] pwm: print error messages with pr_err() instead of pr_debug() Bhuvanchandra DV
2016-10-01 10:12 ` [PATCH v2 2/6] pwm: core: make the PWM_POLARITY flag in DTB optional Bhuvanchandra DV
2016-10-06  6:36   ` Lukasz Majewski
2016-10-07  4:49     ` Bhuvanchandra DV
2016-10-06  6:49   ` Lukasz Majewski [this message]
2016-10-01 10:12 ` [PATCH v2 3/6] pwm: imx: support output polarity inversion Bhuvanchandra DV
2016-10-01 10:12 ` [PATCH v2 4/6] arm: dts: imx7: Update #pwm-cells for PWM polarity control Bhuvanchandra DV
2016-10-01 10:12 ` [PATCH v2 5/6] arm: dts: imx7-colibri: Use pwm " Bhuvanchandra DV
2016-10-01 10:12 ` [PATCH v2 6/6] arm: dts: imx7-colibri: Use enable-gpios for BL_ON Bhuvanchandra DV
2016-10-04  7:48 ` [PATCH v2 0/6] Support PWM polarity control Lukasz Majewski
2016-10-05 16:50   ` Stefan Agner
2016-10-06  6:26     ` Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475736594-23028-1-git-send-email-l.majewski@majess.pl \
    --to=l.majewski@majess.pl \
    --cc=LW@KARO-electronics.de \
    --cc=bhuvanchandra.dv@toradex.com \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=l.majewski@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=stefan@agner.ch \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).