2 * MediaTek Bluetooth USB Driver
4 * Copyright (C) 2013, MediaTek co.
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.
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.
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.
24 #ifndef __BTMTK_USB_H__
25 #define __BTMTK_USB_H_
27 /* Memory map for MTK BT */
30 #define SYSCTL 0x400000
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
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
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
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
67 struct btmtk_usb_data {
69 struct usb_device *udev;
70 struct usb_interface *intf;
71 struct usb_interface *isoc;
76 struct work_struct work;
77 struct work_struct waker;
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;
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;
99 /* request for different io operation */
103 /* io buffer for usb control transfer */
106 struct semaphore fw_upload_sem;
108 /* unsigned char *fw_image; */
109 /* unsigned char *rom_patch; */
110 const struct firmware *firmware;
113 u8 need_load_rom_patch;
114 u32 rom_patch_offset;
118 static inline int is_mt7630(struct btmtk_usb_data *data)
120 return ((data->chip_id & 0xffff0000) == 0x76300000);
123 static inline int is_mt7650(struct btmtk_usb_data *data)
125 return ((data->chip_id & 0xffff0000) == 0x76500000);
128 static inline int is_mt7632(struct btmtk_usb_data *data)
130 return ((data->chip_id & 0xffff0000) == 0x76320000);
133 static inline int is_mt7662(struct btmtk_usb_data *data)
135 return ((data->chip_id & 0xffff0000) == 0x76620000);