linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: s3c24xx/rx1950: switch to atomic pwm API
@ 2020-01-20 19:33 Uwe Kleine-König
  2020-01-21  2:01 ` Vasily Khoruzhick
  2020-01-21 19:59 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2020-01-20 19:33 UTC (permalink / raw)
  To: Kukjin Kim, Krzysztof Kozlowski, Thierry Reding
  Cc: linux-pwm, linux-samsung-soc, linux-arm-kernel

Stop using the legacy PWM API which only still exists because there are
some users left.

Note this change make use of the fact that the value of struct
pwm_state::duty_cycle doesn't matter for a disabled PWM and so its value
can stay constant simplifying the code a bit.

A side effect of the conversion is that the pwm isn't stopped in
rx1950_backlight_init() by the call to pwm_apply_args() just before
reenabling it when rx1950_lcd_power(1) is called.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 arch/arm/mach-s3c24xx/mach-rx1950.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index 29f9b345a531..03d8f27cdc32 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -377,6 +377,7 @@ static struct pwm_lookup rx1950_pwm_lookup[] = {
 };
 
 static struct pwm_device *lcd_pwm;
+static struct pwm_state lcd_pwm_state;
 
 static void rx1950_lcd_power(int enable)
 {
@@ -429,15 +430,16 @@ static void rx1950_lcd_power(int enable)
 
 		/* GPB1->OUTPUT, GPB1->0 */
 		gpio_direction_output(S3C2410_GPB(1), 0);
-		pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
-		pwm_disable(lcd_pwm);
+
+		lcd_pwm_state.enabled = false;
+		pwm_apply_state(lcd_pwm, &lcd_pwm_state);
 
 		/* GPC0->0, GPC10->0 */
 		gpio_direction_output(S3C2410_GPC(0), 0);
 		gpio_direction_output(S3C2410_GPC(10), 0);
 	} else {
-		pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
-		pwm_enable(lcd_pwm);
+		lcd_pwm_state.enabled = true;
+		pwm_apply_state(lcd_pwm, &lcd_pwm_state);
 
 		gpio_direction_output(S3C2410_GPC(0), 1);
 		gpio_direction_output(S3C2410_GPC(5), 1);
@@ -493,10 +495,13 @@ static int rx1950_backlight_init(struct device *dev)
 	}
 
 	/*
-	 * FIXME: pwm_apply_args() should be removed when switching to
-	 * the atomic PWM API.
+	 * This is only required to initialize .polarity; all other values are
+	 * fixed in this driver.
 	 */
-	pwm_apply_args(lcd_pwm);
+	pwm_init_state(lcd_pwm, &lcd_pwm_state);
+
+	lcd_pwm_state.period = LCD_PWM_PERIOD;
+	lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
 
 	rx1950_lcd_power(1);
 	rx1950_bl_power(1);
-- 
2.24.0


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

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

* Re: [PATCH] ARM: s3c24xx/rx1950: switch to atomic pwm API
  2020-01-20 19:33 [PATCH] ARM: s3c24xx/rx1950: switch to atomic pwm API Uwe Kleine-König
@ 2020-01-21  2:01 ` Vasily Khoruzhick
  2020-01-21 19:59 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Vasily Khoruzhick @ 2020-01-21  2:01 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-pwm, linux-samsung-soc, Krzysztof Kozlowski, Kukjin Kim,
	Thierry Reding, arm-linux

On Mon, Jan 20, 2020 at 11:33 AM Uwe Kleine-König <uwe@kleine-koenig.org> wrote:
>
> Stop using the legacy PWM API which only still exists because there are
> some users left.
>
> Note this change make use of the fact that the value of struct
> pwm_state::duty_cycle doesn't matter for a disabled PWM and so its value
> can stay constant simplifying the code a bit.
>
> A side effect of the conversion is that the pwm isn't stopped in
> rx1950_backlight_init() by the call to pwm_apply_args() just before
> reenabling it when rx1950_lcd_power(1) is called.
>
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>

> ---
>  arch/arm/mach-s3c24xx/mach-rx1950.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
> index 29f9b345a531..03d8f27cdc32 100644
> --- a/arch/arm/mach-s3c24xx/mach-rx1950.c
> +++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
> @@ -377,6 +377,7 @@ static struct pwm_lookup rx1950_pwm_lookup[] = {
>  };
>
>  static struct pwm_device *lcd_pwm;
> +static struct pwm_state lcd_pwm_state;
>
>  static void rx1950_lcd_power(int enable)
>  {
> @@ -429,15 +430,16 @@ static void rx1950_lcd_power(int enable)
>
>                 /* GPB1->OUTPUT, GPB1->0 */
>                 gpio_direction_output(S3C2410_GPB(1), 0);
> -               pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
> -               pwm_disable(lcd_pwm);
> +
> +               lcd_pwm_state.enabled = false;
> +               pwm_apply_state(lcd_pwm, &lcd_pwm_state);
>
>                 /* GPC0->0, GPC10->0 */
>                 gpio_direction_output(S3C2410_GPC(0), 0);
>                 gpio_direction_output(S3C2410_GPC(10), 0);
>         } else {
> -               pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
> -               pwm_enable(lcd_pwm);
> +               lcd_pwm_state.enabled = true;
> +               pwm_apply_state(lcd_pwm, &lcd_pwm_state);
>
>                 gpio_direction_output(S3C2410_GPC(0), 1);
>                 gpio_direction_output(S3C2410_GPC(5), 1);
> @@ -493,10 +495,13 @@ static int rx1950_backlight_init(struct device *dev)
>         }
>
>         /*
> -        * FIXME: pwm_apply_args() should be removed when switching to
> -        * the atomic PWM API.
> +        * This is only required to initialize .polarity; all other values are
> +        * fixed in this driver.
>          */
> -       pwm_apply_args(lcd_pwm);
> +       pwm_init_state(lcd_pwm, &lcd_pwm_state);
> +
> +       lcd_pwm_state.period = LCD_PWM_PERIOD;
> +       lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
>
>         rx1950_lcd_power(1);
>         rx1950_bl_power(1);
> --
> 2.24.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
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] 3+ messages in thread

* Re: [PATCH] ARM: s3c24xx/rx1950: switch to atomic pwm API
  2020-01-20 19:33 [PATCH] ARM: s3c24xx/rx1950: switch to atomic pwm API Uwe Kleine-König
  2020-01-21  2:01 ` Vasily Khoruzhick
@ 2020-01-21 19:59 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2020-01-21 19:59 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-samsung-soc, Kukjin Kim, Thierry Reding, linux-arm-kernel,
	linux-pwm

On Mon, Jan 20, 2020 at 08:33:28PM +0100, Uwe Kleine-König wrote:
> Stop using the legacy PWM API which only still exists because there are
> some users left.
> 
> Note this change make use of the fact that the value of struct
> pwm_state::duty_cycle doesn't matter for a disabled PWM and so its value
> can stay constant simplifying the code a bit.
> 
> A side effect of the conversion is that the pwm isn't stopped in
> rx1950_backlight_init() by the call to pwm_apply_args() just before
> reenabling it when rx1950_lcd_power(1) is called.
> 
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
>  arch/arm/mach-s3c24xx/mach-rx1950.c | 19 ++++++++++++-------

Thanks, applied.

Best regards,
Krzysztof


_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2020-01-21 19:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 19:33 [PATCH] ARM: s3c24xx/rx1950: switch to atomic pwm API Uwe Kleine-König
2020-01-21  2:01 ` Vasily Khoruzhick
2020-01-21 19:59 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).