3 * Touch Screen I2C Driver for EETI Controller
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 // Release Date: 2010/11/08
19 #include <linux/module.h>
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/interrupt.h>
23 #include <linux/wait.h>
24 #include <linux/delay.h>
25 #include <linux/platform_device.h>
26 #include <linux/freezer.h>
27 #include <linux/proc_fs.h>
28 #include <linux/clk.h>
29 #include <linux/i2c.h>
30 #include <linux/gpio.h>
31 #include <linux/device.h>
32 #include <linux/cdev.h>
34 #include <asm/system.h>
35 #include <asm/uaccess.h>
36 #include <linux/poll.h>
37 #include <linux/kfifo.h>
38 #include <linux/version.h>
39 #include <linux/input.h>
40 #include <linux/irq.h>
41 #include <linux/async.h>
42 #include <mach/board.h>
45 #ifdef CONFIG_EETI_EGALAX_DEBUG
46 #define TS_DEBUG(fmt,args...) printk( KERN_DEBUG "[egalax_i2c]: " fmt, ## args)
47 #define DBG() printk("[%s]:%d => \n",__FUNCTION__,__LINE__)
49 #define TS_DEBUG(fmt,args...)
53 //#define _NON_INPUT_DEV // define this to disable register input device
55 static int global_major = 0; // dynamic major by default
56 static int global_minor = 0;
57 #define EETI_I2C_RATE (200*1000)
58 #define MAX_I2C_LEN 10
59 #define FIFO_SIZE PAGE_SIZE
60 #define MAX_SUPPORT_POINT 5
61 #define REPORTID_MOUSE 0x01
62 #define REPORTID_VENDOR 0x03
63 #define REPORTID_MTOUCH 0x04
66 #define EGALAX_IOC_MAGIC 0x72
67 #define EGALAX_IOCWAKEUP _IO(EGALAX_IOC_MAGIC, 1)
68 #define EGALAX_IOC_MAXNR 1
77 struct workqueue_struct *ktouch_wq;
78 struct work_struct work;
79 struct mutex mutex_wq;
80 struct i2c_client *client;
86 struct egalax_char_dev
90 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
91 struct kfifo* pDataKFiFo;
93 struct kfifo DataKFiFo;
95 unsigned char *pFiFoBuf;
98 wait_queue_head_t fifo_inq;
101 static struct _egalax_i2c *p_egalax_i2c_dev = NULL; // allocated in egalax_i2c_probe
102 static struct egalax_char_dev *p_char_dev = NULL; // allocated in init_module
103 static atomic_t egalax_char_available = ATOMIC_INIT(1);
104 static struct class *egalax_class;
105 #ifndef _NON_INPUT_DEV
106 static struct input_dev *input_dev = NULL;
107 static struct point_data PointBuf[MAX_SUPPORT_POINT];
108 #endif //#ifndef _NON_INPUT_DEV
110 static int egalax_cdev_open(struct inode *inode, struct file *filp)
112 struct egalax_char_dev *cdev;
116 cdev = container_of(inode->i_cdev, struct egalax_char_dev, cdev);
119 TS_DEBUG(" No such char device node \n");
123 if( !atomic_dec_and_test(&egalax_char_available) )
125 atomic_inc(&egalax_char_available);
126 return -EBUSY; /* already open */
130 filp->private_data = cdev;// Used by the read and write metheds
132 TS_DEBUG(" egalax_cdev_open done \n");
133 try_module_get(THIS_MODULE);
137 static int egalax_cdev_release(struct inode *inode, struct file *filp)
139 struct egalax_char_dev *cdev; // device information
143 cdev = container_of(inode->i_cdev, struct egalax_char_dev, cdev);
146 TS_DEBUG(" No such char device node \n");
150 atomic_inc(&egalax_char_available); /* release the device */
152 filp->private_data = NULL;
154 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
155 kfifo_reset( cdev->pDataKFiFo );
157 kfifo_reset( &cdev->DataKFiFo );
160 TS_DEBUG(" egalax_cdev_release done \n");
161 module_put(THIS_MODULE);
165 #define MAX_READ_BUF_LEN 50
166 static char fifo_read_buf[MAX_READ_BUF_LEN];
167 static ssize_t egalax_cdev_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
169 int read_cnt, ret, fifoLen;
170 struct egalax_char_dev *cdev = file->private_data;
174 if( down_interruptible(&cdev->sem) )
177 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
178 fifoLen = kfifo_len(cdev->pDataKFiFo);
180 fifoLen = kfifo_len(&cdev->DataKFiFo);
183 while( fifoLen<1 ) /* nothing to read */
185 up(&cdev->sem); /* release the lock */
186 if( file->f_flags & O_NONBLOCK )
189 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
190 if( wait_event_interruptible(cdev->fifo_inq, kfifo_len( cdev->pDataKFiFo )>0) )
192 if( wait_event_interruptible(cdev->fifo_inq, kfifo_len( &cdev->DataKFiFo )>0) )
195 return -ERESTARTSYS; /* signal: tell the fs layer to handle it */
198 if( down_interruptible(&cdev->sem) )
202 if(count > MAX_READ_BUF_LEN)
203 count = MAX_READ_BUF_LEN;
205 TS_DEBUG("\"%s\" reading: real fifo data\n", current->comm);
206 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
207 read_cnt = kfifo_get(cdev->pDataKFiFo, fifo_read_buf, count);
209 read_cnt = kfifo_out_locked(&cdev->DataKFiFo, fifo_read_buf, count, &cdev->FiFoLock);
212 ret = copy_to_user(buf, fifo_read_buf, read_cnt)?-EFAULT:read_cnt;
219 static ssize_t egalax_cdev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
222 struct egalax_char_dev *cdev = file->private_data;
227 if( down_interruptible(&cdev->sem) )
230 if (count > MAX_I2C_LEN)
233 tmp = kmalloc(count,GFP_KERNEL);
240 if(copy_from_user(tmp, buf, count))
247 ret = i2c_master_normal_send(p_egalax_i2c_dev->client, tmp, count,EETI_I2C_RATE);
248 TS_DEBUG("I2C writing %zu bytes.\n", count);
257 static int wakeup_controller(int gpio)
263 if( (ret=gpio_request(gpio, "Touch Wakeup GPIO"))!=0 )
265 printk(KERN_ERR "[egalax_i2c]: Failed to request GPIO for Touch Wakeup GPIO. Err:%d\n", ret);
270 gpio_direction_output(gpio, 0);
271 for(i=0; i<100; i++);
272 gpio_direction_input(gpio);
273 printk(KERN_ERR "[egalax_i2c]: INT wakeup touch controller done\n");
279 static int egalax_cdev_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long args)
281 //struct egalax_char_dev *cdev = file->private_data;
284 if(_IOC_TYPE(cmd) != EGALAX_IOC_MAGIC)
286 if(_IOC_NR(cmd) > EGALAX_IOC_MAXNR)
289 if(_IOC_DIR(cmd) & _IOC_READ)
290 ret = !access_ok(VERIFY_WRITE, (void __user*)args, _IOC_SIZE(cmd));
291 else if(_IOC_DIR(cmd) & _IOC_WRITE)
292 ret = !access_ok(VERIFY_READ, (void __user*)args, _IOC_SIZE(cmd));
297 //printk(KERN_ERR "Handle device ioctl command\n");
300 case EGALAX_IOCWAKEUP:
301 ret = wakeup_controller(irq_to_gpio(p_egalax_i2c_dev->irq));
311 static unsigned int egalax_cdev_poll(struct file *filp, struct poll_table_struct *wait)
313 struct egalax_char_dev *cdev = filp->private_data;
314 unsigned int mask = 0;
318 poll_wait(filp, &cdev->fifo_inq, wait);
320 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
321 fifoLen = kfifo_len(cdev->pDataKFiFo);
323 fifoLen = kfifo_len(&cdev->DataKFiFo);
327 mask |= POLLIN | POLLRDNORM; /* readable */
328 if( (FIFO_SIZE - fifoLen) > MAX_I2C_LEN )
329 mask |= POLLOUT | POLLWRNORM; /* writable */
335 #ifndef _NON_INPUT_DEV
336 static int LastUpdateID = 0;
337 static void ProcessReport(unsigned char *buf, int buflen)
340 short X=0, Y=0, ContactID=0, Status=0;
341 if(buflen!=MAX_I2C_LEN || buf[0]!=0x04) // check buffer len & header
344 Status = buf[1]&0x01;
345 ContactID = (buf[1]&0x7C)>>2;
346 X = ((buf[3]<<8) + buf[2])>>4;
347 Y = ((buf[5]<<8) + buf[4])>>4;
349 PointBuf[ContactID].Status = Status;
350 PointBuf[ContactID].X = X;
351 PointBuf[ContactID].Y = Y;
353 TS_DEBUG("Get Point[%d] Update: Status=%d X=%d Y=%d\n", ContactID, Status, X, Y);
356 if( !Status || (ContactID <= LastUpdateID) )
358 for(i=0; i<MAX_SUPPORT_POINT;i++)
360 if(PointBuf[i].Status >= 0)
362 input_report_abs(input_dev, ABS_MT_TRACKING_ID, i);
363 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, PointBuf[i].Status);
364 input_report_abs(input_dev, ABS_MT_WIDTH_MAJOR, 0);
365 input_report_abs(input_dev, ABS_MT_POSITION_X, PointBuf[i].X);
366 input_report_abs(input_dev, ABS_MT_POSITION_Y, PointBuf[i].Y);
368 input_mt_sync(input_dev);
370 if(PointBuf[i].Status == 0)
371 PointBuf[i].Status--;
374 input_sync(input_dev);
375 TS_DEBUG("Input sync point data done!\n");
378 LastUpdateID = ContactID;
381 static struct input_dev * allocate_Input_Dev(void)
384 struct input_dev *pInputDev=NULL;
386 pInputDev = input_allocate_device();
387 if(pInputDev == NULL)
389 TS_DEBUG("Failed to allocate input device\n");
390 return NULL;//-ENOMEM;
393 pInputDev->name = "eGalax Touch Screen";
394 pInputDev->phys = "I2C";
395 pInputDev->id.bustype = BUS_I2C;
396 pInputDev->id.vendor = 0x0EEF;
397 pInputDev->id.product = 0x0020;
399 set_bit(EV_ABS, pInputDev->evbit);
401 input_set_abs_params(pInputDev, ABS_MT_POSITION_X, 0, CONFIG_EETI_EGALAX_MAX_X, 0, 0);
402 input_set_abs_params(pInputDev, ABS_MT_POSITION_Y, 0, CONFIG_EETI_EGALAX_MAX_Y, 0, 0);
403 input_set_abs_params(pInputDev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
404 input_set_abs_params(pInputDev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
405 input_set_abs_params(pInputDev, ABS_MT_TRACKING_ID, 0, 10, 0, 0);
407 ret = input_register_device(pInputDev);
410 TS_DEBUG("Unable to register input device.\n");
411 input_free_device(pInputDev);
417 #endif //#ifndef _NON_INPUT_DEV
419 static int egalax_i2c_measure(struct i2c_client *client, char skip_packet)
421 u8 x_buf[MAX_I2C_LEN];
425 count = i2c_master_normal_recv(client, x_buf, MAX_I2C_LEN,EETI_I2C_RATE);
426 }while(count==EAGAIN && --loop);
428 if( count<0 || (x_buf[0]!=REPORTID_VENDOR && x_buf[0]!=REPORTID_MTOUCH) )
430 TS_DEBUG("I2C read error data with Len=%d hedaer=%d\n", count, x_buf[0]);
434 TS_DEBUG("egalax_i2c read data with Len=%d\n", count);
435 if(x_buf[0]==REPORTID_VENDOR)
436 TS_DEBUG("egalax_i2c get command packet\n");
438 if( skip_packet > 0 )
441 #ifndef _NON_INPUT_DEV
442 if( count>0 && x_buf[0]==REPORTID_MTOUCH )
444 ProcessReport(x_buf, count);
448 #endif //#ifndef _NON_INPUT_DEV
450 if( count>0 && p_char_dev->OpenCnts>0 ) // If someone reading now! put the data into the buffer!
452 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
453 kfifo_put(p_char_dev->pDataKFiFo, x_buf, count);
455 kfifo_in_locked(&p_char_dev->DataKFiFo, x_buf, count, &p_char_dev->FiFoLock);
457 wake_up_interruptible( &p_char_dev->fifo_inq );
463 static void egalax_i2c_wq(struct work_struct *work)
465 struct _egalax_i2c *egalax_i2c = container_of(work, struct _egalax_i2c, work);
466 struct i2c_client *client = egalax_i2c->client;
467 int gpio = client->irq;
468 TS_DEBUG("egalax_i2c_wq run\n");
469 mutex_lock(&egalax_i2c->mutex_wq);
471 /*continue recv data*/
472 while( !gpio_get_value(gpio) && egalax_i2c->work_state>0 )
474 egalax_i2c_measure(client, egalax_i2c->skip_packet);
478 if( egalax_i2c->skip_packet > 0 )
479 egalax_i2c->skip_packet = 0;
481 mutex_unlock(&egalax_i2c->mutex_wq);
483 if( egalax_i2c->work_state > 0 )
484 enable_irq(p_egalax_i2c_dev->irq);
486 TS_DEBUG("egalax_i2c_wq leave\n");
489 static irqreturn_t egalax_i2c_interrupt(int irq, void *dev_id)
491 struct _egalax_i2c *egalax_i2c = (struct _egalax_i2c *)dev_id;
492 TS_DEBUG("egalax_i2c_interrupt with irq:%d\n", irq);
493 disable_irq_nosync(irq);
494 queue_work(egalax_i2c->ktouch_wq, &egalax_i2c->work);
500 void egalax_i2c_set_standby(struct i2c_client *client, int enable)
502 struct eeti_egalax_platform_data *pdata = pdata = client->dev.platform_data;
503 unsigned lcd_standby = pdata->standby_pin;
504 int lcd_standby_pol = pdata->standby_value;
505 printk("%s : %s, enable = %d", __FILE__, __FUNCTION__,enable);
507 if(lcd_standby != INVALID_GPIO)
509 gpio_direction_output(lcd_standby, 0);
510 gpio_set_value(lcd_standby, enable ? lcd_standby_pol : !lcd_standby_pol);
515 static int egalax_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
517 struct _egalax_i2c *egalax_i2c = i2c_get_clientdata(client);
518 u8 cmdbuf[MAX_I2C_LEN]={0x03, 0x05, 0x0A, 0x03, 0x36, 0x3F, 0x02, 0, 0, 0};
520 i2c_master_normal_send(client, cmdbuf, MAX_I2C_LEN, EETI_I2C_RATE);
522 egalax_i2c->work_state = 0;
523 disable_irq(p_egalax_i2c_dev->irq);
524 cancel_work_sync(&egalax_i2c->work);
526 printk(KERN_DEBUG "[egalax_i2c]: device suspend done\n");
528 if(device_may_wakeup(&client->dev))
530 enable_irq_wake(p_egalax_i2c_dev->irq);
534 printk(KERN_DEBUG "[egalax_i2c]: device_may_wakeup false\n");
536 egalax_i2c_set_standby(client, 1);
540 static int egalax_i2c_resume(struct i2c_client *client)
542 struct _egalax_i2c *egalax_i2c = i2c_get_clientdata(client);
543 egalax_i2c_set_standby(client, 0);
544 if(device_may_wakeup(&client->dev))
546 disable_irq_wake(p_egalax_i2c_dev->irq);
550 printk(KERN_DEBUG "[egalax_i2c]: device_may_wakeup false\n");
553 wakeup_controller(irq_to_gpio(p_egalax_i2c_dev->irq));
554 egalax_i2c->work_state = 1;
555 enable_irq(p_egalax_i2c_dev->irq);
557 printk(KERN_DEBUG "[egalax_i2c]: device wakeup done\n");
562 #define egalax_i2c_suspend NULL
563 #define egalax_i2c_resume NULL
566 static int __devinit egalax_i2c_probe(struct i2c_client *client)
569 int gpio = client->irq;
570 struct eeti_egalax_platform_data *pdata = pdata = client->dev.platform_data;
572 printk(KERN_DEBUG "[egalax_i2c]: start probe\n");
574 p_egalax_i2c_dev = (struct _egalax_i2c *)kzalloc(sizeof(struct _egalax_i2c), GFP_KERNEL);
575 if (!p_egalax_i2c_dev)
577 printk(KERN_ERR "[egalax_i2c]: request memory failed\n");
582 #ifndef _NON_INPUT_DEV
583 input_dev = allocate_Input_Dev();
586 printk(KERN_ERR "[egalax_i2c]: allocate_Input_Dev failed\n");
590 TS_DEBUG("egalax_i2c register input device done\n");
591 memset(PointBuf, 0, sizeof(struct point_data)*MAX_SUPPORT_POINT);
592 #endif //#ifndef _NON_INPUT_DEV
594 if (pdata->init_platform_hw)
595 pdata->init_platform_hw();
597 p_egalax_i2c_dev->client = client;
598 mutex_init(&p_egalax_i2c_dev->mutex_wq);
600 p_egalax_i2c_dev->ktouch_wq = create_workqueue("egalax_touch_wq");
601 INIT_WORK(&p_egalax_i2c_dev->work, egalax_i2c_wq);
603 i2c_set_clientdata(client, p_egalax_i2c_dev);
605 if( gpio_get_value(gpio) )
606 p_egalax_i2c_dev->skip_packet = 0;
608 p_egalax_i2c_dev->skip_packet = 1;
610 p_egalax_i2c_dev->work_state = 1;
612 p_egalax_i2c_dev->irq = gpio_to_irq(client->irq);
614 ret = request_irq(p_egalax_i2c_dev->irq, egalax_i2c_interrupt, 0,
615 client->name, p_egalax_i2c_dev);
618 printk(KERN_ERR "[egalax_i2c]: request irq(%d) failed\n", p_egalax_i2c_dev->irq);
621 TS_DEBUG("egalax_i2c request irq(%d) gpio(%d) with result:%d\n", p_egalax_i2c_dev->irq, gpio, ret);
624 device_init_wakeup(&client->dev, 0);
627 printk(KERN_DEBUG "[egalax_i2c]: probe done\n");
631 i2c_set_clientdata(client, NULL);
632 destroy_workqueue(p_egalax_i2c_dev->ktouch_wq);
633 free_irq(p_egalax_i2c_dev->irq, p_egalax_i2c_dev);
634 #ifndef _NON_INPUT_DEV
635 input_unregister_device(input_dev);
636 input_free_device(input_dev);
638 #endif //#ifndef _NON_INPUT_DEV
641 kfree(p_egalax_i2c_dev);
642 p_egalax_i2c_dev = NULL;
644 printk(KERN_DEBUG "[egalax_i2c]: probe failed\n");
648 static int __devexit egalax_i2c_remove(struct i2c_client *client)
650 struct _egalax_i2c *egalax_i2c = i2c_get_clientdata(client);
654 #ifndef _NON_INPUT_DEV
657 TS_DEBUG("unregister input device\n");
658 input_unregister_device(input_dev);
659 input_free_device(input_dev);
662 #endif //#ifndef _NON_INPUT_DEV
664 if(p_egalax_i2c_dev->ktouch_wq)
666 destroy_workqueue(p_egalax_i2c_dev->ktouch_wq);
669 if(p_egalax_i2c_dev->irq)
671 free_irq(p_egalax_i2c_dev->irq, egalax_i2c);
674 i2c_set_clientdata(client, NULL);
676 p_egalax_i2c_dev = NULL;
681 static struct i2c_device_id egalax_i2c_idtable[] = {
686 MODULE_DEVICE_TABLE(i2c, egalax_i2c_idtable);
688 static struct i2c_driver egalax_i2c_driver = {
690 .name = "egalax_i2c",
692 .id_table = egalax_i2c_idtable,
693 .probe = egalax_i2c_probe,
694 .remove = __devexit_p(egalax_i2c_remove),
695 .suspend = egalax_i2c_suspend,
696 .resume = egalax_i2c_resume,
699 static const struct file_operations egalax_cdev_fops = {
700 .owner = THIS_MODULE,
701 .read = egalax_cdev_read,
702 .write = egalax_cdev_write,
703 .ioctl = egalax_cdev_ioctl,
704 .poll = egalax_cdev_poll,
705 .open = egalax_cdev_open,
706 .release= egalax_cdev_release,
709 static void egalax_i2c_ts_exit(void)
711 dev_t devno = MKDEV(global_major, global_minor);
716 TS_DEBUG("unregister character device\n");
717 if( p_char_dev->pFiFoBuf )
718 kfree(p_char_dev->pFiFoBuf);
720 cdev_del(&p_char_dev->cdev);
725 unregister_chrdev_region( devno, 1);
727 if(!IS_ERR(egalax_class))
729 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
730 class_device_destroy(egalax_class, devno);
732 device_destroy(egalax_class, devno);
734 class_destroy(egalax_class);
737 i2c_del_driver(&egalax_i2c_driver);
739 printk(KERN_DEBUG "[egalax_i2c]: driver exit\n");
742 static struct egalax_char_dev* setup_chardev(dev_t dev)
744 struct egalax_char_dev *pCharDev;
747 pCharDev = kmalloc(1*sizeof(struct egalax_char_dev), GFP_KERNEL);
750 memset(pCharDev, 0, sizeof(struct egalax_char_dev));
752 spin_lock_init( &pCharDev->FiFoLock );
753 pCharDev->pFiFoBuf = kmalloc(sizeof(unsigned char)*FIFO_SIZE, GFP_KERNEL);
754 if(!pCharDev->pFiFoBuf)
756 memset(pCharDev->pFiFoBuf, 0, sizeof(unsigned char)*FIFO_SIZE);
758 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
759 pCharDev->pDataKFiFo = kfifo_init(pCharDev->pFiFoBuf, FIFO_SIZE, GFP_KERNEL, &pCharDev->FiFoLock);
760 if( pCharDev->pDataKFiFo==NULL )
763 kfifo_init(&pCharDev->DataKFiFo, pCharDev->pFiFoBuf, FIFO_SIZE);
764 if( !kfifo_initialized(&pCharDev->DataKFiFo) )
768 pCharDev->OpenCnts = 0;
769 cdev_init(&pCharDev->cdev, &egalax_cdev_fops);
770 pCharDev->cdev.owner = THIS_MODULE;
771 sema_init(&pCharDev->sem, 1);
772 init_waitqueue_head(&pCharDev->fifo_inq);
774 result = cdev_add(&pCharDev->cdev, dev, 1);
777 TS_DEBUG(KERN_ERR "Error cdev ioctldev added\n");
784 kfree(pCharDev->pFiFoBuf);
791 static void __init egalax_i2c_ts_init_async(void *unused, async_cookie_t cookie)
798 // Asking for a dynamic major unless directed otherwise at load time.
801 devno = MKDEV(global_major, global_minor);
802 result = register_chrdev_region(devno, 1, "egalax_i2c");
806 result = alloc_chrdev_region(&devno, global_minor, 1, "egalax_i2c");
807 global_major = MAJOR(devno);
812 TS_DEBUG(" egalax_i2c cdev can't get major number\n");
816 // allocate the character device
817 p_char_dev = setup_chardev(devno);
824 egalax_class = class_create(THIS_MODULE, "egalax_i2c");
825 if(IS_ERR(egalax_class))
827 TS_DEBUG("Err: failed in creating class.\n");
832 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
833 class_device_create(egalax_class, NULL, devno, NULL, "egalax_i2c");
835 device_create(egalax_class, NULL, devno, NULL, "egalax_i2c");
837 TS_DEBUG("register egalax_i2c cdev, major: %d \n",global_major);
839 printk(KERN_DEBUG "[egalax_i2c]: init done\n");
840 return i2c_add_driver(&egalax_i2c_driver);
843 egalax_i2c_ts_exit();
847 static int __init egalax_i2c_ts_init(void)
849 async_schedule(egalax_i2c_ts_init_async, NULL);
852 module_init(egalax_i2c_ts_init);
853 module_exit(egalax_i2c_ts_exit);
855 MODULE_DESCRIPTION("egalax touch screen i2c driver");
856 MODULE_LICENSE("GPL");