aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-02-08 10:43:59 -0500
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2017-02-08 10:43:59 -0500
commitba14301e0356c99803e07db60e129a2ca9e50ff0 (patch)
tree22f0b3946af992c9dfd42022b11c205a96f59710
parentfdde1a8148d81617582c138cd1fbdc4594d4c941 (diff)
fbdev/ssd1307fb: add support to enable VBAT
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>
-rw-r--r--Documentation/devicetree/bindings/display/ssd1307fb.txt1
-rw-r--r--drivers/video/fbdev/ssd1307fb.c20
2 files changed, 20 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/display/ssd1307fb.txt b/Documentation/devicetree/bindings/display/ssd1307fb.txt
index 6617df68d8b8..209d931ef16c 100644
--- a/Documentation/devicetree/bindings/display/ssd1307fb.txt
+++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt
@@ -16,6 +16,7 @@ Required properties:
16Optional properties: 16Optional properties:
17 - reset-gpios: The GPIO used to reset the OLED display, if available. See 17 - reset-gpios: The GPIO used to reset the OLED display, if available. See
18 Documentation/devicetree/bindings/gpio/gpio.txt for details. 18 Documentation/devicetree/bindings/gpio/gpio.txt for details.
19 - vbat-supply: The supply for VBAT
19 - solomon,segment-no-remap: Display needs normal (non-inverted) data column 20 - solomon,segment-no-remap: Display needs normal (non-inverted) data column
20 to segment mapping 21 to segment mapping
21 - solomon,com-seq: Display uses sequential COM pin configuration 22 - solomon,com-seq: Display uses sequential COM pin configuration
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 89372af7bc5b..616a6a3fabf9 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -16,6 +16,7 @@
16#include <linux/of_gpio.h> 16#include <linux/of_gpio.h>
17#include <linux/pwm.h> 17#include <linux/pwm.h>
18#include <linux/uaccess.h> 18#include <linux/uaccess.h>
19#include <linux/regulator/consumer.h>
19 20
20#define SSD1307FB_DATA 0x40 21#define SSD1307FB_DATA 0x40
21#define SSD1307FB_COMMAND 0x80 22#define SSD1307FB_COMMAND 0x80
@@ -74,6 +75,7 @@ struct ssd1307fb_par {
74 struct pwm_device *pwm; 75 struct pwm_device *pwm;
75 u32 pwm_period; 76 u32 pwm_period;
76 struct gpio_desc *reset; 77 struct gpio_desc *reset;
78 struct regulator *vbat_reg;
77 u32 seg_remap; 79 u32 seg_remap;
78 u32 vcomh; 80 u32 vcomh;
79 u32 width; 81 u32 width;
@@ -574,6 +576,14 @@ static int ssd1307fb_probe(struct i2c_client *client,
574 goto fb_alloc_error; 576 goto fb_alloc_error;
575 } 577 }
576 578
579 par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat");
580 if (IS_ERR(par->vbat_reg)) {
581 dev_err(&client->dev, "failed to get VBAT regulator: %ld\n",
582 PTR_ERR(par->vbat_reg));
583 ret = PTR_ERR(par->vbat_reg);
584 goto fb_alloc_error;
585 }
586
577 if (of_property_read_u32(node, "solomon,width", &par->width)) 587 if (of_property_read_u32(node, "solomon,width", &par->width))
578 par->width = 96; 588 par->width = 96;
579 589
@@ -658,9 +668,15 @@ static int ssd1307fb_probe(struct i2c_client *client,
658 udelay(4); 668 udelay(4);
659 } 669 }
660 670
671 ret = regulator_enable(par->vbat_reg);
672 if (ret) {
673 dev_err(&client->dev, "failed to enable VBAT: %d\n", ret);
674 goto reset_oled_error;
675 }
676
661 ret = ssd1307fb_init(par); 677 ret = ssd1307fb_init(par);
662 if (ret) 678 if (ret)
663 goto reset_oled_error; 679 goto regulator_enable_error;
664 680
665 ret = register_framebuffer(info); 681 ret = register_framebuffer(info);
666 if (ret) { 682 if (ret) {
@@ -693,6 +709,8 @@ panel_init_error:
693 pwm_disable(par->pwm); 709 pwm_disable(par->pwm);
694 pwm_put(par->pwm); 710 pwm_put(par->pwm);
695 }; 711 };
712regulator_enable_error:
713 regulator_disable(par->vbat_reg);
696reset_oled_error: 714reset_oled_error:
697 fb_deferred_io_cleanup(info); 715 fb_deferred_io_cleanup(info);
698fb_alloc_error: 716fb_alloc_error: