Merge tag 'lsk-android-14.02' into develop-3.10
[firefly-linux-kernel-4.4.55.git] / net / rfkill / rfkill-bt.c
1 /*
2  * Copyright (C) 2012 ROCKCHIP, Inc.
3  *
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.
7  *
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.
12  *
13  */
14 /* Rock-chips rfkill driver for bluetooth
15  *
16 */
17
18 #include <linux/kernel.h>
19 #include <linux/platform_device.h>
20 #include <linux/module.h>
21 #include <linux/rfkill.h>
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <asm/gpio.h>
25 #include <linux/delay.h>
26 #include <linux/rfkill-bt.h>
27 #include <linux/wakelock.h>
28 #include <linux/interrupt.h>
29 #include <asm/irq.h>
30 #include <linux/suspend.h>
31 #include <linux/proc_fs.h>
32 #include <linux/uaccess.h>
33 #include <linux/gpio.h>
34 #include <dt-bindings/gpio/gpio.h>
35 #include <uapi/linux/rfkill.h>
36 #ifdef CONFIG_OF
37 #include <linux/of.h>
38 #include <linux/of_device.h>
39 #include <linux/of_gpio.h>
40 #endif
41
42 #if 0
43 #define DBG(x...)   printk(KERN_INFO "[BT_RFKILL]: "x)
44 #else
45 #define DBG(x...)
46 #endif
47
48 #define LOG(x...)   printk(KERN_INFO "[BT_RFKILL]: "x)
49
50 #define BT_WAKEUP_TIMEOUT           10000
51 #define BT_IRQ_WAKELOCK_TIMEOUT     10*1000
52
53 #define BT_BLOCKED     true
54 #define BT_UNBLOCK     false
55 #define BT_SLEEP       true
56 #define BT_WAKEUP      false
57
58 enum {
59     IOMUX_FNORMAL=0,
60     IOMUX_FGPIO,
61     IOMUX_FMUX,
62 };
63
64 struct rfkill_rk_data {
65         struct rfkill_rk_platform_data  *pdata;
66     struct platform_device      *pdev;
67         struct rfkill                           *rfkill_dev;
68     struct wake_lock            bt_irq_wl;
69     struct delayed_work         bt_sleep_delay_work;
70 };
71
72 static struct rfkill_rk_data *g_rfkill = NULL;
73
74 static const char bt_name[] = 
75 #if defined (CONFIG_BCM4330)
76     #if defined (CONFIG_BT_MODULE_NH660)
77         "nh660"
78     #else
79         "bcm4330"
80     #endif
81 #elif defined (CONFIG_RK903)
82     #if defined(CONFIG_RKWIFI_26M)
83         "rk903_26M"
84     #else
85         "rk903"
86     #endif
87 #elif defined(CONFIG_BCM4329)
88         "bcm4329"
89 #elif defined(CONFIG_MV8787)
90         "mv8787"
91 #elif defined(CONFIG_AP6210)
92     #if defined(CONFIG_RKWIFI_26M)
93         "ap6210"
94     #else
95         "ap6210_24M"
96     #endif
97 #elif defined(CONFIG_AP6330)
98                 "ap6330"
99 #elif defined(CONFIG_AP6476)
100                 "ap6476"
101 #elif defined(CONFIG_AP6493)
102                 "ap6493"
103 #elif defined(CONFIG_AP6441)
104         "ap6441"
105 #elif defined(CONFIG_AP6335)
106         "ap6335"
107 #elif defined(CONFIG_GB86302I)
108         "gb86302i"
109 #else
110         "bt_default"
111 #endif
112 ;
113
114 static irqreturn_t rfkill_rk_wake_host_irq(int irq, void *dev)
115 {
116     struct rfkill_rk_data *rfkill = dev;
117     LOG("BT_WAKE_HOST IRQ fired\n");
118     
119     DBG("BT IRQ wakeup, request %dms wakelock\n", BT_IRQ_WAKELOCK_TIMEOUT);
120
121     wake_lock_timeout(&rfkill->bt_irq_wl, 
122                     msecs_to_jiffies(BT_IRQ_WAKELOCK_TIMEOUT));
123     
124         return IRQ_HANDLED;
125 }
126
127 static int rfkill_rk_setup_gpio(struct platform_device *pdev, struct rfkill_rk_gpio* gpio, 
128         const char* prefix, const char* name)
129 {
130         if (gpio_is_valid(gpio->io)) {
131         int ret=0;
132         sprintf(gpio->name, "%s_%s", prefix, name);
133                 ret = devm_gpio_request(&pdev->dev, gpio->io, gpio->name);
134                 if (ret) {
135                         LOG("Failed to get %s gpio.\n", gpio->name);
136                         return -1;
137                 }
138         }
139
140     return 0;
141 }
142
143 static int rfkill_rk_setup_wake_irq(struct rfkill_rk_data* rfkill)
144 {
145     int ret=0;
146     struct rfkill_rk_irq* irq = &(rfkill->pdata->wake_host_irq);
147     
148     ret = rfkill_rk_setup_gpio(rfkill->pdev, &irq->gpio, rfkill->pdata->name, "wake_host");
149     if (ret) goto fail1;
150     if (gpio_is_valid(irq->gpio.io))
151     {
152         //ret = gpio_pull_updown(irq->gpio.io, (irq->gpio.enable==GPIO_ACTIVE_LOW)?GPIOPullUp:GPIOPullDown);
153         //if (ret) goto fail2;
154         LOG("Request irq for bt wakeup host\n");
155         irq->irq = gpio_to_irq(irq->gpio.io);
156         sprintf(irq->name, "%s_irq", irq->gpio.name);
157         ret = request_irq(irq->irq,
158                     rfkill_rk_wake_host_irq,
159                     (irq->gpio.enable==GPIO_ACTIVE_LOW)?IRQF_TRIGGER_FALLING:IRQF_TRIGGER_RISING,
160                     irq->name,
161                     rfkill);
162         if (ret) goto fail2;
163         LOG("** disable irq\n");
164         disable_irq(irq->irq);
165         ret = enable_irq_wake(irq->irq);
166         if (ret) goto fail3;
167     }
168
169     return ret;
170
171 fail3:
172     free_irq(irq->gpio.io, rfkill);
173 fail2:
174     gpio_free(irq->gpio.io);
175 fail1:
176     return ret;
177 }
178
179 static inline void rfkill_rk_sleep_bt_internal(struct rfkill_rk_data *rfkill, bool sleep)
180 {
181     struct rfkill_rk_gpio *wake = &rfkill->pdata->wake_gpio;
182     
183     DBG("*** bt sleep: %d ***\n", sleep);
184 #ifndef CONFIG_BK3515A_COMBO
185     gpio_direction_output(wake->io, sleep?!wake->enable:wake->enable);
186 #else
187     if(!sleep)
188     {
189         DBG("HOST_UART0_TX pull down 10us\n");
190         if (rfkill_rk_setup_gpio(rfkill->pdev, wake, rfkill->pdata->name, "wake") != 0) {
191             return;
192         }
193
194         gpio_direction_output(wake->io, wake->enable);
195         udelay(10);
196         gpio_direction_output(wake->io, !wake->enable);
197
198         gpio_free(wake->io);
199     }
200 #endif
201 }
202
203 static void rfkill_rk_delay_sleep_bt(struct work_struct *work)
204 {
205     struct rfkill_rk_data *rfkill = NULL;
206     DBG("Enter %s\n",__FUNCTION__);
207
208     rfkill = container_of(work, struct rfkill_rk_data, bt_sleep_delay_work.work);
209
210     rfkill_rk_sleep_bt_internal(rfkill, BT_SLEEP);
211 }
212
213 void rfkill_rk_sleep_bt(bool sleep)
214 {
215     struct rfkill_rk_data *rfkill = g_rfkill;
216     struct rfkill_rk_gpio *wake;
217     bool ret;
218     DBG("Enter %s\n",__FUNCTION__);
219     
220     if (rfkill==NULL)
221     {
222         LOG("*** RFKILL is empty???\n");
223         return;
224     }
225
226     wake = &rfkill->pdata->wake_gpio;
227     if (!gpio_is_valid(wake->io))
228     {
229         DBG("*** Not support bt wakeup and sleep\n");
230         return;
231     }
232
233     ret = cancel_delayed_work_sync(&rfkill->bt_sleep_delay_work);
234
235     rfkill_rk_sleep_bt_internal(rfkill, sleep);
236
237 #ifdef CONFIG_BT_AUTOSLEEP
238     if (sleep==BT_WAKEUP)
239     {
240         schedule_delayed_work(&rfkill->bt_sleep_delay_work, 
241                             msecs_to_jiffies(BT_WAKEUP_TIMEOUT));
242     }
243 #endif
244 }
245 EXPORT_SYMBOL(rfkill_rk_sleep_bt);
246
247 static int rfkill_rk_set_power(void *data, bool blocked)
248 {
249         struct rfkill_rk_data *rfkill = data;
250     struct rfkill_rk_gpio *poweron = &rfkill->pdata->poweron_gpio;
251     struct rfkill_rk_gpio *reset = &rfkill->pdata->reset_gpio;
252 #if defined(CONFIG_AP6210) || defined(CONFIG_AP6335)
253     struct rfkill_rk_gpio* rts = &rfkill->pdata->rts_gpio;
254     struct pinctrl *pinctrl = rfkill->pdata->pinctrl;
255 #endif
256
257     DBG("Enter %s\n", __func__);
258
259     DBG("Set blocked:%d\n", blocked);
260
261         if (false == blocked) { 
262         rfkill_rk_sleep_bt(BT_WAKEUP); // ensure bt is wakeup
263
264                 if (gpio_is_valid(poweron->io))
265         {
266                         gpio_direction_output(poweron->io, !poweron->enable);
267             msleep(20);
268                         gpio_direction_output(poweron->io, poweron->enable);
269             msleep(20);
270         }
271                 if (gpio_is_valid(reset->io))
272         {
273                         gpio_direction_output(reset->io, !reset->enable);
274             msleep(20);
275                         gpio_direction_output(reset->io, reset->enable);
276         }
277
278 #if defined(CONFIG_AP6210) || defined(CONFIG_AP6335)
279         if (gpio_is_valid(rts->io))
280         {
281             pinctrl_select_state(pinctrl, rts->gpio_state);
282             LOG("ENABLE UART_RTS\n");
283             gpio_direction_output(rts->io, rts->enable);
284             msleep(100);
285             LOG("DISABLE UART_RTS\n");
286             gpio_direction_output(rts->io, !rts->enable);
287             pinctrl_select_state(pinctrl, rts->default_state);
288         }
289 #endif
290
291         LOG("bt turn on power\n");
292         } else {
293             if (gpio_is_valid(poweron->io))
294             {      
295                 gpio_direction_output(poweron->io, !poweron->enable);
296                 msleep(20);
297             }
298
299                 LOG("bt shut off power\n");
300                 if (gpio_is_valid(reset->io))
301         {      
302                         gpio_direction_output(reset->io, !reset->enable);/* bt reset active*/
303             msleep(20);
304         }
305         }
306
307         return 0;
308 }
309
310 static int rfkill_rk_pm_prepare(struct device *dev)
311 {
312     struct rfkill_rk_data *rfkill = g_rfkill;
313     struct rfkill_rk_gpio* rts;
314     struct rfkill_rk_irq*  wake_host_irq;
315     struct pinctrl *pinctrl = rfkill->pdata->pinctrl;
316
317     DBG("Enter %s\n",__FUNCTION__);
318
319     if (!rfkill)
320         return 0;
321
322     rts = &rfkill->pdata->rts_gpio;
323     wake_host_irq = &rfkill->pdata->wake_host_irq;
324
325     //To prevent uart to receive bt data when suspended
326     if (gpio_is_valid(rts->io))
327     {
328         DBG("Disable UART_RTS\n");
329         //pinctrl_select_state(pinctrl, rts->gpio_state);
330         //gpio_direction_output(rts->io, !rts->enable);
331     }
332
333 #ifdef CONFIG_BT_AUTOSLEEP
334     rfkill_rk_sleep_bt(BT_SLEEP);
335 #endif
336
337     // enable bt wakeup host
338     if (gpio_is_valid(wake_host_irq->gpio.io))
339     {
340         DBG("enable irq for bt wakeup host\n");
341         enable_irq(wake_host_irq->irq);
342     }
343
344 #ifdef CONFIG_RFKILL_RESET
345     rfkill_set_states(rfkill->rfkill_dev, BT_BLOCKED, false);
346     rfkill_rk_set_power(rfkill, BT_BLOCKED);
347 #endif
348
349     return 0;
350 }
351
352 static void rfkill_rk_pm_complete(struct device *dev)
353 {
354     struct rfkill_rk_data *rfkill = g_rfkill;
355     struct rfkill_rk_irq*  wake_host_irq;
356     struct rfkill_rk_gpio* rts;
357     struct pinctrl *pinctrl = rfkill->pdata->pinctrl;
358
359     DBG("Enter %s\n",__FUNCTION__);
360
361     if (!rfkill)
362         return;
363
364     wake_host_irq = &rfkill->pdata->wake_host_irq;
365     rts = &rfkill->pdata->rts_gpio;
366
367     if (gpio_is_valid(wake_host_irq->gpio.io))
368     {
369         LOG("** disable irq\n");
370         disable_irq(wake_host_irq->irq);
371     }
372
373     if (gpio_is_valid(rts->io))
374     {
375         DBG("Enable UART_RTS\n");
376         gpio_direction_output(rts->io, rts->enable);
377         pinctrl_select_state(pinctrl, rts->default_state);
378     }
379 }
380
381 static const struct rfkill_ops rfkill_rk_ops = {
382     .set_block = rfkill_rk_set_power,
383 };
384
385 #define PROC_DIR        "bluetooth/sleep"
386
387 static struct proc_dir_entry *bluetooth_dir, *sleep_dir;
388
389 static int bluesleep_read_proc_lpm(char *page, char **start, off_t offset,
390                                         int count, int *eof, void *data)
391 {
392     *eof = 1;
393     return sprintf(page, "unsupported to read\n");
394 }
395
396 static int bluesleep_write_proc_lpm(struct file *file, const char *buffer,
397                                         unsigned long count, void *data)
398 {
399     return count;
400 }
401
402 static int bluesleep_read_proc_btwrite(char *page, char **start, off_t offset,
403                                         int count, int *eof, void *data)
404 {
405     *eof = 1;
406     return sprintf(page, "unsupported to read\n");
407 }
408
409 static int bluesleep_write_proc_btwrite(struct file *file, const char *buffer,
410                                         unsigned long count, void *data)
411 {
412     char b;
413
414     if (count < 1)
415         return -EINVAL;
416
417     if (copy_from_user(&b, buffer, 1))
418         return -EFAULT;
419
420     DBG("btwrite %c\n", b);
421     /* HCI_DEV_WRITE */
422     if (b != '0') {
423         rfkill_rk_sleep_bt(BT_WAKEUP);
424     }
425
426     return count;
427 }
428
429 #ifdef CONFIG_OF
430 static int bluetooth_platdata_parse_dt(struct device *dev,
431                   struct rfkill_rk_platform_data *data)
432 {
433     struct device_node *node = dev->of_node;
434     int gpio;
435     enum of_gpio_flags flags;
436
437     if (!node)
438         return -ENODEV;
439
440     memset(data, 0, sizeof(*data));
441
442     if (of_find_property(node, "support_uart_rts_ctrl", NULL)) {
443         gpio = of_get_named_gpio_flags(node, "uart_rts_gpios", 0, &flags);
444         if (gpio_is_valid(gpio)) {
445             data->rts_gpio.io = gpio;
446             data->rts_gpio.enable = flags;
447             LOG("%s: get property: uart_rts_gpios = %d.\n", __func__, gpio);
448             data->pinctrl = devm_pinctrl_get(dev);
449             if (!IS_ERR(data->pinctrl)) {
450                 data->rts_gpio.default_state = pinctrl_lookup_state(data->pinctrl, "default");
451             } else {
452                 LOG("%s: dts does't define the uart rts iomux.\n", __func__);
453                 return -EINVAL;
454             }
455         } else {
456             LOG("%s: uart_rts_gpios is unvalid.\n", __func__);
457             return -EINVAL;
458         }
459     }
460
461     gpio = of_get_named_gpio_flags(node, "BT,power_gpio", 0, &flags);
462     if (gpio_is_valid(gpio)){
463         data->poweron_gpio.io = gpio;
464         data->poweron_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
465         LOG("%s: get property: BT,power_gpio = %d.\n", __func__, gpio);
466     }
467     gpio = of_get_named_gpio_flags(node, "BT,reset_gpio", 0, &flags);
468     if (gpio_is_valid(gpio)){
469         data->reset_gpio.io = gpio;
470         data->reset_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
471         LOG("%s: get property: BT,reset_gpio = %d.\n", __func__, gpio);
472     }
473     gpio = of_get_named_gpio_flags(node, "BT,wake_gpio", 0, &flags);
474     if (gpio_is_valid(gpio)){
475         data->wake_gpio.io = gpio;
476         data->wake_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
477         LOG("%s: get property: BT,wake_gpio = %d.\n", __func__, gpio);
478     }
479     gpio = of_get_named_gpio_flags(node, "BT,wake_host_irq", 0, &flags);
480     if (gpio_is_valid(gpio)) {
481         data->wake_host_irq.gpio.io = gpio;
482         data->wake_host_irq.gpio.enable = flags;
483         LOG("%s: get property: BT,wake_host_irq = %d.\n", __func__, gpio);
484     }
485
486     return 0;
487 }
488 #endif //CONFIG_OF
489
490 static const struct file_operations bluesleep_lpm = {
491     .owner = THIS_MODULE,
492     .read = bluesleep_read_proc_lpm,
493     .write = bluesleep_write_proc_lpm,
494 };
495
496 static const struct file_operations bluesleep_btwrite = {
497     .owner = THIS_MODULE,
498     .read = bluesleep_read_proc_btwrite,
499     .write = bluesleep_write_proc_btwrite,
500 };
501
502 static int rfkill_rk_probe(struct platform_device *pdev)
503 {
504         struct rfkill_rk_data *rfkill;
505         struct rfkill_rk_platform_data *pdata = pdev->dev.platform_data;
506         int ret = 0;
507     struct proc_dir_entry *ent;
508
509     DBG("Enter %s\n", __func__);
510
511     if (!pdata) {
512 #ifdef CONFIG_OF
513         pdata = devm_kzalloc(&pdev->dev, sizeof(struct rfkill_rk_platform_data), GFP_KERNEL);
514         if (!pdata)
515             return -ENOMEM;
516
517         ret = bluetooth_platdata_parse_dt(&pdev->dev, pdata);
518         if (ret < 0) {
519 #endif
520             LOG("%s: No platform data specified\n", __func__);
521             return ret;
522 #ifdef CONFIG_OF
523         }
524 #endif
525     }
526
527     pdata->name = (char*)bt_name;
528     pdata->type = RFKILL_TYPE_BLUETOOTH;
529
530         rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
531         if (!rfkill) {
532         kfree(pdata);
533                 return -ENOMEM;
534     }
535
536         rfkill->pdata = pdata;
537     rfkill->pdev = pdev;
538     g_rfkill = rfkill;
539
540     bluetooth_dir = proc_mkdir("bluetooth", NULL);
541     if (bluetooth_dir == NULL) {
542         LOG("Unable to create /proc/bluetooth directory");
543         return -ENOMEM;
544     }
545
546     sleep_dir = proc_mkdir("sleep", bluetooth_dir);
547     if (sleep_dir == NULL) {
548         LOG("Unable to create /proc/%s directory", PROC_DIR);
549         return -ENOMEM;
550     }
551
552         /* read/write proc entries */
553     ent = proc_create("lpm", 0, sleep_dir, &bluesleep_lpm);
554     if (ent == NULL) {
555         LOG("Unable to create /proc/%s/lpm entry", PROC_DIR);
556         ret = -ENOMEM;
557         goto fail_alloc;
558     }
559
560     /* read/write proc entries */
561     ent = proc_create("btwrite", 0, sleep_dir, &bluesleep_btwrite);
562     if (ent == NULL) {
563         LOG("Unable to create /proc/%s/btwrite entry", PROC_DIR);
564         ret = -ENOMEM;
565         goto fail_alloc;
566     }
567
568     DBG("init gpio\n");
569
570     ret = rfkill_rk_setup_gpio(pdev, &pdata->poweron_gpio, pdata->name, "poweron");
571     if (ret) goto fail_gpio;
572
573     ret = rfkill_rk_setup_gpio(pdev, &pdata->reset_gpio, pdata->name, "reset");
574     if (ret) goto fail_gpio;
575
576     ret = rfkill_rk_setup_gpio(pdev, &pdata->wake_gpio, pdata->name, "wake");
577     if (ret) goto fail_gpio;
578
579     ret = rfkill_rk_setup_wake_irq(rfkill);
580     if (ret) goto fail_gpio;
581
582     //ret = rfkill_rk_setup_gpio(pdev, &pdata->rts_gpio, rfkill->pdata->name, "rts"); 
583     //if (ret) goto fail_gpio;
584
585     DBG("setup rfkill\n");
586         rfkill->rfkill_dev = rfkill_alloc(pdata->name, &pdev->dev, pdata->type,
587                                 &rfkill_rk_ops, rfkill);
588         if (!rfkill->rfkill_dev)
589                 goto fail_alloc;
590
591     rfkill_set_states(rfkill->rfkill_dev, BT_BLOCKED, false);
592         ret = rfkill_register(rfkill->rfkill_dev);
593         if (ret < 0)
594                 goto fail_rfkill;
595
596     wake_lock_init(&(rfkill->bt_irq_wl), WAKE_LOCK_SUSPEND, "rfkill_rk_irq_wl");
597     INIT_DELAYED_WORK(&rfkill->bt_sleep_delay_work, rfkill_rk_delay_sleep_bt);
598
599     rfkill_rk_set_power(rfkill, BT_BLOCKED);
600
601         platform_set_drvdata(pdev, rfkill);
602
603     LOG("%s device registered.\n", pdata->name);
604
605         return 0;
606
607 fail_rfkill:
608         rfkill_destroy(rfkill->rfkill_dev);
609 fail_alloc:
610     g_rfkill = NULL;
611
612         remove_proc_entry("btwrite", sleep_dir);
613         remove_proc_entry("lpm", sleep_dir);
614 fail_gpio:
615
616         return ret;
617 }
618
619 static int rfkill_rk_remove(struct platform_device *pdev)
620 {
621         struct rfkill_rk_data *rfkill = platform_get_drvdata(pdev);
622
623     LOG("Enter %s\n", __func__);
624
625         rfkill_unregister(rfkill->rfkill_dev);
626         rfkill_destroy(rfkill->rfkill_dev);
627
628     
629     cancel_delayed_work_sync(&rfkill->bt_sleep_delay_work);
630
631     // free gpio
632     if (gpio_is_valid(rfkill->pdata->rts_gpio.io))
633         gpio_free(rfkill->pdata->rts_gpio.io);
634     
635     if (gpio_is_valid(rfkill->pdata->wake_host_irq.gpio.io)){
636         free_irq(rfkill->pdata->wake_host_irq.irq, rfkill);
637 #ifndef CONFIG_BK3515A_COMBO
638         gpio_free(rfkill->pdata->wake_host_irq.gpio.io);
639 #endif
640     }
641     
642 #ifndef CONFIG_BK3515A_COMBO
643     if (gpio_is_valid(rfkill->pdata->wake_gpio.io))
644         gpio_free(rfkill->pdata->wake_gpio.io);
645 #endif
646     
647     if (gpio_is_valid(rfkill->pdata->reset_gpio.io))
648         gpio_free(rfkill->pdata->reset_gpio.io);
649     
650     if (gpio_is_valid(rfkill->pdata->poweron_gpio.io))
651         gpio_free(rfkill->pdata->poweron_gpio.io);
652
653     kfree(rfkill);
654     g_rfkill = NULL;
655
656         return 0;
657 }
658
659 static const struct dev_pm_ops rfkill_rk_pm_ops = {
660         .prepare = rfkill_rk_pm_prepare,
661         .complete = rfkill_rk_pm_complete,
662 };
663
664 #ifdef CONFIG_OF
665 static struct of_device_id bt_platdata_of_match[] = {
666     { .compatible = "bluetooth-platdata" },
667     { }
668 };
669 MODULE_DEVICE_TABLE(of, bt_platdata_of_match);
670 #endif //CONFIG_OF
671
672 static struct platform_driver rfkill_rk_driver = {
673         .probe = rfkill_rk_probe,
674         .remove = rfkill_rk_remove,
675         .driver = {
676                 .name = "rfkill_bt",
677                 .owner = THIS_MODULE,
678                 .pm = &rfkill_rk_pm_ops,
679         .of_match_table = of_match_ptr(bt_platdata_of_match),
680         },
681 };
682
683 static int __init rfkill_rk_init(void)
684 {
685     LOG("Enter %s\n", __func__);
686         return platform_driver_register(&rfkill_rk_driver);
687 }
688
689 static void __exit rfkill_rk_exit(void)
690 {
691     LOG("Enter %s\n", __func__);
692         platform_driver_unregister(&rfkill_rk_driver);
693 }
694
695 module_init(rfkill_rk_init);
696 module_exit(rfkill_rk_exit);
697
698 MODULE_DESCRIPTION("rock-chips rfkill for Bluetooth v0.3");
699 MODULE_AUTHOR("cmy@rock-chips.com, gwl@rock-chips.com");
700 MODULE_LICENSE("GPL");
701