mt6622: support wake up host
authorhwg <hwg@rock-chips.com>
Wed, 3 Jul 2013 09:08:35 +0000 (17:08 +0800)
committerhwg <hwg@rock-chips.com>
Wed, 3 Jul 2013 09:08:35 +0000 (17:08 +0800)
drivers/mtk_wcn_bt/bt_eirq_handler.c
drivers/mtk_wcn_bt/bt_hwctl.h
drivers/mtk_wcn_bt/bt_hwctl_dev.c
drivers/mtk_wcn_bt/bt_plat_smdk.c

index e419fb0d613ad971f9aeaa24fa4bca4222d415ac..e0d8d662da14b93a7d06599760d48d2e569ef386 100755 (executable)
@@ -60,7 +60,7 @@ if(eint_handle_method == 0) {
         //BT_HWCTL_ALERT("hdev is NULL\n");
     }else{
         //BT_HWCTL_ALERT("EINT arrives! notify host wakeup\n");
-        printk("Send host wakeup command\n");
+        //printk("Send host wakeup command\n");
         hci_send_cmd(hdev, 0xFCC1, 0, NULL);
         /* enable irq after receiving host wakeup command's event */
     }
@@ -70,6 +70,7 @@ if(eint_handle_method == 0) {
     /* Maybe handle the interrupt in user space? */
     eint_gen = 1;
     wake_up_interruptible(&eint_wait);
+
     /* Send host wakeup command in user space, enable irq then */
 //#endif
 }
index e1fa8143280a35f81f2d1254b5fce54ed7f35c34..6f6dbb35847fce7d3c11e9693c62ba170f058361 100755 (executable)
@@ -41,6 +41,7 @@
 #include <linux/types.h>
 #include <linux/irq.h>
 #include <linux/rfkill-rk.h>
+#include <linux/wakelock.h>
 
 struct gpio_set {
        unsigned int gpio;
index 479cc5f51e35be323279c2fcff15158294cff00d..10ff73a1d1daf44231dec37e6226fb7123684c39 100755 (executable)
@@ -85,6 +85,8 @@ wait_queue_head_t eint_wait;
 int eint_gen;
 int eint_mask;
 int eint_handle_method = 0; // 0: for 4.1; 1: for 4.2 
+struct wake_lock mt6622_irq_wakelock;
+int mt6622_suspend_flag;
 
 struct bt_hwctl {
     bool powerup;
@@ -202,6 +204,12 @@ static unsigned int bt_hwctl_poll(struct file *file, poll_table *wait)
     wait_event_interruptible(eint_wait, (eint_gen == 1 || eint_mask == 1));
     BT_HWCTL_DEBUG("bt_hwctl_poll eint_gen %d, eint_mask %d --\n", eint_gen, eint_mask);
     
+    if(mt6622_suspend_flag == 1) {
+       printk("mt6622 wake lock 5000ms\n");
+        mt6622_suspend_flag = 0;
+        wake_lock_timeout(&mt6622_irq_wakelock, msecs_to_jiffies(5000));
+    }
+    
     if(eint_gen == 1){
         mask = POLLIN|POLLRDNORM;
         eint_gen = 0;
@@ -310,8 +318,8 @@ static struct file_operations bt_hwctl_fops = {
 static struct platform_driver mt6622_driver = {
     .probe = mt6622_probe,
     .remove = mt6622_remove,
-    //.suspend = mt6622_suspend,
-    //.resume = mt6622_resume,
+    .suspend = mt6622_suspend,
+    .resume = mt6622_resume,
     .driver = {
         .name = "mt6622",
         .owner = THIS_MODULE,
@@ -365,6 +373,8 @@ static int __init bt_hwctl_init(void)
     
     init_waitqueue_head(&eint_wait);
     
+    wake_lock_init(&mt6622_irq_wakelock, WAKE_LOCK_SUSPEND, "mt6622_irq_wakelock");
+    
     /*INIT_WORK(&mtk_wcn_bt_event_work, mtk_wcn_bt_work_fun);
     mtk_wcn_bt_workqueue = create_singlethread_workqueue("mtk_wcn_bt");
     if (!mtk_wcn_bt_workqueue) {
@@ -398,6 +408,8 @@ static void __exit bt_hwctl_exit(void)
 {
     BT_HWCTL_DEBUG("bt_hwctl_exit\n");
     
+    wake_lock_destroy(&mt6622_irq_wakelock);
+    
     platform_driver_unregister(&mt6622_driver);
     
     if (bh){
index fecb1200292f442678fa9fcc7ebf062e6573779a..eb928d16cf713193b1c391f2cc93647b6de0425e 100755 (executable)
@@ -46,6 +46,8 @@
 \r
 #include "bt_hwctl.h"\r
 \r
+extern int mt6622_suspend_flag;\r
+\r
 /****************************************************************************\r
  *                           C O N S T A N T S                              *\r
 *****************************************************************************/\r
@@ -105,6 +107,7 @@ int mt6622_suspend(struct platform_device *pdev, pm_message_t state)
 {\r
     if(irq_num != -1) {\r
         printk(KERN_INFO MODULE_TAG "mt6622_suspend\n");\r
+        mt6622_suspend_flag = 1;\r
         enable_irq_wake(irq_num);\r
     }\r
        return 0;\r