rk_headset: fix compilation error on arm64
[firefly-linux-kernel-4.4.55.git] / drivers / headset_observe / rk_headset.c
index c294446a64017bcf15350c42c6ee74284f732972..1b8a10f88606535b1da2bbdd115ac455ca05e18f 100755 (executable)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/sysdev.h>
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
 #include <linux/err.h>
 #include <linux/hrtimer.h>
 #include <linux/switch.h>
-#include <linux/input.h>
 #include <linux/debugfs.h>
 #include <linux/wakelock.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
 #include <asm/atomic.h>
-#include <asm/mach-types.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/spi/spi.h>
 #include "rk_headset.h"
+#ifdef CONFIG_HAS_EARLYSUSPEND
 #include <linux/earlysuspend.h>
+#endif
 
 /* Debug */
-#if 1
+#if 0
 #define DBG(x...) printk(x)
 #else
 #define DBG(x...) do { } while (0)
 #define BIT_HEADSET             (1 << 0)
 #define BIT_HEADSET_NO_MIC      (1 << 1)
 
-struct rk2818_headset_dev{
-       struct switch_dev sdev;
-       int cur_headset_status; 
-       int pre_headset_status; 
-       struct mutex mutex_lock;
-};
+#define HEADSET 0
+#define HOOK 1
+
+#define HEADSET_IN 1
+#define HEADSET_OUT 0
+#define HOOK_DOWN 1
+#define HOOK_UP 0
+#define enable 1
+#define disable 0
 
-static struct rk2818_headset_dev Headset_dev;
-static struct delayed_work g_headsetobserve_work;
-static struct rk2818_headset_data *prk2818_headset_info;
-#if defined(CONFIG_MACH_BENGO_V2) || defined(CONFIG_MACH_BENGO) || defined(CONFIG_MACH_Z5) || defined(CONFIG_MACH_Z5_V2) || defined(CONFIG_MACH_A22)
-extern void detect_HSMic(void);
+#if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610)
+extern void rk2928_codec_set_spk(bool on);
+#endif
+#ifdef CONFIG_SND_SOC_WM8994
+extern int wm8994_set_status(void);
 #endif
 
-int headset_status(void)
-{          
-       if(Headset_dev.cur_headset_status & BIT_HEADSET)                        
-               return 1;
+/* headset private data */
+struct headset_priv {
+       struct input_dev *input_dev;
+       struct rk_headset_pdata *pdata;
+       unsigned int headset_status:1;
+       unsigned int hook_status:1;
+       unsigned int isMic:1;
+       unsigned int isHook_irq:1;
+       int cur_headset_status; 
+       
+       unsigned int irq[2];
+       unsigned int irq_type[2];
+       struct delayed_work h_delayed_work[2];
+       struct switch_dev sdev;
+       struct mutex mutex_lock[2];     
+       struct timer_list headset_timer;
+       unsigned char *keycodes;
+};
+static struct headset_priv *headset_info;
+
+#ifdef CONFIG_MODEM_MIC_SWITCH
+#define HP_MIC 0
+#define MAIN_MIC 1
+void Modem_Mic_switch(int value)
+{
+       if(value == HP_MIC)
+               gpio_set_value(headset_info->pdata->mic_switch_gpio, headset_info->pdata->hp_mic_io_value);
+       else if(value == MAIN_MIC)
+               gpio_set_value(headset_info->pdata->mic_switch_gpio,headset_info->pdata->main_mic_io_value);
+}
+void Modem_Mic_release(void)
+{
+       if(headset_info->cur_headset_status == 1)
+               gpio_set_value(headset_info->pdata->mic_switch_gpio, headset_info->pdata->hp_mic_io_value);
        else
-               return 0;
+               gpio_set_value(headset_info->pdata->mic_switch_gpio,headset_info->pdata->main_mic_io_value);
 }
+#endif
+
+static int read_gpio(int gpio)
+{
+       int i,level;
+       for(i=0; i<3; i++)
+       {
+               level = gpio_get_value(gpio);
+               if(level < 0)
+               {
+                       printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,gpio,i);
+                       msleep(1);
+                       continue;
+               }
+               else
+               break;
+       }
+       if(level < 0)
+               printk("%s:get pin level  err!\n",__FUNCTION__);
 
-EXPORT_SYMBOL_GPL(headset_status);
+       return level;
+}
 
 static irqreturn_t headset_interrupt(int irq, void *dev_id)
 {
-//     DBG("---headset_interrupt---\n");       
-       schedule_delayed_work(&g_headsetobserve_work, msecs_to_jiffies(20));
+       DBG("---headset_interrupt---\n");       
+       schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(50));
        return IRQ_HANDLED;
 }
 
