3 #include <linux/i2c.h>
\r
4 #include <linux/input.h>
\r
6 #include <linux/interrupt.h>
\r
7 #include <linux/delay.h>
\r
8 #include <linux/interrupt.h>
\r
9 #include <linux/errno.h>
\r
10 #include <linux/kernel.h>
\r
11 #include <linux/module.h>
\r
12 #include <linux/slab.h>
\r
13 #include <linux/input/mt.h> //use slot B protocol, Android 4.0 system
\r
14 #include <linux/platform_device.h>
\r
15 #include <linux/async.h>
\r
16 #include <linux/hrtimer.h>
\r
17 #include <linux/init.h>
\r
18 #include <linux/ioport.h>
\r
19 #include <asm/irq.h>
\r
21 #include <asm/uaccess.h>
\r
22 #include <linux/gpio.h>
\r
23 #ifdef CONFIG_RK_CONFIG
\r
24 #include <mach/config.h>
\r
26 #include <mach/irqs.h>
\r
27 //#include <mach/system.h>
\r
28 //#include <mach/hardware.h>
\r
29 //#include <mach/sys_config.h>
\r
30 #include <mach/board.h>
\r
32 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
33 #include <linux/pm.h>
\r
34 #include <linux/earlysuspend.h>
\r
37 //#define CONFIG_TS_FUNCTION_CALLED_DEBUG //Display the debug information whitch function is called
\r
38 //#define CONFIG_TS_PROBE_DEBUG //Display the debug information in byd693x_ts_probe function
\r
39 //#define CONFIG_TS_I2C_TRANSFER_DEBUG //Display the debug information of IIC transfer
\r
40 //#define CONFIG_TPKEY_STATUS_DEBUG //Display the debug information of Touch Key status
\r
41 //#define CONFIG_TS_WORKQUEUE_DEBUG //Display the debug ihnformation of creating work queue
\r
42 //#define CONFIG_TS_COORDIATE_DEBUG //
\r
43 //#define CONFIG_TS_CUTEDGE_DEBUG //
\r
45 //----------------------------------------//
\r
46 #define TOUCH_INT_NO SW_INT_IRQNO_PIO //GPIO :set the interrupt
\r
47 #define byd693x_I2C_NAME "byd693x-ts"
\r
49 //----------------------------------------//
\r
50 struct ChipSetting {
\r
57 #include "byd693x_ts.h"
\r
59 #define VERSION "byd693x_20120731_16:52_V1.2_Charles@Raysens@Zed"
\r
60 #define CTP_NAME "byd693x-ts"
\r
62 #define TP_MODULE_NAME CTP_NAME
\r
63 #ifdef CONFIG_RK_CONFIG
\r
66 #if defined(RK2928_PHONEPAD_DEFAULT_CONFIG)
\r
71 DEF_IRQ = 0x002003c7,
\r
72 DEF_RST = 0X000003d5,
\r
78 static int en = DEF_EN;
\r
79 module_param(en, int, 0644);
\r
81 static int irq = DEF_IRQ;
\r
82 module_param(irq, int, 0644);
\r
83 static int rst =DEF_RST;
\r
84 module_param(rst, int, 0644);
\r
86 static int i2c = DEF_I2C; // i2c channel
\r
87 module_param(i2c, int, 0644);
\r
88 static int addr = DEF_ADDR; // i2c addr
\r
89 module_param(addr, int, 0644);
\r
90 static int x_max = DEF_X_MAX;
\r
91 module_param(x_max, int, 0644);
\r
92 static int y_max = DEF_Y_MAX;
\r
93 module_param(y_max, int, 0644);
\r
100 struct byd_platform_data *byd6932_pdata;
\r
103 #define FINGER_NO_MAX 10 //Define the max finger number, but the really finger number: fetch from .fex file
\r
104 #define BYD_COORD_READ_ADDR 0x5c
\r
106 static int SCREEN_MAX_X = 1024;
\r
107 static int SCREEN_MAX_Y = 600;
\r
108 static int Get_Finger_Num = 5;
\r
110 #define RESO_X_NO 0
\r
111 #define RESO_Y_NO 1
\r
113 struct ChipSetting byd693xcfg_Resolution[]={
\r
114 //{ 2,0x08, 200/256, 200%256}, // 1 FTHD_H;FTHD_L //¨º???¡ã¡ä?¨¹?D?¦Ì
\r
115 //{ 2,0x0A, 120/256, 120%256}, // 2 NTHD_H;NTHD_L //??¨¦¨´?D?¦Ì
\r
116 { 2,0x0C, 800/256, 800%256}, // 3 RESX_H;RESX_L //X¡¤?¡À??¨º
\r
117 { 2,0x0E, 480/256, 480%256}, // 4 RESY_H;RESY_L //Y¡¤?¡À??¨º
\r
120 static void deviceResume(struct i2c_client *client);
\r
121 static void deviceSuspend(struct i2c_client *client);
\r
122 void byd693xdeviceInit(struct i2c_client *client);
\r
124 //static int byd693x_ts_open(struct input_dev *dev);
\r
125 //static void byd693x_ts_close(struct input_dev *dev);
\r
126 static int byd693x_ts_suspend(struct i2c_client *client, pm_message_t mesg);
\r
127 static int byd693x_ts_resume(struct i2c_client *client);
\r
128 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
129 static void byd693x_ts_early_suspend(struct early_suspend *h);
\r
130 static void byd693x_ts_late_resume(struct early_suspend *h);
\r
131 #endif /* CONFIG_HAS_EARLYSUSPEND */
\r
133 static irqreturn_t byd693x_ts_isr(int irq, void *dev_id);
\r
134 static struct workqueue_struct *byd693x_wq;
\r
137 struct byd_ts_priv {
\r
138 struct i2c_client *client;
\r
139 struct input_dev *input;
\r
140 struct hrtimer timer;
\r
141 struct work_struct byd_work;
\r
142 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
143 struct early_suspend early_suspend;
\r
153 /***********************************************************
\r
154 Read Data from TP through IIC
\r
155 ***********************************************************/
\r
156 static int ReadRegister(struct i2c_client *client,uint8_t reg,unsigned char *buf, int ByteLen)
\r
158 // unsigned char buf[4];
\r
159 struct i2c_msg msg[2];
\r
162 // memset(buf, 0xFF, sizeof(buf));
\r
163 msg[0].addr = client->addr;
\r
167 msg[0].scl_rate=byd693x_I2C_RATE;
\r
169 msg[1].addr = client->addr;
\r
170 msg[1].flags = I2C_M_RD;
\r
171 msg[1].len = ByteLen;
\r
173 msg[1].scl_rate=byd693x_I2C_RATE;
\r
175 ret = i2c_transfer(client->adapter, msg, 2);
\r
177 #ifdef CONFIG_TS_I2C_TRANSFER_DEBUG
\r
178 if(ret<0) printk(" ReadRegister: i2c_transfer Error !\n");
\r
179 else printk(" ReadRegister: i2c_transfer OK !\n");
\r
181 if(ret<0) { return 0; }
\r
185 /***********************************************************
\r
186 Write Data to TP through IIC
\r
187 ***********************************************************/
\r
188 static void WriteRegister(struct i2c_client *client,uint8_t Reg,unsigned char Data1,unsigned char Data2,int ByteNo)
\r
190 struct i2c_msg msg;
\r
191 unsigned char buf[4];
\r
199 msg.addr = client->addr;
\r
201 msg.len = ByteNo+1;
\r
202 msg.buf = (char *)buf;
\r
203 msg.scl_rate=byd693x_I2C_RATE;
\r
204 ret = i2c_transfer(client->adapter, &msg, 1);
\r
206 #ifdef CONFIG_TS_I2C_TRANSFER_DEBUG
\r
207 if(ret<0) printk(" WriteRegister: i2c_master_send Error !\n");
\r
208 else printk(" WriteRegister: i2c_master_send OK !\n");
\r
212 void byd693xdeviceInit(struct i2c_client *client)
\r
214 deviceSuspend(client);
\r
215 deviceResume(client);
\r
219 static void deviceResume(struct i2c_client *client)
\r
223 for(i=0;i<sizeof(Resume)/sizeof(Resume[0]);i++)
\r
225 WriteRegister( client,Resume[i].Reg,
\r
226 Resume[i].Data1,Resume[i].Data2,
\r
230 //Config the resolution of CTP
\r
231 for(i=0;i<sizeof(byd693xcfg_Resolution)/sizeof(byd693xcfg_Resolution[0]);i++)
\r
233 WriteRegister( client,byd693xcfg_Resolution[i].Reg,
\r
234 byd693xcfg_Resolution[i].Data1,byd693xcfg_Resolution[i].Data2,
\r
235 byd693xcfg_Resolution[i].No);
\r
240 static void deviceSuspend(struct i2c_client *client)
\r
244 for(i=0;i<sizeof(Suspend)/sizeof(Suspend[0]);i++)
\r
246 WriteRegister( client,Suspend[i].Reg,
\r
247 Suspend[i].Data1,Suspend[i].Data2,
\r
253 static void bf693x_ts_send_keyevent(struct byd_ts_priv *byd_priv,u8 btn_status)
\r
256 switch(btn_status & 0xf0)
\r
259 byd_priv->btn_pre_TPKey = TPKey_code[0];
\r
262 byd_priv->btn_pre_TPKey = TPKey_code[1];
\r
265 byd_priv->btn_pre_TPKey = TPKey_code[2];
\r
268 byd_priv->btn_pre_TPKey = TPKey_code[3];
\r
271 input_report_key(byd_priv->input, byd_priv->btn_pre_TPKey, REPORT_TPKEY_UP);
\r
272 input_sync(byd_priv->input);
\r
277 input_report_key(byd_priv->input, byd_priv->btn_pre_TPKey, REPORT_TPKEY_DOWN);
\r
278 input_sync(byd_priv->input);
\r
281 static void byd693x_ts_work(struct work_struct *work)
\r
284 unsigned short xpos=0, ypos=0;
\r
285 unsigned char Coord_Buf[4*FINGER_NO_MAX +1]; //Define the max finger data
\r
287 u8 Finger_ID,Finger_Status,Report_Status;
\r
289 struct byd_ts_priv *byd_priv = container_of(work,struct byd_ts_priv,byd_work);
\r
291 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
292 printk("+-----------------------------------------+\n");
\r
293 printk("| byd693x_ts_work! |\n");
\r
294 printk("+-----------------------------------------+\n");
\r
296 if (byd_priv->suspend_opend == 1)
\r
299 ReadRegister(byd_priv->client,BYD_COORD_READ_ADDR,Coord_Buf,(4 * Get_Finger_Num +1)); //read only the used finger number data
\r
301 btn_status = Coord_Buf[0];
\r
302 #ifdef CONFIG_TS_COORDIATE_DEBUG
\r
303 printk("btn_status is: 0x%x\n",btn_status);
\r
306 if ( 0x00 == (btn_status & 0x80))
\r
311 bf693x_ts_send_keyevent(byd_priv,btn_status);
\r
313 byd_priv->FingerDetect = 0;
\r
315 if ((btn_status & 0x0f))
\r
317 for(i=0;i< (btn_status & 0x0f);i++)
\r
319 Finger_ID = (Coord_Buf[i*4 + 1]>>4)-1;
\r
320 Finger_Status = Coord_Buf[i*4 + 3] & 0xf0;
\r
321 xpos = Coord_Buf[i*4 + 1] & 0x0f;
\r
322 xpos = (xpos <<8) | Coord_Buf[i*4 + 2];
\r
324 ypos = Coord_Buf[i*4 + 3] & 0x0f;
\r
325 ypos = (ypos <<8) | Coord_Buf[i*4 + 4];
\r
327 if (byd6932_pdata ->swap_xy)
\r
329 if (byd6932_pdata ->xpol)
\r
330 xpos = byd6932_pdata ->screen_max_x -xpos;
\r
331 if (byd6932_pdata ->ypol)
\r
332 ypos = byd6932_pdata ->screen_max_y -ypos;
\r
334 if((0xa0 == Finger_Status) || (0x90 == Finger_Status)) //0xa0:The first Touch; 0x90: Hold Finger Touch
\r
336 byd_priv->FingerDetect++;
\r
338 // printk("Finger_ID = 0x%x, DOWN\n", Finger_ID);
\r
339 input_mt_slot(byd_priv->input, Finger_ID); //Slot B protocol
\r
340 input_report_abs(byd_priv->input, ABS_MT_TRACKING_ID, Finger_ID);
\r
341 input_report_abs(byd_priv->input, ABS_MT_TOUCH_MAJOR, REPORT_TOUCH_MAJOR); //Finger Size
\r
342 input_report_abs(byd_priv->input, ABS_MT_POSITION_X, xpos);
\r
343 input_report_abs(byd_priv->input, ABS_MT_POSITION_Y, ypos);
\r
344 input_report_abs(byd_priv->input, ABS_MT_WIDTH_MAJOR, REPORT_WIDTH_MAJOR); //Touch Size
\r
346 #ifdef CONFIG_TS_COORDIATE_DEBUG
\r
347 printk(" Finger Touch X = %d , Y = %d, State = 0x%x,Finger_ID=0x%x\n\n",xpos,ypos,Finger_Status,Finger_ID);
\r
351 if (Finger_Status == 0xc0)
\r
354 input_mt_slot(byd_priv->input, Finger_ID);
\r
355 input_report_abs(byd_priv->input, ABS_MT_TRACKING_ID, -1);
\r
356 #ifdef CONFIG_TS_COORDIATE_DEBUG
\r
357 printk(" Touch release X = %d , Y = %d, State = 0x%x,Finger_ID=0x%x\n\n",xpos,ypos,Finger_Status,Finger_ID);
\r
364 input_sync(byd_priv->input);
\r
368 static int byd693x_init_platform_hw(void)
\r
370 if(gpio_request(byd6932_pdata->rst_pin,NULL) != 0){
\r
371 gpio_free(byd6932_pdata->rst_pin);
\r
372 printk("byd693x_init_platform_hw gpio_request error\n");
\r
376 if(gpio_request(byd6932_pdata->int_pin, NULL) != 0){
\r
377 gpio_free(byd6932_pdata->int_pin);
\r
378 printk("byd693x_init_platform_hw gpio_request error\n");
\r
381 gpio_pull_updown(byd6932_pdata->int_pin, 1);
\r
382 gpio_direction_output(byd6932_pdata->rst_pin, 1);
\r
387 static int byd693x_ts_probe(struct i2c_client *client,const struct i2c_device_id *idp)
\r
389 struct byd_ts_priv *byd_priv;
\r
390 struct input_dev *byd_input = NULL;
\r
391 struct byd_platform_data *pdata = client->dev.platform_data;
\r
392 unsigned char tp_buf[1];
\r
394 #ifdef CONFIG_RK_CONFIG
\r
395 struct port_config rst_cfg = get_port_config(rst);
\r
396 struct port_config irq_cfg = get_port_config(irq);
\r
399 pdata = kzalloc(sizeof(struct byd_platform_data), GFP_KERNEL);
\r
401 printk("byd693x_ts_probe: kzalloc Error!\n");
\r
405 pdata->rst_pin = rst_cfg.gpio;
\r
406 pdata->int_pin = irq_cfg.gpio;
\r
407 pdata->screen_max_x = x_max;
\r
408 pdata->screen_max_y = y_max;
\r
412 byd6932_pdata = pdata;
\r
413 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
414 printk("+-----------------------------------------+\n");
\r
415 printk("| byd693x_ts_probe! |\n");
\r
416 printk("+-----------------------------------------+\n");
\r
419 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
\r
421 #ifdef CONFIG_TS_PROBE_DEBUG
\r
422 printk(" byd693x_ts_probe: need I2C_FUNC_I2C\n");
\r
428 #ifdef CONFIG_TS_PROBE_DEBUG
\r
429 printk(" byd693x_ts_probe: i2c Check OK!\n");
\r
430 printk(" byd693x_ts_probe: i2c_client name : %s\n",client->name);
\r
434 byd_priv = kzalloc(sizeof(*byd_priv), GFP_KERNEL);
\r
437 #ifdef CONFIG_TS_PROBE_DEBUG
\r
438 printk(" byd693x_ts_probe: kzalloc Error!\n");
\r
445 #ifdef CONFIG_TS_PROBE_DEBUG
\r
446 printk(" byd693x_ts_probe: kzalloc OK!\n");
\r
452 dev_set_drvdata(&client->dev, byd_priv);
\r
453 byd_input = input_allocate_device();
\r
456 #ifdef CONFIG_TS_PROBE_DEBUG
\r
457 printk(" byd693x_ts_probe: input_allocate_device Error\n");
\r
464 #ifdef CONFIG_TS_PROBE_DEBUG
\r
465 printk(" byd693x_ts_probe: input_allocate_device OK\n");
\r
469 //only check BYD BF6932
\r
470 error = ReadRegister(client, BYD_COORD_READ_ADDR, tp_buf, sizeof(tp_buf));
\r
473 printk(KERN_ALERT "BYD BF6932 Touchscreen not found \n");
\r
474 gpio_free(pdata->rst_pin);
\r
475 gpio_free(pdata->int_pin);
\r
479 // byd_input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT_MASK(EV_SYN)|BIT_MASK(EV_REP) ;
\r
480 // byd_input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_2);
\r
481 byd_input->name = client->name;
\r
482 byd_input->id.bustype = BUS_I2C;
\r
483 byd_input->id.vendor = 0x2878; // Modify for Vendor ID
\r
484 byd_input->dev.parent = &client->dev;
\r
485 // byd_input->open = byd693x_ts_open;
\r
486 // byd_input->close = byd693x_ts_close;
\r
487 input_set_drvdata(byd_input, byd_priv);
\r
488 byd_priv->client = client;
\r
489 byd_priv->input = byd_input;
\r
490 byd_priv->irq = pdata->int_pin;
\r
491 byd_priv->FingerNo=FINGER_NO_MAX;
\r
493 byd_input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
\r
494 byd_input->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); // for android
\r
496 __set_bit(EV_ABS, byd_input->evbit);
\r
497 __set_bit(INPUT_PROP_DIRECT, byd_input->propbit);
\r
498 set_bit(ABS_MT_POSITION_X, byd_input->absbit);
\r
499 set_bit(ABS_MT_POSITION_Y, byd_input->absbit);
\r
500 set_bit(ABS_MT_TOUCH_MAJOR, byd_input->absbit);
\r
501 set_bit(ABS_MT_WIDTH_MAJOR, byd_input->absbit);
\r
503 // deviceReset(client);
\r
504 // printk("BYD Touchscreen I2C Address: 0x%02X\n",client->addr);
\r
505 // printk("BYD Touchscreen Device ID : BF6932\n");
\r
507 //config the resolution of CTP
\r
508 byd693xcfg_Resolution[RESO_X_NO].Data1 = (char)(pdata->screen_max_x >>8);
\r
509 byd693xcfg_Resolution[RESO_X_NO].Data2 = (char)(pdata->screen_max_x & 0xff);
\r
511 byd693xcfg_Resolution[RESO_Y_NO].Data1 = (char)(pdata->screen_max_y >>8);
\r
512 byd693xcfg_Resolution[RESO_Y_NO].Data2 = (char)(pdata->screen_max_y & 0xff);
\r
514 byd693xdeviceInit(client);
\r
516 input_mt_init_slots(byd_input, MAX_TRACKID_ITEM);
\r
519 input_set_abs_params(byd_input, ABS_MT_TOUCH_MAJOR, 0, MAX_TOUCH_MAJOR, 0, 0);
\r
520 input_set_abs_params(byd_input, ABS_MT_WIDTH_MAJOR, 0, MAX_WIDTH_MAJOR, 0, 0);
\r
521 input_set_abs_params(byd_input, ABS_MT_POSITION_X, 0,pdata->screen_max_x + 1, 0, 0);
\r
522 input_set_abs_params(byd_input, ABS_MT_POSITION_Y, 0,pdata->screen_max_y + 1, 0, 0);
\r
524 #ifdef USE_TOUCH_KEY
\r
525 set_bit(KEY_MENU, byd_input->keybit);
\r
526 set_bit(KEY_HOME, byd_input->keybit);
\r
527 set_bit(KEY_BACK, byd_input->keybit);
\r
528 set_bit(KEY_SEARCH, byd_input->keybit);
\r
531 INIT_WORK(&byd_priv->byd_work, byd693x_ts_work);
\r
533 error = input_register_device(byd_input);
\r
537 #ifdef CONFIG_TS_PROBE_DEBUG
\r
538 printk(" byd693x_ts_probe: input_register_device input Error!\n");
\r
545 #ifdef CONFIG_TS_PROBE_DEBUG
\r
546 printk(" byd693x_ts_probe: input_register_device input OK!\n");
\r
550 error = byd693x_init_platform_hw(); //Init RK29 GPIO
\r
553 printk("%s:Init_INT set_irq_mode err. \n", __func__);
\r
554 goto exit_set_irq_mode;
\r
556 // Options for different interrupt system
\r
557 // error = request_irq(byd_priv->irq, byd693x_ts_isr, IRQF_DISABLED|IRQF_TRIGGER_FALLING, client->name,byd_priv);
\r
558 // error = request_irq(byd_priv->irq, byd693x_ts_isr, IRQF_TRIGGER_FALLING, client->name,byd_priv);
\r
559 error = request_irq(byd_priv->irq, byd693x_ts_isr, IRQF_TRIGGER_FALLING, client->name,byd_priv);
\r
562 #ifdef CONFIG_TS_PROBE_DEBUG
\r
563 printk(" byd693x_ts_probe: request_irq Error!\n");
\r
570 #ifdef CONFIG_TS_PROBE_DEBUG
\r
571 printk(" byd693x_ts_probe: request_irq OK!\n");
\r
575 printk("Install BYD BF6932 Touchscreen driver successfully\n");
\r
577 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
578 byd_priv->early_suspend.suspend = byd693x_ts_early_suspend;
\r
579 byd_priv->early_suspend.resume = byd693x_ts_late_resume;
\r
580 byd_priv->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB+1;
\r
581 register_early_suspend(&byd_priv->early_suspend);
\r
585 err2: input_unregister_device(byd_input);
\r
586 err1: input_free_device(byd_input);
\r
588 //exit_gpio_wakeup_request_failed:
\r
589 err0: dev_set_drvdata(&client->dev, NULL);
\r
594 static int byd693x_ts_open(struct input_dev *dev)
\r
596 struct byd_ts_priv *byd_priv = input_get_drvdata(dev);
\r
597 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
598 printk("+-----------------------------------------+\n");
\r
599 printk("| byd693x_ts_open! |\n");
\r
600 printk("+-----------------------------------------+\n");
\r
602 deviceResume(byd_priv->client);
\r
603 enable_irq(byd_priv->irq);
\r
604 byd_priv->suspend_opend = 0;
\r
608 static void byd693x_ts_close(struct input_dev *dev)
\r
610 struct byd_ts_priv *byd_priv = input_get_drvdata(dev);
\r
611 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
612 printk("+-----------------------------------------+\n");
\r
613 printk("| byd693x_ts_close! |\n");
\r
614 printk("+-----------------------------------------+\n");
\r
616 deviceSuspend(byd_priv->client);
\r
617 byd_priv->suspend_opend = 1;
\r
618 disable_irq(byd_priv->irq);
\r
622 static int byd693x_ts_resume(struct i2c_client *client)
\r
624 struct byd_ts_priv *byd_priv = dev_get_drvdata(&client->dev);
\r
625 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
626 printk("+-----------------------------------------+\n");
\r
627 printk("| byd693x_ts_resume! |\n");
\r
628 printk("+-----------------------------------------+\n");
\r
631 deviceResume(client);
\r
632 byd_priv->suspend_opend = 0;
\r
633 enable_irq(byd_priv->irq);
\r
637 static int byd693x_ts_suspend(struct i2c_client *client, pm_message_t mesg)
\r
639 struct byd_ts_priv *byd_priv = dev_get_drvdata(&client->dev);
\r
640 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
641 printk("+-----------------------------------------+\n");
\r
642 printk("| byd693x_ts_suspend! |\n");
\r
643 printk("+-----------------------------------------+\n");
\r
645 byd_priv->suspend_opend = 1;
\r
647 disable_irq(byd_priv->irq);
\r
648 deviceSuspend(client);
\r
652 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
653 static void byd693x_ts_late_resume(struct early_suspend *h)
\r
655 struct byd_ts_priv *byd_priv = container_of(h, struct byd_ts_priv, early_suspend);
\r
656 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
657 printk("+-----------------------------------------+\n");
\r
658 printk("| byd693x_ts_late_resume! |\n");
\r
659 printk("+-----------------------------------------+\n");
\r
661 byd693x_ts_resume(byd_priv->client);
\r
663 static void byd693x_ts_early_suspend(struct early_suspend *h)
\r
665 struct byd_ts_priv *byd_priv = container_of(h, struct byd_ts_priv, early_suspend);
\r
666 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
667 printk("+-----------------------------------------+\n");
\r
668 printk("| byd693x_ts_early_suspend! |\n");
\r
669 printk("+-----------------------------------------+\n");
\r
671 byd693x_ts_suspend(byd_priv->client, PMSG_SUSPEND);
\r
675 static int byd693x_ts_remove(struct i2c_client *client)
\r
677 struct byd_ts_priv *byd_priv = dev_get_drvdata(&client->dev);
\r
678 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
679 printk("+-----------------------------------------+\n");
\r
680 printk("| byd693x_ts_remove ! |\n");
\r
681 printk("+-----------------------------------------+\n");
\r
683 free_irq(byd_priv->irq, byd_priv);
\r
684 input_unregister_device(byd_priv->input);
\r
685 input_free_device(byd_priv->input);
\r
687 dev_set_drvdata(&client->dev, NULL);
\r
691 static irqreturn_t byd693x_ts_isr(int irq, void *dev_id)
\r
693 struct byd_ts_priv *byd_priv = dev_id;
\r
694 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
695 printk("+-----------------------------------------+\n");
\r
696 printk("| byd693x_ts_isr! |\n");
\r
697 printk("+-----------------------------------------+\n");
\r
699 disable_irq_nosync(byd_priv->irq);
\r
700 queue_work(byd693x_wq, &byd_priv->byd_work);
\r
701 enable_irq(byd_priv->irq);
\r
702 return IRQ_HANDLED;
\r
705 static const struct i2c_device_id byd693x_ts_id[] = {
\r
710 MODULE_DEVICE_TABLE(i2c, byd693x_ts_id);
\r
712 static struct i2c_driver byd693x_ts_driver = {
\r
716 .probe = byd693x_ts_probe,
\r
717 .remove = byd693x_ts_remove,
\r
718 #ifndef CONFIG_HAS_EARLYSUSPEND
\r
719 .suspend = byd693x_ts_suspend,
\r
720 .resume = byd693x_ts_resume,
\r
722 .id_table = byd693x_ts_id,
\r
725 static char banner[] __initdata = KERN_INFO "BYD Touchscreen driver, (c) 2012 BYD Systech Ltd.\n";
\r
726 static int __init byd693x_ts_init(void)
\r
730 #ifdef CONFIG_RK_CONFIG
\r
731 ret = tp_board_init();
\r
736 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
737 printk("+-----------------------------------------+\n");
\r
738 printk("| byd_ts_init! |\n");
\r
739 printk("+-----------------------------------------+\n");
\r
742 printk("==================byd693x_ts_init===========================\n");
\r
743 printk("Version =%s\n",VERSION);
\r
744 byd693x_wq = create_singlethread_workqueue("byd693x_wq");
\r
747 #ifdef CONFIG_TS_WORKQUEUE_DEBUG
\r
748 printk(" byd693x_ts_init: create_singlethread_workqueue Error!\n");
\r
754 #ifdef CONFIG_TS_WORKQUEUE_DEBUG
\r
755 printk(" byd693x_ts_init: create_singlethread_workqueue OK!\n");
\r
758 ret=i2c_add_driver(&byd693x_ts_driver);
\r
759 #ifdef CONFIG_TS_I2C_TRANSFER_DEBUG
\r
760 if(ret) printk(" byd693x_ts_init: i2c_add_driver Error! \n");
\r
761 else printk(" byd693x_ts_init: i2c_add_driver OK! \n");
\r
766 static void __exit byd693x_ts_exit(void)
\r
768 #ifdef CONFIG_TS_FUNCTION_CALLED_DEBUG
\r
769 printk("+-----------------------------------------+\n");
\r
770 printk("| byd693x_ts_exit! |\n");
\r
771 printk("+-----------------------------------------+\n");
\r
773 i2c_del_driver(&byd693x_ts_driver);
\r
774 if (byd693x_wq) destroy_workqueue(byd693x_wq);
\r
777 module_init(byd693x_ts_init);
\r
778 module_exit(byd693x_ts_exit);
\r
780 MODULE_AUTHOR("BYD Systech Ltd - Raysens Design Technology, Charles Chen.");
\r
781 MODULE_LICENSE("GPL v2");
\r
782 MODULE_DESCRIPTION("byd693x Touchscreen Driver 1.2_Charles@Raysens@20120731");
\r