diff mbox series

[3/5] drm/panel/samsung-sofef00: make gpio optional

Message ID 20210720153125.43389-4-caleb@connolly.tech
State New
Headers show
Series OnePlus 6 fixes | expand

Commit Message

Caleb Connolly July 20, 2021, 3:33 p.m. UTC
The OnePlus 6T panel fails to initialise if it has been reset,
workaround this by allowing panels to not specify a reset GPIO.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
---
 drivers/gpu/drm/panel/panel-samsung-sofef00.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--
2.32.0
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-samsung-sofef00.c b/drivers/gpu/drm/panel/panel-samsung-sofef00.c
index 8cb1853574bb..a20a5af14653 100644
--- a/drivers/gpu/drm/panel/panel-samsung-sofef00.c
+++ b/drivers/gpu/drm/panel/panel-samsung-sofef00.c
@@ -44,6 +44,8 @@  struct sofef00_panel *to_sofef00_panel(struct drm_panel *panel)

 static void sofef00_panel_reset(struct sofef00_panel *ctx)
 {
+	if (!ctx->reset_gpio)
+		return;
 	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
 	usleep_range(5000, 6000);
 	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
@@ -137,7 +139,8 @@  static int sofef00_panel_prepare(struct drm_panel *panel)
 	ret = sofef00_panel_on(ctx);
 	if (ret < 0) {
 		dev_err(dev, "Failed to initialize panel: %d\n", ret);
-		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+		if (ctx->reset_gpio)
+			gpiod_set_value_cansleep(ctx->reset_gpio, 1);
 		return ret;
 	}

@@ -276,7 +279,7 @@  static int sofef00_panel_probe(struct mipi_dsi_device *dsi)
 		return ret;
 	}

-	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(ctx->reset_gpio)) {
 		ret = PTR_ERR(ctx->reset_gpio);
 		dev_warn(dev, "Failed to get reset-gpios: %d\n", ret);