From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm@vger.kernel.org, voice.shen@atmel.com,
Nicolas Ferre <nicolas.ferre@atmel.com>,
Ludovic Desroches <ludovic.desroches@atmel.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH v2] PWM: atmel-pwm: use request/free instead of enable/disable
Date: Mon, 30 Sep 2013 17:22:33 +0200 [thread overview]
Message-ID: <1380554553-25676-1-git-send-email-alexandre.belloni@free-electrons.com> (raw)
I found that disabling a pwm while it is at a low level will actually put it
back at a high level. The main symptom is that leds-pwm is calling pwm_disable()
after setting the duty cycle to 0. Hence, instead of getting a switched off LED,
you get an LED lit up at full brightness.
Solve that by using the request and free callbacks to enable and disable the
pwm channels and the clock.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Applies on [PATCH v5] PWM: atmel-pwm: add PWM controller driver
Changes in v2:
- add dummies pwm_enable and pwm_disable to be able to register the pwm chip.
drivers/pwm/pwm-atmel.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index b4df36c..732312c 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -206,7 +206,7 @@ static int atmel_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
return 0;
}
-static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+static int atmel_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
int ret;
@@ -222,7 +222,7 @@ static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
return 0;
}
-static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
+static void atmel_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
@@ -231,9 +231,28 @@ static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
clk_disable(atmel_pwm->clk);
}
+static int atmel_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+ /*
+ * This is a dummy function, required to be able to register the pwm
+ * chip, see pwmadd_chip() in pwm/core.c
+ */
+ return 0;
+}
+
+static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+ /*
+ * This is a dummy function, required to be able to register the pwm
+ * chip, see pwmadd_chip() in pwm/core.c
+ */
+}
+
static const struct pwm_ops atmel_pwm_ops = {
.config = atmel_pwm_config,
.set_polarity = atmel_pwm_set_polarity,
+ .request = atmel_pwm_request,
+ .free = atmel_pwm_free,
.enable = atmel_pwm_enable,
.disable = atmel_pwm_disable,
.owner = THIS_MODULE,
--
1.8.1.2
next reply other threads:[~2013-09-30 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-30 15:22 Alexandre Belloni [this message]
2013-10-08 12:05 ` Thierry Reding
2013-10-09 11:14 ` Alexandre Belloni
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=1380554553-25676-1-git-send-email-alexandre.belloni@free-electrons.com \
--to=alexandre.belloni@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=ludovic.desroches@atmel.com \
--cc=nicolas.ferre@atmel.com \
--cc=thierry.reding@gmail.com \
--cc=voice.shen@atmel.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
all inboxes | Powered by JetHome®