From patchwork Sun Sep 11 08:55:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 9325163 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 2EDE160231 for ; Sun, 11 Sep 2016 09:00:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A5BE283E0 for ; Sun, 11 Sep 2016 09:00:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D60A2840E; Sun, 11 Sep 2016 09:00:07 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 A14D7283E0 for ; Sun, 11 Sep 2016 09:00:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bj0Yt-0004GE-PT; Sun, 11 Sep 2016 08:56:27 +0000 Received: from 10.mo69.mail-out.ovh.net ([46.105.73.241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bj0Yq-0004Ex-8h for linux-arm-kernel@lists.infradead.org; Sun, 11 Sep 2016 08:56:25 +0000 Received: from player696.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 6344EFF8886 for ; Sun, 11 Sep 2016 10:55:58 +0200 (CEST) Received: from localhost.localdomain (unknown [109.241.15.61]) (Authenticated sender: l.majewski@majess.pl) by player696.ha.ovh.net (Postfix) with ESMTPSA id 042AA3C0069; Sun, 11 Sep 2016 10:55:54 +0200 (CEST) From: Lukasz Majewski To: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= Subject: [PATCH] pwm: imx: Port "pwm: imx: support output polarity inversion" to Linux v4.7 Date: Sun, 11 Sep 2016 10:55:09 +0200 Message-Id: <1473584109-10710-1-git-send-email-l.majewski@majess.pl> X-Mailer: git-send-email 2.1.4 X-Ovh-Tracer-Id: 2026056883340952239 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeluddrieejgdeffeculddtuddrfeeltddrtddtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160911_015624_546444_8E85C376 X-CRM114-Status: GOOD ( 10.54 ) 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: Lukasz Majewski , Stefan Agner , 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 This patch ports "pwm: imx: support output polarity inversion" patch set written by Lothar Wassmann (v6 from 10.2014). It is used to control backlight of panels via inverted PWM signal. The "inversion" of PWM output is not an issue at such devices, since separate GPIO pin is responsible for enabling and disabling the panel's backlight. This patch should be put on top of: https://patchwork.kernel.org/patch/5065841/ https://patchwork.kernel.org/patch/5065821/ https://patchwork.kernel.org/patch/5065811/ Signed-off-by: Lukasz Majewski --- drivers/pwm/pwm-imx.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index 471a99e..c37d223 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -181,7 +181,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip, if (enable) cr |= MX3_PWMCR_EN; - if (pwm->polarity == PWM_POLARITY_INVERSED) + if (pwm->args.polarity == PWM_POLARITY_INVERSED) cr |= MX3_PWMCR_POUTC; writel(cr, imx->mmio_base + MX3_PWMCR); @@ -201,11 +201,6 @@ static void imx_pwm_set_enable_v2(struct pwm_chip *chip, bool enable) else val &= ~MX3_PWMCR_EN; - if (chip->pwms[0].polarity == PWM_POLARITY_INVERSED) - val |= MX3_PWMCR_POUTC; - else - val &= ~MX3_PWMCR_POUTC; - writel(val, imx->mmio_base + MX3_PWMCR); } @@ -253,6 +248,19 @@ static int imx_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm, enum pwm_polarity polarity) { struct imx_chip *imx = to_imx_chip(chip); + u32 val; + + if (polarity == pwm->args.polarity) + return 0; + + val = readl(imx->mmio_base + MX3_PWMCR); + + if (polarity == PWM_POLARITY_INVERSED) + val |= MX3_PWMCR_POUTC; + else + val &= ~MX3_PWMCR_POUTC; + + writel(val, imx->mmio_base + MX3_PWMCR); dev_dbg(imx->chip.dev, "%s: polarity set to %s\n", __func__, polarity == PWM_POLARITY_INVERSED ? "inverted" : "normal");