From efd3b084c0fadb4daa8b054b66354db359108342 Mon Sep 17 00:00:00 2001 From: wdc Date: Fri, 11 May 2012 10:37:04 +0800 Subject: [PATCH] Loquate: update bt for bcm4329 --- .../board-rk30-phone-loquat-rfkill.c | 106 +++++------------- 1 file changed, 30 insertions(+), 76 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-phone-loquat-rfkill.c b/arch/arm/mach-rk30/board-rk30-phone-loquat-rfkill.c index 2e2cb2e16bce..2cb64a5bd6b4 100755 --- a/arch/arm/mach-rk30/board-rk30-phone-loquat-rfkill.c +++ b/arch/arm/mach-rk30/board-rk30-phone-loquat-rfkill.c @@ -24,7 +24,6 @@ #include #include #include -#include #if 0 #define DBG(x...) printk(KERN_INFO x) @@ -44,31 +43,20 @@ struct bt_ctrl #endif }; -#ifdef CONFIG_RK903 -#define BT_GPIO_POWER RK30_PIN3_PC7 -#define IOMUX_BT_GPIO_POWER rk29_mux_api_set(GPIO3C7_SDMMC1WRITEPRT_NAME, GPIO3C_GPIO3C7); -#define BT_GPIO_RESET RK30_PIN3_PD1 +#define BT_GPIO_POWER RK30_PIN4_PD5 +#define IOMUX_BT_GPIO_POWER rk29_mux_api_set(GPIO4D5_SMCDATA13_TRACEDATA13_NAME, GPIO4D_GPIO4D5); +#define BT_GPIO_RESET RK30_PIN3_PD1 #define IOMUX_BT_GPIO_RESET rk29_mux_api_set(GPIO3D1_SDMMC1BACKENDPWR_NAME, GPIO3D_GPIO3D1); -#else -#define BT_GPIO_POWER RK30_PIN3_PD1 -#define IOMUX_BT_GPIO_POWER rk29_mux_api_set(GPIO3D1_SDMMC1BACKENDPWR_NAME, GPIO3D_GPIO3D1); -#endif #ifdef CONFIG_BT_HCIBCM4325 #define BT_GPIO_WAKE_UP RK30_PIN3_PC6 -#define IOMUX_BT_GPIO_WAKE_UP() rk29_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_GPIO3C6); #endif #if BT_WAKE_HOST_SUPPORT -#define BT_GPIO_WAKE_UP_HOST RK30_PIN6_PA7 -#define IOMUX_BT_GPIO_WAKE_UP_HOST() +#define BT_GPIO_WAKE_UP_HOST RK30_PIN3_PD2 +#define IOMUX_BT_GPIO_WAKE_UP_HOST() rk29_mux_api_set(GPIO3D2_SDMMC1INTN_NAME, GPIO3D_GPIO3D2); #define BT_WAKE_LOCK_TIMEOUT 10 //s - -//bt cts paired to uart rts -#define UART_RTS RK30_PIN1_PA3 -#define IOMUX_UART_RTS_GPIO rk29_mux_api_set(GPIO1A3_UART0RTSN_NAME, GPIO1A_GPIO1A3); -#define IOMUX_UART_RTS rk29_mux_api_set(GPIO1A3_UART0RTSN_NAME, GPIO1A_UART0_RTS_N); #endif static const char bt_name[] = @@ -83,8 +71,8 @@ static const char bt_name[] = #endif ; -//extern int rk29sdk_bt_power_state; -//extern int rk29sdk_wifi_power_state; +extern int rk29sdk_bt_power_state; +extern int rk29sdk_wifi_power_state; struct bt_ctrl gBtCtrl; @@ -118,46 +106,19 @@ static void timer_hostSleep(unsigned long arg) btWakeupHostUnlock(); } -extern int bcm4325_sleep(int bSleep); #ifdef CONFIG_PM -static void rfkill_do_wakeup(struct work_struct *work) -{ - DBG("Enable UART_RTS\n"); - gpio_set_value(UART_RTS, GPIO_LOW); - IOMUX_UART_RTS; -} - -static DECLARE_DELAYED_WORK(wakeup_work, rfkill_do_wakeup); - static int bcm4329_rfkill_suspend(struct platform_device *pdev, pm_message_t state) -{ - DBG("%s\n",__FUNCTION__); - -#ifdef CONFIG_BT_HCIBCM4325 - bcm4325_sleep(1); -#endif - - DBG("Disable UART_RTS\n"); - //To prevent uart to receive bt data when suspended - IOMUX_UART_RTS_GPIO; - gpio_request(UART_RTS, "uart_rts"); - gpio_set_value(UART_RTS, GPIO_HIGH); - +{ + DBG("%s\n",__FUNCTION__); return 0; } static int bcm4329_rfkill_resume(struct platform_device *pdev) { DBG("%s\n",__FUNCTION__); - -#ifdef CONFIG_BT_HCIBCM4325 - bcm4325_sleep(0); -#endif - - DBG("delay 1s\n"); - schedule_delayed_work(&wakeup_work, HZ); - + btWakeupHostLock(); + resetBtHostSleepTimer(); return 0; } #else @@ -167,8 +128,6 @@ static int bcm4329_rfkill_resume(struct platform_device *pdev) static irqreturn_t bcm4329_wake_host_irq(int irq, void *dev) { - DBG("%s\n",__FUNCTION__); - btWakeupHostLock(); resetBtHostSleepTimer(); return IRQ_HANDLED; @@ -178,11 +137,12 @@ static irqreturn_t bcm4329_wake_host_irq(int irq, void *dev) #ifdef CONFIG_BT_HCIBCM4325 int bcm4325_sleep(int bSleep) { - DBG("************* bt enter sleep: %d ***************\n", bSleep); - //low represent bt device may enter sleep - //high represent bt device must be awake - IOMUX_BT_GPIO_WAKE_UP(); - gpio_set_value(BT_GPIO_WAKE_UP, bSleep?GPIO_LOW:GPIO_HIGH); + printk("*************bt enter sleep***************\n"); + if (bSleep) + gpio_set_value(BT_GPIO_WAKE_UP, GPIO_LOW); //low represent bt device may enter sleep + else + gpio_set_value(BT_GPIO_WAKE_UP, GPIO_HIGH); //high represent bt device must be awake + printk("sleep=%d\n",bSleep); return 0; } #endif @@ -192,42 +152,38 @@ static int bcm4329_set_block(void *data, bool blocked) DBG("%s---blocked :%d\n", __FUNCTION__, blocked); IOMUX_BT_GPIO_POWER; -#ifdef CONFIG_RK903 IOMUX_BT_GPIO_RESET; -#endif if (false == blocked) { gpio_set_value(BT_GPIO_POWER, GPIO_HIGH); /* bt power on */ -#ifdef CONFIG_RK903 - gpio_set_value(BT_GPIO_RESET, GPIO_LOW); - mdelay(20); + + gpio_set_value(BT_GPIO_RESET, GPIO_LOW); + mdelay(20); gpio_set_value(BT_GPIO_RESET, GPIO_HIGH); /* bt reset deactive*/ -#endif mdelay(20); #if BT_WAKE_HOST_SUPPORT -// btWakeupHostLock(); + btWakeupHostLock(); #endif pr_info("bt turn on power\n"); } else { #if BT_WAKE_HOST_SUPPORT -// btWakeupHostUnlock(); + btWakeupHostUnlock(); #endif -// if (!rk29sdk_wifi_power_state) { + if (!rk29sdk_wifi_power_state) { gpio_set_value(BT_GPIO_POWER, GPIO_LOW); /* bt power off */ mdelay(20); pr_info("bt shut off power\n"); -// }else { -// pr_info("bt shouldn't shut off power, wifi is using it!\n"); -// } -#ifdef CONFIG_RK903 + }else { + pr_info("bt shouldn't shut off power, wifi is using it!\n"); + } + gpio_set_value(BT_GPIO_RESET, GPIO_LOW); /* bt reset active*/ mdelay(20); -#endif } -// rk29sdk_bt_power_state = !blocked; + rk29sdk_bt_power_state = !blocked; return 0; } @@ -268,17 +224,15 @@ static int __devinit bcm4329_rfkill_probe(struct platform_device *pdev) } gpio_request(BT_GPIO_POWER, NULL); -#ifdef CONFIG_RK903 gpio_request(BT_GPIO_RESET, NULL); -#endif #ifdef CONFIG_BT_HCIBCM4325 gpio_request(BT_GPIO_WAKE_UP, NULL); #endif #if BT_WAKE_HOST_SUPPORT init_timer(&(gBtCtrl.tl)); - gBtCtrl.tl.expires = 0; - gBtCtrl.tl.function = timer_hostSleep; + gBtCtrl.tl.expires = jiffies + BT_WAKE_LOCK_TIMEOUT*HZ; + gBtCtrl.tl.function = timer_hostSleep; add_timer(&(gBtCtrl.tl)); gBtCtrl.b_HostWake = false; -- 2.34.1