From patchwork Fri Dec 1 12:06:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 10086945 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 223446035E for ; Fri, 1 Dec 2017 12:07:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15CD82A455 for ; Fri, 1 Dec 2017 12:07:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A3CD2A4EB; Fri, 1 Dec 2017 12:07:36 +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,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25FAE2A455 for ; Fri, 1 Dec 2017 12:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=85jB6+wMR4GlKr/giE3q71yvXjoODpZ2EFCPL0XpeKQ=; b=bx6ehnMHtGSxfQu2nmb6Qeb6Ni iXA+BHDOVoR34RJ4j4jEVjauQ8D7f2oXqpszKXO0iHjniZ4DQLqMU+9qjxVsNYYYlASfsLDB3Z/Ol glOYl9hhVSGaKhAFiQG28CjLQmEN021mSGdlUECrXtpA3Cl/Vt9w1M+zZtmV89TaN+YVJSk5r/FYE DpUnH9f/AluXhIh7iKz5CBsuE4TLd5rL3WdnR1JorKJ0GBLx9EKiBdGaohOb/IzX1qQcKS6yOEQzw AlWxVl/h0jd4BkZkMLTEJUvbvexOjgrdQFDlEx0X1VNssc5lsPeTgiRb1W9g03JlFWgpygbkMRR3I 4JrcuMjQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKk6Q-00086K-N7; Fri, 01 Dec 2017 12:07:34 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKk6M-0007o4-Ii for linux-rockchip@lists.infradead.org; Fri, 01 Dec 2017 12:07:33 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 39C522701A1 From: Enric Balletbo i Serra To: Lee Jones , Daniel Thompson , Jingoo Han , Rob Herring , Pavel Machek , Heiko Stuebner Subject: [PATCH v5 3/5] pwm-backlight: add support for PWM delays proprieties. Date: Fri, 1 Dec 2017 13:06:49 +0100 Message-Id: <20171201120651.29633-3-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171201120651.29633-1-enric.balletbo@collabora.com> References: <20171201120651.29633-1-enric.balletbo@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171201_040730_928381_61ABB48D X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Thierry Reding , Richard Purdie , Jacek Anaszewski , groeck@chromium.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some panels (i.e. N116BGE-L41), in their power sequence specifications, request a delay between set the PWM signal and enable the backlight and between clear the PWM signal and disable the backlight. Add support for the new post-pwm-on-delay-ms and pwm-off-delay-ms proprieties to meet the timings. Signed-off-by: Enric Balletbo i Serra Acked-by: Pavel Machek Acked-by: Daniel Thompson Acked-by: Jingoo Han --- Changes since v4: - Rebased on top of mainline. - Added the acks from Pavel Machek, Daniel thompson and Jingoo Han Changes since v3: - Use two named members instead of pwm_delay[] (Daniel and Pavel) - Use msleep instead of usleep_range. (Pavel) Changes since v2: - Move the pwm/enable sequence to another patch (Thierry Reding) Changes since v1: - As suggested by Daniel Thompson - Do not assume power-on delay and power-off delay will be the same - Move the check of dt property to the parse dt function. drivers/video/backlight/pwm_bl.c | 19 +++++++++++++++++++ include/linux/pwm_backlight.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 698ec68..8e3f124 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -35,6 +36,8 @@ struct pwm_bl_data { struct gpio_desc *enable_gpio; unsigned int scale; bool legacy; + unsigned int post_pwm_on_delay; + unsigned int pwm_off_delay; int (*notify)(struct device *, int brightness); void (*notify_after)(struct device *, @@ -56,6 +59,9 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness) pwm_enable(pb->pwm); + if (pb->post_pwm_on_delay) + msleep(pb->post_pwm_on_delay); + if (pb->enable_gpio) gpiod_set_value_cansleep(pb->enable_gpio, 1); @@ -70,6 +76,9 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) if (pb->enable_gpio) gpiod_set_value_cansleep(pb->enable_gpio, 0); + if (pb->pwm_off_delay) + msleep(pb->pwm_off_delay); + pwm_config(pb->pwm, 0, pb->period); pwm_disable(pb->pwm); @@ -178,6 +187,14 @@ static int pwm_backlight_parse_dt(struct device *dev, data->max_brightness--; } + /* + * These values are optional and set as 0 by default, the out values + * are modified only if a valid u32 value can be decoded. + */ + of_property_read_u32(node, "post-pwm-on-delay-ms", + &data->post_pwm_on_delay); + of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay); + data->enable_gpio = -EINVAL; return 0; } @@ -276,6 +293,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->exit = data->exit; pb->dev = &pdev->dev; pb->enabled = false; + pb->post_pwm_on_delay = data->post_pwm_on_delay; + pb->pwm_off_delay = data->pwm_off_delay; pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_ASIS); diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index e8afbd7..8ea265a 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -14,6 +14,8 @@ struct platform_pwm_backlight_data { unsigned int lth_brightness; unsigned int pwm_period_ns; unsigned int *levels; + unsigned int post_pwm_on_delay; + unsigned int pwm_off_delay; /* TODO remove once all users are switched to gpiod_* API */ int enable_gpio; int (*init)(struct device *dev);