mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Bastian Stender <bst@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Bastian Stender <bst@pengutronix.de>
Subject: [PATCH] video/ssd1307fb: add support for VBAT
Date: Mon, 24 Jul 2017 16:12:01 +0200	[thread overview]
Message-ID: <20170724141201.8709-1-bst@pengutronix.de> (raw)

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

                 reply	other threads:[~2017-07-24 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170724141201.8709-1-bst@pengutronix.de \
    --to=bst@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox