From patchwork Mon Sep 30 15:22:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 2966161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 058639F88A for ; Mon, 30 Sep 2013 15:23:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E0540201FA for ; Mon, 30 Sep 2013 15:23:29 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C9992017E for ; Mon, 30 Sep 2013 15:23:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VQfJh-0003iR-8d; Mon, 30 Sep 2013 15:23:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VQfJe-000750-Tl; Mon, 30 Sep 2013 15:23:18 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VQfJb-00074D-Q7 for linux-arm-kernel@lists.infradead.org; Mon, 30 Sep 2013 15:23:16 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id C63828CE; Mon, 30 Sep 2013 17:22:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (128-79-216-144.hfc.dyn.abo.bbox.fr [128.79.216.144]) by mail.free-electrons.com (Postfix) with ESMTPSA id 81074147; Mon, 30 Sep 2013 17:22:55 +0200 (CEST) From: Alexandre Belloni To: Thierry Reding Subject: [PATCH v2] PWM: atmel-pwm: use request/free instead of enable/disable Date: Mon, 30 Sep 2013 17:22:33 +0200 Message-Id: <1380554553-25676-1-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 1.8.1.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130930_112315_967425_3AC50E56 X-CRM114-Status: GOOD ( 12.17 ) X-Spam-Score: -1.9 (-) Cc: linux-pwm@vger.kernel.org, Nicolas Ferre , linux-kernel@vger.kernel.org, Ludovic Desroches , Alexandre Belloni , voice.shen@atmel.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,