All of lore.kernel.org
 help / color / mirror / Atom feed
* The default value of enable_gpio in pwm-backlight driver?
@ 2015-09-03 13:08 YH Huang
  2015-09-14  3:24   ` Yingjoe Chen
  0 siblings, 1 reply; 3+ messages in thread
From: YH Huang @ 2015-09-03 13:08 UTC (permalink / raw)
  To: Alexandre Courbot, Thierry Reding
  Cc: linux-pwm, linux-mediatek, djkurtz, yingjoe.chen, yh.huang

Hi all,

I have a problem while using the pwm-backlight driver.
I want to match the panel power sequence timing but fail in the probe
function. I think it is right to set the gpio "inactive" at
initialization. For now, the probe function always pulls high
enable_gpio although I set it as GPIO_ACTIVE_HIGH in dts.
I find the change and excerpt part of it. I am not sure if it is right.
If I misunderstanding something, please let me know.

Regards,
YH Huang


From	Alexandre Courbot <>
Subject	[PATCH 2/2] pwm-backlight: switch to gpiod interface
Date	Thu, 27 Feb 2014 14:53:34 +0900

Switch to the new gpiod interface, which allows to handle GPIO
properties such as active low transparently and removes a whole bunch of
code.

There are still a couple of users of this driver that rely on passing
the enable GPIO number through platform data, so a fallback mechanism
using a GPIO number is still available to avoid breaking them. It will
be removed once current users have switched to the GPIO lookup tables
provided by the gpiod interface.

--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c

@@ -265,26 +245,39 @@ static int pwm_backlight_probe(struct
platform_device *pdev)
 	pb->dev = &pdev->dev;
 	pb->enabled = false;
 
-	if (gpio_is_valid(pb->enable_gpio)) {
-		unsigned long flags;
-
-		if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW)
-			flags = GPIOF_OUT_INIT_HIGH;
-		else
-			flags = GPIOF_OUT_INIT_LOW;
+	pb->enable_gpio = devm_gpiod_get(&pdev->dev, "enable");
+	if (IS_ERR(pb->enable_gpio)) {
+		ret = PTR_ERR(pb->enable_gpio);
+		if (ret == -ENOENT) {
+			pb->enable_gpio = NULL;
+			ret = 0;
+		} else {
+			goto err_alloc;
+		}
+	}
 
-		ret = gpio_request_one(pb->enable_gpio, flags, "enable");
+	/*
+	 * Compatibility fallback for drivers still using the integer GPIO
+	 * platform data. Must go away soon.
+	 */
+	if (pb->enable_gpio == NULL && gpio_is_valid(data->enable_gpio)) {
+		ret = devm_gpio_request_one(&pdev->dev, data->enable_gpio,
+					    GPIOF_OUT_INIT_HIGH, "enable");
 		if (ret < 0) {
 			dev_err(&pdev->dev, "failed to request GPIO#%d: %d\n",
-				pb->enable_gpio, ret);
+				data->enable_gpio, ret);
 			goto err_alloc;
 		}
+		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
 	}
 
+	if (pb->enable_gpio)
+		gpiod_direction_output(pb->enable_gpio, 1);
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	Is here right?

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

* Re: The default value of enable_gpio in pwm-backlight driver?
  2015-09-03 13:08 The default value of enable_gpio in pwm-backlight driver? YH Huang
@ 2015-09-14  3:24   ` Yingjoe Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Yingjoe Chen @ 2015-09-14  3:24 UTC (permalink / raw)
  To: Thierry Reding, Alexandre Courbot
  Cc: YH Huang, linux-pwm, linux-mediatek, djkurtz, lee.jones,
	jingoohan1, linux-kernel


Hi Alexandre, Thierry,


On Thu, 2015-09-03 at 21:08 +0800, YH Huang wrote:
<...>
> From	Alexandre Courbot <>
> Subject	[PATCH 2/2] pwm-backlight: switch to gpiod interface
> Date	Thu, 27 Feb 2014 14:53:34 +0900
> 
> Switch to the new gpiod interface, which allows to handle GPIO
> properties such as active low transparently and removes a whole bunch of
> code.
> 
> There are still a couple of users of this driver that rely on passing
> the enable GPIO number through platform data, so a fallback mechanism
> using a GPIO number is still available to avoid breaking them. It will
> be removed once current users have switched to the GPIO lookup tables
> provided by the gpiod interface.
> 
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> 
> @@ -265,26 +245,39 @@ static int pwm_backlight_probe(struct
> platform_device *pdev)
>  	pb->dev = &pdev->dev;
>  	pb->enabled = false;
>  
> -	if (gpio_is_valid(pb->enable_gpio)) {
> -		unsigned long flags;
> -
> -		if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW)
> -			flags = GPIOF_OUT_INIT_HIGH;
> -		else
> -			flags = GPIOF_OUT_INIT_LOW;

