mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] video/ssd1307fb: add support for VBAT
@ 2017-07-24 14:12 Bastian Stender
  0 siblings, 0 replies; only message in thread
From: Bastian Stender @ 2017-07-24 14:12 UTC (permalink / raw)
  To: barebox; +Cc: Bastian Stender

Adds support to the driver to enable VBAT regulator at init time.

This is similar to ba14301e0356 ("fbdev/ssd1307fb: add support to enable
VBAT") and cfc5b2b551d8 ("fbdev/ssd1307fb: fix optional VBAT support")
in Linux kernel.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
---
 drivers/video/ssd1307fb.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
index 7437d340ee..54e02e7220 100644
--- a/drivers/video/ssd1307fb.c
+++ b/drivers/video/ssd1307fb.c
@@ -24,6 +24,7 @@
 #include <of_device.h>
 #include <gpio.h>
 #include <of_gpio.h>
+#include <regulator.h>
 
 #define SSD1307FB_DATA                          0x40
 #define SSD1307FB_COMMAND                       0x80
@@ -70,6 +71,7 @@ struct ssd1307fb_par {
 	u32 prechargep1;
 	u32 prechargep2;
 	int reset;
+	struct regulator *vbat;
 	u32 seg_remap;
 	u32 vcomh;
 	u32 width;
@@ -422,6 +424,12 @@ static int ssd1307fb_probe(struct device_d *dev)
 		goto fb_alloc_error;
 	}
 
+	par->vbat = regulator_get(&client->dev, "vbat-supply");
+	if (IS_ERR(par->vbat)) {
+		dev_info(&client->dev, "Will not use VBAT");
+		par->vbat = NULL;
+	}
+
 	ret = of_property_read_u32(node, "solomon,width", &par->width);
 	if (ret) {
 		dev_err(&client->dev,
@@ -505,11 +513,26 @@ static int ssd1307fb_probe(struct device_d *dev)
 		goto reset_oled_error;
 	}
 
+	if (par->vbat) {
+		ret = regulator_disable(par->vbat);
+		if (ret < 0)
+			goto reset_oled_error;
+	}
+
 	i2c_set_clientdata(client, info);
 
 	/* Reset the screen */
 	gpio_set_value(par->reset, 0);
 	udelay(4);
+
+	if (par->vbat) {
+		ret = regulator_enable(par->vbat);
+		if (ret < 0)
+			goto reset_oled_error;
+	}
+
+	mdelay(100);
+
 	gpio_set_value(par->reset, 1);
 	udelay(4);
 
@@ -548,6 +571,7 @@ static int ssd1307fb_probe(struct device_d *dev)
 panel_init_error:
 reset_oled_error:
 fb_alloc_error:
+	regulator_disable(par->vbat);
 	free(info);
 	return ret;
 }
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-24 14:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-24 14:12 [PATCH] video/ssd1307fb: add support for VBAT Bastian Stender

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox