Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: gpio-backlight: Use default-on on GPIO request

There are situations where the backlight should be on at boot time
(e.g. if the boot loader already turned the display on). The DT
bindings specify the "default-on" property for that purpose.
Currently, the initial state of the GPIO at request time is always
set to logical off (high or low depending on whether it is an
active high or low GPIO). Since the GPIO is requested as an output,
the GPIO will be driven low for a short period of time, which leads
to a flickering display in the above use-case.

Initialize the GPIO depending on the default-on property to be
logical on or off.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Stefan Agner and committed by
Lee Jones
2f4647a1 87770780

+7 -3
+7 -3
drivers/video/backlight/gpio_backlight.c
··· 89 89 struct backlight_device *bl; 90 90 struct gpio_backlight *gbl; 91 91 struct device_node *np = pdev->dev.of_node; 92 + unsigned long flags = GPIOF_DIR_OUT; 92 93 int ret; 93 94 94 95 if (!pdata && !np) { ··· 115 114 gbl->def_value = pdata->def_value; 116 115 } 117 116 118 - ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT | 119 - (gbl->active ? GPIOF_INIT_LOW 120 - : GPIOF_INIT_HIGH), 117 + if (gbl->active) 118 + flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW; 119 + else 120 + flags |= gbl->def_value ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH; 121 + 122 + ret = devm_gpio_request_one(gbl->dev, gbl->gpio, flags, 121 123 pdata ? pdata->name : "backlight"); 122 124 if (ret < 0) { 123 125 dev_err(&pdev->dev, "unable to request GPIO\n");