video: fbdev: pxafb: Add support for lcd-supply regulator
authorDaniel Mack <daniel@zonque.org>
Tue, 24 Jul 2018 17:11:26 +0000 (19:11 +0200)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Tue, 24 Jul 2018 17:11:26 +0000 (19:11 +0200)
Optionally obtain a lcd-supply regulator during probe and use it in
__pxafb_lcd_power() to switch the power supply of LCD panels.

This helps boards booted from DT to control such voltages without
callbacks.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Documentation/devicetree/bindings/display/marvell,pxa2xx-lcdc.txt
drivers/video/fbdev/pxafb.c
drivers/video/fbdev/pxafb.h

index f79641bd5f18e013a69ff939aa81a3f8cb02de5f..45ffd6c417487692df9ff8507e2fd62ced32846b 100644 (file)
@@ -10,6 +10,9 @@ Required properties:
  - interrupts : framebuffer controller interrupt.
  - clocks: phandle to input clocks
 
+Optional properties:
+ - lcd-supply: A phandle to a power regulator that controls the LCD voltage.
+
 Required nodes:
  - port: connection to the LCD panel (see video-interfaces.txt)
         This node must have its properties bus-width and remote-endpoint set.
index 68459b07d44253c7a61b348cd952a4dae8aece4a..bbed039617a4259b0517cb09e1f88676158ad8eb 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/freezer.h>
 #include <linux/console.h>
 #include <linux/of_graph.h>
+#include <linux/regulator/consumer.h>
 #include <video/of_display_timing.h>
 #include <video/videomode.h>
 
@@ -1423,6 +1424,21 @@ static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
 
        if (fbi->lcd_power)
                fbi->lcd_power(on, &fbi->fb.var);
+
+       if (fbi->lcd_supply && fbi->lcd_supply_enabled != on) {
+               int ret;
+
+               if (on)
+                       ret = regulator_enable(fbi->lcd_supply);
+               else
+                       ret = regulator_disable(fbi->lcd_supply);
+
+               if (ret < 0)
+                       pr_warn("Unable to %s LCD supply regulator: %d\n",
+                               on ? "enable" : "disable", ret);
+               else
+                       fbi->lcd_supply_enabled = on;
+       }
 }
 
 static void pxafb_enable_controller(struct pxafb_info *fbi)
@@ -2299,6 +2315,14 @@ static int pxafb_probe(struct platform_device *dev)
        fbi->backlight_power = inf->pxafb_backlight_power;
        fbi->lcd_power = inf->pxafb_lcd_power;
 
+       fbi->lcd_supply = devm_regulator_get_optional(&dev->dev, "lcd");
+       if (IS_ERR(fbi->lcd_supply)) {
+               if (PTR_ERR(fbi->lcd_supply) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+
+               fbi->lcd_supply = NULL;
+       }
+
        r = platform_get_resource(dev, IORESOURCE_MEM, 0);
        if (r == NULL) {
                dev_err(&dev->dev, "no I/O memory resource defined\n");
index 5dc414e26fc84b2e02ba490b911a215c4f2c3694..b641289c8a99133e13bff44be0a540f6261339fc 100644 (file)
@@ -165,6 +165,9 @@ struct pxafb_info {
        struct notifier_block   freq_policy;
 #endif
 
+       struct regulator *lcd_supply;
+       bool lcd_supply_enabled;
+
        void (*lcd_power)(int, struct fb_var_screeninfo *);
        void (*backlight_power)(int);