2 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
3 * Author: Patrick Delaunay <patrick.delaunay@st.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <backlight.h>
13 struct gpio_backlight_priv {
14 struct gpio_desc gpio;
18 static int gpio_backlight_enable(struct udevice *dev)
20 struct gpio_backlight_priv *priv = dev_get_priv(dev);
22 dm_gpio_set_value(&priv->gpio, 1);
27 static int gpio_backlight_ofdata_to_platdata(struct udevice *dev)
29 struct gpio_backlight_priv *priv = dev_get_priv(dev);
32 ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio,
35 debug("%s: Warning: cannot get GPIO: ret=%d\n",
40 priv->def_value = dev_read_bool(dev, "default-on");
45 static int gpio_backlight_probe(struct udevice *dev)
47 struct gpio_backlight_priv *priv = dev_get_priv(dev);
50 gpio_backlight_enable(dev);
55 static const struct backlight_ops gpio_backlight_ops = {
56 .enable = gpio_backlight_enable,
59 static const struct udevice_id gpio_backlight_ids[] = {
60 { .compatible = "gpio-backlight" },
64 U_BOOT_DRIVER(gpio_backlight) = {
65 .name = "gpio_backlight",
66 .id = UCLASS_PANEL_BACKLIGHT,
67 .of_match = gpio_backlight_ids,
68 .ops = &gpio_backlight_ops,
69 .ofdata_to_platdata = gpio_backlight_ofdata_to_platdata,
70 .probe = gpio_backlight_probe,
71 .priv_auto_alloc_size = sizeof(struct gpio_backlight_priv),