Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / drivers / staging / btmtk_usb / btmtk_usb.h
1 /*
2  *  MediaTek Bluetooth USB Driver
3  *
4  *  Copyright (C) 2013, MediaTek co.
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *  or on the worldwide web at
20  *  http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
21  *
22  */
23
24 #ifndef __BTMTK_USB_H__
25 #define __BTMTK_USB_H_
26
27 /* Memory map for MTK BT */
28
29 /* SYS Control */
30 #define SYSCTL  0x400000
31
32 /* WLAN */
33 #define WLAN            0x410000
34
35 /* MCUCTL */
36 #define INT_LEVEL               0x0718
37 #define COM_REG0                0x0730
38 #define SEMAPHORE_00    0x07B0
39 #define SEMAPHORE_01    0x07B4
40 #define SEMAPHORE_02    0x07B8
41 #define SEMAPHORE_03    0x07BC
42
43 /* Chip definition */
44
45 #define CONTROL_TIMEOUT_JIFFIES ((300 * HZ) / 100)
46 #define DEVICE_VENDOR_REQUEST_OUT       0x40
47 #define DEVICE_VENDOR_REQUEST_IN        0xc0
48 #define DEVICE_CLASS_REQUEST_OUT        0x20
49
50 #define BTUSB_MAX_ISOC_FRAMES   10
51 #define BTUSB_INTR_RUNNING      0
52 #define BTUSB_BULK_RUNNING      1
53 #define BTUSB_ISOC_RUNNING      2
54 #define BTUSB_SUSPENDING        3
55 #define BTUSB_DID_ISO_RESUME    4
56
57 /* ROM Patch */
58 #define PATCH_HCI_HEADER_SIZE 4
59 #define PATCH_WMT_HEADER_SIZE 5
60 #define PATCH_HEADER_SIZE (PATCH_HCI_HEADER_SIZE + PATCH_WMT_HEADER_SIZE)
61 #define UPLOAD_PATCH_UNIT 2048
62 #define PATCH_INFO_SIZE 30
63 #define PATCH_PHASE1 1
64 #define PATCH_PHASE2 2
65 #define PATCH_PHASE3 3
66
67 struct btmtk_usb_data {
68         struct hci_dev *hdev;
69         struct usb_device    *udev;
70         struct usb_interface *intf;
71         struct usb_interface *isoc;
72
73         spinlock_t lock;
74
75         unsigned long flags;
76         struct work_struct work;
77         struct work_struct waker;
78
79         struct usb_anchor tx_anchor;
80         struct usb_anchor intr_anchor;
81         struct usb_anchor bulk_anchor;
82         struct usb_anchor isoc_anchor;
83         struct usb_anchor deferred;
84         int tx_in_flight;
85         spinlock_t txlock;
86
87         struct usb_endpoint_descriptor *intr_ep;
88         struct usb_endpoint_descriptor *bulk_tx_ep;
89         struct usb_endpoint_descriptor *bulk_rx_ep;
90         struct usb_endpoint_descriptor *isoc_tx_ep;
91         struct usb_endpoint_descriptor *isoc_rx_ep;
92
93         __u8 cmdreq_type;
94
95         unsigned int sco_num;
96         int isoc_altsetting;
97         int suspend_count;
98
99         /* request for different io operation */
100         u8 w_request;
101         u8 r_request;
102
103         /* io buffer for usb control transfer */
104         char *io_buf;
105
106         struct semaphore fw_upload_sem;
107
108         /* unsigned char *fw_image; */
109         /* unsigned char *rom_patch; */
110         const struct firmware *firmware;
111         u32 chip_id;
112         u8 need_load_fw;
113         u8 need_load_rom_patch;
114         u32 rom_patch_offset;
115         u32 rom_patch_len;
116 };
117
118 static inline int is_mt7630(struct btmtk_usb_data *data)
119 {
120         return ((data->chip_id & 0xffff0000) == 0x76300000);
121 }
122
123 static inline int is_mt7650(struct btmtk_usb_data *data)
124 {
125         return ((data->chip_id & 0xffff0000) == 0x76500000);
126 }
127
128 static inline int is_mt7632(struct btmtk_usb_data *data)
129 {
130         return ((data->chip_id & 0xffff0000) == 0x76320000);
131 }
132
133 static inline int is_mt7662(struct btmtk_usb_data *data)
134 {
135         return ((data->chip_id & 0xffff0000) == 0x76620000);
136 }
137
138 #endif