#include <mach/iomux.h>
#include <linux/wakelock.h>
#include <linux/timer.h>
-#include <mach/board.h>
#if 0
#define DBG(x...) printk(KERN_INFO x)
#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[] =
#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;
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
static irqreturn_t bcm4329_wake_host_irq(int irq, void *dev)
{
- DBG("%s\n",__FUNCTION__);
-
btWakeupHostLock();
resetBtHostSleepTimer();
return IRQ_HANDLED;
#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
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;
}
}
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;