Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tomi Valkeinen and committed by
Bartlomiej Zolnierkiewicz
ba14301e fdde1a81

+20 -1
+1
Documentation/devicetree/bindings/display/ssd1307fb.txt
··· 16 16 Optional properties: 17 17 - reset-gpios: The GPIO used to reset the OLED display, if available. See 18 18 Documentation/devicetree/bindings/gpio/gpio.txt for details. 19 + - vbat-supply: The supply for VBAT 19 20 - solomon,segment-no-remap: Display needs normal (non-inverted) data column 20 21 to segment mapping 21 22 - solomon,com-seq: Display uses sequential COM pin configuration
+19 -1
drivers/video/fbdev/ssd1307fb.c
··· 16 16 #include <linux/of_gpio.h> 17 17 #include <linux/pwm.h> 18 18 #include <linux/uaccess.h> 19 + #include <linux/regulator/consumer.h> 19 20 20 21 #define SSD1307FB_DATA 0x40 21 22 #define SSD1307FB_COMMAND 0x80 ··· 75 74 struct pwm_device *pwm; 76 75 u32 pwm_period; 77 76 struct gpio_desc *reset; 77 + struct regulator *vbat_reg; 78 78 u32 seg_remap; 79 79 u32 vcomh; 80 80 u32 width; ··· 576 574 goto fb_alloc_error; 577 575 } 578 576 577 + par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat"); 578 + if (IS_ERR(par->vbat_reg)) { 579 + dev_err(&client->dev, "failed to get VBAT regulator: %ld\n", 580 + PTR_ERR(par->vbat_reg)); 581 + ret = PTR_ERR(par->vbat_reg); 582 + goto fb_alloc_error; 583 + } 584 + 579 585 if (of_property_read_u32(node, "solomon,width", &par->width)) 580 586 par->width = 96; 581 587 ··· 668 658 udelay(4); 669 659 } 670 660 661 + ret = regulator_enable(par->vbat_reg); 662 + if (ret) { 663 + dev_err(&client->dev, "failed to enable VBAT: %d\n", ret); 664 + goto reset_oled_error; 665 + } 666 + 671 667 ret = ssd1307fb_init(par); 672 668 if (ret) 673 - goto reset_oled_error; 669 + goto regulator_enable_error; 674 670 675 671 ret = register_framebuffer(info); 676 672 if (ret) { ··· 709 693 pwm_disable(par->pwm); 710 694 pwm_put(par->pwm); 711 695 }; 696 + regulator_enable_error: 697 + regulator_disable(par->vbat_reg); 712 698 reset_oled_error: 713 699 fb_deferred_io_cleanup(info); 714 700 fb_alloc_error: