xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bluetooth_usb_driver/rtk_misc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  *  Realtek Bluetooth USB download firmware driver
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  *  This program is free software; you can redistribute it and/or modify
7*4882a593Smuzhiyun  *  it under the terms of the GNU General Public License as published by
8*4882a593Smuzhiyun  *  the Free Software Foundation; either version 2 of the License, or
9*4882a593Smuzhiyun  *  (at your option) any later version.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  *  This program is distributed in the hope that it will be useful,
12*4882a593Smuzhiyun  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13*4882a593Smuzhiyun  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*4882a593Smuzhiyun  *  GNU General Public License for more details.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  *  You should have received a copy of the GNU General Public License
17*4882a593Smuzhiyun  *  along with this program; if not, write to the Free Software
18*4882a593Smuzhiyun  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #include <linux/kernel.h>
23*4882a593Smuzhiyun #include <linux/module.h>
24*4882a593Smuzhiyun #include <linux/version.h>
25*4882a593Smuzhiyun #include <linux/pm_runtime.h>
26*4882a593Smuzhiyun #include <linux/usb.h>
27*4882a593Smuzhiyun #include <linux/suspend.h>
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /* Download LPS patch when host suspends or power off
30*4882a593Smuzhiyun  *   LPS patch name:  lps_rtl8xxx_fw
31*4882a593Smuzhiyun  *   LPS config name: lps_rtl8xxx_config
32*4882a593Smuzhiyun  * Download normal patch when host resume or power on */
33*4882a593Smuzhiyun /* #define RTKBT_SWITCH_PATCH */
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /* RTKBT Power-on Whitelist for sideband wake-up by LE Advertising from Remote.
36*4882a593Smuzhiyun  * Note that it's necessary to apply TV FW Patch. */
37*4882a593Smuzhiyun /* #define RTKBT_TV_POWERON_WHITELIST */
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #if 1
40*4882a593Smuzhiyun #define RTKBT_DBG(fmt, arg...) printk(KERN_INFO "rtk_btusb: " fmt "\n" , ## arg)
41*4882a593Smuzhiyun #define RTKBT_INFO(fmt, arg...) printk(KERN_INFO "rtk_btusb: " fmt "\n" , ## arg)
42*4882a593Smuzhiyun #define RTKBT_WARN(fmt, arg...) printk(KERN_WARNING "rtk_btusb: " fmt "\n", ## arg)
43*4882a593Smuzhiyun #else
44*4882a593Smuzhiyun #define RTKBT_DBG(fmt, arg...)
45*4882a593Smuzhiyun #endif
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #if 1
48*4882a593Smuzhiyun #define RTKBT_ERR(fmt, arg...) printk(KERN_ERR "rtk_btusb: " fmt "\n" , ## arg)
49*4882a593Smuzhiyun #else
50*4882a593Smuzhiyun #define RTKBT_ERR(fmt, arg...)
51*4882a593Smuzhiyun #endif
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 33)
54*4882a593Smuzhiyun #define USB_RPM			1
55*4882a593Smuzhiyun #else
56*4882a593Smuzhiyun #define USB_RPM			0
57*4882a593Smuzhiyun #endif
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun #define CONFIG_NEEDS_BINDING
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* If module is still powered when kernel suspended, there is no re-binding. */
62*4882a593Smuzhiyun #ifdef RTKBT_SWITCH_PATCH
63*4882a593Smuzhiyun #undef CONFIG_NEEDS_BINDING
64*4882a593Smuzhiyun #endif
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /* 1 SS enable; 0 SS disable */
68*4882a593Smuzhiyun #define BTUSB_RPM		(0*USB_RPM)
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #define PRINT_CMD_EVENT			0
71*4882a593Smuzhiyun #define PRINT_ACL_DATA			0
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun extern int patch_add(struct usb_interface *intf);
74*4882a593Smuzhiyun extern void patch_remove(struct usb_interface *intf);
75*4882a593Smuzhiyun extern int download_patch(struct usb_interface *intf);
76*4882a593Smuzhiyun extern void print_event(struct sk_buff *skb);
77*4882a593Smuzhiyun extern void print_command(struct sk_buff *skb);
78*4882a593Smuzhiyun extern void print_acl(struct sk_buff *skb, int dataOut);
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun #if defined RTKBT_SWITCH_PATCH || defined RTKBT_TV_POWERON_WHITELIST
81*4882a593Smuzhiyun int __rtk_send_hci_cmd(struct usb_device *udev, u8 *buf, u16 size);
82*4882a593Smuzhiyun int __rtk_recv_hci_evt(struct usb_device *udev, u8 *buf, u8 len, u16 opcode);
83*4882a593Smuzhiyun #endif
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun #ifdef RTKBT_SWITCH_PATCH
86*4882a593Smuzhiyun #define RTLBT_CLOSE	(1 << 0)
87*4882a593Smuzhiyun struct api_context {
88*4882a593Smuzhiyun 	u32			flags;
89*4882a593Smuzhiyun 	struct completion	done;
90*4882a593Smuzhiyun 	int			status;
91*4882a593Smuzhiyun };
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun int download_lps_patch(struct usb_interface *intf);
94*4882a593Smuzhiyun int set_scan(struct usb_interface *intf);
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #endif
97