#include <linux/fb.h>\r
#include <linux/delay.h>\r
+#include <linux/earlysuspend.h>\r
#include "../../rk29_fb.h"\r
#include <mach/gpio.h>\r
#include <mach/iomux.h>\r
void init_nt35510(void)\r
{\r
WriteCommand(0X1100); \r
- msleep(10);\r
+ usleep_range(10*1000, 10*1000);\r
\r
WriteCommand(0X1300); \r
\r
WriteCommand(0X2000); //\r
\r
WriteCommand(0X1100); \r
- msleep(120);\r
+ usleep_range(120*1000, 120*1000);\r
\r
WriteCommand(0X2900); \r
\r
- msleep(100);\r
+ usleep_range(100*1000, 100*1000);\r
WriteCommand(0X2C00); \r
}\r
\r
WriteCommand(0X2C00); \r
}\r
\r
+static DEFINE_MUTEX(lcd_mutex);\r
+extern void rk29_lcd_spim_spin_lock(void);\r
+extern void rk29_lcd_spim_spin_unlock(void);\r
+\r
+static void lcd_resume(struct work_struct *work)\r
+{\r
+ mutex_lock(&lcd_mutex);\r
+ rk29_lcd_spim_spin_lock();\r
+ if(gLcd_info)\r
+ gLcd_info->io_init();\r
+\r
+ gpio_request(RK29_PIN6_PC6, NULL);\r
+ gpio_direction_output(RK29_PIN6_PC6, 1);\r
+ gpio_direction_output(RK29_PIN6_PC6, 0);\r
+ usleep_range(5*1000, 5*1000);\r
+ gpio_set_value(RK29_PIN6_PC6, 1);\r
+ usleep_range(50*1000, 50*1000);\r
+ gpio_free(RK29_PIN6_PC6);\r
+ init_nt35510();\r
+ //set_backlight(255);\r
+ //resume_nt35510();//may be fail to wake up LCD some time,so change to init lcd again\r
+ printk(KERN_DEBUG "%s\n",__FUNCTION__);\r
+\r
+ if(gLcd_info)\r
+ gLcd_info->io_deinit();\r
+\r
+ rk29_lcd_spim_spin_unlock();\r
+ mutex_unlock(&lcd_mutex);\r
+}\r
+\r
+static DECLARE_WORK(lcd_resume_work, lcd_resume);\r
+static struct workqueue_struct *lcd_resume_wq;\r
+\r
+static void lcd_late_resume(struct early_suspend *h)\r
+{\r
+ queue_work(lcd_resume_wq, &lcd_resume_work);\r
+}\r
+\r
+static struct early_suspend lcd_early_suspend_desc = {\r
+ .level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1, // before fb resume\r
+ .resume = lcd_late_resume,\r
+};\r
+\r
int init(void)\r
{ \r
volatile u32 data;\r
\r
//set_backlight(255);\r
\r
+ lcd_resume_wq = create_singlethread_workqueue("lcd");\r
+ register_early_suspend(&lcd_early_suspend_desc);\r
return 0;\r
}\r
-extern void rk29_lcd_spim_spin_lock(void);\r
-extern void rk29_lcd_spim_spin_unlock(void);\r
+\r
int standby(u8 enable) //***enable =1 means suspend, 0 means resume \r
{\r
- rk29_lcd_spim_spin_lock();\r
- if(gLcd_info)\r
- gLcd_info->io_init();\r
+ if (enable) {\r
+ mutex_lock(&lcd_mutex);\r
+ rk29_lcd_spim_spin_lock();\r
+ if(gLcd_info)\r
+ gLcd_info->io_init();\r
\r
- if(enable) {\r
WriteCommand(0X2800); \r
//set_backlight(0);\r
WriteCommand(0X1100); \r
msleep(5);\r
WriteCommand(0X4f00); \r
WriteParameter(0x01);\r
- } else { \r
- gpio_request(RK29_PIN6_PC6, NULL);\r
- gpio_direction_output(RK29_PIN6_PC6, 1);\r
- gpio_direction_output(RK29_PIN6_PC6, 0);\r
- msleep(5);\r
- gpio_set_value(RK29_PIN6_PC6, 1);\r
- msleep(50);\r
- gpio_free(RK29_PIN6_PC6);\r
- init_nt35510();\r
- //set_backlight(255);\r
- //resume_nt35510();//may be fail to wake up LCD some time,so change to init lcd again\r
- printk("%s\n",__FUNCTION__);\r
- }\r
-\r
- if(gLcd_info)\r
- gLcd_info->io_deinit();\r
-\r
- rk29_lcd_spim_spin_unlock();\r
+ if(gLcd_info)\r
+ gLcd_info->io_deinit();\r
\r
- return 0;\r
+ rk29_lcd_spim_spin_unlock();\r
+ mutex_unlock(&lcd_mutex);\r
+ } else {\r
+ flush_workqueue(lcd_resume_wq);\r
+ }\r
+ return 0;\r
}\r
\r
\r