disable IMQ on 2.6.28 as well -- people should use IFB..
[openwrt/openwrt.git] / target / linux / s3c24xx / patches / 0083-fix-lcm-reinit-post-resume.patch.patch
1 From 3d71204efba10914e339b411471877b81cf1e5d9 Mon Sep 17 00:00:00 2001
2 From: warmcat <andy@warmcat.com>
3 Date: Fri, 25 Jul 2008 23:06:01 +0100
4 Subject: [PATCH] fix-lcm-reinit-post-resume.patch
5
6 ---
7 arch/arm/mach-s3c2440/mach-gta02.c | 12 +++++++++
8 drivers/mfd/glamo/glamo-core.c | 15 ++++++++++-
9 drivers/mfd/glamo/glamo-spi-gpio.c | 38 ++++++++++++++++++++++++++--
10 drivers/video/display/jbt6k74.c | 47 ++++++++++++++++++++++++++++++++----
11 include/linux/glamofb.h | 1 +
12 include/linux/jbt6k74.h | 8 ++++++
13 6 files changed, 111 insertions(+), 10 deletions(-)
14 create mode 100644 include/linux/jbt6k74.h
15
16 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
17 index f2b1b66..750fd97 100644
18 --- a/arch/arm/mach-s3c2440/mach-gta02.c
19 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
20 @@ -76,6 +76,7 @@
21 #include <asm/plat-s3c24xx/cpu.h>
22 #include <asm/plat-s3c24xx/pm.h>
23 #include <asm/plat-s3c24xx/udc.h>
24 +#include <linux/jbt6k74.h>
25
26 #include <linux/glamofb.h>
27
28 @@ -756,10 +757,21 @@ static struct s3c2410_ts_mach_info gta02_ts_cfg = {
29
30 /* SPI: LCM control interface attached to Glamo3362 */
31
32 +void gta02_jbt6k74_reset(int devidx, int level)
33 +{
34 + glamo_lcm_reset(level);
35 +}
36 +
37 +
38 +const struct jbt6k74_platform_data jbt6k74_pdata = {
39 + .reset = gta02_jbt6k74_reset,
40 +};
41 +
42 static struct spi_board_info gta02_spi_board_info[] = {
43 {
44 .modalias = "jbt6k74",
45 /* platform_data */
46 + .platform_data = &jbt6k74_pdata,
47 /* controller_data */
48 /* irq */
49 .max_speed_hz = 10 * 1000 * 1000,
50 diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
51 index ffa4945..2076e61 100644
52 --- a/drivers/mfd/glamo/glamo-core.c
53 +++ b/drivers/mfd/glamo/glamo-core.c
54 @@ -513,6 +513,17 @@ void glamo_engine_reset(struct glamo_core *glamo, enum glamo_engine engine)
55 }
56 EXPORT_SYMBOL_GPL(glamo_engine_reset);
57
58 +void glamo_lcm_reset(int level)
59 +{
60 + if (!glamo_handle)
61 + return;
62 +
63 + glamo_gpio_setpin(glamo_handle, GLAMO_GPIO4, level);
64 + glamo_gpio_cfgpin(glamo_handle, GLAMO_GPIO4_OUTPUT);
65 +
66 +}
67 +EXPORT_SYMBOL_GPL(glamo_lcm_reset);
68 +
69 enum glamo_pll {
70 GLAMO_PLL1,
71 GLAMO_PLL2,
72 @@ -1142,8 +1153,8 @@ static int glamo_resume(struct platform_device *pdev)
73 static struct platform_driver glamo_driver = {
74 .probe = glamo_probe,
75 .remove = glamo_remove,
76 - .suspend = glamo_suspend,
77 - .resume = glamo_resume,
78 + .suspend_late = glamo_suspend,
79 + .resume_early = glamo_resume,
80 .driver = {
81 .name = "glamo3362",
82 .owner = THIS_MODULE,
83 diff --git a/drivers/mfd/glamo/glamo-spi-gpio.c b/drivers/mfd/glamo/glamo-spi-gpio.c
84 index 73926bd..eda7322 100644
85 --- a/drivers/mfd/glamo/glamo-spi-gpio.c
86 +++ b/drivers/mfd/glamo/glamo-spi-gpio.c
87 @@ -224,14 +224,46 @@ static int glamo_spigpio_remove(struct platform_device *pdev)
88 return 0;
89 }
90
91 -#define glamo_spigpio_suspend NULL
92 +/*#define glamo_spigpio_suspend NULL
93 #define glamo_spigpio_resume NULL
94 +*/
95 +
96 +
97 +#ifdef CONFIG_PM
98 +static int glamo_spigpio_suspend(struct platform_device *pdev, pm_message_t state)
99 +{
100 + return 0;
101 +}
102 +
103 +static int glamo_spigpio_resume(struct platform_device *pdev)
104 +{
105 + struct glamo_spigpio *sp = platform_get_drvdata(pdev);
106 +
107 + if (!sp)
108 + return 0;
109 +
110 + /* set state of spi pins */
111 + glamo_gpio_setpin(sp->glamo, sp->info->pin_clk, 0);
112 + glamo_gpio_setpin(sp->glamo, sp->info->pin_mosi, 0);
113 + glamo_gpio_setpin(sp->glamo, sp->info->pin_cs, 1);
114 +
115 + glamo_gpio_cfgpin(sp->glamo, sp->info->pin_clk);
116 + glamo_gpio_cfgpin(sp->glamo, sp->info->pin_mosi);
117 + glamo_gpio_cfgpin(sp->glamo, sp->info->pin_cs);
118 + if (sp->info->pin_miso)
119 + glamo_gpio_cfgpin(sp->glamo, sp->info->pin_miso);
120 +
121 + return 0;
122 +}
123 +#endif
124
125 static struct platform_driver glamo_spi_drv = {
126 .probe = glamo_spigpio_probe,
127 .remove = glamo_spigpio_remove,
128 - .suspend = glamo_spigpio_suspend,
129 - .resume = glamo_spigpio_resume,
130 +#ifdef CONFIG_PM
131 + .suspend_late = glamo_spigpio_suspend,
132 + .resume_early = glamo_spigpio_resume,
133 +#endif
134 .driver = {
135 .name = "glamo-spi-gpio",
136 .owner = THIS_MODULE,
137 diff --git a/drivers/video/display/jbt6k74.c b/drivers/video/display/jbt6k74.c
138 index d021d7e..d7e9442 100644
139 --- a/drivers/video/display/jbt6k74.c
140 +++ b/drivers/video/display/jbt6k74.c
141 @@ -27,6 +27,8 @@
142 #include <linux/device.h>
143 #include <linux/platform_device.h>
144 #include <linux/delay.h>
145 +#include <linux/workqueue.h>
146 +#include <linux/jbt6k74.h>
147
148 #include <linux/spi/spi.h>
149
150 @@ -114,11 +116,15 @@ struct jbt_info {
151 struct mutex lock; /* protects tx_buf and reg_cache */
152 u16 tx_buf[8];
153 u16 reg_cache[0xEE];
154 + struct work_struct work;
155 };
156
157 #define JBT_COMMAND 0x000
158 #define JBT_DATA 0x100
159
160 +static void jbt_resume_work(struct work_struct *work);
161 +
162 +
163 static int jbt_reg_write_nodata(struct jbt_info *jbt, u8 reg)
164 {
165 int rc;
166 @@ -130,6 +136,9 @@ static int jbt_reg_write_nodata(struct jbt_info *jbt, u8 reg)
167 1*sizeof(u16));
168 if (rc == 0)
169 jbt->reg_cache[reg] = 0;
170 + else
171 + printk(KERN_ERR"jbt_reg_write_nodata spi_write ret %d\n",
172 + rc);
173
174 mutex_unlock(&jbt->lock);
175
176 @@ -149,6 +158,8 @@ static int jbt_reg_write(struct jbt_info *jbt, u8 reg, u8 data)
177 2*sizeof(u16));
178 if (rc == 0)
179 jbt->reg_cache[reg] = data;
180 + else
181 + printk(KERN_ERR"jbt_reg_write spi_write ret %d\n", rc);
182
183 mutex_unlock(&jbt->lock);
184
185 @@ -169,6 +180,8 @@ static int jbt_reg_write16(struct jbt_info *jbt, u8 reg, u16 data)
186 3*sizeof(u16));
187 if (rc == 0)
188 jbt->reg_cache[reg] = data;
189 + else
190 + printk(KERN_ERR"jbt_reg_write16 spi_write ret %d\n", rc);
191
192 mutex_unlock(&jbt->lock);
193
194 @@ -563,6 +576,8 @@ static int __devinit jbt_probe(struct spi_device *spi)
195 if (!jbt)
196 return -ENOMEM;
197
198 + INIT_WORK(&jbt->work, jbt_resume_work);
199 +
200 jbt->spi_dev = spi;
201 jbt->state = JBT_STATE_DEEP_STANDBY;
202 mutex_init(&jbt->lock);
203 @@ -618,28 +633,50 @@ static int __devexit jbt_remove(struct spi_device *spi)
204 static int jbt_suspend(struct spi_device *spi, pm_message_t state)
205 {
206 struct jbt_info *jbt = dev_get_drvdata(&spi->dev);
207 + struct jbt6k74_platform_data *jbt6k74_pdata = spi->dev.platform_data;
208
209 /* Save mode for resume */
210 jbt->last_state = jbt->state;
211 jbt6k74_enter_state(jbt, JBT_STATE_DEEP_STANDBY);
212
213 + (jbt6k74_pdata->reset)(0, 0);
214 +
215 return 0;
216 }
217
218 -static int jbt_resume(struct spi_device *spi)
219 +static void jbt_resume_work(struct work_struct *work)
220 {
221 - struct jbt_info *jbt = dev_get_drvdata(&spi->dev);
222 + struct jbt_info *jbt = container_of(work, struct jbt_info, work);
223 +
224 + printk(KERN_INFO"jbt_resume_work waiting...\n");
225 + msleep(2000);
226 + printk(KERN_INFO"jbt_resume_work GO...\n");
227
228 - jbt6k74_enter_state(jbt, jbt->last_state);
229 + jbt6k74_enter_state(jbt, JBT_STATE_DEEP_STANDBY);
230 + msleep(100);
231
232 switch (jbt->last_state) {
233 - case JBT_STATE_NORMAL:
234 case JBT_STATE_QVGA_NORMAL:
235 - jbt6k74_display_onoff(jbt, 1);
236 + jbt6k74_enter_state(jbt, JBT_STATE_QVGA_NORMAL);
237 break;
238 default:
239 + jbt6k74_enter_state(jbt, JBT_STATE_NORMAL);
240 break;
241 }
242 + jbt6k74_display_onoff(jbt, 1);
243 +
244 + printk(KERN_INFO"jbt_resume_work done...\n");
245 +}
246 +
247 +static int jbt_resume(struct spi_device *spi)
248 +{
249 + struct jbt_info *jbt = dev_get_drvdata(&spi->dev);
250 + struct jbt6k74_platform_data *jbt6k74_pdata = spi->dev.platform_data;
251 +
252 + (jbt6k74_pdata->reset)(0, 1);
253 +
254 + if (!schedule_work(&jbt->work))
255 + dev_err(&spi->dev, "Unable to schedule LCM wakeup work\n");
256
257 return 0;
258 }
259 diff --git a/include/linux/glamofb.h b/include/linux/glamofb.h
260 index 24742a2..75eefef 100644
261 --- a/include/linux/glamofb.h
262 +++ b/include/linux/glamofb.h
263 @@ -35,5 +35,6 @@ struct glamofb_platform_data {
264
265 void glamofb_cmd_mode(struct glamofb_handle *gfb, int on);
266 int glamofb_cmd_write(struct glamofb_handle *gfb, u_int16_t val);
267 +void glamo_lcm_reset(int level);
268
269 #endif
270 diff --git a/include/linux/jbt6k74.h b/include/linux/jbt6k74.h
271 new file mode 100644
272 index 0000000..3fbe178
273 --- /dev/null
274 +++ b/include/linux/jbt6k74.h
275 @@ -0,0 +1,8 @@
276 +#ifndef __JBT6K74_H__
277 +#define __JBT6K74_H__
278 +
279 +struct jbt6k74_platform_data {
280 + void (* reset)(int devindex, int level);
281 +};
282 +
283 +#endif
284 --
285 1.5.6.3
286