hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <linux/module.h>
#include <linux/inetdevice.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/platform_device.h>
#include "lpm.h"
#include "rfkill.h"
 
#define DRV_CONFIG_FW_NAME    "fw.bin"
#define DRV_DESCRIPTION       "AIC BLUETOOTH"
#define DRV_COPYRIGHT         "Copyright(c) 2015-2020 AICSemi"
#define DRV_AUTHOR            "AICSemi"
#define DRV_VERS_MOD          "1.0"
 
static struct platform_device *aicbt_pdev;
 
static struct platform_driver aicbt_driver = {
   .driver = {
       .owner = THIS_MODULE,
       .name = "aic_bt",
   },
   //.probe = aicbt_probe,
   //.remove = aicbt_remove,
};
 
static int __init aic_bluetooth_mod_init(void)
{
   int ret;
   printk("%s\n", __func__);
   ret = platform_driver_register(&aicbt_driver);
   if (ret) {
       pr_err("register platform driver failed: %d\n", ret);
       return ret;
   }
 
   aicbt_pdev = platform_device_alloc("aic-bt", -1);
   ret = platform_device_add(aicbt_pdev);
   if (ret) {
       pr_err("register platform device failed: %d\n", ret);
       goto err0;
   }
 
   ret = rfkill_bluetooth_init(aicbt_pdev);
   if (ret) {
       pr_err("rfkill init fail\n");
       goto err1;
   }
#ifdef ANDROID_PLATFORM
#ifndef CONFIG_PLATFORM_ROCKCHIP
#ifndef CONFIG_PLATFORM_ROCKCHIP2
   ret = bluesleep_init(aicbt_pdev);
   if (ret) {
       pr_err("bluesleep init fail\n");
       goto err2;
   }
#endif
#endif
#endif
 
   return 0;
 
#ifdef ANDROID_PLATFORM
#ifndef CONFIG_PLATFORM_ROCKCHIP
#ifndef CONFIG_PLATFORM_ROCKCHIP2
err2:
#endif
#endif
#endif
   rfkill_bluetooth_remove(aicbt_pdev);
err1:
   platform_device_del(aicbt_pdev);
err0:
   platform_driver_unregister(&aicbt_driver);
   return ret;
}
 
static void __exit aic_bluetooth_mod_exit(void)
{
   printk("%s\n", __func__);
#ifdef ANDROID_PLATFORM
#ifndef CONFIG_PLATFORM_ROCKCHIP
#ifndef CONFIG_PLATFORM_ROCKCHIP2
   bluesleep_exit(aicbt_pdev);
#endif
#endif
#endif
   rfkill_bluetooth_remove(aicbt_pdev);
   platform_device_del(aicbt_pdev);
   platform_driver_unregister(&aicbt_driver);
}
 
module_init(aic_bluetooth_mod_init);
module_exit(aic_bluetooth_mod_exit);
 
MODULE_DESCRIPTION(DRV_DESCRIPTION);
MODULE_VERSION(DRV_VERS_MOD);
MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
MODULE_LICENSE("GPL");