Advertisement
Guest User

Untitled

a guest
Dec 4th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 16.98 KB | None | 0 0
  1. /* drivers/input/touchscreen/msm_ts.c
  2.  *
  3.  * Copyright (C) 2008 Google, Inc.
  4.  * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  5.  *
  6.  * This software is licensed under the terms of the GNU General Public
  7.  * License version 2, as published by the Free Software Foundation, and
  8.  * may be copied, distributed, and modified under those terms.
  9.  *
  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.
  14.  *
  15.  * TODO:
  16.  *      - Add a timer to simulate a pen_up in case there's a timeout.
  17.  */
  18.  /*
  19. ====================================================================================
  20. when         who        what, where, why                               comment tag
  21. --------     ----          -------------------------------------    ------------------
  22. 2010-12-07   wly         modify v9 driver                               ZTE_TS_WLY_CRDB00567837
  23. 2010-11-04   wly         ajust zero pressure                            ZTE_TS_WLY_CRDB00567837
  24. 2010-05-21   wly         modify debounce time                           ZTE_TS_WLY_0521
  25. 2010-03-05   zt          add mod_timer to avoid no rebounce interrupt   ZTE_TS_ZT_005
  26. 2010-01-28   zt          Modified for new BSP                                           ZTE_TS_ZT_004
  27. 2010-01-28   zt            Change debounce time                                       ZTE_TS_ZT_003
  28. 2010-01-28   zt            Resolve touch no response when power on          ZTE_TS_ZT_002
  29. 2010-01-28   zt            Update touchscreen driver.                                 ZTE_TS_ZT_001
  30.                          register two interrupt and delet virtual key.     
  31. =====================================================================================
  32. */
  33.  
  34. #include <linux/delay.h>
  35. #include <linux/device.h>
  36. #include <linux/init.h>
  37. #include <linux/input.h>
  38. #include <linux/interrupt.h>
  39. #include <linux/io.h>
  40. #include <linux/module.h>
  41. #include <linux/platform_device.h>
  42. #include <linux/mfd/marimba-tsadc.h>
  43. #include <linux/pm.h>
  44.  
  45. #if defined(CONFIG_HAS_EARLYSUSPEND)
  46. #include <linux/earlysuspend.h>
  47. #endif
  48.  
  49. #include <mach/msm_ts.h>
  50. #include <linux/jiffies.h>  
  51.  
  52. #define TSSC_CTL            0x100
  53. #define     TSSC_CTL_PENUP_IRQ  (1 << 12)
  54. #define     TSSC_CTL_DATA_FLAG  (1 << 11)
  55. #define     TSSC_CTL_DEBOUNCE_EN    (1 << 6)
  56. #define     TSSC_CTL_EN_AVERAGE (1 << 5)
  57. #define     TSSC_CTL_MODE_MASTER    (3 << 3)
  58. #define     TSSC_CTL_SW_RESET   (1 << 2)
  59. #define     TSSC_CTL_ENABLE     (1 << 0)
  60. #define TSSC_OPN            0x104
  61. #define     TSSC_OPN_NOOP       0x00
  62. #define     TSSC_OPN_4WIRE_X    0x01
  63. #define     TSSC_OPN_4WIRE_Y    0x02
  64. #define     TSSC_OPN_4WIRE_Z1   0x03
  65. #define     TSSC_OPN_4WIRE_Z2   0x04
  66. #define TSSC_SAMPLING_INT       0x108
  67. #define TSSC_STATUS         0x10c
  68. #define TSSC_AVG_12         0x110
  69. #define TSSC_AVG_34         0x114
  70. #define TSSC_SAMPLE(op,samp)        ((0x118 + ((op & 0x3) * 0x20)) + \
  71.                      ((samp & 0x7) * 0x4))
  72. #define TSSC_TEST_1         0x198
  73.     #define TSSC_TEST_1_EN_GATE_DEBOUNCE (1 << 2)
  74. #define TSSC_TEST_2         0x19c
  75. #define TS_PENUP_TIMEOUT_MS 400 // 20  -->  70  ZTE_TS_ZT_005 @2010-03-05
  76.  
  77. struct msm_ts {
  78.     struct msm_ts_platform_data *pdata;
  79.     struct input_dev        *input_dev;
  80.     void __iomem            *tssc_base;
  81.     uint32_t            ts_down:1;
  82.     struct ts_virt_key      *vkey_down;
  83.     //struct marimba_tsadc_client   *ts_client;
  84.  
  85.     unsigned int            sample_irq;
  86.     unsigned int            pen_up_irq;
  87.  
  88. #if defined(CONFIG_HAS_EARLYSUSPEND)
  89.     struct early_suspend        early_suspend;
  90. #endif
  91.     struct device           *dev;
  92. struct timer_list timer;  //wlyZTE_TS_ZT_005 @2010-03-05
  93. };
  94.  
  95. static uint32_t msm_tsdebug;
  96. module_param_named(tsdebug, msm_tsdebug, uint, 0664);
  97.  
  98. #define tssc_readl(t, a)    (readl(((t)->tssc_base) + (a)))
  99. #define tssc_writel(t, v, a)    do {writel(v, ((t)->tssc_base) + (a));} while(0)
  100.  
  101. static void setup_next_sample(struct msm_ts *ts)
  102. {
  103.     uint32_t tmp;
  104.  
  105.     /* 6ms debounce time ,ZTE_TS_WLY_0521*/
  106.     tmp = ((7 << 7) | TSSC_CTL_DEBOUNCE_EN | TSSC_CTL_EN_AVERAGE |
  107.            TSSC_CTL_MODE_MASTER | TSSC_CTL_ENABLE);
  108.  
  109.     tssc_writel(ts, tmp, TSSC_CTL);
  110. }
  111.  
  112.  
  113. /*
  114. static struct ts_virt_key *find_virt_key(struct msm_ts *ts,
  115.                      struct msm_ts_virtual_keys *vkeys,
  116.                      uint32_t val)
  117. {
  118.     int i;
  119.  
  120.     if (!vkeys)
  121.         return NULL;
  122.  
  123.     for (i = 0; i < vkeys->num_keys; ++i)
  124.         if ((val >= vkeys->keys[i].min) && (val <= vkeys->keys[i].max))
  125.             return &vkeys->keys[i];
  126.     return NULL;
  127. }
  128. */
  129.  
  130.  
  131. static void ts_timer(unsigned long arg)
  132. {
  133.     struct msm_ts *ts = (struct msm_ts *)arg;
  134.     enable_irq(ts->pen_up_irq);
  135.     input_report_key(ts->input_dev, BTN_TOUCH, 0);
  136.     input_sync(ts->input_dev);
  137. }
  138.  
  139. static irqreturn_t msm_ts_irq(int irq, void *dev_id)
  140. {
  141.     struct msm_ts *ts = dev_id;
  142.     struct msm_ts_platform_data *pdata = ts->pdata;
  143.  
  144.     uint32_t tssc_avg12, tssc_avg34, tssc_status, tssc_ctl;
  145.     int x, y, z1, z2;
  146.     int was_down;
  147.     int down;
  148.   int z=0;  //wly
  149.   //del_timer_sync(&ts->timer);
  150.     tssc_ctl = tssc_readl(ts, TSSC_CTL);
  151.     tssc_status = tssc_readl(ts, TSSC_STATUS);
  152.     tssc_avg12 = tssc_readl(ts, TSSC_AVG_12);
  153.     tssc_avg34 = tssc_readl(ts, TSSC_AVG_34);
  154.  
  155.     setup_next_sample(ts);
  156.  
  157.     x = tssc_avg12 & 0xffff;
  158.     y = tssc_avg12 >> 16;
  159.     z1 = tssc_avg34 & 0xffff;
  160.     z2 = tssc_avg34 >> 16;
  161.    
  162.     down = !(tssc_ctl & TSSC_CTL_PENUP_IRQ);
  163.     was_down = ts->ts_down;
  164.     ts->ts_down = down;
  165.  
  166.     /* no valid data */
  167.     if (down && !(tssc_ctl & TSSC_CTL_DATA_FLAG))
  168.         return IRQ_HANDLED;
  169.  
  170.     if (msm_tsdebug & 2)
  171.         printk("%s: down=%d, x=%d, y=%d, z1=%d, z2=%d, status %x\n",
  172.                __func__, down, x, y, z1, z2, tssc_status);
  173.     if (down)
  174.         {
  175.         //if ( 0 == z1 ) return IRQ_HANDLED;
  176.             //z = ( ( 2 * z2 - 2 * z1 - 3) * x) / ( 2 * z1 + 3);
  177.             z = ( ( z2 - z1 - 2)*x) / ( z1 + 2 );
  178.             z = ( 2500 - z ) * 1000 / ( 2500 - 900 );
  179.             //printk("wly: msm_ts_irq,z=%d,z1=%d,z2=%d,x=%d\n",z,z1,z2,x);
  180.             if( z<=0 ) z = 255;
  181.         }
  182.    
  183.     /* invert the inputs if necessary */
  184.  
  185.     if (pdata->inv_x) x = pdata->inv_x - x;
  186.     if (pdata->inv_y) y = pdata->inv_y - y;
  187.  
  188.    
  189.     if (x < 0) x = 0;
  190.     if (y < 0) y = 0;
  191.     if ((x==1001)&&(y>970))
  192.     {
  193.         if (31 == irq)disable_irq_nosync(irq);
  194.         input_report_abs(ts->input_dev, ABS_X, x);
  195.         input_report_abs(ts->input_dev, ABS_Y, y);
  196.         input_report_abs(ts->input_dev, ABS_PRESSURE, z);
  197.         input_report_key(ts->input_dev, BTN_TOUCH, 1);
  198.         input_sync(ts->input_dev);
  199.         //racer_flag = false;
  200.         if (31 == irq)mod_timer(&ts->timer,jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));
  201.         return IRQ_HANDLED;
  202.     }
  203.  
  204. /*
  205.     if (!was_down && down) {
  206.         struct ts_virt_key *vkey = NULL;
  207.  
  208.         if (pdata->vkeys_y && (y > pdata->virt_y_start))
  209.             vkey = find_virt_key(ts, pdata->vkeys_y, x);
  210.         if (!vkey && ts->pdata->vkeys_x && (x > pdata->virt_x_start))
  211.             vkey = find_virt_key(ts, pdata->vkeys_x, y);
  212.  
  213.         if (vkey) {
  214.             WARN_ON(ts->vkey_down != NULL);
  215.             if(msm_tsdebug)
  216.                 printk("%s: virtual key down %d\n", __func__,
  217.                        vkey->key);
  218.             ts->vkey_down = vkey;
  219.             input_report_key(ts->input_dev, vkey->key, 1);
  220.             input_sync(ts->input_dev);
  221.             return IRQ_HANDLED;
  222.         }
  223.     } else if (ts->vkey_down != NULL) {
  224.         if (!down) {
  225.             if(msm_tsdebug)
  226.                 printk("%s: virtual key up %d\n", __func__,
  227.                        ts->vkey_down->key);
  228.             input_report_key(ts->input_dev, ts->vkey_down->key, 0);
  229.             input_sync(ts->input_dev);
  230.             ts->vkey_down = NULL;
  231.         }
  232.         return IRQ_HANDLED;
  233.     }
  234.     */
  235.    
  236.  
  237.     if (down) {
  238.         input_report_abs(ts->input_dev, ABS_X, x);
  239.         input_report_abs(ts->input_dev, ABS_Y, y);
  240.             input_report_abs(ts->input_dev, ABS_PRESSURE, z);
  241.     }
  242.     input_report_key(ts->input_dev, BTN_TOUCH, down);
  243.     input_sync(ts->input_dev);
  244.     //if (30 == irq)mod_timer(&ts->timer,jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));
  245.     return IRQ_HANDLED;
  246. }
  247.  
  248. /*
  249. static void dump_tssc_regs(struct msm_ts *ts)
  250. {
  251. #define __dump_tssc_reg(r) \
  252.         do { printk(#r " %x\n", tssc_readl(ts, (r))); } while(0)
  253.  
  254.     __dump_tssc_reg(TSSC_CTL);
  255.     __dump_tssc_reg(TSSC_OPN);
  256.     __dump_tssc_reg(TSSC_SAMPLING_INT);
  257.     __dump_tssc_reg(TSSC_STATUS);
  258.     __dump_tssc_reg(TSSC_AVG_12);
  259.     __dump_tssc_reg(TSSC_AVG_34);
  260.     __dump_tssc_reg(TSSC_TEST_1);
  261. #undef __dump_tssc_reg
  262. }
  263. */
  264.  
  265. static int __devinit msm_ts_hw_init(struct msm_ts *ts)
  266. {
  267.  
  268. #if 0 //wly
  269.     uint32_t tmp;
  270.  
  271.     /* Enable the register clock to tssc so we can configure it. */
  272.     tssc_writel(ts, TSSC_CTL_ENABLE, TSSC_CTL);
  273.     /* Enable software reset*/
  274.     tssc_writel(ts, TSSC_CTL_SW_RESET, TSSC_CTL);
  275.  
  276.     /* op1 - measure X, 1 sample, 12bit resolution */
  277.     tmp = (TSSC_OPN_4WIRE_X << 16) | (2 << 8) | (2 << 0);
  278.     /* op2 - measure Y, 1 sample, 12bit resolution */
  279.     tmp |= (TSSC_OPN_4WIRE_Y << 20) | (2 << 10) | (2 << 2);
  280.     /* op3 - measure Z1, 1 sample, 8bit resolution */
  281.     tmp |= (TSSC_OPN_4WIRE_Z1 << 24) | (2 << 12) | (0 << 4);
  282.  
  283.     /* XXX: we don't actually need to measure Z2 (thus 0 samples) when
  284.      * doing voltage-driven measurement */
  285.     /* op4 - measure Z2, 0 samples, 8bit resolution */
  286.     tmp |= (TSSC_OPN_4WIRE_Z2 << 28) | (0 << 14) | (0 << 6);
  287.     tssc_writel(ts, tmp, TSSC_OPN);
  288.  
  289.     /* 16ms sampling interval */
  290.     tssc_writel(ts, 16, TSSC_SAMPLING_INT);
  291.     /* Enable gating logic to fix the timing delays caused because of
  292.      * enabling debounce logic */
  293.     tssc_writel(ts, TSSC_TEST_1_EN_GATE_DEBOUNCE, TSSC_TEST_1);
  294. #endif
  295.  
  296.     setup_next_sample(ts);
  297.  
  298.     return 0;
  299. }
  300.  
  301. #ifdef CONFIG_PM
  302. static int
  303. msm_ts_suspend(struct device *dev)
  304. {
  305.     struct msm_ts *ts =  dev_get_drvdata(dev);
  306.     uint32_t val;
  307.  
  308.     disable_irq(ts->sample_irq);
  309.     disable_irq(ts->pen_up_irq);
  310.  
  311.     val = tssc_readl(ts, TSSC_CTL);
  312.     val &= ~TSSC_CTL_ENABLE;
  313.     tssc_writel(ts, val, TSSC_CTL);
  314.  
  315.     return 0;
  316. }
  317.  
  318. static int
  319. msm_ts_resume(struct device *dev)
  320. {
  321.     struct msm_ts *ts =  dev_get_drvdata(dev);
  322.  
  323.     msm_ts_hw_init(ts);
  324.  
  325.     enable_irq(ts->sample_irq);
  326.     enable_irq(ts->pen_up_irq);
  327.  
  328.     return 0;
  329. }
  330.  
  331. static struct dev_pm_ops msm_touchscreen_pm_ops = {
  332. #ifndef CONFIG_HAS_EARLYSUSPEND
  333.     .suspend    = msm_ts_suspend,
  334.     .resume     = msm_ts_resume,
  335. #endif
  336. };
  337. #endif
  338.  
  339. #ifdef CONFIG_HAS_EARLYSUSPEND
  340. static void msm_ts_early_suspend(struct early_suspend *h)
  341. {
  342.     struct msm_ts *ts = container_of(h, struct msm_ts, early_suspend);
  343.  
  344.     msm_ts_suspend(ts->dev);
  345. }
  346.  
  347. static void msm_ts_late_resume(struct early_suspend *h)
  348. {
  349.     struct msm_ts *ts = container_of(h, struct msm_ts, early_suspend);
  350.  
  351.     msm_ts_resume(ts->dev);
  352. }
  353. #endif
  354.  
  355. #if defined(CONFIG_TOUCHSCREEN_VIRTUAL_KEYS)
  356. #define virtualkeys virtualkeys.msm-touchscreen
  357. #if defined(CONFIG_MACH_MOONCAKE)
  358. static const char ts_keys_size[] = "0x01:102:40:340:60:50:0x01:139:120:340:60:50:0x01:158:200:340:60:50";
  359. #elif defined(CONFIG_MACH_V9)
  360. static const char ts_keys_size[] = "0x01:102:70:850:60:50:0x01:139:230:850:60:50:0x01:158:390:850:60:50";
  361. #endif
  362.  
  363. static ssize_t virtualkeys_show(struct device *dev,
  364.         struct device_attribute *attr, char *buf)
  365. {
  366.     sprintf(buf,"%s\n",ts_keys_size);
  367.     printk("wly:%s\n",__FUNCTION__);
  368.     return strlen(ts_keys_size)+2;
  369. }
  370. static DEVICE_ATTR(virtualkeys, 0444, virtualkeys_show, NULL);
  371. extern struct kobject *android_touch_kobj;
  372. static struct kobject * virtual_key_kobj;
  373. static int ts_key_report_init(void)
  374. {
  375.     int ret;
  376.     virtual_key_kobj = kobject_get(android_touch_kobj);
  377.     if (virtual_key_kobj == NULL) {
  378.         virtual_key_kobj = kobject_create_and_add("board_properties", NULL);
  379.         if (virtual_key_kobj == NULL) {
  380.             printk(KERN_ERR "%s: subsystem_register failed\n", __func__);
  381.             ret = -ENOMEM;
  382.             return ret;
  383.         }
  384.     }
  385.     ret = sysfs_create_file(virtual_key_kobj, &dev_attr_virtualkeys.attr);
  386.     if (ret) {
  387.         printk(KERN_ERR "%s: sysfs_create_file failed\n", __func__);
  388.         return ret;
  389.     }
  390.  
  391.     return 0;
  392. }
  393.  
  394. /*static void ts_key_report_init_deinit(void)
  395. {
  396.     sysfs_remove_file(virtual_key_kobj, &dev_attr_virtualkeys.attr);
  397.     kobject_del(virtual_key_kobj);
  398. }*/
  399.  
  400. #endif  //xiayc
  401.  
  402. static int __devinit msm_ts_probe(struct platform_device *pdev)
  403. {
  404.     struct msm_ts_platform_data *pdata = pdev->dev.platform_data;
  405.     struct msm_ts *ts;
  406.     struct resource *tssc_res;
  407.     struct resource *irq1_res;
  408.     struct resource *irq2_res;
  409.     int err = 0;
  410.    
  411.     /*int i;*/
  412.     /*struct marimba_tsadc_client *ts_client;*/
  413.    
  414.  
  415.     tssc_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tssc");
  416.     irq1_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "tssc1");
  417.     irq2_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "tssc2");
  418.  
  419.     if (!tssc_res || !irq1_res || !irq2_res) {
  420.         pr_err("%s: required resources not defined\n", __func__);
  421.         return -ENODEV;
  422.     }
  423.  
  424.     if (pdata == NULL) {
  425.         pr_err("%s: missing platform_data\n", __func__);
  426.         return -ENODEV;
  427.     }
  428.  
  429.     ts = kzalloc(sizeof(struct msm_ts), GFP_KERNEL);
  430.     if (ts == NULL) {
  431.         pr_err("%s: No memory for struct msm_ts\n", __func__);
  432.         return -ENOMEM;
  433.     }
  434.     ts->pdata = pdata;
  435.     ts->dev   = &pdev->dev;
  436.  
  437.     ts->sample_irq = irq1_res->start;
  438.     ts->pen_up_irq = irq2_res->start;
  439.  
  440.     ts->tssc_base = ioremap(tssc_res->start, resource_size(tssc_res));
  441.     if (ts->tssc_base == NULL) {
  442.         pr_err("%s: Can't ioremap region (0x%08x - 0x%08x)\n", __func__,
  443.                (uint32_t)tssc_res->start, (uint32_t)tssc_res->end);
  444.         err = -ENOMEM;
  445.         goto err_ioremap_tssc;
  446.     }
  447. #if 0
  448.     ts_client = marimba_tsadc_register(pdev, 1);
  449.     if (IS_ERR(ts_client)) {
  450.         pr_err("%s: Unable to register with TSADC\n", __func__);
  451.         err = -ENOMEM;
  452.         goto err_tsadc_register;
  453.     }
  454.     ts->ts_client = ts_client;
  455.  
  456.     err = marimba_tsadc_start(ts_client);
  457.     if (err) {
  458.         pr_err("%s: Unable to start TSADC\n", __func__);
  459.         err = -EINVAL;
  460.         goto err_start_tsadc;
  461.     }
  462. #endif
  463.     ts->input_dev = input_allocate_device();
  464.     if (ts->input_dev == NULL) {
  465.         pr_err("failed to allocate touchscreen input device\n");
  466.         err = -ENOMEM;
  467.         goto err_alloc_input_dev;
  468.     }
  469.     ts->input_dev->name = "msm-touchscreen";
  470.     ts->input_dev->dev.parent = &pdev->dev;
  471.  
  472.     input_set_drvdata(ts->input_dev, ts);
  473.  
  474.     input_set_capability(ts->input_dev, EV_KEY, BTN_TOUCH);
  475.     set_bit(EV_ABS, ts->input_dev->evbit);
  476.  
  477.     input_set_abs_params(ts->input_dev, ABS_X, pdata->min_x, pdata->max_x,
  478.                  0, 0);
  479.     input_set_abs_params(ts->input_dev, ABS_Y, pdata->min_y, pdata->max_y,
  480.                  0, 0);
  481.     input_set_abs_params(ts->input_dev, ABS_PRESSURE, pdata->min_press,
  482.                  pdata->max_press, 0, 0);
  483.  
  484. /*
  485.     for (i = 0; pdata->vkeys_x && (i < pdata->vkeys_x->num_keys); ++i)
  486.         input_set_capability(ts->input_dev, EV_KEY,
  487.                      pdata->vkeys_x->keys[i].key);
  488.     for (i = 0; pdata->vkeys_y && (i < pdata->vkeys_y->num_keys); ++i)
  489.         input_set_capability(ts->input_dev, EV_KEY,
  490.                      pdata->vkeys_y->keys[i].key);
  491. */
  492.  
  493.     err = input_register_device(ts->input_dev);
  494.     if (err != 0) {
  495.         pr_err("%s: failed to register input device\n", __func__);
  496.         goto err_input_dev_reg;
  497.     }
  498.  
  499.   setup_timer(&ts->timer, ts_timer, (unsigned long)ts);  
  500.     msm_ts_hw_init(ts);
  501.  
  502.     err = request_irq(ts->sample_irq, msm_ts_irq,
  503.               (irq1_res->flags & ~IORESOURCE_IRQ) | IRQF_DISABLED,
  504.               "msm_touchscreen", ts);
  505.     if (err != 0) {
  506.         pr_err("%s: Cannot register irq1 (%d)\n", __func__, err);
  507.         goto err_request_irq1;
  508.     }
  509.  
  510.     err = request_irq(ts->pen_up_irq, msm_ts_irq,
  511.               (irq2_res->flags & ~IORESOURCE_IRQ) | IRQF_DISABLED,
  512.               "msm_touchscreen", ts);
  513.     if (err != 0) {
  514.         pr_err("%s: Cannot register irq2 (%d)\n", __func__, err);
  515.         goto err_request_irq2;
  516.     }
  517.  
  518.     platform_set_drvdata(pdev, ts);
  519.  
  520. #ifdef CONFIG_HAS_EARLYSUSPEND
  521.     ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN +
  522.                         TSSC_SUSPEND_LEVEL;
  523.     ts->early_suspend.suspend = msm_ts_early_suspend;
  524.     ts->early_suspend.resume = msm_ts_late_resume;
  525.     register_early_suspend(&ts->early_suspend);
  526. #endif
  527.  
  528.     pr_info("%s: tssc_base=%p irq1=%d irq2=%d\n", __func__,
  529.         ts->tssc_base, (int)ts->sample_irq, (int)ts->pen_up_irq);
  530.  
  531. //xiayc
  532. #if defined(CONFIG_TOUCHSCREEN_VIRTUAL_KEYS)
  533.     ts_key_report_init();
  534. #endif
  535. //  dump_tssc_regs(ts);
  536.     return 0;
  537.  
  538. err_request_irq2:
  539.     free_irq(ts->sample_irq, ts);
  540.  
  541. err_request_irq1:
  542.     /* disable the tssc */
  543.     tssc_writel(ts, TSSC_CTL_ENABLE, TSSC_CTL);
  544.  
  545. err_input_dev_reg:
  546.     input_set_drvdata(ts->input_dev, NULL);
  547.     input_free_device(ts->input_dev);
  548.  
  549. err_alloc_input_dev:
  550. #if 0
  551. err_start_tsadc:
  552.     marimba_tsadc_unregister(ts->ts_client);
  553.  
  554. err_tsadc_register:
  555. #endif
  556.     iounmap(ts->tssc_base);
  557.  
  558. err_ioremap_tssc:
  559.     kfree(ts);
  560.     return err;
  561. }
  562. #if 0
  563. static int __devexit msm_ts_remove(struct platform_device *pdev)
  564. {
  565.     struct msm_ts *ts = platform_get_drvdata(pdev);
  566.  
  567.     marimba_tsadc_unregister(ts->ts_client);
  568.     free_irq(ts->sample_irq, ts);
  569.     free_irq(ts->pen_up_irq, ts);
  570.     input_unregister_device(ts->input_dev);
  571.     iounmap(ts->tssc_base);
  572. #ifdef CONFIG_HAS_EARLYSUSPEND
  573.     unregister_early_suspend(&ts->early_suspend);
  574. #endif
  575.     platform_set_drvdata(pdev, NULL);
  576.     kfree(ts);
  577.  
  578.     return 0;
  579. }
  580. #endif
  581. static struct platform_driver msm_touchscreen_driver = {
  582.     .driver = {
  583.         .name = "msm_touchscreen",
  584.         .owner = THIS_MODULE,
  585. #ifdef CONFIG_PM
  586.         .pm = &msm_touchscreen_pm_ops,
  587. #endif
  588.     },
  589.     .probe      = msm_ts_probe,
  590.     //.remove = __devexit_p(msm_ts_remove),
  591. };
  592.  
  593. static int __init msm_ts_init(void)
  594. {
  595.     return platform_driver_register(&msm_touchscreen_driver);
  596. }
  597.  
  598. static void __exit msm_ts_exit(void)
  599. {
  600.     platform_driver_unregister(&msm_touchscreen_driver);
  601. }
  602.  
  603. module_init(msm_ts_init);
  604. module_exit(msm_ts_exit);
  605. MODULE_DESCRIPTION("Qualcomm MSM/QSD Touchscreen controller driver");
  606. MODULE_LICENSE("GPL");
  607. MODULE_ALIAS("platform:msm_touchscreen");
  608.  
  609.  
  610.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement