diff options
author | matt_hsu <matt_hsu@openmoko.org> | 2008-11-19 17:09:42 +0000 |
---|---|---|
committer | Andy Green <agreen@pads.home.warmcat.com> | 2008-11-19 17:09:42 +0000 |
commit | 55a09978f230a2ec899ce5adda219c7f7819c3a1 (patch) | |
tree | 96d0b32fd2b0ec5aa3c2dd6b68b8b9f3520dc4fa | |
parent | d2332a3f8c6f2bcc86602af2d4385addb8a190bd (diff) |
s3c24xx-pwm-platform-driver.patch
This patch is to register pwm as platform driver to keep the PWM-related
config when system is in suspend/resume. This could fix the following
issue after resume:
- HDQ read timeout
- LEDs blinked abnormally(if LEDs is driven by PWM)
Signed-off-by: Matt Hsu <matt_hsu@openmoko.org>
-rw-r--r-- | arch/arm/mach-s3c2410/pwm.c | 63 | ||||
-rw-r--r-- | arch/arm/mach-s3c2440/mach-gta02.c | 6 |
2 files changed, 69 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2410/pwm.c b/arch/arm/mach-s3c2410/pwm.c index 23738c1482a..86a4faa3007 100644 --- a/arch/arm/mach-s3c2410/pwm.c +++ b/arch/arm/mach-s3c2410/pwm.c @@ -20,10 +20,17 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/clk.h> +#include <linux/device.h> #include <asm/hardware.h> #include <asm/plat-s3c/regs-timer.h> #include <asm/arch/pwm.h> +#ifdef CONFIG_PM + static unsigned long standby_reg_tcon; + static unsigned long standby_reg_tcfg0; + static unsigned long standby_reg_tcfg1; +#endif + int s3c2410_pwm_disable(struct s3c2410_pwm *pwm) { unsigned long tcon; @@ -212,3 +219,59 @@ int s3c2410_pwm_dumpregs(void) return 0; } EXPORT_SYMBOL_GPL(s3c2410_pwm_dumpregs); + +static int __init s3c24xx_pwm_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "s3c24xx_pwm is registered \n"); + + return 0; +} + +#ifdef CONFIG_PM +static int s3c24xx_pwm_suspend(struct platform_device *pdev, pm_message_t state) +{ + /* PWM config should be kept in suspending */ + standby_reg_tcon = __raw_readl(S3C2410_TCON); + standby_reg_tcfg0 = __raw_readl(S3C2410_TCFG0); + standby_reg_tcfg1 = __raw_readl(S3C2410_TCFG1); + + return 0; +} + +static int s3c24xx_pwm_resume(struct platform_device *pdev) +{ + __raw_writel(standby_reg_tcon, S3C2410_TCON); + __raw_writel(standby_reg_tcfg0, S3C2410_TCFG0); + __raw_writel(standby_reg_tcfg1, S3C2410_TCFG1); + + return 0; +} +#else +#define sc32440_pwm_suspend NULL +#define sc32440_pwm_resume NULL +#endif + +static struct platform_driver s3c24xx_pwm_driver = { + .driver = { + .name = "s3c24xx_pwm", + .owner = THIS_MODULE, + }, + .probe = s3c24xx_pwm_probe, + .suspend = s3c24xx_pwm_suspend, + .resume = s3c24xx_pwm_resume, +}; + +static int __init s3c24xx_pwm_init(void) +{ + return platform_driver_register(&s3c24xx_pwm_driver); +} + +static void __exit s3c24xx_pwm_exit(void) +{ +} + +MODULE_AUTHOR("Javi Roman <javiroman@kernel-labs.org>"); +MODULE_LICENSE("GPL"); + +module_init(s3c24xx_pwm_init); +module_exit(s3c24xx_pwm_exit); diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c index 27babc9f968..1954121e67c 100644 --- a/arch/arm/mach-s3c2440/mach-gta02.c +++ b/arch/arm/mach-s3c2440/mach-gta02.c @@ -719,6 +719,11 @@ static struct platform_device gta02_sdio_dev = { .num_resources = ARRAY_SIZE(gta02_sdio_resources), }; +struct platform_device s3c24xx_pwm_device = { + .name = "s3c24xx_pwm", + .num_resources = 0, +}; + static struct platform_device *gta02_devices[] __initdata = { &s3c_device_usb, &s3c_device_wdt, @@ -731,6 +736,7 @@ static struct platform_device *gta02_devices[] __initdata = { >a02_nor_flash, &sc32440_fiq_device, >a02_version_device, + &s3c24xx_pwm_device, }; static struct s3c2410_nand_set gta02_nand_sets[] = { |