+++ /dev/null
-/*\r
- * Copyright (C) 2010 ROCKCHIP, Inc.\r
- * Author: roger_chen <cz@rock-chips.com>\r
- *\r
- * This program is the bluetooth device bcm4325's driver,\r
- *\r
- */\r
-\r
-#include <linux/kernel.h>\r
-#include <linux/platform_device.h>\r
-#include <linux/module.h>\r
-#include <linux/device.h>\r
-#include <linux/rfkill.h>\r
-#include <linux/delay.h>\r
-#include <linux/i2c.h>\r
-#include <linux/init.h>\r
-#include <linux/slab.h>\r
-//#include <asm/gpio.h>\r
-//#include <asm/arch/gpio.h>\r
-//#include <asm/arch/iomux.h>\r
-//#include <asm/arch/gpio.h>\r
-#include <linux/interrupt.h>\r
-#include <linux/wakelock.h>\r
-#include <mach/spi_fpga.h>\r
-#include <linux/fs.h>\r
-#include <asm/uaccess.h>\r
-\r
-#define BT_PWR_ON {spi_gpio_set_pinlevel(SPI_GPIO_P1_06, SPI_GPIO_HIGH); \\r
- spi_gpio_set_pindirection(SPI_GPIO_P1_06, SPI_GPIO_OUT);}\r
-#define BT_PWR_OFF {spi_gpio_set_pinlevel(SPI_GPIO_P1_06, SPI_GPIO_LOW); \\r
- spi_gpio_set_pindirection(SPI_GPIO_P1_06, SPI_GPIO_OUT);}\r
-\r
-#define BT_RESET_HIGH {spi_gpio_set_pinlevel(SPI_GPIO_P1_07, SPI_GPIO_HIGH); \\r
- spi_gpio_set_pindirection(SPI_GPIO_P1_07, SPI_GPIO_OUT);}\r
-#define BT_RESET_LOW {spi_gpio_set_pinlevel(SPI_GPIO_P1_07, SPI_GPIO_LOW); \\r
- spi_gpio_set_pindirection(SPI_GPIO_P1_07, SPI_GPIO_OUT);}\r
-\r
-#define BT_SLEEP_GPIO_IOMUX \r
-#define BT_SLEEP_GPIO_SET_OUT spi_gpio_set_pindirection(SPI_GPIO_P1_08, SPI_GPIO_OUT);\r
-#define BT_WAKEUP //spi_gpio_set_pinlevel(SPI_GPIO_P1_08, SPI_GPIO_HIGH);\r
-#define BT_SLEEP //spi_gpio_set_pinlevel(SPI_GPIO_P1_08, SPI_GPIO_LOW);\r
-\r
-#if 1\r
-#define DBG(x...) printk(KERN_INFO x)\r
-#else\r
-#define DBG(x...)\r
-#endif\r
-\r
-static struct rfkill *bt_rfk;\r
-static const char bt_name[] = "bcm4325";\r
-//extern void rfkill_switch_all(enum rfkill_type type, bool blocked);\r
-\r
- \r
-/*\r
-bSleep:\r
-0: wakeup\r
-1: sleep\r
-*/\r
-int bcm4325_sleep(int bSleep)\r
-{\r
- if(0 == bSleep) /*wake up*/\r
- {\r
- BT_WAKEUP;\r
- }\r
- else /*sleep*/\r
- {\r
- BT_SLEEP;\r
- }\r
- \r
- return 0;\r
-}\r
-\r
-static int bcm4325_set_block(void *data, bool blocked)\r
-{\r
- DBG("%s---blocked :%d\n", __FUNCTION__, blocked);\r
-\r
- if (false == blocked) { \r
- BT_SLEEP_GPIO_IOMUX;\r
- BT_SLEEP_GPIO_SET_OUT;\r
- BT_PWR_ON;\r
- mdelay(2);\r
- BT_RESET_LOW; \r
- mdelay(40);\r
- BT_RESET_HIGH;\r
- mdelay(10);\r
- BT_WAKEUP;\r
- printk("Enter::%s,bluetooth is power on!\n",__FUNCTION__);\r
- }\r
- else {\r
- BT_SLEEP; \r
-// BT_PWR_OFF;\r
- printk("Enter::%s,bluetooth is power off!\n",__FUNCTION__);\r
- }\r
-\r
- return 0;\r
-}\r
-\r
-\r
-static const struct rfkill_ops bcm4325_rfk_ops = {\r
- .set_block = bcm4325_set_block,\r
-};\r
-\r
-static int __init bcm4325_rfkill_probe(struct platform_device *pdev)\r
-{\r
- int rc = 0;\r
- \r
- DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);\r
- \r
- /* default to bluetooth off */\r
-// rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, true);\r
- \r
- bt_rfk = rfkill_alloc(bt_name, \r
- NULL, \r
- RFKILL_TYPE_BLUETOOTH, \r
- &bcm4325_rfk_ops, \r
- NULL);\r
-\r
- if (!bt_rfk)\r
- {\r
- printk("fail to rfkill_allocate************\n");\r
- return -ENOMEM;\r
- }\r
-\r
- \r
- rc = rfkill_register(bt_rfk);\r
- if (rc)\r
- rfkill_destroy(bt_rfk);\r
-\r
- printk("rc=0x%x\n", rc);\r
- \r
- return rc;\r
-}\r
-\r
-\r
-static int __devexit bcm4325_rfkill_remove(struct platform_device *pdev)\r
-{\r
- if (bt_rfk)\r
- rfkill_unregister(bt_rfk);\r
- bt_rfk = NULL;\r
-\r
- platform_set_drvdata(pdev, NULL);\r
- DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);\r
- return 0;\r
-}\r
-\r
-static struct platform_driver bcm4325_rfkill_driver = {\r
- .probe = bcm4325_rfkill_probe,\r
- .remove = __devexit_p(bcm4325_rfkill_remove),\r
- .driver = {\r
- .name = "rkbt_rfkill", //"bcm4325_rfkill",\r
- .owner = THIS_MODULE,\r
- },\r
-};\r
-\r
-/*\r
- * Module initialization\r
- */\r
-static int __init bcm4325_mod_init(void)\r
-{\r
- int ret;\r
- DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);\r
- ret = platform_driver_register(&bcm4325_rfkill_driver);\r
- printk("ret=0x%x\n", ret);\r
- return ret;\r
-}\r
-\r
-static void __exit bcm4325_mod_exit(void)\r
-{\r
- platform_driver_unregister(&bcm4325_rfkill_driver);\r
-}\r
-\r
-module_init(bcm4325_mod_init);\r
-module_exit(bcm4325_mod_exit);\r
-MODULE_DESCRIPTION("bcm4325 Bluetooth driver");\r
-MODULE_AUTHOR("roger_chen cz@rock-chips.com");\r
-MODULE_LICENSE("GPL");\r
-\r