Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] drm/tilcdc: Switch to using GPIO descriptors
@ 2019-12-03 13:09 Linus Walleij
  2019-12-03 15:50 ` David Lechner
  2019-12-03 18:29 ` Jyri Sarha
  0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2019-12-03 13:09 UTC (permalink / raw)
  To: dri-devel, Maarten Lankhorst, Maxime Ripard, Sean Paul
  Cc: Linus Walleij, Tomi Valkeinen, Jyri Sarha, linux-arm-kernel,
	David Lechner

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@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: David Lechner <david@lechnology.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 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@gmail.com>
  */
 
-#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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/tilcdc: Switch to using GPIO descriptors
  2019-12-03 13:09 [PATCH] drm/tilcdc: Switch to using GPIO descriptors Linus Walleij
@ 2019-12-03 15:50 ` David Lechner
  2019-12-03 18:29 ` Jyri Sarha
  1 sibling, 0 replies; 4+ messages in thread
From: David Lechner @ 2019-12-03 15:50 UTC (permalink / raw)
  To: Linus Walleij, dri-devel, Maarten Lankhorst, Maxime Ripard, Sean Paul
  Cc: Tomi Valkeinen, Jyri Sarha, linux-arm-kernel

On 12/3/19 7:09 AM, Linus Walleij wrote:
> 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@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: David Lechner <david@lechnology.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---

Reviewed-by: David Lechner <david@lechnology.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/tilcdc: Switch to using GPIO descriptors
  2019-12-03 13:09 [PATCH] drm/tilcdc: Switch to using GPIO descriptors Linus Walleij
  2019-12-03 15:50 ` David Lechner
@ 2019-12-03 18:29 ` Jyri Sarha
  2019-12-04 14:30   ` Sam Ravnborg
  1 sibling, 1 reply; 4+ messages in thread
From: Jyri Sarha @ 2019-12-03 18:29 UTC (permalink / raw)
  To: Linus Walleij, dri-devel, Maarten Lankhorst, Maxime Ripard, Sean Paul
  Cc: Tomi Valkeinen, David Lechner, linux-arm-kernel

On 03/12/2019 15:09, Linus Walleij wrote:
> 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.
> 

Hmmm, I have been considering ditching this driver all together since no
mainline platform has ever used it. Also, if anybody ever wants to
connect tfp410 to tilcdc, he should use drm/bridge/ti-tfp410.c instead.

But since the patch is there, maybe I should pick it up, and remove the
bundled driver later a bit later.

BR,
Jyri

> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: David Lechner <david@lechnology.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  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@gmail.com>
>   */
>  
> -#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);
>  
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/tilcdc: Switch to using GPIO descriptors
  2019-12-03 18:29 ` Jyri Sarha
@ 2019-12-04 14:30   ` Sam Ravnborg
  0 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2019-12-04 14:30 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: David Lechner, Maxime Ripard, Linus Walleij, Maarten Lankhorst,
	dri-devel, Tomi Valkeinen, Sean Paul, linux-arm-kernel

Hi Jyri.

On Tue, Dec 03, 2019 at 08:29:45PM +0200, Jyri Sarha wrote:
> On 03/12/2019 15:09, Linus Walleij wrote:
> > 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.
> > 
> 
> Hmmm, I have been considering ditching this driver all together since no
> mainline platform has ever used it. Also, if anybody ever wants to
> connect tfp410 to tilcdc, he should use drm/bridge/ti-tfp410.c instead.
> 
> But since the patch is there, maybe I should pick it up, and remove the
> bundled driver later a bit later.

IMO much better to just get rid of it now - as there is anyway no users.
No reason to patch code that is essential dead.
You just postpone the task for no gain.

	Sam

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 13:09 [PATCH] drm/tilcdc: Switch to using GPIO descriptors Linus Walleij
2019-12-03 15:50 ` David Lechner
2019-12-03 18:29 ` Jyri Sarha
2019-12-04 14:30   ` Sam Ravnborg

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git