{"id":797139,"url":"http://patchwork.ozlabs.org/api/patches/797139/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1501756568-28641-3-git-send-email-philippe.cornu@st.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1501756568-28641-3-git-send-email-philippe.cornu@st.com>","list_archive_url":null,"date":"2017-08-03T10:36:07","name":"[U-Boot,v1,2/3] dm: backlight: Add a driver for GPIO backlight","commit_ref":"5b6a6a91c870949e21b7fd3865582ea6a32ea922","pull_url":null,"state":"accepted","archived":false,"hash":"78047142b18ae7c718b6994e47347002275f8192","submitter":{"id":71606,"url":"http://patchwork.ozlabs.org/api/people/71606/?format=json","name":"Philippe CORNU","email":"philippe.cornu@st.com"},"delegate":{"id":1700,"url":"http://patchwork.ozlabs.org/api/users/1700/?format=json","username":"ag","first_name":"Anatolij","last_name":"Gustschin","email":"agust@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1501756568-28641-3-git-send-email-philippe.cornu@st.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/797139/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/797139/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xNRX54Vq6z9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  3 Aug 2017 20:44:53 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 49372C21D7A; Thu,  3 Aug 2017 10:43:45 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id CD87AC21D65;\n\tThu,  3 Aug 2017 10:43:27 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 7F5D4C21C6A; Thu,  3 Aug 2017 10:36:33 +0000 (UTC)","from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com\n\t[91.207.212.93])\n\tby lists.denx.de (Postfix) with ESMTPS id 0AA18C21C51\n\tfor <u-boot@lists.denx.de>; Thu,  3 Aug 2017 10:36:33 +0000 (UTC)","from pps.filterd (m0046660.ppops.net [127.0.0.1])\n\tby mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv73AYm8X014939; Thu, 3 Aug 2017 12:36:31 +0200","from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35])\n\tby mx08-.pphosted.com with ESMTP id 2c2upm448g-1\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT);\n\tThu, 03 Aug 2017 12:36:31 +0200","from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9])\n\tby beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 170C431;\n\tThu,  3 Aug 2017 10:36:31 +0000 (GMT)","from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92])\n\tby zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0002014DA;\n\tThu,  3 Aug 2017 10:36:30 +0000 (GMT)","from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com\n\t(10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.339.0;\n\tThu, 3 Aug 2017 12:36:30 +0200","from localhost (10.201.23.32) by Webmail-ga.st.com (10.75.90.48)\n\twith Microsoft SMTP Server (TLS) id 14.3.339.0;\n\tThu, 3 Aug 2017 12:36:30 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW\n\tautolearn=unavailable autolearn_force=no version=3.4.0","From":"Philippe CORNU <philippe.cornu@st.com>","To":"Anatolij Gustschin <agust@denx.de>, <u-boot@lists.denx.de>, \"Christophe\n\tKerello\" <christophe.kerello@st.com>, Patrick Delaunay\n\t<patrick.delaunay@st.com>, Vikas Manocha <vikas.manocha@st.com>, \"Patrice\n\tChotard\" <patrice.chotard@st.com>","Date":"Thu, 3 Aug 2017 12:36:07 +0200","Message-ID":"<1501756568-28641-3-git-send-email-philippe.cornu@st.com>","X-Mailer":"git-send-email 1.9.1","In-Reply-To":"<1501756568-28641-1-git-send-email-philippe.cornu@st.com>","References":"<1501756568-28641-1-git-send-email-philippe.cornu@st.com>","MIME-Version":"1.0","X-Originating-IP":"[10.201.23.32]","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-03_06:, , signatures=0","X-Mailman-Approved-At":"Thu, 03 Aug 2017 10:43:25 +0000","Cc":"Yannick Fertre <yannick.fertre@st.com>,\n\tBenjamin Gaignard <benjamin.gaignard@linaro.org>","Subject":"[U-Boot] [PATCH v1 2/3] dm: backlight: Add a driver for GPIO\n\tbacklight","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"From: Patrick Delaunay <patrick.delaunay@st.com>\n\nAdd a driver for GPIO backlights.\nIt understands the standard device tree binding.\nIt can be used with simple-panel when PWM is not necessary.\n\nSigned-off-by: Patrick Delaunay <patrick.delaunay@st.com>\n---\n drivers/video/Kconfig          | 10 ++++++\n drivers/video/Makefile         |  1 +\n drivers/video/backlight_gpio.c | 74 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 85 insertions(+)\n create mode 100644 drivers/video/backlight_gpio.c","diff":"diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig\nindex da23d39..32dc8ea 100644\n--- a/drivers/video/Kconfig\n+++ b/drivers/video/Kconfig\n@@ -25,6 +25,16 @@ config BACKLIGHT_PWM\n \t  it understands the standard device tree\n \t  (leds/backlight/pwm-backlight.txt)\n \n+config BACKLIGHT_GPIO\n+\tbool \"Generic GPIO based Backlight Driver\"\n+\tdepends on DM_VIDEO\n+\thelp\n+\t  If you have a LCD backlight adjustable by GPIO, say Y to enable\n+\t  this driver.\n+\t  This driver can be used with \"simple-panel\" and\n+\t  it understands the standard device tree\n+\t  (leds/backlight/gpio-backlight.txt)\n+\n config VIDEO_BPP8\n \tbool \"Support 8-bit-per-pixel displays\"\n \tdepends on DM_VIDEO\ndiff --git a/drivers/video/Makefile b/drivers/video/Makefile\nindex 3839433..d6df709 100644\n--- a/drivers/video/Makefile\n+++ b/drivers/video/Makefile\n@@ -12,6 +12,7 @@ obj-$(CONFIG_DM_VIDEO) += panel-uclass.o simple_panel.o\n obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o\n obj-$(CONFIG_DM_VIDEO) += video_bmp.o\n obj-$(CONFIG_BACKLIGHT_PWM) += pwm_backlight.o\n+obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o\n obj-$(CONFIG_CONSOLE_NORMAL) += console_normal.o\n obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o\n obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/\ndiff --git a/drivers/video/backlight_gpio.c b/drivers/video/backlight_gpio.c\nnew file mode 100644\nindex 0000000..772df5d\n--- /dev/null\n+++ b/drivers/video/backlight_gpio.c\n@@ -0,0 +1,74 @@\n+/*\n+ * Copyright (C) 2017, STMicroelectronics - All Rights Reserved\n+ * Author: Patrick Delaunay <patrick.delaunay@st.com>\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#include <common.h>\n+#include <dm.h>\n+#include <backlight.h>\n+#include <asm/gpio.h>\n+\n+DECLARE_GLOBAL_DATA_PTR;\n+\n+struct gpio_backlight_priv {\n+\tstruct gpio_desc gpio;\n+\tbool def_value;\n+};\n+\n+static int gpio_backlight_enable(struct udevice *dev)\n+{\n+\tstruct gpio_backlight_priv *priv = dev_get_priv(dev);\n+\n+\tdm_gpio_set_value(&priv->gpio, 1);\n+\n+\treturn 0;\n+}\n+\n+static int gpio_backlight_ofdata_to_platdata(struct udevice *dev)\n+{\n+\tstruct gpio_backlight_priv *priv = dev_get_priv(dev);\n+\tint ret;\n+\n+\tret = gpio_request_by_name(dev, \"gpios\", 0, &priv->gpio,\n+\t\t\t\t   GPIOD_IS_OUT);\n+\tif (ret) {\n+\t\tdebug(\"%s: Warning: cannot get GPIO: ret=%d\\n\",\n+\t\t      __func__, ret);\n+\t\treturn ret;\n+\t}\n+\n+\tpriv->def_value = dev_read_bool(dev, \"default-on\");\n+\n+\treturn 0;\n+}\n+\n+static int gpio_backlight_probe(struct udevice *dev)\n+{\n+\tstruct gpio_backlight_priv *priv = dev_get_priv(dev);\n+\n+\tif (priv->def_value)\n+\t\tgpio_backlight_enable(dev);\n+\n+\treturn 0;\n+}\n+\n+static const struct backlight_ops gpio_backlight_ops = {\n+\t.enable\t= gpio_backlight_enable,\n+};\n+\n+static const struct udevice_id gpio_backlight_ids[] = {\n+\t{ .compatible = \"gpio-backlight\" },\n+\t{ }\n+};\n+\n+U_BOOT_DRIVER(gpio_backlight) = {\n+\t.name\t= \"gpio_backlight\",\n+\t.id\t= UCLASS_PANEL_BACKLIGHT,\n+\t.of_match = gpio_backlight_ids,\n+\t.ops\t= &gpio_backlight_ops,\n+\t.ofdata_to_platdata\t= gpio_backlight_ofdata_to_platdata,\n+\t.probe\t\t= gpio_backlight_probe,\n+\t.priv_auto_alloc_size\t= sizeof(struct gpio_backlight_priv),\n+};\n","prefixes":["U-Boot","v1","2/3"]}