-static int headset_change_irqtype(unsigned int irq_type)
+static irqreturn_t hook_interrupt(int irq, void *dev_id)
 {
-       int ret = 0;
-//     DBG("--------%s----------\n",__FUNCTION__);
-       free_irq(prk2818_headset_info->irq,NULL);
-       
-       ret = request_irq(prk2818_headset_info->irq, headset_interrupt, irq_type, NULL, NULL);
-       if (ret) 
-       {
-               DBG("headsetobserve: request irq failed\n");
-        return ret;
-       }
-       return ret;
+       DBG("---Hook_interrupt---\n");  
+//     disable_irq_nosync(headset_info->irq[HOOK]);
+       schedule_delayed_work(&headset_info->h_delayed_work[HOOK], msecs_to_jiffies(100));
+       return IRQ_HANDLED;
 }
 
 static void headsetobserve_work(struct work_struct *work)
 {
-       int i,level = 0;
+       int level = 0;
+       int level2 = 0;
+       struct rk_headset_pdata *pdata = headset_info->pdata;
+       static unsigned int old_status = 0;
+       DBG("---headsetobserve_work---\n");
+       mutex_lock(&headset_info->mutex_lock[HEADSET]);
 
-//     DBG("---headsetobserve_work---\n");
-       mutex_lock(&Headset_dev.mutex_lock);
+       level = read_gpio(pdata->headset_gpio);
+       if(level < 0)
+               goto out;
+       msleep(100);    
+       level2 = read_gpio(pdata->headset_gpio);
+       if(level2 < 0)
+               goto out;
+       if(level2 != level)
+               goto out;
+       old_status = headset_info->headset_status;
+       if(pdata->headset_insert_type == HEADSET_IN_HIGH)
+               headset_info->headset_status = level?HEADSET_IN:HEADSET_OUT;
+       else
+               headset_info->headset_status = level?HEADSET_OUT:HEADSET_IN;
 
-       for(i=0; i<3; i++)
+       if(old_status == headset_info->headset_status)  {
+               DBG("old_status == headset_info->headset_status\n");
+               goto out;
+       }
+       
+       DBG("(headset in is %s)headset status is %s\n",
+               pdata->headset_insert_type?"high level":"low level",
+               headset_info->headset_status?"in":"out");
+               
+       if(headset_info->headset_status == HEADSET_IN)
        {
-               level = gpio_get_value(prk2818_headset_info->gpio);
-               if(level < 0)
-               {
-                       printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,prk2818_headset_info->gpio,i);
-                       msleep(1);
-                       continue;
+               headset_info->cur_headset_status = BIT_HEADSET_NO_MIC;
+               if(pdata->headset_insert_type == HEADSET_IN_HIGH)
+                       irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING);
+               else
+                       irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING);
+               if (pdata->hook_gpio) {
+                       del_timer(&headset_info->headset_timer);//Start the timer, wait for switch to the headphone channel
+                       headset_info->headset_timer.expires = jiffies + 100;
+                       add_timer(&headset_info->headset_timer);
+                       goto out;
                }
