linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Lothar Waßmann" <LW@KARO-electronics.de>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-pwm@vger.kernel.org, Pawel Moll <pawel.moll@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Rob Landley <rob@landley.net>, Kumar Gala <galak@codeaurora.org>,
	Shawn Guo <shawn.guo@linaro.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] PWM: let of_xlate handlers check args count
Date: Fri, 24 Jan 2014 08:41:03 +0100	[thread overview]
Message-ID: <20140124074103.GJ16215@pengutronix.de> (raw)
In-Reply-To: <20140124064254.0369084d@ipc1.ka-ro>

On Fri, Jan 24, 2014 at 06:42:54AM +0100, Lothar Waßmann wrote:
> Hi,
> 
> > Okay, this works, but there's a problem with pwm-leds.
> > 
> > When the duty cycle is set to zero (when you set the brightness to zero)
> > pwm-leds decides to disable the PWM after configuring it.  This causes
> > the PWM output to be driven low, causing the LED to go to maximum
> > brightness.
> > 
> > So, using the inversion at PWM level doesn't work.
> > 
> The problem is that the driver calls pwm_disable() when the duty cycle is 0.
> This sets the PWM output low independent from the output polarity setting.
> 
> > To make this work correctly, we really need pwm-leds to do the inversion
> > rather than setting the inversion bit in hardware.
> > 
> The same holds for the pwm-backlight driver.
> 
> The easiest fix would be not to call pwm_disable() even for a zero duty
> cycle.

IMO that's the right thing to do anyway due to the different PWM
hardware controllers we have. I'm thinking about the following patch
for some time.

Sascha

--------------------8<--------------------------

From 9ebbc3d72c71bd97d7fc4458f60ae3ecd5876984 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Fri, 24 Jan 2014 08:34:16 +0100
Subject: [PATCH] PWM: Document disabled PWM output as undefined

When disabled PWM hardware reacts differently. Some controllers
just stop with their current value, others produce a constant high
or low output, sometimes depending on the output inversion bit. Update
the documentation to reflect that and request from the PWM consumer
drivers to set a constant high/low value with duty cycles of 0/100%
instead of disabling the PWM.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/pwm.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index 93cb979..b7e8a31 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -44,6 +44,8 @@ After being requested, a PWM has to be configured using:
 int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
 
 To start/stop toggling the PWM output use pwm_enable()/pwm_disable().
+The output of a disabled PWM is undefined. Set the duty cycle to 100%
+for a constant high output and to 0 for constant low output.
 
 Using PWMs with the sysfs interface
 -----------------------------------
-- 
1.8.5.2

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2014-01-24  7:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16  8:06 [PATCHv2 0/2] pwm: imx: support polarity inversion Lothar Waßmann
2014-01-16  8:06 ` [PATCHv2 1/2] pwm: imx: indentation cleanup Lothar Waßmann
2014-01-16  8:06 ` [PATCHv2 2/2] pwm: imx: support polarity inversion Lothar Waßmann
2014-01-16 16:03   ` Sascha Hauer
2014-01-23  7:37     ` Lothar Waßmann
2014-01-23  9:04       ` Sascha Hauer
2014-01-23  9:04         ` [PATCH 1/2] PWM: let of_xlate handlers check args count Sascha Hauer
2014-01-23 10:56           ` Lothar Waßmann
2014-01-23 11:04             ` Sascha Hauer
2014-01-23 16:53               ` Russell King - ARM Linux
2014-01-23 17:36                 ` Russell King - ARM Linux
2014-01-24  5:42                   ` Lothar Waßmann
2014-01-24  7:41                     ` Sascha Hauer [this message]
2014-01-23  9:04         ` [PATCH 2/2] PWM: handle additional flags in of_pwm_simple_xlate Sascha Hauer
2014-01-23 11:52       ` [PATCHv2 2/2] pwm: imx: support polarity inversion Russell King - ARM Linux
2014-01-23 12:33         ` Russell King - ARM Linux
2014-01-23 16:44         ` Russell King - ARM Linux

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=20140124074103.GJ16215@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=LW@KARO-electronics.de \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=rob@landley.net \
    --cc=robh+dt@kernel.org \
    --cc=shawn.guo@linaro.org \
    --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).