[PATCH] drm/tilcdc: Switch to using GPIO descriptors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The TI LCDC picks a GPIO line from the device tree to use
for DPMS power on/off. We can switch this to use a GPIO
descriptor pretty easily. Make sure to request the GPIO
"as is" so that the DPMS state that we start (boot) in is
preserved.

Cc: Jyri Sarha <jsarha@xxxxxx>
Cc: Tomi Valkeinen <tomi.valkeinen@xxxxxx>
Cc: David Lechner <david@xxxxxxxxxxxxxx>
Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 30 ++++++++++++--------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
index 530edb3b51cc..41cd9a7c4316 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
@@ -4,9 +4,8 @@
  * Author: Rob Clark <robdclark@xxxxxxxxx>
  */
 
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/mod_devicetable.h>
-#include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 
@@ -21,7 +20,7 @@
 struct tfp410_module {
 	struct tilcdc_module base;
 	struct i2c_adapter *i2c;
-	int gpio;
+	struct gpio_desc *power_gpiod;
 };
 #define to_tfp410_module(x) container_of(x, struct tfp410_module, base)
 
@@ -58,10 +57,10 @@ static void tfp410_encoder_dpms(struct drm_encoder *encoder, int mode)
 
 	if (mode == DRM_MODE_DPMS_ON) {
 		DBG("Power on");
-		gpio_direction_output(tfp410_encoder->mod->gpio, 1);
+		gpiod_direction_output(tfp410_encoder->mod->power_gpiod, 1);
 	} else {
 		DBG("Power off");
-		gpio_direction_output(tfp410_encoder->mod->gpio, 0);
+		gpiod_direction_output(tfp410_encoder->mod->power_gpiod, 0);
 	}
 
 	tfp410_encoder->dpms = mode;
@@ -318,17 +317,17 @@ static int tfp410_probe(struct platform_device *pdev)
 
 	of_node_put(i2c_node);
 
-	tfp410_mod->gpio = of_get_named_gpio_flags(node, "powerdn-gpio",
-			0, NULL);
-	if (tfp410_mod->gpio < 0) {
-		dev_warn(&pdev->dev, "No power down GPIO\n");
-	} else {
-		ret = gpio_request(tfp410_mod->gpio, "DVI_PDn");
-		if (ret) {
-			dev_err(&pdev->dev, "could not get DVI_PDn gpio\n");
-			goto fail_adapter;
-		}
+	tfp410_mod->power_gpiod = devm_gpiod_get_optional(&pdev->dev,
+							  "powerdn",
+							  GPIOD_ASIS);
+	if (IS_ERR(tfp410_mod->power_gpiod)) {
+		dev_err(&pdev->dev, "could not get DVI_PDn gpio\n");
+		goto fail_adapter;
 	}
+	if (!tfp410_mod->power_gpiod)
+		dev_warn(&pdev->dev, "No power down GPIO\n");
+	else
+		gpiod_set_consumer_name(tfp410_mod->power_gpiod, "DVI_PDn");
 
 	return 0;
 
@@ -346,7 +345,6 @@ static int tfp410_remove(struct platform_device *pdev)
 	struct tfp410_module *tfp410_mod = to_tfp410_module(mod);
 
 	i2c_put_adapter(tfp410_mod->i2c);
-	gpio_free(tfp410_mod->gpio);
 
 	tilcdc_module_cleanup(mod);
 
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux