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
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
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
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>
26 #include <linux/glamofb.h>
28 @@ -756,10 +757,21 @@ static struct s3c2410_ts_mach_info gta02_ts_cfg = {
30 /* SPI: LCM control interface attached to Glamo3362 */
32 +void gta02_jbt6k74_reset(int devidx, int level)
34 + glamo_lcm_reset(level);
38 +const struct jbt6k74_platform_data jbt6k74_pdata = {
39 + .reset = gta02_jbt6k74_reset,
42 static struct spi_board_info gta02_spi_board_info[] = {
44 .modalias = "jbt6k74",
46 + .platform_data = &jbt6k74_pdata,
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)
56 EXPORT_SYMBOL_GPL(glamo_engine_reset);
58 +void glamo_lcm_reset(int level)
63 + glamo_gpio_setpin(glamo_handle, GLAMO_GPIO4, level);
64 + glamo_gpio_cfgpin(glamo_handle, GLAMO_GPIO4_OUTPUT);
67 +EXPORT_SYMBOL_GPL(glamo_lcm_reset);
72 @@ -1142,8 +1153,8 @@ static int glamo_resume(struct platform_device *pdev)
73 static struct platform_driver glamo_driver = {
75 .remove = glamo_remove,
76 - .suspend = glamo_suspend,
77 - .resume = glamo_resume,
78 + .suspend_late = glamo_suspend,
79 + .resume_early = glamo_resume,
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)
91 -#define glamo_spigpio_suspend NULL
92 +/*#define glamo_spigpio_suspend NULL
93 #define glamo_spigpio_resume NULL
98 +static int glamo_spigpio_suspend(struct platform_device *pdev, pm_message_t state)
103 +static int glamo_spigpio_resume(struct platform_device *pdev)
105 + struct glamo_spigpio *sp = platform_get_drvdata(pdev);
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);
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);
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,
131 + .suspend_late = glamo_spigpio_suspend,
132 + .resume_early = glamo_spigpio_resume,
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
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>
148 #include <linux/spi/spi.h>
150 @@ -114,11 +116,15 @@ struct jbt_info {
151 struct mutex lock; /* protects tx_buf and reg_cache */
154 + struct work_struct work;
157 #define JBT_COMMAND 0x000
158 #define JBT_DATA 0x100
160 +static void jbt_resume_work(struct work_struct *work);
163 static int jbt_reg_write_nodata(struct jbt_info *jbt, u8 reg)
166 @@ -130,6 +136,9 @@ static int jbt_reg_write_nodata(struct jbt_info *jbt, u8 reg)
169 jbt->reg_cache[reg] = 0;
171 + printk(KERN_ERR"jbt_reg_write_nodata spi_write ret %d\n",
174 mutex_unlock(&jbt->lock);
176 @@ -149,6 +158,8 @@ static int jbt_reg_write(struct jbt_info *jbt, u8 reg, u8 data)
179 jbt->reg_cache[reg] = data;
181 + printk(KERN_ERR"jbt_reg_write spi_write ret %d\n", rc);
183 mutex_unlock(&jbt->lock);
185 @@ -169,6 +180,8 @@ static int jbt_reg_write16(struct jbt_info *jbt, u8 reg, u16 data)
188 jbt->reg_cache[reg] = data;
190 + printk(KERN_ERR"jbt_reg_write16 spi_write ret %d\n", rc);
192 mutex_unlock(&jbt->lock);
194 @@ -563,6 +576,8 @@ static int __devinit jbt_probe(struct spi_device *spi)
198 + INIT_WORK(&jbt->work, jbt_resume_work);
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)
206 struct jbt_info *jbt = dev_get_drvdata(&spi->dev);
207 + struct jbt6k74_platform_data *jbt6k74_pdata = spi->dev.platform_data;
209 /* Save mode for resume */
210 jbt->last_state = jbt->state;
211 jbt6k74_enter_state(jbt, JBT_STATE_DEEP_STANDBY);
213 + (jbt6k74_pdata->reset)(0, 0);
218 -static int jbt_resume(struct spi_device *spi)
219 +static void jbt_resume_work(struct work_struct *work)
221 - struct jbt_info *jbt = dev_get_drvdata(&spi->dev);
222 + struct jbt_info *jbt = container_of(work, struct jbt_info, work);
224 + printk(KERN_INFO"jbt_resume_work waiting...\n");
226 + printk(KERN_INFO"jbt_resume_work GO...\n");
228 - jbt6k74_enter_state(jbt, jbt->last_state);
229 + jbt6k74_enter_state(jbt, JBT_STATE_DEEP_STANDBY);
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);
239 + jbt6k74_enter_state(jbt, JBT_STATE_NORMAL);
242 + jbt6k74_display_onoff(jbt, 1);
244 + printk(KERN_INFO"jbt_resume_work done...\n");
247 +static int jbt_resume(struct spi_device *spi)
249 + struct jbt_info *jbt = dev_get_drvdata(&spi->dev);
250 + struct jbt6k74_platform_data *jbt6k74_pdata = spi->dev.platform_data;
252 + (jbt6k74_pdata->reset)(0, 1);
254 + if (!schedule_work(&jbt->work))
255 + dev_err(&spi->dev, "Unable to schedule LCM wakeup work\n");
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 {
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);
270 diff --git a/include/linux/jbt6k74.h b/include/linux/jbt6k74.h
272 index 0000000..3fbe178
274 +++ b/include/linux/jbt6k74.h
276 +#ifndef __JBT6K74_H__
277 +#define __JBT6K74_H__
279 +struct jbt6k74_platform_data {
280 + void (* reset)(int devindex, int level);