+       }
+       else if(headset_info->headset_status == HEADSET_OUT)
+       {       
+               headset_info->hook_status = HOOK_UP;
+               if(headset_info->isHook_irq == enable)
+               {
+                       DBG("disable headset_hook irq\n");
+                       headset_info->isHook_irq = disable;
+                       disable_irq(headset_info->irq[HOOK]);           
+               }       
+               headset_info->cur_headset_status = 0;//~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
+               //#if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SOC_RK3028)
+               //rk2928_codec_set_spk(HEADSET_OUT);
+               //#endif                                                
+               if(pdata->headset_insert_type == HEADSET_IN_HIGH)
+                       irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING);
                else
-               break;
+                       irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING);
        }
-       if(level < 0)
+//     rk28_send_wakeup_key();
+       switch_set_state(&headset_info->sdev, headset_info->cur_headset_status);        
+       #if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610)
+       if (headset_info->headset_status == HEADSET_OUT)
        {
-               printk("%s:get pin level  err!\n",__FUNCTION__);
-               return;
+               mdelay(200);
+               rk2928_codec_set_spk(HEADSET_OUT);
+               gpio_set_value(pdata->Sw_mic_gpio, headset_info->pdata->Main_mic_io_value);
+       }
+       #endif
+       DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status);
+
+out:
+       mutex_unlock(&headset_info->mutex_lock[HEADSET]);       
+}
+
+static void hook_work(struct work_struct *work)
+{
+       int level = 0;
+       struct rk_headset_pdata *pdata = headset_info->pdata;
+       static unsigned int old_status = HOOK_UP;
+
+       mutex_lock(&headset_info->mutex_lock[HOOK]);
+       
+       if(headset_info->headset_status == HEADSET_OUT){
+               DBG("Headset is out\n");
+               goto RE_ERROR;
        }
        
-       switch(prk2818_headset_info->headset_in_type)
+       #ifdef CONFIG_SND_SOC_WM8994
+       if(wm8994_set_status() != 0)    {
+               DBG("wm8994 is not set on heatset channel or suspend\n");
+               goto RE_ERROR;
+       }
+       #endif
+       
+       level = read_gpio(pdata->hook_gpio);
+       if(level < 0)
+               goto RE_ERROR;
+       
+       old_status = headset_info->hook_status;
+       DBG("Hook_work -- level = %d\n",level);
+       
+       if(level == 0)
+               headset_info->hook_status = pdata->hook_down_type == HOOK_DOWN_HIGH?HOOK_UP:HOOK_DOWN;
+       else if(level > 0)      
+               headset_info->hook_status = pdata->hook_down_type == HOOK_DOWN_HIGH?HOOK_DOWN:HOOK_UP;
+               
+       if(old_status == headset_info->hook_status)
+       {
+               DBG("old_status == headset_info->hook_status\n");
+               goto RE_ERROR;
+       }       
+       DBG("Hook_work -- level = %d  hook status is %s\n",level,headset_info->hook_status?"key down":"key up");        
+       if(headset_info->hook_status == HOOK_DOWN)
        {
-               case HEADSET_IN_HIGH:
-                       if(level > 0)
-                       {//in--High level
-                               DBG("--- HEADSET_IN_HIGH headset in---\n");
-                               Headset_dev.cur_headset_status = BIT_HEADSET;
-                               headset_change_irqtype(IRQF_TRIGGER_FALLING);//
-                       }
-                       else if(level == 0)
-                       {//out--Low level
-                               DBG("---HEADSET_IN_HIGH headset out---\n");             
-                               Headset_dev.cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
-                               headset_change_irqtype(IRQF_TRIGGER_RISING);//
-                       }
-                       break;
-               case HEADSET_IN_LOW:
-                       if(level == 0)
-                       {//in--High level
-                               DBG("---HEADSET_IN_LOW headset in---\n");
-                               Headset_dev.cur_headset_status = BIT_HEADSET;
-                               headset_change_irqtype(IRQF_TRIGGER_RISING);//
-                       }
-                       else if(level > 0)
-                       {//out--High level
-                               DBG("---HEADSET_IN_LOW headset out---\n");              
-                               Headset_dev.cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
-                               headset_change_irqtype(IRQF_TRIGGER_FALLING);//
-                       }
-                       break;                  
-               default:
-                       DBG("---- ERROR: on headset headset_in_type error -----\n");
-                       break;                  
+               if(pdata->hook_down_type == HOOK_DOWN_HIGH)
+                       irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_FALLING);
+               else
+                       irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_RISING);          
+       }
+       else
+       {
+               if(pdata->hook_down_type == HOOK_DOWN_HIGH)
+                       irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_RISING);
+               else
+                       irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_FALLING);
        }