In commit 257462dbf3ed ("pwm-backlight: switch to gpiod interface").
It seems to me the original code is trying to make it default disable...

> +	pb->enable_gpio = devm_gpiod_get(&pdev->dev, "enable");
> +	if (IS_ERR(pb->enable_gpio)) {
> +		ret = PTR_ERR(pb->enable_gpio);
> +		if (ret == -ENOENT) {
> +			pb->enable_gpio = NULL;
> +			ret = 0;
> +		} else {
> +			goto err_alloc;
> +		}
> +	}
>  
> -		ret = gpio_request_one(pb->enable_gpio, flags, "enable");
> +	/*
> +	 * Compatibility fallback for drivers still using the integer GPIO
> +	 * platform data. Must go away soon.
> +	 */
> +	if (pb->enable_gpio == NULL && gpio_is_valid(data->enable_gpio)) {
> +		ret = devm_gpio_request_one(&pdev->dev, data->enable_gpio,
> +					    GPIOF_OUT_INIT_HIGH, "enable");
>  		if (ret < 0) {
>  			dev_err(&pdev->dev, "failed to request GPIO#%d: %d\n",
> -				pb->enable_gpio, ret);
> +				data->enable_gpio, ret);
>  			goto err_alloc;
>  		}
> +		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
>  	}
>  
> +	if (pb->enable_gpio)
> +		gpiod_direction_output(pb->enable_gpio, 1);

But the new code here set it to enable. Is this on purpose, or am I miss
read anything?

Joe.C



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

* Re: The default value of enable_gpio in pwm-backlight driver?
@ 2015-09-14  3:24   ` Yingjoe Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Yingjoe Chen @ 2015-09-14  3:24 UTC (permalink / raw)
  To: Thierry Reding, Alexandre Courbot
  Cc: YH Huang, linux-pwm, linux-mediatek, djkurtz, lee.jones,
	jingoohan1, linux-kernel


Hi Alexandre, Thierry,


On Thu, 2015-09-03 at 21:08 +0800, YH Huang wrote:
<...>
> From	Alexandre Courbot <>
> Subject	[PATCH 2/2] pwm-backlight: switch to gpiod interface
> Date	Thu, 27 Feb 2014 14:53:34 +0900
> 
> Switch to the new gpiod interface, which allows to handle GPIO
> properties such as active low transparently and removes a whole bunch of
> code.
> 
> There are still a couple of users of this driver that rely on passing
> the enable GPIO number through platform data, so a fallback mechanism
> using a GPIO number is still available to avoid breaking them. It will
> be removed once current users have switched to the GPIO lookup tables
> provided by the gpiod interface.
> 
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> 
> @@ -265,26 +245,39 @@ static int pwm_backlight_probe(struct
> platform_device *pdev)
>  	pb->dev = &pdev->dev;
>  	pb->enabled = false;
>  
> -	if (gpio_is_valid(pb->enable_gpio)) {
> -		unsigned long flags;
> -
> -		if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW)
> -			flags = GPIOF_OUT_INIT_HIGH;
> -		else
> -			flags = GPIOF_OUT_INIT_LOW;

In commit 257462dbf3ed ("pwm-backlight: switch to gpiod interface").
It seems to me the original code is trying to make it default disable...

> +	pb->enable_gpio = devm_gpiod_get(&pdev->dev, "enable");
> +	if (IS_ERR(pb->enable_gpio)) {
> +		ret = PTR_ERR(pb->enable_gpio);
> +		if (ret == -ENOENT) {
> +			pb->enable_gpio = NULL;
> +			ret = 0;
> +		} else {
> +			goto err_alloc;
> +		}
> +	}
>  
> -		ret = gpio_request_one(pb->enable_gpio, flags, "enable");
> +	/*
> +	 * Compatibility fallback for drivers still using the integer GPIO
> +	 * platform data. Must go away soon.
> +	 */
> +	if (pb->enable_gpio == NULL && gpio_is_valid(data->enable_gpio)) {
> +		ret = devm_gpio_request_one(&pdev->dev, data->enable_gpio,
> +					    GPIOF_OUT_INIT_HIGH, "enable");
>  		if (ret < 0) {
>  			dev_err(&pdev->dev, "failed to request GPIO#%d: %d\n",
> -				pb->enable_gpio, ret);
> +				data->enable_gpio, ret);
>  			goto err_alloc;
>  		}
> +		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
>  	}
>  
> +	if (pb->enable_gpio)
> +		gpiod_direction_output(pb->enable_gpio, 1);

But the new code here set it to enable. Is this on purpose, or am I miss
read anything?

Joe.C

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

end of thread, other threads:[~2015-09-14  3:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 13:08 The default value of enable_gpio in pwm-backlight driver? YH Huang
2015-09-14  3:24 ` Yingjoe Chen
2015-09-14  3:24   ` Yingjoe Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.