2 * Copyright (C) 2012 ROCKCHIP, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 /* Rock-chips rfkill driver for bluetooth
16 * BT Ô´ÂëÓÉÔÀ´µÄarch/arm/mach-rkxx/board-xxx-rfkill.cÒÆÖÁ´Ë´¦
17 * GPIOµÄÅäÖÃÔÚ arch/arm/mach-rkxx/board-rkxx-sdk.c µÄrfkill_rk_platdata½á¹¹ÌåÖÐ
19 * Çë¸ù¾Ýʵ¼ÊÇé¿öÅäÖúÃÀ¶ÑÀµÄ¸÷¸öGPIOÒý½Å£¬Òý½ÅÅäÖÃ˵Ã÷ÈçÏÂ:
21 .io = -1, // GPIOÖµ£¬ -1 ±íʾÎ޴˹¦ÄÜ
22 .enable = -1, // ʹÄÜ, GPIO_HIGH - ¸ßʹÄÜ£¬ GPIO_LOW - µÍʹÄÜ
24 .name = NULL, // IOMUXÃû³Æ£¬NULL ±íʾËüÊǵ¥¹¦ÄÜ£¬²»ÐèÒªmux
25 .fgpio = -1, // ÅäÖÃΪGPIOʱ£¬Ó¦ÉèÖõÄÖµ
26 .fmux = -1, // ÅäÖÃΪ¸´Óù¦ÄÜʱ£¬Ó¦ÉèÖõÄÖµ
31 #include <linux/kernel.h>
32 #include <linux/platform_device.h>
33 #include <linux/module.h>
34 #include <linux/rfkill.h>
35 #include <linux/init.h>
36 #include <linux/slab.h>
38 #include <mach/iomux.h>
39 #include <linux/delay.h>
40 #include <linux/rfkill-rk.h>
41 #include <linux/wakelock.h>
42 #include <linux/interrupt.h>
44 #include <linux/suspend.h>
45 #include <linux/proc_fs.h>
46 #include <linux/uaccess.h>
49 #define DBG(x...) printk(KERN_INFO "[BT_RFKILL]: "x)
54 #define LOG(x...) printk(KERN_INFO "[BT_RFKILL]: "x)
56 #define BT_WAKEUP_TIMEOUT 10000
57 #define BT_IRQ_WAKELOCK_TIMEOUT 10*1000
59 #define BT_BLOCKED true
60 #define BT_UNBLOCK false
62 #define BT_WAKEUP false
70 #ifdef CONFIG_ARCH_RK29
71 #define rk_mux_api_set(name,mode) rk29_mux_api_set(name,mode)
72 #elif defined (CONFIG_ARCH_RK30)
73 #define rk_mux_api_set(name,mode) rk30_mux_api_set(name,mode)
75 #define rk_mux_api_set(name,mode) rk30_mux_api_set(name,mode)
78 // RK29+BCM4329, ÆäwifiÓëbtµÄpower¿ØÖƽÅÊǽÓÔÚÒ»ÆðµÄ
79 // ÔÚ¸øbtϵçʱ£¬ÐèÒªÏÈÅжÏwifi״̬
80 #if defined(CONFIG_BCM4329)
81 #define WIFI_BT_POWER_TOGGLE 1
82 extern int rk29sdk_bt_power_state;
83 extern int rk29sdk_wifi_power_state;
85 #define WIFI_BT_POWER_TOGGLE 0
88 struct rfkill_rk_data {
89 // Ö¸ÏòboardÖж¨ÒåµÄplatform data
90 struct rfkill_rk_platform_data *pdata;
92 // Ö¸ÏòrfkillÉ豸£¬ËüÓÉrfkill_alloc´´½¨
93 struct rfkill *rfkill_dev;
95 // ÔÚIRQÖжϺ¯ÊýÖÐʹÓã¬È·±£ÔÚBT»½ÐÑAPºó£¬²»»áÁ¢¼´
96 // µ÷ÓÃsuspend½øÈë˯Ãß
97 struct wake_lock bt_irq_wl;
99 // ÔÚ»½ÐÑBTºó£¬Í¨¹ý¸Ãdelay workÑÓʱһ¶Îʱ¼äºó½øÈë˯Ãß
100 // Èç¹ûdelay work»¹Î´Ö´ÐоÍÓÖÀ´Ò»´Î BT wake£¬Ôò»áÏÈcancel
101 // ÒÑÓÐµÄ delay work£¬²¢ÖØмÆʱ¡£
102 struct delayed_work bt_sleep_delay_work;
105 static struct rfkill_rk_data *g_rfkill = NULL;
107 static const char bt_name[] =
108 #if defined (CONFIG_BCM4330)
109 #if defined (CONFIG_BT_MODULE_NH660)
114 #elif defined (CONFIG_RK903)
115 #if defined(CONFIG_RKWIFI_26M)
120 #elif defined(CONFIG_BCM4329)
122 #elif defined(CONFIG_MV8787)
124 #elif defined(CONFIG_AP6210)
125 #if defined(CONFIG_RKWIFI_26M)
130 #elif defined(CONFIG_AP6330)
132 #elif defined(CONFIG_AP6476)
134 #elif defined(CONFIG_AP6493)
136 #elif defined(CONFIG_AP6441)
144 * rfkill_rk_wake_host_irq - BT_WAKE_HOST Öжϻص÷º¯Êý
145 * ÉêÇëÒ»¸öwakelock£¬ÒÔÈ·±£´Ë´Î»½ÐѲ»»áÂíÉϽáÊø
147 static irqreturn_t rfkill_rk_wake_host_irq(int irq, void *dev)
149 struct rfkill_rk_data *rfkill = dev;
150 LOG("BT_WAKE_HOST IRQ fired\n");
152 DBG("BT IRQ wakeup, request %dms wakelock\n", BT_IRQ_WAKELOCK_TIMEOUT);
154 wake_lock_timeout(&rfkill->bt_irq_wl,
155 msecs_to_jiffies(BT_IRQ_WAKELOCK_TIMEOUT));
161 * rfkill_rk_setup_gpio - ÉèÖÃGPIO
162 * gpio - ÒªÉèÖõÄGPIO
163 * mux - iomux ʲô¹¦ÄÜ
164 * prefix,name - ×é³É¸ÃIOµÄÃû³Æ
166 * ·µ»ØÖµÓë gpio_request Ïàͬ
168 static int rfkill_rk_setup_gpio(struct rfkill_rk_gpio* gpio, int mux, const char* prefix, const char* name)
170 if (gpio_is_valid(gpio->io)) {
172 sprintf(gpio->name, "%s_%s", prefix, name);
173 ret = gpio_request(gpio->io, gpio->name);
175 LOG("Failed to get %s gpio.\n", gpio->name);
178 if (gpio->iomux.name)
180 if (mux==IOMUX_FGPIO)
181 rk_mux_api_set(gpio->iomux.name, gpio->iomux.fgpio);
182 else if (mux==IOMUX_FMUX)
183 rk_mux_api_set(gpio->iomux.name, gpio->iomux.fmux);
192 // ÉèÖÃ BT_WAKE_HOST IRQ
193 static int rfkill_rk_setup_wake_irq(struct rfkill_rk_data* rfkill)
196 struct rfkill_rk_irq* irq = &(rfkill->pdata->wake_host_irq);
198 #ifndef CONFIG_BK3515A_COMBO
199 ret = rfkill_rk_setup_gpio(&irq->gpio, IOMUX_FGPIO, rfkill->pdata->name, "wake_host");
203 if (gpio_is_valid(irq->gpio.io))
205 #ifndef CONFIG_BK3515A_COMBO
206 ret = gpio_pull_updown(irq->gpio.io, (irq->gpio.enable==GPIO_LOW)?GPIOPullUp:GPIOPullDown);
209 LOG("Request irq for bt wakeup host\n");
210 irq->irq = gpio_to_irq(irq->gpio.io);
211 sprintf(irq->name, "%s_irq", irq->gpio.name);
212 ret = request_irq(irq->irq,
213 rfkill_rk_wake_host_irq,
214 (irq->gpio.enable==GPIO_LOW)?IRQF_TRIGGER_FALLING:IRQF_TRIGGER_RISING,
218 LOG("** disable irq\n");
219 disable_irq(irq->irq);
220 ret = enable_irq_wake(irq->irq);
227 free_irq(irq->gpio.io, rfkill);
229 gpio_free(irq->gpio.io);
234 static inline void rfkill_rk_sleep_bt_internal(struct rfkill_rk_data *rfkill, bool sleep)
236 struct rfkill_rk_gpio *wake = &rfkill->pdata->wake_gpio;
238 DBG("*** bt sleep: %d ***\n", sleep);
239 #ifndef CONFIG_BK3515A_COMBO
240 gpio_direction_output(wake->io, sleep?!wake->enable:wake->enable);
244 DBG("HOST_UART0_TX pull down 10us\n");
245 if (rfkill_rk_setup_gpio(wake, IOMUX_FGPIO, rfkill->pdata->name, "wake") != 0) {
249 gpio_direction_output(wake->io, wake->enable);
251 gpio_direction_output(wake->io, !wake->enable);
253 rk_mux_api_set(wake->iomux.name, wake->iomux.fmux);
259 static void rfkill_rk_delay_sleep_bt(struct work_struct *work)
261 struct rfkill_rk_data *rfkill = NULL;
262 DBG("Enter %s\n",__FUNCTION__);
264 rfkill = container_of(work, struct rfkill_rk_data, bt_sleep_delay_work.work);
266 rfkill_rk_sleep_bt_internal(rfkill, BT_SLEEP);
270 * rfkill_rk_sleep_bt - Sleep or Wakeup BT
271 * 1 ÔÚ¸øBTÉϵçʱºò£¬µ÷Óøú¯Êý»½ÐÑBT
272 * 2 ÔÚsuspendÇý¶¯Ê±ºò£¬µ÷Óøú¯Êý˯ÃßBT
273 * 3 ÔÚHCIÇý¶¯ÖУ¬µ±ÓÐÃüÁî·¢Ë͸øBTʱ£¬µ÷Óøú¯Êý»½ÐÑBT
275 * ¶ÔÀ¶ÑÀµÄÖ¸Áî·¢ËÍÊÇ·¢ÉúÔÚÀ¶ÑÀÉϵçÖ®ºó£¬Òò´Ë1Óë3²»»áͬʱµ÷Óøú¯Êý
276 * À¶ÑÀÖ¸Áî·¢ËÍÓÉÓû§²ã·¢Æð£¬2Óë3²»»áͬʱµ÷Óøú¯Êý
278 void rfkill_rk_sleep_bt(bool sleep)
280 struct rfkill_rk_data *rfkill = g_rfkill;
281 struct rfkill_rk_gpio *wake;
283 DBG("Enter %s\n",__FUNCTION__);
287 LOG("*** RFKILL is empty???\n");
291 wake = &rfkill->pdata->wake_gpio;
292 if (!gpio_is_valid(wake->io))
294 DBG("*** Not support bt wakeup and sleep\n");
298 // È¡Ïûdelay work£¬Èç¹ûwork´¦ÓÚpendding£¬ÔòÁ¢¼´È¡Ïû
299 // Èç¹ûwork´¦ÓÚrunning£¬ÔòµÈ´ýÖ±µ½¸Ãwork½áÊø
300 ret = cancel_delayed_work_sync(&rfkill->bt_sleep_delay_work);
302 rfkill_rk_sleep_bt_internal(rfkill, sleep);
304 #ifdef CONFIG_BT_AUTOSLEEP
305 if (sleep==BT_WAKEUP)
307 // ÖØÐÂÉèÖÃdelay work
308 schedule_delayed_work(&rfkill->bt_sleep_delay_work,
309 msecs_to_jiffies(BT_WAKEUP_TIMEOUT));
313 EXPORT_SYMBOL(rfkill_rk_sleep_bt);
315 static int rfkill_rk_set_power(void *data, bool blocked)
317 struct rfkill_rk_data *rfkill = data;
318 struct rfkill_rk_gpio *poweron = &rfkill->pdata->poweron_gpio;
319 struct rfkill_rk_gpio *reset = &rfkill->pdata->reset_gpio;
320 struct rfkill_rk_gpio* rts = &rfkill->pdata->rts_gpio;
322 DBG("Enter %s\n", __func__);
324 DBG("Set blocked:%d\n", blocked);
326 if (false == blocked) {
327 rfkill_rk_sleep_bt(BT_WAKEUP); // ensure bt is wakeup
329 if (gpio_is_valid(poweron->io))
331 gpio_direction_output(poweron->io, poweron->enable);
334 if (gpio_is_valid(reset->io))
336 gpio_direction_output(reset->io, reset->enable);
338 gpio_direction_output(reset->io, !reset->enable);
342 #if defined(CONFIG_AP6210)
343 if (gpio_is_valid(rts->io))
347 rk_mux_api_set(rts->iomux.name, rts->iomux.fgpio);
349 LOG("ENABLE UART_RTS\n");
350 gpio_direction_output(rts->io, rts->enable);
354 LOG("DISABLE UART_RTS\n");
355 gpio_direction_output(rts->io, !rts->enable);
358 rk_mux_api_set(rts->iomux.name, rts->iomux.fmux);
363 LOG("bt turn on power\n");
365 #if WIFI_BT_POWER_TOGGLE
366 if (!rk29sdk_wifi_power_state) {
368 if (gpio_is_valid(poweron->io))
370 gpio_direction_output(poweron->io, !poweron->enable);
374 LOG("bt shut off power\n");
375 #if WIFI_BT_POWER_TOGGLE
377 LOG("bt shouldn't shut off power, wifi is using it!\n");
380 if (gpio_is_valid(reset->io))
382 gpio_direction_output(reset->io, reset->enable);/* bt reset active*/
387 #if WIFI_BT_POWER_TOGGLE
388 rk29sdk_bt_power_state = !blocked;
393 static int rfkill_rk_pm_prepare(struct device *dev)
395 struct rfkill_rk_data *rfkill = g_rfkill;
396 struct rfkill_rk_gpio* rts;
397 struct rfkill_rk_irq* wake_host_irq;
398 DBG("Enter %s\n",__FUNCTION__);
403 rts = &rfkill->pdata->rts_gpio;
404 wake_host_irq = &rfkill->pdata->wake_host_irq;
406 //To prevent uart to receive bt data when suspended
407 if (gpio_is_valid(rts->io))
409 DBG("Disable UART_RTS\n");
412 rk_mux_api_set(rts->iomux.name, rts->iomux.fgpio);
414 gpio_direction_output(rts->io, !rts->enable);
417 #ifdef CONFIG_BT_AUTOSLEEP
418 // BT½øÈë˯Ãß״̬£¬²»½ÓÊÕÖ÷¿ØÊý¾Ý
419 rfkill_rk_sleep_bt(BT_SLEEP);
422 /* ÖÁ´Ë£¬À¶ÑÀ²»ÔÙËÍÊý¾Ýµ½UART£¬Ò²²»ÔÙ½ÓÊÕÖ÷¿ØµÄUARTÊý¾Ý
423 * ½Ó×ŵ÷ÓÃenable_irqʹÄÜ bt_wake_host irq£¬µ±Ô¶¶ËÉ豸ÓÐÊý¾Ý
424 * µ½À´Ê±£¬½«Í¨¹ý¸ÃIRQ»½ÐÑÖ÷¿Ø
427 // enable bt wakeup host
428 if (gpio_is_valid(wake_host_irq->gpio.io))
430 #ifdef CONFIG_BK3515A_COMBO
432 ret = rfkill_rk_setup_gpio(&wake_host_irq->gpio, IOMUX_FGPIO, rfkill->pdata->name, "wake_host");
434 LOG("irq rfkill_rk_setup_gpio failed\n");
436 ret = gpio_pull_updown(wake_host_irq->gpio.io, (wake_host_irq->gpio.enable==GPIO_LOW)?GPIOPullUp:GPIOPullDown);
438 LOG("irq gpio_pull_updown failed\n");
440 DBG("enable irq for bt wakeup host\n");
441 enable_irq(wake_host_irq->irq);
444 #ifdef CONFIG_RFKILL_RESET
445 rfkill_set_states(rfkill->rfkill_dev, BT_BLOCKED, false);
446 rfkill_rk_set_power(rfkill, BT_BLOCKED);
452 static void rfkill_rk_pm_complete(struct device *dev)
454 struct rfkill_rk_data *rfkill = g_rfkill;
455 struct rfkill_rk_irq* wake_host_irq;
456 struct rfkill_rk_gpio* rts;
457 DBG("Enter %s\n",__FUNCTION__);
462 wake_host_irq = &rfkill->pdata->wake_host_irq;
463 rts = &rfkill->pdata->rts_gpio;
465 if (gpio_is_valid(wake_host_irq->gpio.io))
467 // ½ûÓõô BT_WAKE_HOST IRQ£¬È·±£ÔÚϵͳ»½ÐѺ󲻻áÒòBTµÄ²Ù×÷
469 LOG("** disable irq\n");
470 disable_irq(wake_host_irq->irq);
471 #ifdef CONFIG_BK3515A_COMBO
472 rk_mux_api_set(wake_host_irq->gpio.iomux.name, wake_host_irq->gpio.iomux.fmux);
473 gpio_free(wake_host_irq->gpio.io);
477 /* ʹÓÃUART_RTS£¬´ËʱÀ¶ÑÀÈç¹ûÓÐÊý¾Ý¾Í»áË͵½UART
478 * Éϲã·ÖÎöËÍÀ´µÄÊý¾Ý²¢×ö³öÏàÓ¦µÄ¶¯×÷£¬±ÈÈç: ËÍÀ´µÄÊÇ
479 * Åä¶ÔÇëÇó£¬ÔòÉϲ㽫»áÁÁÆÁ²¢µ¯³öÅä¶Ô½çÃæ
481 if (gpio_is_valid(rts->io))
483 DBG("Enable UART_RTS\n");
484 gpio_direction_output(rts->io, rts->enable);
487 rk_mux_api_set(rts->iomux.name, rts->iomux.fmux);
492 static const struct rfkill_ops rfkill_rk_ops = {
493 .set_block = rfkill_rk_set_power,
496 #define PROC_DIR "bluetooth/sleep"
498 static struct proc_dir_entry *bluetooth_dir, *sleep_dir;
500 static int bluesleep_read_proc_lpm(char *page, char **start, off_t offset,
501 int count, int *eof, void *data)
504 return sprintf(page, "unsupported to read\n");
507 static int bluesleep_write_proc_lpm(struct file *file, const char *buffer,
508 unsigned long count, void *data)
513 static int bluesleep_read_proc_btwrite(char *page, char **start, off_t offset,
514 int count, int *eof, void *data)
517 return sprintf(page, "unsupported to read\n");
520 static int bluesleep_write_proc_btwrite(struct file *file, const char *buffer,
521 unsigned long count, void *data)
528 if (copy_from_user(&b, buffer, 1))
531 DBG("btwrite %c\n", b);
534 rfkill_rk_sleep_bt(BT_WAKEUP);
540 static int rfkill_rk_probe(struct platform_device *pdev)
542 struct rfkill_rk_data *rfkill;
543 struct rfkill_rk_platform_data *pdata = pdev->dev.platform_data;
545 struct proc_dir_entry *ent;
547 DBG("Enter %s\n", __func__);
550 LOG("%s: No platform data specified\n", __func__);
554 pdata->name = (char*)bt_name;
556 rfkill = kzalloc(sizeof(*rfkill), GFP_KERNEL);
560 rfkill->pdata = pdata;
563 bluetooth_dir = proc_mkdir("bluetooth", NULL);
564 if (bluetooth_dir == NULL) {
565 LOG("Unable to create /proc/bluetooth directory");
569 sleep_dir = proc_mkdir("sleep", bluetooth_dir);
570 if (sleep_dir == NULL) {
571 LOG("Unable to create /proc/%s directory", PROC_DIR);
575 /* read/write proc entries */
576 ent = create_proc_entry("lpm", 0, sleep_dir);
578 LOG("Unable to create /proc/%s/lpm entry", PROC_DIR);
582 ent->read_proc = bluesleep_read_proc_lpm;
583 ent->write_proc = bluesleep_write_proc_lpm;
585 /* read/write proc entries */
586 ent = create_proc_entry("btwrite", 0, sleep_dir);
588 LOG("Unable to create /proc/%s/btwrite entry", PROC_DIR);
592 ent->read_proc = bluesleep_read_proc_btwrite;
593 ent->write_proc = bluesleep_write_proc_btwrite;
597 // ¶ÔÓÚRK29 BCM4329£¬ËüµÄpoweron ioÓëwifi¹²Óã¬ÔÚboadÎļþÖÐÒѾrequest
599 #if !WIFI_BT_POWER_TOGGLE
600 ret = rfkill_rk_setup_gpio(&pdata->poweron_gpio, IOMUX_FGPIO, pdata->name, "poweron");
601 if (ret) goto fail_alloc;
604 ret = rfkill_rk_setup_gpio(&pdata->reset_gpio, IOMUX_FGPIO, pdata->name, "reset");
605 if (ret) goto fail_poweron;
607 #ifndef CONFIG_BK3515A_COMBO
608 ret = rfkill_rk_setup_gpio(&pdata->wake_gpio, IOMUX_FGPIO, pdata->name, "wake");
609 if (ret) goto fail_reset;
612 ret = rfkill_rk_setup_wake_irq(rfkill);
613 if (ret) goto fail_wake;
615 ret = rfkill_rk_setup_gpio(&pdata->rts_gpio, IOMUX_FMUX, rfkill->pdata->name, "rts");
616 if (ret) goto fail_wake_host_irq;
618 // ´´½¨²¢×¢²áRFKILLÉ豸
619 DBG("setup rfkill\n");
620 rfkill->rfkill_dev = rfkill_alloc(pdata->name, &pdev->dev, pdata->type,
621 &rfkill_rk_ops, rfkill);
622 if (!rfkill->rfkill_dev)
625 // cmy: ÉèÖÃrfkill³õʼ״̬Ϊblocked£¬ÔÚ×¢²áʱ²»»áµ÷Óà set_blockedº¯Êý
626 rfkill_set_states(rfkill->rfkill_dev, BT_BLOCKED, false);
627 ret = rfkill_register(rfkill->rfkill_dev);
631 wake_lock_init(&(rfkill->bt_irq_wl), WAKE_LOCK_SUSPEND, "rfkill_rk_irq_wl");
632 INIT_DELAYED_WORK(&rfkill->bt_sleep_delay_work, rfkill_rk_delay_sleep_bt);
634 // cmy: ÉèÖÃÀ¶ÑÀµçÔ´µÄ״̬Ϊ blocked
635 rfkill_rk_set_power(rfkill, BT_BLOCKED);
637 platform_set_drvdata(pdev, rfkill);
639 LOG("%s device registered.\n", pdata->name);
644 rfkill_destroy(rfkill->rfkill_dev);
646 if (gpio_is_valid(pdata->rts_gpio.io))
647 gpio_free(pdata->rts_gpio.io);
649 if (gpio_is_valid(pdata->wake_host_irq.gpio.io)){
650 free_irq(pdata->wake_host_irq.irq, rfkill);
651 #ifndef CONFIG_BK3515A_COMBO
652 gpio_free(pdata->wake_host_irq.gpio.io);
656 #ifndef CONFIG_BK3515A_COMBO
657 if (gpio_is_valid(pdata->wake_gpio.io))
658 gpio_free(pdata->wake_gpio.io);
661 if (gpio_is_valid(pdata->reset_gpio.io))
662 gpio_free(pdata->reset_gpio.io);
664 #if !WIFI_BT_POWER_TOGGLE
665 if (gpio_is_valid(pdata->poweron_gpio.io))
666 gpio_free(pdata->poweron_gpio.io);
672 remove_proc_entry("btwrite", sleep_dir);
673 remove_proc_entry("lpm", sleep_dir);
678 static int rfkill_rk_remove(struct platform_device *pdev)
680 struct rfkill_rk_data *rfkill = platform_get_drvdata(pdev);
682 LOG("Enter %s\n", __func__);
684 rfkill_unregister(rfkill->rfkill_dev);
685 rfkill_destroy(rfkill->rfkill_dev);
687 wake_lock_destroy(&rfkill->bt_irq_wl);
689 cancel_delayed_work_sync(&rfkill->bt_sleep_delay_work);
692 if (gpio_is_valid(rfkill->pdata->rts_gpio.io))
693 gpio_free(rfkill->pdata->rts_gpio.io);
695 if (gpio_is_valid(rfkill->pdata->wake_host_irq.gpio.io)){
696 free_irq(rfkill->pdata->wake_host_irq.irq, rfkill);
697 #ifndef CONFIG_BK3515A_COMBO
698 gpio_free(rfkill->pdata->wake_host_irq.gpio.io);
702 #ifndef CONFIG_BK3515A_COMBO
703 if (gpio_is_valid(rfkill->pdata->wake_gpio.io))
704 gpio_free(rfkill->pdata->wake_gpio.io);
707 if (gpio_is_valid(rfkill->pdata->reset_gpio.io))
708 gpio_free(rfkill->pdata->reset_gpio.io);
710 if (gpio_is_valid(rfkill->pdata->poweron_gpio.io))
711 gpio_free(rfkill->pdata->poweron_gpio.io);
719 static const struct dev_pm_ops rfkill_rk_pm_ops = {
720 .prepare = rfkill_rk_pm_prepare,
721 .complete = rfkill_rk_pm_complete,
724 static struct platform_driver rfkill_rk_driver = {
725 .probe = rfkill_rk_probe,
726 .remove = __devexit_p(rfkill_rk_remove),
729 .owner = THIS_MODULE,
730 .pm = &rfkill_rk_pm_ops,
734 static int __init rfkill_rk_init(void)
736 LOG("Enter %s\n", __func__);
737 return platform_driver_register(&rfkill_rk_driver);
740 static void __exit rfkill_rk_exit(void)
742 LOG("Enter %s\n", __func__);
743 platform_driver_unregister(&rfkill_rk_driver);
746 module_init(rfkill_rk_init);
747 module_exit(rfkill_rk_exit);
749 MODULE_DESCRIPTION("rock-chips rfkill for Bluetooth v0.2");
750 MODULE_AUTHOR("cmy@rock-chips.com, cz@rock-chips.com");
751 MODULE_LICENSE("GPL");