From patchwork Wed Mar 19 13:03:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 3859271 Return-Path: X-Original-To: patchwork-linux-fbdev@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 7FADE9F334 for ; Wed, 19 Mar 2014 18:14:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A535B20122 for ; Wed, 19 Mar 2014 18:14:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA42920173 for ; Wed, 19 Mar 2014 18:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965173AbaCSNRx (ORCPT ); Wed, 19 Mar 2014 09:17:53 -0400 Received: from top.free-electrons.com ([176.31.233.9]:42114 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933739AbaCSNEE (ORCPT ); Wed, 19 Mar 2014 09:04:04 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id F0BF119FE; Wed, 19 Mar 2014 14:04:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost (128-79-216-6.hfc.dyn.abo.bbox.fr [128.79.216.6]) by mail.free-electrons.com (Postfix) with ESMTPSA id ACAF519FA; Wed, 19 Mar 2014 14:04:05 +0100 (CET) From: Alexandre Belloni To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Nicolas Ferre , Jean-Christophe Plagniol-Villard , Haavard Skinnemoen , Hans-Christian Egtvedt , Bryan Wu , Richard Purdie , Greg Kroah-Hartman , Thierry Reding , Jingoo Han , linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, Alexandre Belloni Subject: [PATCH 08/16] backlight: pwm_bl: set pwm polarity when using platform data Date: Wed, 19 Mar 2014 14:03:21 +0100 Message-Id: <1395234209-15546-9-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395234209-15546-1-git-send-email-alexandre.belloni@free-electrons.com> References: <1395234209-15546-1-git-send-email-alexandre.belloni@free-electrons.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Set inversed polarity when .pwm_active_low is set in the platform_data. With device tree, this is taken care of by of_pwm_xlate_with_flags(), called from of_pwm_get(). Signed-off-by: Alexandre Belloni --- drivers/video/backlight/pwm_bl.c | 8 ++++++++ include/linux/pwm_backlight.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index b75201ff46f6..ffdd3b2b2742 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -309,6 +309,14 @@ static int pwm_backlight_probe(struct platform_device *pdev) if (data->pwm_period_ns > 0) pwm_set_period(pb->pwm, data->pwm_period_ns); + /* + * The DT case is taking care of polarity in of_pwm_get(). For the + * non-DT case, set the polarity from platform data. + */ + if (data->pwm_active_low) + if (pwm_set_polarity(pb->pwm, PWM_POLARITY_INVERSED)) + dev_err(&pdev->dev, "impossible to invert polarity\n"); + pb->period = pwm_get_period(pb->pwm); pb->lth_brightness = data->lth_brightness * (pb->period / pb->scale); diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index 2de2e275b2cb..b924fce5c97a 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -15,6 +15,7 @@ struct platform_pwm_backlight_data { unsigned int dft_brightness; unsigned int lth_brightness; unsigned int pwm_period_ns; + bool pwm_active_low; unsigned int *levels; int enable_gpio; unsigned long enable_gpio_flags;