+       input_report_key(headset_info->input_dev,HOOK_KEY_CODE,headset_info->hook_status);
+       input_sync(headset_info->input_dev);    
+RE_ERROR:
+       mutex_unlock(&headset_info->mutex_lock[HOOK]);
+}
+
+static void headset_timer_callback(unsigned long arg)
+{
+       struct headset_priv *headset = (struct headset_priv *)(arg);
+       struct rk_headset_pdata *pdata = headset->pdata;
+       int level = 0;
+       
+//     printk("headset_timer_callback,headset->headset_status=%d\n",headset->headset_status);  
 
-       if(Headset_dev.cur_headset_status != Headset_dev.pre_headset_status)
+       if(headset->headset_status == HEADSET_OUT)
        {
-               Headset_dev.pre_headset_status = Headset_dev.cur_headset_status;                                        
-               switch_set_state(&Headset_dev.sdev, Headset_dev.cur_headset_status);    
-               DBG("Headset_dev.cur_headset_status = %d\n",Headset_dev.cur_headset_status);
-#if defined(CONFIG_MACH_BENGO_V2) || defined(CONFIG_MACH_BENGO) || defined(CONFIG_MACH_Z5) || defined(CONFIG_MACH_Z5_V2) || defined(CONFIG_MACH_A22)
-               detect_HSMic();
-#endif
+               printk("Headset is out\n");
+               goto out;
+       }
+       #ifdef CONFIG_SND_SOC_WM8994
+       if(wm8994_set_status() != 0)
+       {
+       //      printk("wait wm8994 set the MICB2\n");
+       //      headset_info->headset_timer.expires = jiffies + 500;
+               headset_info->headset_timer.expires = jiffies + 10;
+               add_timer(&headset_info->headset_timer);        
+               goto out;
        }
-       mutex_unlock(&Headset_dev.mutex_lock);  
+       #endif
+       level = read_gpio(pdata->hook_gpio);
+       if(level < 0)
+               goto out;
+       if((level > 0 && pdata->hook_down_type == HOOK_DOWN_LOW)
+               || (level == 0 && pdata->hook_down_type == HOOK_DOWN_HIGH))
+       {
+               headset->isMic = 1;//have mic
+               DBG("enable headset_hook irq\n");
+               enable_irq(headset_info->irq[HOOK]);
+               headset->isHook_irq = enable;
+               headset_info->hook_status = HOOK_UP;
+               if(pdata->hook_down_type == HOOK_DOWN_HIGH)
+                       irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_RISING);
+               else
+                       irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_FALLING);
+
+       }       
+       else    
+               headset->isMic= 0;//No microphone
+               
+       printk("headset->isMic = %d\n",headset->isMic); 
+       headset_info->cur_headset_status = headset_info->isMic ? 1:2;//BIT_HEADSET:BIT_HEADSET_NO_MIC;//
+       #if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610)
+       rk2928_codec_set_spk(HEADSET_IN);
+       if(headset_info->cur_headset_status == 1)
+               gpio_set_value(pdata->Sw_mic_gpio, pdata->Hp_mic_io_value);
+       #endif
+//     rk28_send_wakeup_key();
+       switch_set_state(&headset_info->sdev, headset_info->cur_headset_status);
+       
+       DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status);        
+
+out:
+       return;
 }
 
 static ssize_t h2w_print_name(struct switch_dev *sdev, char *buf)
