X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fvideo%2Fsimple_panel.c;h=5722811117597c21a964b7f4c87504d80d00dfb8;hb=ea16637525ad6a49626de3fbf01e29e1af08d29f;hp=b16151767488fb4ba42143991ef244b0fd786ed9;hpb=82d72a1b9967cff4908f22c57536c3660f794401;p=oweals%2Fu-boot.git diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c index b161517674..5722811117 100644 --- a/drivers/video/simple_panel.c +++ b/drivers/video/simple_panel.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2016 Google, Inc * Written by Simon Glass - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -12,8 +11,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - struct simple_panel_priv { struct udevice *reg; struct udevice *backlight; @@ -25,8 +22,25 @@ static int simple_panel_enable_backlight(struct udevice *dev) 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_enable(priv->backlight); + debug("%s: done, ret = %d\n", __func__, ret); + if (ret) + return ret; + + 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; @@ -38,19 +52,21 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev) struct simple_panel_priv *priv = dev_get_priv(dev); int ret; - ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev, - "power-supply", &priv->reg); - if (ret) { - debug("%s: Warning: cnnot get power supply: ret=%d\n", - __func__, ret); - if (ret != -ENOENT) - return ret; + if (IS_ENABLED(CONFIG_DM_REGULATOR)) { + ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev, + "power-supply", &priv->reg); + if (ret) { + debug("%s: Warning: cannot get power supply: ret=%d\n", + __func__, ret); + if (ret != -ENOENT) + return ret; + } } ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, 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); @@ -58,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; @@ -69,7 +85,7 @@ static int simple_panel_probe(struct udevice *dev) struct simple_panel_priv *priv = dev_get_priv(dev); int ret; - if (priv->reg) { + if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) { debug("%s: Enable regulator '%s'\n", __func__, priv->reg->name); ret = regulator_set_enable(priv->reg, true); if (ret) @@ -81,10 +97,16 @@ 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[] = { { .compatible = "simple-panel" }, + { .compatible = "auo,b133xtn01" }, + { .compatible = "auo,b116xw03" }, + { .compatible = "auo,b133htn01" }, + { .compatible = "boe,nv140fhmn49" }, + { .compatible = "lg,lb070wv8" }, { } };