Skip to content

Commit

Permalink
ARM: SAMSUNG: Add suspend/resume support for S3C PWM driver
Browse files Browse the repository at this point in the history
Reset period_ns and duty_ns values in suspend handler to avoid skip of
configuration if same values passed to pwm_config;
Restore invertion bit in resume handler.

Without this patch PWM works incorrectly after resume from suspend.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Vasily Khoruzhick authored and Ben Dooks committed Mar 15, 2010
1 parent 664e87e commit e79032a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions arch/arm/plat-samsung/pwm.c
Original file line number Diff line number Diff line change
@@ -379,13 +379,48 @@ static int __devexit s3c_pwm_remove(struct platform_device *pdev)
return 0;
}

#ifdef CONFIG_PM
static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state)
{
struct pwm_device *pwm = platform_get_drvdata(pdev);

/* No one preserve these values during suspend so reset them
* Otherwise driver leaves PWM unconfigured if same values
* passed to pwm_config
*/
pwm->period_ns = 0;
pwm->duty_ns = 0;

return 0;
}

static int s3c_pwm_resume(struct platform_device *pdev)
{
struct pwm_device *pwm = platform_get_drvdata(pdev);
unsigned long tcon;

/* Restore invertion */
tcon = __raw_readl(S3C2410_TCON);
tcon |= pwm_tcon_invert(pwm);
__raw_writel(tcon, S3C2410_TCON);

return 0;
}

#else
#define s3c_pwm_suspend NULL
#define s3c_pwm_resume NULL
#endif

static struct platform_driver s3c_pwm_driver = {
.driver = {
.name = "s3c24xx-pwm",
.owner = THIS_MODULE,
},
.probe = s3c_pwm_probe,
.remove = __devexit_p(s3c_pwm_remove),
.suspend = s3c_pwm_suspend,
.resume = s3c_pwm_resume,
};

static int __init pwm_init(void)

0 comments on commit e79032a

Please sign in to comment.