Skip to content

Commit

Permalink
ARM: s3c24xx: Switch to atomic pwm API in rx1950
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
  • Loading branch information
Uwe Kleine-König authored and Krzysztof Kozlowski committed Jan 21, 2020
1 parent 45984f0 commit 5ec6fd3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions arch/arm/mach-s3c24xx/mach-rx1950.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5ec6fd3

Please sign in to comment.