From patchwork Fri Jun 3 19:37:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Lemieux X-Patchwork-Id: 9153945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 821FC60221 for ; Fri, 3 Jun 2016 19:39:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 670EE2675C for ; Fri, 3 Jun 2016 19:39:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B20D28336; Fri, 3 Jun 2016 19:39:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E5AA12675C for ; Fri, 3 Jun 2016 19:39:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b8uvO-0006D7-IM; Fri, 03 Jun 2016 19:38:30 +0000 Received: from mail-io0-x242.google.com ([2607:f8b0:4001:c06::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b8uvK-0005yT-Or for linux-arm-kernel@lists.infradead.org; Fri, 03 Jun 2016 19:38:27 +0000 Received: by mail-io0-x242.google.com with SMTP id f128so490573iof.3 for ; Fri, 03 Jun 2016 12:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=mfygNcjW0ZCgexbN9HcPEeyIQ8syk4DK9pEZuNSHSK0=; b=TEtnYIiDBx41dTr7D+QwygtBVVwnusDxVYsk/uyD2RsrRI6/M/oUHkBQj8osvH9qNU fCH+AVk+IaMTTMQeqChljzLUa/6MFDuwjpXb7sL+jVeLtwm8Sj1zRimkBXMG4vaHapj4 ycOX+uIQD6mrGqycwI4QBb4Kb/iTh79xU8JbyDS8m5YYySoY5CfVPPkOKtVe1NCK/7XM /BPDpbEp7/lwlCYdXxHTiwOUUAiugN+HbXyDbZOqrjV6q3z4yx+2JISh6v2IhHEWDV6T 6hX8P0kY9KCBSyObulYdyQuM/of4yesqEkUrKBHRMyqwlthrBsh8LNGxtp0dgxdaMb7q zG6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mfygNcjW0ZCgexbN9HcPEeyIQ8syk4DK9pEZuNSHSK0=; b=MI+BIzwaPlp7jELlTLlb+i8CEyVNFrDkcJLT2Fv0i2vQdwvJARJLMZqdz3nMObEXn9 9nwRiaxCK/9gf5pqyMYLMikzgjyY8sHShggK3+mxeTbjhuQxi3DRW8SVesNVUOaHUs19 E1gNzUM/1KUysTNMYIQ05Rym+LiYGt4VnuV0hANn/A7AAyf1d6e0PxgNxRQmWtLGJz6S S+iEg/1439YwyW+qo01QlmFbeTIGCqglBbU10SsxvUno7oUNSITbqCrxHM2pLKf6Xjkp UqRrjb7ECDXIqg5KVvoXme1Ly45z4geA2bFXopTJPFyxPH4F5faAecac4Nhx8hXTiskX IL5Q== X-Gm-Message-State: ALyK8tJh1aldsEwVRKN1RDfbEPz0sNVSe8MfPswSYPnEAgsjhB8JS8RoHe3htUu049VjaA== X-Received: by 10.36.93.139 with SMTP id w133mr1994315ita.6.1464982685666; Fri, 03 Jun 2016 12:38:05 -0700 (PDT) Received: from CABRO3AP00510.americas.tsp.ad ([74.51.240.241]) by smtp.gmail.com with ESMTPSA id e7sm3427231iof.12.2016.06.03.12.38.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jun 2016 12:38:04 -0700 (PDT) From: Sylvain Lemieux To: vz@mleia.com, thierry.reding@gmail.com Subject: [PATCH] pwm: lpc32xx: Set PWM_PIN_LEVEL bit in lpc32xx_pwm_disable Date: Fri, 3 Jun 2016 15:37:57 -0400 Message-Id: <1464982677-24883-1-git-send-email-slemieux.tyco@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160603_123826_869465_DA55D2EC X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 From: Sylvain Lemieux If the PWM_PIN_LEVEL bit is setup to 1 in the bootloader, when the kernel disable the PWM, the PWM output is always set as a logic 1. Prior to commit 08ee77b5a5de27ad63c92262ebcb4efe0da93b58, the PWM_PIN_LEVEL bit was always clear when the PWM was disable and a 0 logic level was apply to the output. According to the LPC32x0 User Manual [1], the default value for bit 30 (PWM_PIN_LEVEL) is 0. This change initialize the pin level to 0 (default value) and update the register value accordingly during the disable process. [1] http://www.nxp.com/documents/user_manual/UM10326.pdf Signed-off-by: Sylvain Lemieux --- drivers/pwm/pwm-lpc32xx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c index 4d470c1..dbf93a1 100644 --- a/drivers/pwm/pwm-lpc32xx.c +++ b/drivers/pwm/pwm-lpc32xx.c @@ -22,9 +22,11 @@ struct lpc32xx_pwm_chip { struct pwm_chip chip; struct clk *clk; void __iomem *base; + unsigned int pin_state; }; #define PWM_ENABLE BIT(31) +#define PWM_PIN_LEVEL BIT(30) #define to_lpc32xx_pwm_chip(_chip) \ container_of(_chip, struct lpc32xx_pwm_chip, chip) @@ -85,7 +87,14 @@ static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) u32 val; val = readl(lpc32xx->base + (pwm->hwpwm << 2)); - val &= ~PWM_ENABLE; + val &= ~(PWM_ENABLE | PWM_PIN_LEVEL); + + /* + * When the PWM is disable, we have to ensure the output is configured + * correctly: + */ + if(lpc32xx->pin_state) + val |= PWM_PIN_LEVEL; writel(val, lpc32xx->base + (pwm->hwpwm << 2)); clk_disable_unprepare(lpc32xx->clk); @@ -121,6 +130,7 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev) lpc32xx->chip.ops = &lpc32xx_pwm_ops; lpc32xx->chip.npwm = 1; lpc32xx->chip.base = -1; + lpc32xx->pin_state = 0; ret = pwmchip_add(&lpc32xx->chip); if (ret < 0) {