2 * Driver for Pixcir I2C touchscreen controllers.
4 * Copyright (C) 2010-2011 Pixcir, Inc.
6 * pixcir_i2c_ts.c V3.0 from v3.0 support TangoC solution and remove the previous soltutions
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/module.h>
22 #include <linux/delay.h>
23 #include <linux/earlysuspend.h>
24 #include <linux/hrtimer.h>
25 #include <linux/i2c.h>
26 #include <linux/input.h>
27 #include <linux/input/mt.h>
28 #include <linux/interrupt.h>
30 #include <linux/gpio.h>
31 #include <mach/iomux.h>
32 #include <linux/platform_device.h>
34 #include <linux/slab.h>
35 #include <asm/uaccess.h>
36 #include <linux/proc_fs.h>
38 #include "pixcir_i2c_ts.h"
40 #define PIXCIR_DEBUG 0
42 #define pixcir_dbg(msg...) printk(msg);
44 #define pixcir_dbg(msg...)
47 static int ts_dbg_enable = 0;
50 ({if(ts_dbg_enable == 1) printk(msg);})
51 /*********************************Bee-0928-TOP****************************************/
53 #define SLAVE_ADDR 0x5c
59 #define I2C_MINORS 256
61 #define CALIBRATION_FLAG 1
63 static unsigned char status_reg = 0;
64 static struct workqueue_struct *pixcir_wq;
65 static struct pixcir_i2c_ts_data *this_data;
68 unsigned char brn; //broken line number
69 unsigned char brn_pre;
70 unsigned char id; //finger ID
75 static struct point_data point[MAX_SUPPORT_POINT];
80 struct list_head list;
81 struct i2c_adapter *adap;
85 static struct i2c_driver pixcir_i2c_ts_driver;
86 static struct class *i2c_dev_class;
87 static LIST_HEAD( i2c_dev_list);
88 static DEFINE_SPINLOCK( i2c_dev_list_lock);
90 static void return_i2c_dev(struct i2c_dev *i2c_dev)
92 spin_lock(&i2c_dev_list_lock);
93 list_del(&i2c_dev->list);
94 spin_unlock(&i2c_dev_list_lock);
98 static struct i2c_dev *i2c_dev_get_by_minor(unsigned index)
100 struct i2c_dev *i2c_dev;
103 spin_lock(&i2c_dev_list_lock);
104 list_for_each_entry(i2c_dev, &i2c_dev_list, list)
106 if (i2c_dev->adap->nr == index)
110 found: spin_unlock(&i2c_dev_list_lock);
114 static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap)
116 struct i2c_dev *i2c_dev;
118 if (adap->nr >= I2C_MINORS) {
119 printk(KERN_ERR "i2c-dev: Out of device minors (%d)\n",
121 return ERR_PTR(-ENODEV);
124 i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL);
126 return ERR_PTR(-ENOMEM);
128 i2c_dev->adap = adap;
130 spin_lock(&i2c_dev_list_lock);
131 list_add_tail(&i2c_dev->list, &i2c_dev_list);
132 spin_unlock(&i2c_dev_list_lock);
135 /*********************************Bee-0928-bottom**************************************/
137 struct pixcir_i2c_ts_data {
138 struct i2c_client *client;
139 struct input_dev *input,*input_key_dev;
143 int gpio_reset_active_low;
144 int pendown_iomux_mode;
145 int resetpin_iomux_mode;
146 char pendown_iomux_name[IOMUX_NAME_SIZE];
147 char resetpin_iomux_name[IOMUX_NAME_SIZE];
148 struct work_struct work;
149 //const struct pixcir_ts_platform_data *chip;
151 struct early_suspend early_suspend;
154 #ifdef CONFIG_HAS_EARLYSUSPEND
155 static void pixcir_ts_early_suspend(struct early_suspend *h);
156 static void pixcir_ts_late_resume(struct early_suspend *h);
159 int tp_pixcir_write_reg(struct i2c_client *client,const char *buf ,int count)
161 struct i2c_msg msg[] = {
163 .addr = client->addr,
170 //ret = i2c_transfer(adap, &msg, 1);
171 if (i2c_transfer(client->adapter, msg, 1) < 0)
173 printk("write the address (0x%x) of the ssd2533 fail.",buf[0]);
179 int tp_pixcir_read_reg(struct i2c_client *client,u8 addr,u8 *buf,u8 len)
181 u8 msgbuf[1] = { addr };
182 struct i2c_msg msgs[] = {
184 .addr = client->addr,
190 .addr = client->addr,
196 if (i2c_transfer(client->adapter, msgs, 2) < 0)
198 printk("read the address (0x%x) of the ssd2533 fail.",addr);
204 static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
206 struct pixcir_i2c_ts_data *tsdata = data;
210 u8 rdbuf[27], wrbuf[1] = { 0 };
214 ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf));
215 if (ret != sizeof(wrbuf)) {
216 dev_err(&tsdata->client->dev,
217 "%s: i2c_master_send failed(), ret=%d\n",
222 ret = i2c_master_recv(tsdata->client, rdbuf, sizeof(rdbuf));
223 if (ret != sizeof(rdbuf)) {
224 dev_err(&tsdata->client->dev,
225 "%s: i2c_master_recv failed(), ret=%d\n",
230 touch = rdbuf[0] & 0x07;
233 for (i = 0; i < touch; i++) {
234 point[i].brn = (*(p + 4)) >> 3;
235 point[i].id = (*(p + 4)) & 0x7;
236 point[i].posx = (*(p + 1) << 8) + (*(p));
237 point[i].posy = (*(p + 3) << 8) + (*(p + 2));
242 for(i=0; i < touch; i++) {
243 if (point[i].posy < 40 || point[i].posy > 520 || point[i].posx < 40) {
244 ignore_cnt++; //invalid point
250 if(point[i].posy < 0)
253 if(point[i].posx < 0)
256 input_mt_slot(tsdata->input, 0);
257 input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, true);
258 input_report_abs(tsdata->input, ABS_MT_TOUCH_MAJOR, 1);
259 input_report_abs(tsdata->input, ABS_MT_POSITION_X, point[i].posy);
260 input_report_abs(tsdata->input, ABS_MT_POSITION_Y, point[i].posx);
262 //input_sync(tsdata->input);
264 DBG("brn%d=%2d id%d=%1d x=%5d y=%5d \n",
265 i,point[i].brn,i,point[i].id,point[i].posy,point[i].posx);
269 if (touch == ignore_cnt)
270 return; //if all touchpoint are invalid, return
272 input_sync(tsdata->input);
276 static void pixcir_ts_work_func(struct work_struct *work)
278 struct pixcir_i2c_ts_data *tsdata = this_data;
279 //DBG("%s\n",__FUNCTION__);
281 while (!tsdata->exiting) {
283 pixcir_ts_poscheck(tsdata);
285 if (attb_read_val()){
286 DBG("%s: >>>>>touch release\n\n",__FUNCTION__);
287 enable_irq(tsdata->client->irq);
288 //input_report_key(tsdata->input, BTN_TOUCH, 0);
289 //input_report_abs(tsdata->input, ABS_MT_TOUCH_MAJOR, 0);
290 input_mt_slot(tsdata->input, 0);
291 input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, false);
292 //input_report_key(tsdata->input, ABS_MT_WIDTH_MAJOR,0);
299 input_sync(tsdata->input);
303 static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
305 struct pixcir_i2c_ts_data *ts = dev_id;
306 DBG("%s: >>>>>>>>>\n",__FUNCTION__);
309 disable_irq_nosync(ts->client->irq);
311 queue_work(pixcir_wq, &ts->work);
317 #ifdef CONFIG_PM_SLEEP
318 static int pixcir_i2c_ts_suspend(struct device *dev)
320 struct i2c_client *client = to_i2c_client(dev);
321 pixcir_dbg("%s\n",__FUNCTION__);
323 if (device_may_wakeup(&client->dev))
324 enable_irq_wake(client->irq);
329 static int pixcir_i2c_ts_resume(struct device *dev)
331 struct i2c_client *client = to_i2c_client(dev);
332 pixcir_dbg("%s\n",__FUNCTION__);
334 if (device_may_wakeup(&client->dev))
335 disable_irq_wake(client->irq);
340 static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
341 pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume);
343 static int __devinit setup_resetPin(struct i2c_client *client, struct pixcir_i2c_ts_data *ts)
345 struct pixcir_platform_data *pdata = client->dev.platform_data;
348 pixcir_dbg("%s\n",__FUNCTION__);
351 ts->gpio_reset = pdata->gpio_reset;
352 ts->gpio_reset_active_low = pdata->gpio_reset_active_low;
353 ts->resetpin_iomux_mode = pdata->resetpin_iomux_mode;
356 if(pdata->resetpin_iomux_name != NULL)
357 strcpy(ts->resetpin_iomux_name,pdata->resetpin_iomux_name);
359 //pixcir_dbg("%s=%d,%s,%d,%d\n",__FUNCTION__,ts->gpio_reset,ts->resetpin_iomux_name,ts->resetpin_iomux_mode,ts->gpio_reset_active_low);
360 if (!gpio_is_valid(ts->gpio_reset)) {
361 dev_err(&client->dev, "no gpio_reset?\n");
365 rk29_mux_api_set(ts->resetpin_iomux_name,ts->resetpin_iomux_mode);
368 err = gpio_request(ts->gpio_reset, "pixcir_resetPin");
370 dev_err(&client->dev, "failed to request resetPin GPIO%d\n",
375 err = gpio_direction_output(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_LOW:GPIO_HIGH);
377 dev_err(&client->dev, "failed to pulldown resetPin GPIO%d,err%d\n",
379 gpio_free(ts->gpio_reset);
383 gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_HIGH:GPIO_LOW);
389 static int __devinit setup_pendown(struct i2c_client *client, struct pixcir_i2c_ts_data *ts)
392 struct pixcir_i2c_ts_data *pdata = client->dev.platform_data;
394 pixcir_dbg("%s\n",__FUNCTION__);
396 dev_dbg(&client->dev, "no IRQ?\n");
400 if (!gpio_is_valid(pdata->gpio_pendown)) {
401 dev_err(&client->dev, "no gpio_pendown?\n");
405 ts->gpio_pendown = pdata->gpio_pendown;
406 strcpy(ts->pendown_iomux_name,pdata->pendown_iomux_name);
407 ts->pendown_iomux_mode = pdata->pendown_iomux_mode;
409 pixcir_dbg("%s=%d,%s,%d\n",__FUNCTION__,ts->gpio_pendown,ts->pendown_iomux_name,ts->pendown_iomux_mode);
411 if (!gpio_is_valid(ts->gpio_pendown)) {
412 dev_err(&client->dev, "no gpio_pendown?\n");
416 rk29_mux_api_set(ts->pendown_iomux_name,ts->pendown_iomux_mode);
417 err = gpio_request(ts->gpio_pendown, "gt801_pendown");
419 dev_err(&client->dev, "failed to request pendown GPIO%d\n",
424 err = gpio_pull_updown(ts->gpio_pendown, GPIOPullUp);
426 dev_err(&client->dev, "failed to pullup pendown GPIO%d\n",
428 gpio_free(ts->gpio_pendown);
435 static ssize_t pixcir_proc_write(struct file *file, const char __user *buffer,
436 size_t count, loff_t *data)
441 rc = get_user(c, buffer);
453 static const struct file_operations pixcir_proc_fops = {
454 .owner = THIS_MODULE,
455 .write = pixcir_proc_write,
457 static int __devinit pixcir_i2c_ts_probe(struct i2c_client *client,
458 const struct i2c_device_id *id)
460 //const struct pixcir_ts_platform_data *pdata = client->dev.platform_data;
461 struct pixcir_i2c_ts_data *tsdata;
462 struct pixcir_platform_data *pdata;
464 struct i2c_dev *i2c_dev;
466 struct proc_dir_entry *pixcir_proc_entry;
469 // dev_err(&client->dev, "platform data not defined\n");
472 pixcir_dbg("%s\n",__FUNCTION__);
474 tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL);
475 tsdata->input = input_allocate_device();
476 if (!tsdata || !(tsdata->input)) {
477 dev_err(&client->dev, "Failed to allocate driver data!\n");
482 pixcir_wq = create_singlethread_workqueue("pixcir_tp_wq");
484 printk(KERN_ERR"%s: create workqueue failed\n", __FUNCTION__);
488 INIT_WORK(&tsdata->work, pixcir_ts_work_func);
491 tsdata->exiting = false;
492 //tsdata->input = input;
493 //tsdata->chip = pdata;
495 tsdata->client = client;
496 i2c_set_clientdata(client, tsdata);
497 pdata = client->dev.platform_data;
499 //error = setup_resetPin(client,tsdata);
502 printk("%s:setup_resetPin fail\n",__FUNCTION__);
505 tsdata->input->phys = "/dev/input/event2";
506 tsdata->input->name = "pixcir_ts-touchscreen";//client->name;
507 tsdata->input->id.bustype = BUS_I2C;
508 tsdata->input->dev.parent = &client->dev;
512 /*set_bit(EV_SYN, tsdata->input->evbit);
513 set_bit(EV_KEY, tsdata->input->evbit);
514 set_bit(EV_ABS, tsdata->input->evbit);
515 set_bit(BTN_TOUCH, tsdata->input->keybit);
516 set_bit(BTN_2, tsdata->input->keybit);//*/
518 //tsdata->input->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_ABS) ;
519 //tsdata->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
520 /*tsdata->input->absbit[0] = BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y) |
521 BIT_MASK(ABS_MT_TOUCH_MAJOR) | BIT_MASK(ABS_MT_WIDTH_MAJOR); // for android*/
522 //tsdata->input->keybit[BIT_WORD(BTN_START)] = BIT_MASK(BTN_START);
524 //input_set_abs_params(input, ABS_X, 0, X_MAX, 0, 0);
525 //input_set_abs_params(input, ABS_Y, 0, Y_MAX, 0, 0);
527 __set_bit(INPUT_PROP_DIRECT, tsdata->input->propbit);
528 __set_bit(EV_ABS, tsdata->input->evbit);
530 input_mt_init_slots(tsdata->input, MAX_SUPPORT_POINT);
531 input_set_abs_params(tsdata->input, ABS_MT_POSITION_X, pdata->x_min, pdata->x_max, 0, 0);
532 input_set_abs_params(tsdata->input, ABS_MT_POSITION_Y, pdata->y_min, pdata->y_max, 0, 0);
533 //input_set_abs_params(tsdata->input, ABS_MT_WIDTH_MAJOR, 0, 16, 0, 0);
534 //input_set_abs_params(tsdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
535 input_set_abs_params(tsdata->input, ABS_MT_TOUCH_MAJOR, 0, 1, 0, 0);
536 //input_set_abs_params(tsdata->input, ABS_MT_TRACKING_ID, 0, 5, 0, 0);
537 input_set_drvdata(tsdata->input, tsdata);
538 //init int and reset ports
539 error = gpio_request(client->irq, "TS_INT"); //Request IO
541 dev_err(&client->dev, "Failed to request GPIO:%d, ERRNO:%d\n",(int)client->irq, error);
544 rk29_mux_api_set(pdata->pendown_iomux_name, pdata->pendown_iomux_mode);
546 gpio_direction_input(client->irq);
547 gpio_set_value(client->irq,GPIO_HIGH);
548 gpio_pull_updown(client->irq, 0);
550 error = gpio_request(pdata->gpio_reset, "pixcir_resetPin");
552 dev_err(&client->dev, "failed to request resetPin GPIO%d\n", pdata->gpio_reset);
555 rk29_mux_api_set(pdata->resetpin_iomux_name, pdata->resetpin_iomux_mode);
557 gpio_pull_updown(pdata->gpio_reset, 1);
558 gpio_direction_output(pdata->gpio_reset, 0);
559 msleep(20); //delay at least 1ms
560 gpio_direction_input(pdata->gpio_reset);
561 gpio_pull_updown(pdata->gpio_reset, 0);
564 gpio_pull_updown(pdata->gpio_reset, 1);
566 gpio_direction_output(pdata->gpio_reset, 0);
567 gpio_set_value(pdata->gpio_reset,GPIO_HIGH);//GPIO_LOW
569 gpio_set_value(pdata->gpio_reset,GPIO_LOW);//GPIO_HIGH
571 // gpio_direction_input(pdata->gpio_reset);
572 printk("pdata->gpio_reset = %d\n",gpio_get_value(pdata->gpio_reset));
573 //printk("ts->gpio_irq = %d\n",gpio_get_value(pdata->gpio_pendown));
574 printk("pdata->gpio_pendown = %d\n",gpio_get_value(client->irq));
577 //**********************************************
581 tp_pixcir_write_reg(client,buffer,2);
583 //********************************************************//
585 client->irq = gpio_to_irq(client->irq);
586 error = request_irq(client->irq, pixcir_ts_isr, IRQF_TRIGGER_FALLING, client->name, (void *)tsdata);
588 dev_err(&client->dev, "request_irq failed\n");
590 error = request_threaded_irq(client->irq, NULL, pixcir_ts_isr,
591 IRQF_TRIGGER_FALLING,
592 client->name, tsdata);*/
595 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
600 error = input_register_device(tsdata->input);
604 i2c_set_clientdata(client, tsdata);
605 device_init_wakeup(&client->dev, 1);
607 /*********************************Bee-0928-TOP****************************************/
608 i2c_dev = get_free_i2c_dev(client->adapter);
609 if (IS_ERR(i2c_dev)) {
610 error = PTR_ERR(i2c_dev);
614 dev = device_create(i2c_dev_class, &client->adapter->dev, MKDEV(I2C_MAJOR,
615 client->adapter->nr), NULL, "pixcir_i2c_ts%d", 0);
617 error = PTR_ERR(dev);
620 /*********************************Bee-0928-BOTTOM****************************************/
621 #ifdef CONFIG_HAS_EARLYSUSPEND
622 tsdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
623 tsdata->early_suspend.suspend = pixcir_ts_early_suspend;
624 tsdata->early_suspend.resume = pixcir_ts_late_resume;
625 register_early_suspend(&tsdata->early_suspend);
627 pixcir_proc_entry = proc_create("driver/pixcir", 0777, NULL, &pixcir_proc_fops);
629 dev_err(&tsdata->client->dev, "insmod successfully!\n");
634 free_irq(client->irq, tsdata);
636 input_free_device(tsdata->input);
641 static int __devexit pixcir_i2c_ts_remove(struct i2c_client *client)
644 struct i2c_dev *i2c_dev;
645 struct pixcir_i2c_ts_data *tsdata = i2c_get_clientdata(client);
647 unregister_early_suspend(&tsdata->early_suspend);
648 device_init_wakeup(&client->dev, 0);
650 tsdata->exiting = true;
652 free_irq(client->irq, tsdata);
654 /*********************************Bee-0928-TOP****************************************/
655 i2c_dev = get_free_i2c_dev(client->adapter);
656 if (IS_ERR(i2c_dev)) {
657 error = PTR_ERR(i2c_dev);
661 return_i2c_dev(i2c_dev);
662 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, client->adapter->nr));
663 /*********************************Bee-0928-BOTTOM****************************************/
665 input_unregister_device(tsdata->input);
671 /*************************************Bee-0928****************************************/
673 /*************************************Bee-0928****************************************/
674 static int pixcir_open(struct inode *inode, struct file *file)
677 struct i2c_client *client;
678 struct i2c_adapter *adapter;
679 struct i2c_dev *i2c_dev;
682 printk("enter pixcir_open function\n");
684 subminor = iminor(inode);
687 i2c_dev = i2c_dev_get_by_minor(subminor);
689 printk("error i2c_dev\n");
693 adapter = i2c_get_adapter(i2c_dev->adap->nr);
698 client = kzalloc(sizeof(*client), GFP_KERNEL);
700 i2c_put_adapter(adapter);
704 snprintf(client->name, I2C_NAME_SIZE, "pixcir_i2c_ts%d", adapter->nr);
705 client->driver = &pixcir_i2c_ts_driver;
706 client->adapter = adapter;
708 file->private_data = client;
713 /*************************************Bee-0928****************************************/
715 /*************************************Bee-0928****************************************/
716 static long pixcir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
718 //printk("ioctl function\n");
719 struct i2c_client *client = (struct i2c_client *) file->private_data;
721 printk("cmd = %d,arg = %d\n", cmd, arg);
726 case CALIBRATION_FLAG: //CALIBRATION_FLAG = 1
728 printk("CALIBRATION\n");
730 client->addr = SLAVE_ADDR;
732 status_reg = CALIBRATION_FLAG;
736 break;//return -ENOTTY;
742 /***********************************Bee-0928****************************************/
744 /***********************************Bee-0928****************************************/
745 static ssize_t pixcir_write(struct file *file,const char __user *buf,size_t count, loff_t *ppos)
747 struct i2c_client *client;
751 pixcir_dbg("%s\n",__FUNCTION__);
753 client = file->private_data;
755 //printk("pixcir_write function\n");
758 case CALIBRATION_FLAG: //CALIBRATION_FLAG=1
759 tmp = kmalloc(count,GFP_KERNEL);
763 if (copy_from_user(tmp,buf,count)) {
764 printk("CALIBRATION_FLAG copy_from_user error\n");
769 ret = i2c_master_send(client,tmp,count);
771 dev_err(&client->dev,
772 "%s: i2c_master_recv failed(), ret=%d\n",
776 while(!attb_read_val());//waiting to finish the calibration.(pixcir application_note_710_v3 p43)
789 /***********************************Bee-0928****************************************/
791 /***********************************Bee-0928****************************************/
792 static int pixcir_release(struct inode *inode, struct file *file)
794 struct i2c_client *client = file->private_data;
796 printk("enter pixcir_release funtion\n");
798 i2c_put_adapter(client->adapter);
800 file->private_data = NULL;
805 /*********************************Bee-0928-TOP****************************************/
806 static const struct file_operations pixcir_i2c_ts_fops =
807 { .owner = THIS_MODULE,
808 .write = pixcir_write,
810 .unlocked_ioctl = pixcir_ioctl,
811 .release = pixcir_release,
813 /*********************************Bee-0928-BOTTOM****************************************/
815 static int pixcir_ts_suspend(struct i2c_client *client, pm_message_t mesg)
817 struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
818 DBG("%s\n",__FUNCTION__);
821 disable_irq(client->irq);
822 //gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_LOW:GPIO_HIGH);
826 static int pixcir_ts_resume(struct i2c_client *client)
828 struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
829 DBG("%s\n",__FUNCTION__);
832 enable_irq(client->irq);
833 //gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_HIGH:GPIO_LOW);
837 #ifdef CONFIG_HAS_EARLYSUSPEND
838 static void pixcir_ts_early_suspend(struct early_suspend *h)
840 struct pixcir_i2c_ts_data *ts;
841 DBG("%s\n",__FUNCTION__);
842 ts = container_of(h, struct pixcir_i2c_ts_data, early_suspend);
843 pixcir_ts_suspend(ts->client, PMSG_SUSPEND);
846 static void pixcir_ts_late_resume(struct early_suspend *h)
848 struct pixcir_i2c_ts_data *ts;
849 DBG("%s\n",__FUNCTION__);
850 ts = container_of(h, struct pixcir_i2c_ts_data, early_suspend);
851 pixcir_ts_resume(ts->client);
855 static const struct i2c_device_id pixcir_i2c_ts_id[] = {
859 MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id);
861 static struct i2c_driver pixcir_i2c_ts_driver = {
863 .owner = THIS_MODULE,
865 //.pm = &pixcir_dev_pm_ops,
867 #ifndef CONFIG_HAS_EARLYSUSPEND
868 .suspend = pixcir_ts_suspend,
869 .resume = pixcir_ts_resume,
871 .probe = pixcir_i2c_ts_probe,
872 .remove = __devexit_p(pixcir_i2c_ts_remove),
873 .id_table = pixcir_i2c_ts_id,
876 static int __init pixcir_i2c_ts_init(void)
880 pixcir_dbg("%s\n",__FUNCTION__);
882 pixcir_wq = create_singlethread_workqueue("pixcir_wq");
886 /*********************************Bee-0928-TOP****************************************/
887 ret = register_chrdev(I2C_MAJOR,"pixcir_i2c_ts",&pixcir_i2c_ts_fops);
889 printk(KERN_ERR "%s:register chrdev failed\n",__FILE__);
893 i2c_dev_class = class_create(THIS_MODULE, "pixcir_i2c_dev");
894 if (IS_ERR(i2c_dev_class)) {
895 ret = PTR_ERR(i2c_dev_class);
896 class_destroy(i2c_dev_class);
898 /********************************Bee-0928-BOTTOM******************************************/
902 return i2c_add_driver(&pixcir_i2c_ts_driver);
904 module_init(pixcir_i2c_ts_init);
906 static void __exit pixcir_i2c_ts_exit(void)
908 i2c_del_driver(&pixcir_i2c_ts_driver);
910 destroy_workqueue(pixcir_wq);
911 /********************************Bee-0928-TOP******************************************/
912 class_destroy(i2c_dev_class);
913 unregister_chrdev(I2C_MAJOR,"pixcir_i2c_ts");
914 /********************************Bee-0928-BOTTOM******************************************/
916 module_exit(pixcir_i2c_ts_exit);
918 MODULE_AUTHOR("Jianchun Bian <jcbian@pixcir.com.cn>");
919 MODULE_DESCRIPTION("Pixcir I2C Touchscreen Driver");
920 MODULE_LICENSE("GPL");