summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-03-02 12:49:55 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-03-09 08:30:47 +0100
commitad86f163a2bab94b1729d73f6888f8452c7477f7 (patch)
tree0ba4c20dd377a87540075ca5c2e5316b864397fc /drivers
parentc195d0aefed81af18186eaa208fd5602ab2d76ba (diff)
downloadbarebox-ad86f163a2bab94b1729d73f6888f8452c7477f7.tar.gz
video/ssd1307fb: make reset GPIO optional
Both reset GPIO and regulator are optional as per the binding and the driver can work without if we ignore their absence. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/ssd1307fb.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
index cc50698..835814b 100644
--- a/drivers/video/ssd1307fb.c
+++ b/drivers/video/ssd1307fb.c
@@ -415,12 +415,8 @@ static int ssd1307fb_probe(struct device_d *dev)
par->reset = of_get_named_gpio(node,
"reset-gpios", 0);
- if (!gpio_is_valid(par->reset)) {
- ret = par->reset;
- if (ret != -EPROBE_DEFER)
- dev_err(&client->dev,
- "Couldn't get named gpio 'reset-gpios': %s.\n",
- strerror(-ret));
+ if (!gpio_is_valid(par->reset) && par->reset == -EPROBE_DEFER) {
+ ret = -EPROBE_DEFER;
goto fb_alloc_error;
}
@@ -503,14 +499,16 @@ static int ssd1307fb_probe(struct device_d *dev)
info->screen_base = (u8 __force __iomem *)vmem;
- ret = gpio_request_one(par->reset,
- GPIOF_OUT_INIT_HIGH,
- "oled-reset");
- if (ret) {
- dev_err(&client->dev,
- "failed to request gpio %d: %d\n",
- par->reset, ret);
- goto reset_oled_error;
+ if (par->reset >= 0) {
+ ret = gpio_request_one(par->reset,
+ GPIOF_OUT_INIT_HIGH,
+ "oled-reset");
+ if (ret) {
+ dev_err(&client->dev,
+ "failed to request gpio %d: %d\n",
+ par->reset, ret);
+ goto reset_oled_error;
+ }
}
ret = regulator_disable(par->vbat);
@@ -519,18 +517,23 @@ static int ssd1307fb_probe(struct device_d *dev)
i2c_set_clientdata(client, info);
- /* Reset the screen */
- gpio_set_value(par->reset, 0);
- udelay(4);
+ if (par->reset > 0) {
+ /* Reset the screen */
+ gpio_set_value(par->reset, 0);
+ udelay(4);
+ }
ret = regulator_enable(par->vbat);
if (ret < 0)
goto reset_oled_error;
- mdelay(100);
+ if (par->vbat)
+ mdelay(100);
- gpio_set_value(par->reset, 1);
- udelay(4);
+ if (par->reset > 0) {
+ gpio_set_value(par->reset, 1);
+ udelay(4);
+ }
ret = ssd1307fb_init(par);
if (ret)