]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pwm-backlight: make power-supply as option
authorKever Yang <kever.yang@rock-chips.com>
Fri, 9 Feb 2018 02:45:12 +0000 (10:45 +0800)
committerAnatolij Gustschin <agust@denx.de>
Tue, 6 Mar 2018 09:17:15 +0000 (10:17 +0100)
Some pwm backlight may not need 'power-supply', let's make it as option
in pwm-backlight driver.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
drivers/video/pwm_backlight.c

index fbd7bf783891655f3bedc10333d7f978ce0cdd0f..f40e57bb8e6841aa9ec7718e31c69ea73b4bdc8e 100644 (file)
@@ -32,16 +32,18 @@ static int pwm_backlight_enable(struct udevice *dev)
        uint duty_cycle;
        int ret;
 
-       plat = dev_get_uclass_platdata(priv->reg);
-       debug("%s: Enable '%s', regulator '%s'/'%s'\n", __func__, dev->name,
-             priv->reg->name, plat->name);
-       ret = regulator_set_enable(priv->reg, true);
-       if (ret) {
-               debug("%s: Cannot enable regulator for PWM '%s'\n", __func__,
-                     dev->name);
-               return ret;
+       if (priv->reg) {
+               plat = dev_get_uclass_platdata(priv->reg);
+               debug("%s: Enable '%s', regulator '%s'/'%s'\n", __func__,
+                     dev->name, priv->reg->name, plat->name);
+               ret = regulator_set_enable(priv->reg, true);
+               if (ret) {
+                       debug("%s: Cannot enable regulator for PWM '%s'\n",
+                             __func__, dev->name);
+                       return ret;
+               }
+               mdelay(120);
        }
-       mdelay(120);
 
        duty_cycle = priv->period_ns * (priv->default_level - priv->min_level) /
                (priv->max_level - priv->min_level + 1);
@@ -68,10 +70,8 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
        debug("%s: start\n", __func__);
        ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
                                           "power-supply", &priv->reg);
-       if (ret) {
+       if (ret)
                debug("%s: Cannot get power supply: ret=%d\n", __func__, ret);
-               return ret;
-       }
        ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
                                   GPIOD_IS_OUT);
        if (ret) {