@@ -174,79 +348,130 @@ static ssize_t h2w_print_name(struct switch_dev *sdev, char *buf)
 #ifdef CONFIG_HAS_EARLYSUSPEND
 static void headset_early_resume(struct early_suspend *h)
 {
-       schedule_delayed_work(&g_headsetobserve_work, msecs_to_jiffies(10));
+       schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(10));
        //DBG(">>>>>headset_early_resume\n");
 }
 
 static struct early_suspend hs_early_suspend;
 #endif
 
-static int rockchip_headsetobserve_probe(struct platform_device *pdev)
+static int rk_hskey_open(struct input_dev *dev)
 {
-       int ret;
+       //struct rk28_adckey *adckey = input_get_drvdata(dev);
+//     DBG("===========rk_Hskey_open===========\n");
+       return 0;
+}
 
-       DBG("RockChip headset observe driver\n");
-       prk2818_headset_info = pdev->dev.platform_data;
-       
-       Headset_dev.cur_headset_status = 0;
-       Headset_dev.pre_headset_status = 0;
-       Headset_dev.sdev.name = "h2w";
-       Headset_dev.sdev.print_name = h2w_print_name;
-       mutex_init(&Headset_dev.mutex_lock);
+static void rk_hskey_close(struct input_dev *dev)
+{
+//     DBG("===========rk_Hskey_close===========\n");
+//     struct rk28_adckey *adckey = input_get_drvdata(dev);
 
-       ret = switch_dev_register(&Headset_dev.sdev);
-       if (ret < 0)
-               return ret;
+}
 
