diff mbox series

video: ssd1307fb: Enable charge pump only on displays that actually have it

Message ID 1616436665-3046-1-git-send-email-michal.vokac@ysoft.com
State Superseded
Headers show
Series video: ssd1307fb: Enable charge pump only on displays that actually have it | expand

Commit Message

Michal Vokáč March 22, 2021, 6:11 p.m. UTC
A note in the datasheet says:

 "Patterns other than those given in the Command Table are prohibited to
  enter the chip as a command; as unexpected results can occur."

So do not send the charge pump command to displays that do not support it.

Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>
---
 drivers/video/fbdev/ssd1307fb.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 1b0b2a096afa..54903ea2e3ac 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -497,14 +497,16 @@  static int ssd1307fb_init_regs(struct ssd1307fb_par *par)
 		return ret;
 
 	/* Turn on the DC-DC Charge Pump */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
-	if (ret < 0)
-		return ret;
+	if (par->device_info->need_chargepump) {
+		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
+		if (ret < 0)
+			return ret;
 
-	ret = ssd1307fb_write_cmd(par->client,
-		BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0));
-	if (ret < 0)
-		return ret;
+		ret = ssd1307fb_write_cmd(par->client,
+			BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0));
+		if (ret < 0)
+			return ret;
+	}
 
 	/* Set lookup table */
 	if (par->lookup_table_set) {