drivers: video: rockchip: fix building eDP and LVDS drivers
[oweals/u-boot.git] / drivers / video / simple_panel.c
index 8824f47e2ea75a0d109a60f9dd0eea89d396046e..c3c0e847327bef44d0a015d7f56a48c6b5fde9ad 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2016 Google, Inc
  * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -33,6 +32,21 @@ static int simple_panel_enable_backlight(struct udevice *dev)
        return 0;
 }
 
+static int simple_panel_set_backlight(struct udevice *dev, int percent)
+{
+       struct simple_panel_priv *priv = dev_get_priv(dev);
+       int ret;
+
+       debug("%s: start, backlight = '%s'\n", __func__, priv->backlight->name);
+       dm_gpio_set_value(&priv->enable, 1);
+       ret = backlight_set_brightness(priv->backlight, percent);
+       debug("%s: done, ret = %d\n", __func__, ret);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static int simple_panel_ofdata_to_platdata(struct udevice *dev)
 {
        struct simple_panel_priv *priv = dev_get_priv(dev);
@@ -52,7 +66,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
                                           "backlight", &priv->backlight);
        if (ret) {
                debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
-               return ret;
+               return log_ret(ret);
        }
        ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
                                   GPIOD_IS_OUT);
@@ -60,7 +74,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
                debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
                      __func__, ret);
                if (ret != -ENOENT)
-                       return ret;
+                       return log_ret(ret);
        }
 
        return 0;
@@ -83,6 +97,7 @@ static int simple_panel_probe(struct udevice *dev)
 
 static const struct panel_ops simple_panel_ops = {
        .enable_backlight       = simple_panel_enable_backlight,
+       .set_backlight          = simple_panel_set_backlight,
 };
 
 static const struct udevice_id simple_panel_ids[] = {
@@ -90,6 +105,7 @@ static const struct udevice_id simple_panel_ids[] = {
        { .compatible = "auo,b133xtn01" },
        { .compatible = "auo,b116xw03" },
        { .compatible = "auo,b133htn01" },
+       { .compatible = "lg,lb070wv8" },
        { }
 };