-       INIT_DELAYED_WORK(&g_headsetobserve_work, headsetobserve_work);
-    
-       ret = gpio_request(prk2818_headset_info->gpio, "headset_det");
-       if (ret) 
-       {
-               DBG("headsetobserve: request gpio_request failed\n");
-               return ret;
+int rk_headset_probe(struct platform_device *pdev,struct rk_headset_pdata *pdata)
+{
+       int ret;
+       struct headset_priv *headset;
+       
+       headset = kzalloc(sizeof(struct headset_priv), GFP_KERNEL);
+       if (headset == NULL) {
+               dev_err(&pdev->dev, "failed to allocate driver data\n");
+               return -ENOMEM;
        }
-       gpio_pull_updown(prk2818_headset_info->gpio, PullDisable);
-       gpio_direction_input(prk2818_headset_info->gpio);
-       prk2818_headset_info->irq = gpio_to_irq(prk2818_headset_info->gpio);
 
-       if(prk2818_headset_info->headset_in_type == HEADSET_IN_HIGH)
-               prk2818_headset_info->irq_type = IRQF_TRIGGER_RISING;
-       else
-               prk2818_headset_info->irq_type = IRQF_TRIGGER_FALLING;
-       ret = request_irq(prk2818_headset_info->irq, headset_interrupt, prk2818_headset_info->irq_type, NULL, NULL);
-       if (ret) 
-       {
-               DBG("headsetobserve: request irq failed\n");
-        return ret;
+       headset->pdata = pdata;
+       headset->headset_status = HEADSET_OUT;
+       headset->hook_status = HOOK_UP;
+       headset->isHook_irq = disable;
+       headset->cur_headset_status = 0;
+       headset->sdev.name = "h2w";
+       headset->sdev.print_name = h2w_print_name;
+       ret = switch_dev_register(&headset->sdev);
+       if (ret < 0)
+               goto failed_free;
+       
+       mutex_init(&headset->mutex_lock[HEADSET]);
+       mutex_init(&headset->mutex_lock[HOOK]);
+       
+       INIT_DELAYED_WORK(&headset->h_delayed_work[HEADSET], headsetobserve_work);
+       INIT_DELAYED_WORK(&headset->h_delayed_work[HOOK], hook_work);
+
+       headset->isMic = 0;
+       setup_timer(&headset->headset_timer, headset_timer_callback, (unsigned long)headset);
+//------------------------------------------------------------------   
+       // Create and register the input driver. 
+       headset->input_dev = input_allocate_device();
+       if (!headset->input_dev) {
+               dev_err(&pdev->dev, "failed to allocate input device\n");
+               ret = -ENOMEM;
+               goto failed_free;
+       }       
+       headset->input_dev->name = pdev->name;
+       headset->input_dev->open = rk_hskey_open;
+       headset->input_dev->close = rk_hskey_close;
+       headset->input_dev->dev.parent = &pdev->dev;
+       //input_dev->phys = KEY_PHYS_NAME;
+       headset->input_dev->id.vendor = 0x0001;
+       headset->input_dev->id.product = 0x0001;
+       headset->input_dev->id.version = 0x0100;
+       // Register the input device 
+       ret = input_register_device(headset->input_dev);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to register input device\n");
+               goto failed_free_dev;
        }
+       input_set_capability(headset->input_dev, EV_KEY,HOOK_KEY_CODE);
 
-       schedule_delayed_work(&g_headsetobserve_work, msecs_to_jiffies(500));
-       
 #ifdef CONFIG_HAS_EARLYSUSPEND
-    hs_early_suspend.suspend = NULL;
-    hs_early_suspend.resume = headset_early_resume;
-    hs_early_suspend.level = ~0x0;
-    register_early_suspend(&hs_early_suspend);
+       hs_early_suspend.suspend = NULL;
+       hs_early_suspend.resume = headset_early_resume;
+       hs_early_suspend.level = ~0x0;
+       register_early_suspend(&hs_early_suspend);
 #endif
+       //------------------------------------------------------------------
+       if (pdata->headset_gpio) {
+               if(!pdata->headset_gpio){
+                       dev_err(&pdev->dev,"failed init headset,please full hook_io_init function in board\n");
+                       goto failed_free_dev;
+               }       
+
+               headset->irq[HEADSET] = gpio_to_irq(pdata->headset_gpio);
 
+               if(pdata->headset_insert_type == HEADSET_IN_HIGH)
+                       headset->irq_type[HEADSET] = IRQF_TRIGGER_RISING;
+               else
+                       headset->irq_type[HEADSET] = IRQF_TRIGGER_FALLING;
+               ret = request_irq(headset->irq[HEADSET], headset_interrupt, headset->irq_type[HEADSET], "headset_input", NULL);
+               if (ret) 
+                       goto failed_free_dev;
+               enable_irq_wake(headset->irq[HEADSET]);
+       }
+       else
+               goto failed_free_dev;
+//------------------------------------------------------------------
+       if (pdata->hook_gpio) {
+               headset->irq[HOOK] = gpio_to_irq(pdata->hook_gpio);
+               headset->irq_type[HOOK] = pdata->hook_down_type == HOOK_DOWN_HIGH ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
+                       
+               ret = request_irq(headset->irq[HOOK], hook_interrupt, headset->irq_type[HOOK] , "headset_hook", NULL);
+               if (ret) 
+                       goto failed_free_dev;
+               disable_irq(headset->irq[HOOK]);
+       }
+//------------------------------------------------------------------   
+       headset_info = headset;
+       schedule_delayed_work(&headset->h_delayed_work[HEADSET], msecs_to_jiffies(500));                
        return 0;       
+       
+failed_free_dev:
+       platform_set_drvdata(pdev, NULL);
+       input_free_device(headset->input_dev);
+failed_free:
+       dev_err(&pdev->dev, "failed to headset probe\n");
+       kfree(headset);
+       return ret;
 }
 
-static struct platform_driver rockchip_headsetobserve_driver = {
-       .probe  = rockchip_headsetobserve_probe,
-       .driver = {
-               .name   = "rk2818_headsetdet",
-               .owner  = THIS_MODULE,
-       },
-};
 
 
-static int __init rockchip_headsetobserve_init(void)
-{
-       platform_driver_register(&rockchip_headsetobserve_driver);
-       return 0;
-}
-module_init(rockchip_headsetobserve_init);
-MODULE_DESCRIPTION("Rockchip Headset Driver");
-MODULE_LICENSE("GPL");