linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: pwm pin stays on 1 on mxs after pwm_config(pwm, 0, period); pwm_disable(pwm);
Date: Wed, 24 Oct 2012 11:56:03 +0200	[thread overview]
Message-ID: <20121024095603.GH639@pengutronix.de> (raw)

Hello,

the leds-pwm driver does the following in its led_pwm_set routine:

	if (brightness == 0) {
		pwm_config(led_dat->pwm, 0, period);
		pwm_disable(led_dat->pwm);
	} else {
		pwm_config(led_dat->pwm, brightness * period / max, period);
		pwm_enable(led_dat->pwm);
	}

The effect on setting brightness = 0 on an i.MX28 based machine after
having brightness = max = 255 before is:

pwm_config(..., 0, period) doesn't disable the output at once because of
some logic (in hardware) to prevent glitches. According to the Hardware
manual the new values take effect after the current period (which has the
output on 1). Now pwm_disable stopps the counter, the current period
doesn't run out and the output keeps the 1. So the LED stays on.

Where do I fix that? In the pwm driver (somehow block in pwm_config
until the current period is over, don't know how yet), remove the
pwm_disable in the brightness == 0 case (and then probably making the
whole if block a simple pwm_config(led_dat->pwm, brightness * period /
max, period)) or do we need a new API for that introducing a wait flag
or something different I didn't think of?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

             reply	other threads:[~2012-10-24  9:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  9:56 Uwe Kleine-König [this message]
2012-10-24 13:52 ` [PATCH] RFC: leds-pwm: don't disable pwm when setting brightness to 0 Uwe Kleine-König
2012-10-25  8:03   ` Shawn Guo
2013-01-03  9:01     ` Thierry Reding
2013-01-03 20:55       ` Uwe Kleine-König
2013-01-04  7:34         ` Thierry Reding
2013-01-04 11:55       ` Sascha Hauer
2013-01-04 23:26         ` Matt Sealey

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=20121024095603.GH639@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).