From ef499194986eee715c3a84d86f96ce650323a083 Mon Sep 17 00:00:00 2001 From: hwg Date: Wed, 3 Jul 2013 17:08:35 +0800 Subject: [PATCH] mt6622: support wake up host --- drivers/mtk_wcn_bt/bt_eirq_handler.c | 3 ++- drivers/mtk_wcn_bt/bt_hwctl.h | 1 + drivers/mtk_wcn_bt/bt_hwctl_dev.c | 16 ++++++++++++++-- drivers/mtk_wcn_bt/bt_plat_smdk.c | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/mtk_wcn_bt/bt_eirq_handler.c b/drivers/mtk_wcn_bt/bt_eirq_handler.c index e419fb0d613a..e0d8d662da14 100755 --- a/drivers/mtk_wcn_bt/bt_eirq_handler.c +++ b/drivers/mtk_wcn_bt/bt_eirq_handler.c @@ -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 } diff --git a/drivers/mtk_wcn_bt/bt_hwctl.h b/drivers/mtk_wcn_bt/bt_hwctl.h index e1fa8143280a..6f6dbb35847f 100755 --- a/drivers/mtk_wcn_bt/bt_hwctl.h +++ b/drivers/mtk_wcn_bt/bt_hwctl.h @@ -41,6 +41,7 @@ #include #include #include +#include struct gpio_set { unsigned int gpio; diff --git a/drivers/mtk_wcn_bt/bt_hwctl_dev.c b/drivers/mtk_wcn_bt/bt_hwctl_dev.c index 479cc5f51e35..10ff73a1d1da 100755 --- a/drivers/mtk_wcn_bt/bt_hwctl_dev.c +++ b/drivers/mtk_wcn_bt/bt_hwctl_dev.c @@ -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){ diff --git a/drivers/mtk_wcn_bt/bt_plat_smdk.c b/drivers/mtk_wcn_bt/bt_plat_smdk.c index fecb1200292f..eb928d16cf71 100755 --- a/drivers/mtk_wcn_bt/bt_plat_smdk.c +++ b/drivers/mtk_wcn_bt/bt_plat_smdk.c @@ -46,6 +46,8 @@ #include "bt_hwctl.h" +extern int mt6622_suspend_flag; + /**************************************************************************** * C O N S T A N T S * *****************************************************************************/ @@ -105,6 +107,7 @@ int mt6622_suspend(struct platform_device *pdev, pm_message_t state) { if(irq_num != -1) { printk(KERN_INFO MODULE_TAG "mt6622_suspend\n"); + mt6622_suspend_flag = 1; enable_irq_wake(irq_num); } return 0; -- 2.34.1