1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
From 6563c08a68d30e3b53b6a3a2b1916b129f4afc68 Mon Sep 17 00:00:00 2001
From: matt_hsu <matt_hsu@openmoko.org>
Date: Fri, 25 Jul 2008 23:06:08 +0100
Subject: [PATCH] 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>
---
arch/arm/mach-s3c2410/pwm.c | 63 ++++++++++++++++++++++++++++++++++++
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 23738c1..86a4faa 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 27babc9..1954121 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[] = {
--
1.5.6.3
|