Merge remote-tracking branch 'aosp/android-3.0' into develop-3.0
[firefly-linux-kernel-4.4.55.git] / drivers / headset_observe / rk_headset_irq_hook_adc.c
1 /* arch/arm/mach-rockchip/rk28_headset.c
2  *
3  * Copyright (C) 2009 Rockchip Corporation.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/module.h>
17 #include <linux/sysdev.h>
18 #include <linux/device.h>
19 #include <linux/fs.h>
20 #include <linux/interrupt.h>
21 #include <linux/workqueue.h>
22 #include <linux/irq.h>
23 #include <linux/delay.h>
24 #include <linux/types.h>
25 #include <linux/input.h>
26 #include <linux/platform_device.h>
27 #include <linux/mutex.h>
28 #include <linux/errno.h>
29 #include <linux/err.h>
30 #include <linux/hrtimer.h>
31 #include <linux/switch.h>
32 #include <linux/input.h>
33 #include <linux/debugfs.h>
34 #include <linux/wakelock.h>
35 #include <asm/gpio.h>
36 #include <asm/atomic.h>
37 #include <asm/mach-types.h>
38 #include "rk_headset.h"
39 #include <linux/earlysuspend.h>
40 #include <linux/gpio.h>
41 #include <mach/board.h>
42 #include <linux/slab.h>
43 #include <linux/adc.h>
44 #include <linux/wakelock.h>
45
46 /* Debug */
47 #if 1
48 #define DBG(x...) printk(x)
49 #else
50 #define DBG(x...) do { } while (0)
51 #endif
52
53 #define HOOK_ADC_SAMPLE_TIME    50
54 #define HOOK_LEVEL_HIGH                 410             //1V*1024/2.5
55 #define HOOK_LEVEL_LOW                  204             //0.5V*1024/2.5
56 #define HOOK_DEFAULT_VAL                1024    
57
58 #define BIT_HEADSET             (1 << 0)
59 #define BIT_HEADSET_NO_MIC      (1 << 1)
60
61 #define HEADSET 0
62 #define HOOK 1
63
64 #define HEADSET_IN 1
65 #define HEADSET_OUT 0
66 #define HOOK_DOWN 1
67 #define HOOK_UP 0
68 #define enable 1
69 #define disable 0
70
71 #define HEADSET_TIMER 1
72 #define HOOK_TIMER 2
73
74 #define WAIT 2
75 #define BUSY 1
76 #define IDLE 0
77
78 #ifdef CONFIG_SND_SOC_WM8994
79 extern int wm8994_headset_mic_detect(bool headset_status);
80 #endif
81 #ifdef CONFIG_SND_SOC_RT5631_PHONE
82 extern int rt5631_headset_mic_detect(bool headset_status);
83 #endif
84 #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
85 extern int rt3261_headset_mic_detect(int jack_insert);
86 #endif
87
88 /* headset private data */
89 struct headset_priv {
90         struct input_dev *input_dev;
91         struct rk_headset_pdata *pdata;
92         unsigned int headset_status:1;
93         unsigned int hook_status:1;
94         int isMic;
95         unsigned int heatset_irq_working;// headset interrupt working will not check hook key   
96         int cur_headset_status; 
97         
98         unsigned int irq[2];
99         unsigned int irq_type[2];
100         struct delayed_work h_delayed_work[2];
101         struct switch_dev sdev;
102         struct mutex mutex_lock[2];     
103         struct timer_list headset_timer;
104         unsigned char *keycodes;
105         struct adc_client *client;
106         struct timer_list hook_timer;
107         unsigned int hook_time;//ms
108         struct wake_lock headset_on_wake;
109 };
110 static struct headset_priv *headset_info;
111
112 int Headset_isMic(void)
113 {
114         return headset_info->isMic;
115 }
116 EXPORT_SYMBOL_GPL(Headset_isMic);
117
118 //1
119 static irqreturn_t headset_interrupt(int irq, void *dev_id)
120 {
121         struct rk_headset_pdata *pdata = headset_info->pdata;
122         static unsigned int old_status = 0;
123         int i,level = 0;        
124         int adc_value = 0;
125         wake_lock(&headset_info->headset_on_wake);
126         if(headset_info->heatset_irq_working == BUSY || headset_info->heatset_irq_working == WAIT)
127                 return IRQ_HANDLED;
128         DBG("In the headset_interrupt for read headset level  wake_lock headset_on_wake\n");            
129         headset_info->heatset_irq_working = BUSY;
130         msleep(150);
131         for(i=0; i<3; i++)
132         {
133                 level = gpio_get_value(pdata->Headset_gpio);
134                 if(level < 0)
135                 {
136                         printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,pdata->Headset_gpio,i);
137                         msleep(1);
138                         continue;
139                 }
140                 else
141                 break;
142         }
143         if(level < 0)
144         {
145                 printk("%s:get pin level  err!\n",__FUNCTION__);
146                 goto out;
147         }
148
149         old_status = headset_info->headset_status;
150         switch(pdata->headset_in_type)
151         {
152         case HEADSET_IN_HIGH:
153                 if(level > 0)
154                         headset_info->headset_status = HEADSET_IN;
155                 else if(level == 0)
156                         headset_info->headset_status = HEADSET_OUT;     
157                 break;
158         case HEADSET_IN_LOW:
159                 if(level == 0)
160                         headset_info->headset_status = HEADSET_IN;
161                 else if(level > 0)
162                         headset_info->headset_status = HEADSET_OUT;             
163                 break;                  
164         default:
165                 DBG("---- ERROR: on headset headset_in_type error -----\n");
166                 break;                  
167         }
168         if(old_status == headset_info->headset_status)
169         {
170                 DBG("Read Headset IO level old status == now status\n");
171                 goto out;
172         }
173
174         DBG("(headset in is %s)headset status is %s\n",
175                 pdata->headset_in_type?"high level":"low level",
176                 headset_info->headset_status?"in":"out");
177         if(headset_info->headset_status == HEADSET_IN)
178         {
179                 #if 0
180                 while(1)
181                 {
182                         if(adc_sync_read(headset_info->client) > HOOK_DEFAULT_VAL
183                          || adc_sync_read(headset_info->client) < 0)
184                         {
185                                 printk("headset is showly inside\n");
186                         }
187                         else
188                                 break;
189                         msleep(50);
190                         
191                         if(pdata->headset_in_type == HEADSET_IN_HIGH)
192                                 old_status = headset_info->headset_status = gpio_get_value(pdata->Headset_gpio)?HEADSET_IN:HEADSET_OUT;
193                         else
194                                 old_status = headset_info->headset_status = gpio_get_value(pdata->Headset_gpio)?HEADSET_OUT:HEADSET_IN;
195                         if(headset_info->headset_status == HEADSET_OUT)
196                                 goto out1;
197                         msleep(5);      
198                 }
199                 #endif
200                 if(pdata->Hook_adc_chn>=0 && 3>=pdata->Hook_adc_chn)
201                 {
202                 // wait for find Hook key
203                         //#ifdef CONFIG_SND_SOC_RT5625
204                         CHECK_AGAIN:
205                         //headset_info->isMic = rt5625_headset_mic_detect(true);
206                         #ifdef CONFIG_SND_SOC_WM8994
207                         wm8994_headset_mic_detect(true);
208                         #endif
209                         #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
210                         rt3261_headset_mic_detect(true);
211                         #endif
212                         #ifdef CONFIG_SND_SOC_RT5631_PHONE
213                         rt5631_headset_mic_detect(true);
214                         #endif                  
215                         //mdelay(400);
216                         adc_value = adc_sync_read(headset_info->client);
217                         if(adc_value >= 0 && adc_value < HOOK_LEVEL_LOW)
218                         {
219                                 headset_info->isMic= 0;//No microphone
220                                 #ifdef CONFIG_SND_SOC_WM8994
221                                 wm8994_headset_mic_detect(false);
222                                 #endif
223                                 #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
224                                 rt3261_headset_mic_detect(false);
225                                 #endif  
226                                 #ifdef CONFIG_SND_SOC_RT5631_PHONE
227                                 rt5631_headset_mic_detect(false);
228                                 #endif                                  
229                         }       
230                         else if(adc_value >= HOOK_LEVEL_HIGH)
231                                 headset_info->isMic = 1;//have mic
232
233                         if(headset_info->isMic < 0)     
234                         {
235                                 printk("codec is error\n");
236                                 headset_info->heatset_irq_working = WAIT;
237                                 if(pdata->headset_in_type == HEADSET_IN_HIGH)
238                                         irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_LOW|IRQF_ONESHOT);
239                                 else
240                                         irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_HIGH|IRQF_ONESHOT);
241                                 schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(0));     
242                                 wake_unlock(&headset_info->headset_on_wake);
243                                 return IRQ_HANDLED;
244                         }
245                         //adc_value = adc_sync_read(headset_info->client);
246                         printk("headset adc value = %d\n",adc_value);
247                         if(headset_info->isMic) {
248                                 if(adc_value > HOOK_DEFAULT_VAL || adc_value < HOOK_LEVEL_HIGH)
249                                         goto CHECK_AGAIN;
250                                 mod_timer(&headset_info->hook_timer, jiffies + msecs_to_jiffies(1000));
251                         }       
252                         //#endif                
253                         headset_info->cur_headset_status = headset_info->isMic ? BIT_HEADSET:BIT_HEADSET_NO_MIC;
254                 }
255                 else
256                 {
257                         headset_info->isMic= 0;//No microphone
258                         headset_info->cur_headset_status = BIT_HEADSET_NO_MIC;
259                 }
260                 printk("headset->isMic = %d\n",headset_info->isMic);            
261                 if(pdata->headset_in_type == HEADSET_IN_HIGH)
262                         irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING);
263                 else
264                         irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING);
265         }
266         else if(headset_info->headset_status == HEADSET_OUT)
267         {
268                 headset_info->cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
269                 del_timer(&headset_info->hook_timer);
270                 if(headset_info->isMic)
271                 {
272                         headset_info->hook_status = HOOK_UP;
273                         #ifdef CONFIG_SND_SOC_WM8994
274                         //rt5625_headset_mic_detect(false);
275                         wm8994_headset_mic_detect(false);
276                         #endif
277                         #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
278                         rt3261_headset_mic_detect(false);
279                         #endif
280                         #ifdef CONFIG_SND_SOC_RT5631_PHONE
281                         rt5631_headset_mic_detect(false);
282                         #endif                          
283                 }       
284                 if(pdata->headset_in_type == HEADSET_IN_HIGH)
285                         irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING);
286                 else
287                         irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING);                      
288         }       
289
290         rk28_send_wakeup_key();                 
291         switch_set_state(&headset_info->sdev, headset_info->cur_headset_status);        
292         DBG("headset notice android headset status = %d\n",headset_info->cur_headset_status);   
293
294 //      schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(0));
295 out:
296         headset_info->heatset_irq_working = IDLE;
297         wake_unlock(&headset_info->headset_on_wake);
298         return IRQ_HANDLED;
299 }
300
301 static int headset_change_irqtype(int type,unsigned int irq_type)
302 {
303         int ret = 0;
304         free_irq(headset_info->irq[type],NULL);
305
306         DBG("%s: type is %s irqtype is %s\n",__FUNCTION__,      type?"hook":"headset",(irq_type == IRQF_TRIGGER_RISING)?"RISING":"FALLING");
307 //      DBG("%s: type is %s irqtype is %s\n",__FUNCTION__,      type?"hook":"headset",(irq_type == IRQF_TRIGGER_LOW)?"LOW":"HIGH");
308         switch(type)
309         {
310         case HEADSET:
311                 ret = request_threaded_irq(headset_info->irq[type],NULL, headset_interrupt, irq_type, "headset_input", NULL);
312                 if (ret<0) 
313                         DBG("headset_change_irqtype: request irq failed\n");            
314                 break;
315         default:
316                 ret = -1;
317                 break;
318         }
319         return ret;
320 }
321 //2
322 static void headsetobserve_work(struct work_struct *work)
323 {
324         struct rk_headset_pdata *pdata = headset_info->pdata;
325         DBG("In the headsetobserve_work headset_status is %s\n",headset_info->headset_status?"in":"out");
326
327         if(headset_info->heatset_irq_working == WAIT && headset_info->headset_status == HEADSET_IN)
328         {
329                 printk("wait for codec\n");
330                 headset_info->heatset_irq_working = IDLE;
331                 headset_info->headset_status = HEADSET_OUT;     
332                 
333                 free_irq(headset_info->irq[HEADSET],NULL);      
334                 msleep(100);
335                 if(pdata->headset_in_type == HEADSET_IN_HIGH)
336                         headset_info->irq_type[HEADSET] = IRQF_TRIGGER_HIGH|IRQF_ONESHOT;
337                 else
338                         headset_info->irq_type[HEADSET] = IRQF_TRIGGER_LOW|IRQF_ONESHOT;
339                 if(request_threaded_irq(headset_info->irq[HEADSET], NULL,headset_interrupt, headset_info->irq_type[HEADSET]|IRQF_NO_SUSPEND, "headset_input", NULL) < 0)
340                         printk("headset request_threaded_irq error\n");
341                 return; 
342         }
343 /*      
344         if(pdata->headset_in_type == HEADSET_IN_HIGH && headset_info->headset_status == HEADSET_IN)
345                 headset_change_irqtype(HEADSET,IRQF_TRIGGER_FALLING);
346         else if(pdata->headset_in_type == HEADSET_IN_LOW && headset_info->headset_status == HEADSET_IN)
347                 headset_change_irqtype(HEADSET,IRQF_TRIGGER_RISING);
348
349         if(pdata->headset_in_type == HEADSET_IN_HIGH && headset_info->headset_status == HEADSET_OUT)
350                 headset_change_irqtype(HEADSET,IRQF_TRIGGER_RISING);
351         else if(pdata->headset_in_type == HEADSET_IN_LOW && headset_info->headset_status == HEADSET_OUT)
352                 headset_change_irqtype(HEADSET,IRQF_TRIGGER_FALLING);
353 */              
354 }
355 //4
356 static void hook_adc_callback(struct adc_client *client, void *client_param, int result)
357 {
358         int level = result;
359         struct headset_priv *headset = (struct headset_priv *)client_param;
360         struct rk_headset_pdata *pdata = headset->pdata;
361         static unsigned int old_status = HOOK_UP;
362
363 //      DBG("hook_adc_callback read adc value: %d\n",level);
364
365         if(level < 0)
366         {
367                 printk("%s:get adc level err = %d!\n",__FUNCTION__,level);
368                 return;
369         }
370
371         if(headset->headset_status == HEADSET_OUT
372                 || headset->heatset_irq_working == BUSY
373                 || headset->heatset_irq_working == WAIT
374                 || pdata->headset_in_type?gpio_get_value(pdata->Headset_gpio) == 0:gpio_get_value(pdata->Headset_gpio) > 0)
375         {
376                 DBG("Headset is out or waiting for headset is in or out,after same time check HOOK key\n");
377                 return;
378         }       
379         
380         old_status = headset->hook_status;
381         if(level < HOOK_LEVEL_LOW && level >= 0)        
382                 headset->hook_status = HOOK_DOWN;
383         else if(level > HOOK_LEVEL_HIGH && level < HOOK_DEFAULT_VAL)
384                 headset->hook_status = HOOK_UP;
385         else{
386         //      DBG("hook_adc_callback read adc value.........outside showly....: %d\n",level);
387                 del_timer(&headset->hook_timer);
388                 mod_timer(&headset->hook_timer, jiffies + msecs_to_jiffies(50));
389                 return;
390         }
391         
392         if(old_status == headset->hook_status)
393         {
394         //      DBG("Hook adc read old_status == headset->hook_status hook_time = %d\n",headset->hook_time);
395                 return;
396         }       
397         
398         DBG("HOOK status is %s , adc value = %d hook_time = %d\n",headset->hook_status?"down":"up",level,headset->hook_time);   
399         if(headset->headset_status == HEADSET_OUT
400                 || headset->heatset_irq_working == BUSY
401                 || headset->heatset_irq_working == WAIT
402                 || (pdata->headset_in_type?gpio_get_value(pdata->Headset_gpio) == 0:gpio_get_value(pdata->Headset_gpio) > 0))
403                 DBG("headset is out,HOOK status must discard\n");
404         else
405         {
406                 input_report_key(headset->input_dev,pdata->hook_key_code,headset->hook_status);
407                 input_sync(headset->input_dev);
408         }       
409 }
410 //3
411 static void hook_timer_callback(unsigned long arg)
412 {
413         struct headset_priv *headset = (struct headset_priv *)(arg);
414 //      DBG("hook_timer_callback\n");
415         if(headset->headset_status == HEADSET_OUT
416                 || headset->heatset_irq_working == BUSY
417                 || headset->heatset_irq_working == WAIT)
418                 return;
419         adc_async_read(headset->client);
420         mod_timer(&headset->hook_timer, jiffies + msecs_to_jiffies(headset->hook_time));
421 }
422
423 static ssize_t h2w_print_name(struct switch_dev *sdev, char *buf)
424 {
425         return sprintf(buf, "Headset\n");
426 }
427
428 #ifdef CONFIG_HAS_EARLYSUSPEND
429 static void headset_early_resume(struct early_suspend *h)
430 {
431         schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(10));
432         //DBG(">>>>>headset_early_resume\n");
433 }
434
435 static struct early_suspend hs_early_suspend;
436 #endif
437
438 static int rk_Hskey_open(struct input_dev *dev)
439 {
440         //struct rk28_adckey *adckey = input_get_drvdata(dev);
441 //      DBG("===========rk_Hskey_open===========\n");
442         return 0;
443 }
444
445 static void rk_Hskey_close(struct input_dev *dev)
446 {
447 //      DBG("===========rk_Hskey_close===========\n");
448 //      struct rk28_adckey *adckey = input_get_drvdata(dev);
449
450 }
451
452 static int rockchip_headsetobserve_probe(struct platform_device *pdev)
453 {
454         int ret;
455         struct headset_priv *headset;
456         struct rk_headset_pdata *pdata;
457
458         headset = kzalloc(sizeof(struct headset_priv), GFP_KERNEL);
459         if (headset == NULL) {
460                 dev_err(&pdev->dev, "failed to allocate driver data\n");
461                 return -ENOMEM;
462         }
463         headset_info = headset;
464         headset->pdata = pdev->dev.platform_data;
465         pdata = headset->pdata;
466         headset->headset_status = HEADSET_OUT;
467         headset->heatset_irq_working = IDLE;
468         headset->hook_status = HOOK_UP;
469         headset->hook_time = HOOK_ADC_SAMPLE_TIME;
470         headset->cur_headset_status = 0;
471         headset->sdev.name = "h2w";
472         headset->sdev.print_name = h2w_print_name;
473         ret = switch_dev_register(&headset->sdev);
474         if (ret < 0)
475                 goto failed_free;
476         
477 //      mutex_init(&headset->mutex_lock[HEADSET]);
478 //      mutex_init(&headset->mutex_lock[HOOK]);
479         wake_lock_init(&headset->headset_on_wake, WAKE_LOCK_SUSPEND, "headset_on_wake");
480         INIT_DELAYED_WORK(&headset->h_delayed_work[HEADSET], headsetobserve_work);
481
482         headset->isMic = 0;
483 //------------------------------------------------------------------            
484         // Create and register the input driver. 
485         headset->input_dev = input_allocate_device();
486         if (!headset->input_dev) {
487                 dev_err(&pdev->dev, "failed to allocate input device\n");
488                 ret = -ENOMEM;
489                 goto failed_free;
490         }       
491         headset->input_dev->name = pdev->name;
492         headset->input_dev->open = rk_Hskey_open;
493         headset->input_dev->close = rk_Hskey_close;
494         headset->input_dev->dev.parent = &pdev->dev;
495         //input_dev->phys = KEY_PHYS_NAME;
496         headset->input_dev->id.vendor = 0x0001;
497         headset->input_dev->id.product = 0x0001;
498         headset->input_dev->id.version = 0x0100;
499         // Register the input device 
500         ret = input_register_device(headset->input_dev);
501         if (ret) {
502                 dev_err(&pdev->dev, "failed to register input device\n");
503                 goto failed_free_dev;
504         }
505
506         input_set_capability(headset->input_dev, EV_KEY, pdata->hook_key_code);
507 //------------------------------------------------------------------
508         if (pdata->Headset_gpio) {
509                 ret = pdata->headset_io_init(pdata->Headset_gpio, pdata->headset_gpio_info.iomux_name, pdata->headset_gpio_info.iomux_mode);
510                 if (ret) 
511                         goto failed_free;
512
513                 headset->irq[HEADSET] = gpio_to_irq(pdata->Headset_gpio);
514
515                 if(pdata->headset_in_type == HEADSET_IN_HIGH)
516                         headset->irq_type[HEADSET] = IRQF_TRIGGER_HIGH|IRQF_ONESHOT;
517                 else
518                         headset->irq_type[HEADSET] = IRQF_TRIGGER_LOW|IRQF_ONESHOT;
519                 ret = request_threaded_irq(headset->irq[HEADSET], NULL,headset_interrupt, headset->irq_type[HEADSET]|IRQF_NO_SUSPEND, "headset_input", NULL);
520                 if (ret) 
521                         goto failed_free;
522                 enable_irq_wake(headset->irq[HEADSET]);
523         }
524         else
525                 goto failed_free;
526 //------------------------------------------------------------------
527         if(pdata->Hook_adc_chn>=0 && 3>=pdata->Hook_adc_chn)
528         {
529                 headset->client = adc_register(pdata->Hook_adc_chn, hook_adc_callback, (void *)headset);
530                 if(!headset->client) {
531                         printk("hook adc register error\n");
532                         ret = -EINVAL;
533                         goto failed_free;
534                 }
535                 setup_timer(&headset->hook_timer,hook_timer_callback, (unsigned long)headset);  
536                 printk("headset adc default value = %d\n",adc_sync_read(headset->client));
537         }
538         
539 #ifdef CONFIG_HAS_EARLYSUSPEND
540         hs_early_suspend.suspend = NULL;
541         hs_early_suspend.resume = headset_early_resume;
542         hs_early_suspend.level = ~0x0;
543         register_early_suspend(&hs_early_suspend);
544 #endif
545
546         return 0;       
547         
548 failed_free_dev:
549         platform_set_drvdata(pdev, NULL);
550         input_free_device(headset->input_dev);
551 failed_free:
552         dev_err(&pdev->dev, "failed to headset probe\n");
553         kfree(headset);
554         return ret;
555 }
556
557 static int rockchip_headsetobserve_suspend(struct platform_device *pdev, pm_message_t state)
558 {
559         DBG("%s----%d\n",__FUNCTION__,__LINE__);
560 //      disable_irq(headset_info->irq[HEADSET]);
561         del_timer(&headset_info->hook_timer);
562         return 0;
563 }
564
565 static int rockchip_headsetobserve_resume(struct platform_device *pdev)
566 {
567         DBG("%s----%d\n",__FUNCTION__,__LINE__);        
568 //      enable_irq(headset_info->irq[HEADSET]);
569         if(headset_info->isMic)
570                 mod_timer(&headset_info->hook_timer, jiffies + msecs_to_jiffies(1500)); 
571         return 0;
572 }
573
574 static struct platform_driver rockchip_headsetobserve_driver = {
575         .probe  = rockchip_headsetobserve_probe,
576         .resume =       rockchip_headsetobserve_resume, 
577         .suspend =      rockchip_headsetobserve_suspend,        
578         .driver = {
579                 .name   = "rk_headsetdet",
580                 .owner  = THIS_MODULE,
581         },
582 };
583
584 static int __init rockchip_headsetobserve_init(void)
585 {
586         platform_driver_register(&rockchip_headsetobserve_driver);
587         return 0;
588 }
589 late_initcall(rockchip_headsetobserve_init);
590 MODULE_DESCRIPTION("Rockchip Headset Driver");
591 MODULE_LICENSE("GPL");
592