X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=arch%2Farm%2Fplat-samsung%2Fpwm.c;h=2eeb49fa056d6413c1963abc6113fa0eff76caf8;hp=ef019f27b67d5822afc8c3e4fbdac17220eebbd6;hb=5a0e3ad6af8660be21ca98a971cd00f331318c05;hpb=722874465e3cd3268387b96e02220f84b35a8d98 diff --git a/arch/arm/plat-samsung/pwm.c b/arch/arm/plat-samsung/pwm.c index ef019f27b67d..2eeb49fa056d 100644 --- a/arch/arm/plat-samsung/pwm.c +++ b/arch/arm/plat-samsung/pwm.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -379,6 +380,39 @@ 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", @@ -386,6 +420,8 @@ static struct platform_driver s3c_pwm_driver = { }, .probe = s3c_pwm_probe, .remove = __devexit_p(s3c_pwm_remove), + .suspend = s3c_pwm_suspend, + .resume = s3c_pwm_resume, }; static int __init pwm_init(void)