1 From 966a29020932751ba6a1a137b0e1e25ac0708be7 Mon Sep 17 00:00:00 2001
2 From: matt_hsu <matt_hsu@openmoko.org>
3 Date: Thu, 8 May 2008 10:23:07 +0100
4 Subject: [PATCH] s3c24xx-pwm-platform-driver.patch
6 This patch is to register pwm as platform driver to keep the PWM-related
7 config when system is in suspend/resume. This could fix the following
11 - LEDs blinked abnormally(if LEDs is driven by PWM)
13 Signed-off-by: Matt Hsu <matt_hsu@openmoko.org>
15 arch/arm/mach-s3c2410/pwm.c | 63 ++++++++++++++++++++++++++++++++++++
16 arch/arm/mach-s3c2440/mach-gta02.c | 6 +++
17 2 files changed, 69 insertions(+), 0 deletions(-)
19 diff --git a/arch/arm/mach-s3c2410/pwm.c b/arch/arm/mach-s3c2410/pwm.c
20 index 23738c1..86a4faa 100644
21 --- a/arch/arm/mach-s3c2410/pwm.c
22 +++ b/arch/arm/mach-s3c2410/pwm.c
24 #include <linux/kernel.h>
25 #include <linux/init.h>
26 #include <linux/clk.h>
27 +#include <linux/device.h>
28 #include <asm/hardware.h>
29 #include <asm/plat-s3c/regs-timer.h>
30 #include <asm/arch/pwm.h>
33 + static unsigned long standby_reg_tcon;
34 + static unsigned long standby_reg_tcfg0;
35 + static unsigned long standby_reg_tcfg1;
38 int s3c2410_pwm_disable(struct s3c2410_pwm *pwm)
41 @@ -212,3 +219,59 @@ int s3c2410_pwm_dumpregs(void)
44 EXPORT_SYMBOL_GPL(s3c2410_pwm_dumpregs);
46 +static int __init s3c24xx_pwm_probe(struct platform_device *pdev)
48 + dev_info(&pdev->dev, "s3c24xx_pwm is registered \n");
54 +static int s3c24xx_pwm_suspend(struct platform_device *pdev, pm_message_t state)
56 + /* PWM config should be kept in suspending */
57 + standby_reg_tcon = __raw_readl(S3C2410_TCON);
58 + standby_reg_tcfg0 = __raw_readl(S3C2410_TCFG0);
59 + standby_reg_tcfg1 = __raw_readl(S3C2410_TCFG1);
64 +static int s3c24xx_pwm_resume(struct platform_device *pdev)
66 + __raw_writel(standby_reg_tcon, S3C2410_TCON);
67 + __raw_writel(standby_reg_tcfg0, S3C2410_TCFG0);
68 + __raw_writel(standby_reg_tcfg1, S3C2410_TCFG1);
73 +#define sc32440_pwm_suspend NULL
74 +#define sc32440_pwm_resume NULL
77 +static struct platform_driver s3c24xx_pwm_driver = {
79 + .name = "s3c24xx_pwm",
80 + .owner = THIS_MODULE,
82 + .probe = s3c24xx_pwm_probe,
83 + .suspend = s3c24xx_pwm_suspend,
84 + .resume = s3c24xx_pwm_resume,
87 +static int __init s3c24xx_pwm_init(void)
89 + return platform_driver_register(&s3c24xx_pwm_driver);
92 +static void __exit s3c24xx_pwm_exit(void)
96 +MODULE_AUTHOR("Javi Roman <javiroman@kernel-labs.org>");
97 +MODULE_LICENSE("GPL");
99 +module_init(s3c24xx_pwm_init);
100 +module_exit(s3c24xx_pwm_exit);
101 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
102 index 27babc9..1954121 100644
103 --- a/arch/arm/mach-s3c2440/mach-gta02.c
104 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
105 @@ -719,6 +719,11 @@ static struct platform_device gta02_sdio_dev = {
106 .num_resources = ARRAY_SIZE(gta02_sdio_resources),
109 +struct platform_device s3c24xx_pwm_device = {
110 + .name = "s3c24xx_pwm",
111 + .num_resources = 0,
114 static struct platform_device *gta02_devices[] __initdata = {
117 @@ -731,6 +736,7 @@ static struct platform_device *gta02_devices[] __initdata = {
120 >a02_version_device,
121 + &s3c24xx_pwm_device,
124 static struct s3c2410_nand_set gta02_nand_sets[] = {