]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
fbdev/ssd1307fb: add support to enable VBAT
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 8 Feb 2017 15:43:59 +0000 (16:43 +0100)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Wed, 8 Feb 2017 15:43:59 +0000 (16:43 +0100)
SSD1306 needs VBAT when it is wired in charge pump configuration. This
patch adds support to the driver to enable VBAT regulator at init time.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: BenoƮt Cousson <bcousson@baylibre.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Documentation/devicetree/bindings/display/ssd1307fb.txt
drivers/video/fbdev/ssd1307fb.c

index 6617df68d8b8675dcfad49221e6a2717db94be50..209d931ef16c4e53e46e8378b09f5cf04b121586 100644 (file)
@@ -16,6 +16,7 @@ Required properties:
 Optional properties:
   - reset-gpios: The GPIO used to reset the OLED display, if available. See
                  Documentation/devicetree/bindings/gpio/gpio.txt for details.
+  - vbat-supply: The supply for VBAT
   - solomon,segment-no-remap: Display needs normal (non-inverted) data column
                               to segment mapping
   - solomon,com-seq: Display uses sequential COM pin configuration
index 89372af7bc5b508bdbb3333b7953a4903cc8c00d..616a6a3fabf978d958a31e8a91e57e57141be591 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/of_gpio.h>
 #include <linux/pwm.h>
 #include <linux/uaccess.h>
+#include <linux/regulator/consumer.h>
 
 #define SSD1307FB_DATA                 0x40
 #define SSD1307FB_COMMAND              0x80
@@ -74,6 +75,7 @@ struct ssd1307fb_par {
        struct pwm_device *pwm;
        u32 pwm_period;
        struct gpio_desc *reset;
+       struct regulator *vbat_reg;
        u32 seg_remap;
        u32 vcomh;
        u32 width;
@@ -574,6 +576,14 @@ static int ssd1307fb_probe(struct i2c_client *client,
                goto fb_alloc_error;
        }
 
+       par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat");
+       if (IS_ERR(par->vbat_reg)) {
+               dev_err(&client->dev, "failed to get VBAT regulator: %ld\n",
+                       PTR_ERR(par->vbat_reg));
+               ret = PTR_ERR(par->vbat_reg);
+               goto fb_alloc_error;
+       }
+
        if (of_property_read_u32(node, "solomon,width", &par->width))
                par->width = 96;
 
@@ -658,9 +668,15 @@ static int ssd1307fb_probe(struct i2c_client *client,
                udelay(4);
        }
 
+       ret = regulator_enable(par->vbat_reg);
+       if (ret) {
+               dev_err(&client->dev, "failed to enable VBAT: %d\n", ret);
+               goto reset_oled_error;
+       }
+
        ret = ssd1307fb_init(par);
        if (ret)
-               goto reset_oled_error;
+               goto regulator_enable_error;
 
        ret = register_framebuffer(info);
        if (ret) {
@@ -693,6 +709,8 @@ panel_init_error:
                pwm_disable(par->pwm);
                pwm_put(par->pwm);
        };
+regulator_enable_error:
+       regulator_disable(par->vbat_reg);
 reset_oled_error:
        fb_deferred_io_cleanup(info);
 fb_alloc_error: