From 8f546c3213b233667d588b65ff1c5e29c4dd30b5 Mon Sep 17 00:00:00 2001 From: hwg Date: Tue, 18 Jun 2013 20:15:17 +0800 Subject: [PATCH] mt6622 driver update to support 4.2 --- drivers/mtk_wcn_bt/bt_eirq_handler.c | 16 +++++++------ drivers/mtk_wcn_bt/bt_hwctl_dev.c | 18 +++++++-------- drivers/mtk_wcn_bt/bt_plat_smdk.c | 34 +++++++++++++++++----------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/drivers/mtk_wcn_bt/bt_eirq_handler.c b/drivers/mtk_wcn_bt/bt_eirq_handler.c index 4beca42a009e..e419fb0d613a 100755 --- a/drivers/mtk_wcn_bt/bt_eirq_handler.c +++ b/drivers/mtk_wcn_bt/bt_eirq_handler.c @@ -42,8 +42,7 @@ extern wait_queue_head_t eint_wait; extern int eint_gen; -extern struct work_struct mtk_wcn_bt_event_work; -extern struct workqueue_struct *mtk_wcn_bt_workqueue; +extern int eint_handle_method; // 0: for 4.1; 1: for 4.2 irqreturn_t mt_bt_eirq_handler(int i, void *arg) { @@ -52,7 +51,8 @@ irqreturn_t mt_bt_eirq_handler(int i, void *arg) //printk(KERN_ALERT "mt_bt_eirq_handler\n"); mt_bt_disable_irq(); -#ifdef CONFIG_BT_HCIUART +if(eint_handle_method == 0) { +//#ifdef CONFIG_BT_HCIUART /* BlueZ stack, hci_uart driver */ hdev = hci_dev_get(0); if(hdev == NULL){ @@ -60,17 +60,19 @@ irqreturn_t mt_bt_eirq_handler(int i, void *arg) //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 */ } -#else + mt_bt_enable_irq(); +} else { +//#else /* 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 +//#endif +} - mt_bt_enable_irq(); return IRQ_HANDLED; } diff --git a/drivers/mtk_wcn_bt/bt_hwctl_dev.c b/drivers/mtk_wcn_bt/bt_hwctl_dev.c index 8e3c9f2dfd70..479cc5f51e35 100755 --- a/drivers/mtk_wcn_bt/bt_hwctl_dev.c +++ b/drivers/mtk_wcn_bt/bt_hwctl_dev.c @@ -84,8 +84,7 @@ wait_queue_head_t eint_wait; int eint_gen; int eint_mask; -struct work_struct mtk_wcn_bt_event_work; -struct workqueue_struct *mtk_wcn_bt_workqueue; +int eint_handle_method = 0; // 0: for 4.1; 1: for 4.2 struct bt_hwctl { bool powerup; @@ -195,7 +194,9 @@ static int bt_hwctl_release(struct inode *inode, struct file *file) static unsigned int bt_hwctl_poll(struct file *file, poll_table *wait) { uint32_t mask = 0; - + + eint_handle_method = 1; + BT_HWCTL_DEBUG("bt_hwctl_poll eint_gen %d, eint_mask %d ++\n", eint_gen, eint_mask); //poll_wait(file, &eint_wait, wait); wait_event_interruptible(eint_wait, (eint_gen == 1 || eint_mask == 1)); @@ -309,8 +310,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, @@ -412,9 +413,6 @@ static void __exit bt_hwctl_exit(void) bh = NULL; } - cancel_work_sync(&mtk_wcn_bt_event_work); - destroy_workqueue(mtk_wcn_bt_workqueue); - /* release gpio used by BT */ //mt_bt_gpio_release(); } @@ -422,8 +420,8 @@ static void __exit bt_hwctl_exit(void) EXPORT_SYMBOL(mt_bt_get_platform_data); EXPORT_SYMBOL(eint_wait); EXPORT_SYMBOL(eint_gen); -EXPORT_SYMBOL(mtk_wcn_bt_event_work); -EXPORT_SYMBOL(mtk_wcn_bt_workqueue); +//EXPORT_SYMBOL(mtk_wcn_bt_event_work); +//EXPORT_SYMBOL(mtk_wcn_bt_workqueue); module_init(bt_hwctl_init); module_exit(bt_hwctl_exit); diff --git a/drivers/mtk_wcn_bt/bt_plat_smdk.c b/drivers/mtk_wcn_bt/bt_plat_smdk.c index 9df7ccb4d9f6..fecb1200292f 100755 --- a/drivers/mtk_wcn_bt/bt_plat_smdk.c +++ b/drivers/mtk_wcn_bt/bt_plat_smdk.c @@ -61,6 +61,11 @@ static int irq_num = -1; #define rk_mux_api_set(name,mode) rk30_mux_api_set(name,mode) #endif +static int irq_num; +// to avoid irq enable and disable not match +static unsigned int irq_mask; +//static spinlock_t bt_irq_lock; + /**************************************************************************** * I R Q F U N C T I O N S * *****************************************************************************/ @@ -70,6 +75,7 @@ static int mt_bt_request_irq(void) int trigger = IRQF_TRIGGER_RISING; struct mt6622_platform_data *pdata = (struct mt6622_platform_data *)mt_bt_get_platform_data(); + irq_mask = 0; if(pdata->irq_gpio.enable == GPIO_LOW) trigger = IRQF_TRIGGER_FALLING; @@ -89,10 +95,10 @@ static int mt_bt_request_irq(void) static void mt_bt_free_irq(void) { - if(irq_num != -1) { + if(irq_num != -1) free_irq(irq_num, NULL); - irq_num = -1; - } + irq_mask = 0; + irq_num = -1; } int mt6622_suspend(struct platform_device *pdev, pm_message_t state) @@ -115,8 +121,8 @@ int mt6622_resume(struct platform_device *pdev) void mt_bt_enable_irq(void) { - if(irq_num != -1) { - //printk("mt_bt_enable_irq\n"); + if (irq_mask){ + irq_mask = 0; enable_irq(irq_num); } } @@ -124,10 +130,10 @@ EXPORT_SYMBOL(mt_bt_enable_irq); void mt_bt_disable_irq(void) { - if(irq_num != -1) { - //printk("mt_bt_disable_irq\n"); + if (!irq_mask){ + irq_mask = 1; disable_irq_nosync(irq_num); - } + } } EXPORT_SYMBOL(mt_bt_disable_irq); @@ -162,7 +168,7 @@ int mt_bt_power_init(void) if(pdata->reset_gpio.io != INVALID_GPIO) gpio_direction_output(pdata->reset_gpio.io, 1); msleep(1000); - + //pdata->power_gpio.io = INVALID_GPIO; pdata->reset_gpio.io = INVALID_GPIO; } @@ -204,6 +210,12 @@ int mt_bt_power_on(void) // 32k CLK //mt_set_gpio_mode(GPIO_BT_CLK_PIN , GPIO_BT_CLK_PIN_M_CLK); //mt_set_clock_output(GPIO_BT_CLK_PIN_CLK, CLK_SRC_F32K, 1); + + if(gpio_is_valid(pdata->rts_gpio.io)) { + printk(KERN_INFO MODULE_TAG "mt_bt_power_on rts iomux\n"); + rk_mux_api_set(pdata->rts_gpio.iomux.name, pdata->rts_gpio.iomux.fgpio); + gpio_direction_output(pdata->rts_gpio.io, 0); + } // PWR_EN and RESET /* PWR_EN set to gpio output low */ @@ -224,10 +236,6 @@ int mt_bt_power_on(void) msleep(1000); if(gpio_is_valid(pdata->rts_gpio.io)) { - printk(KERN_INFO MODULE_TAG "mt_bt_power_on rts iomux\n"); - rk_mux_api_set(pdata->rts_gpio.iomux.name, pdata->rts_gpio.iomux.fgpio); - gpio_direction_output(pdata->rts_gpio.io, 0); - msleep(100); rk_mux_api_set(pdata->rts_gpio.iomux.name, pdata->rts_gpio.iomux.fmux); } -- 2.34.1