Staging: add USB MTK bluetooth driver
This driver is for the Mediatek Bluetooth that can be found in many different laptops. It was written by Mediatek, but cleaned up to work properly in the kernel tree by SUSE. -- Changes since v1: 1.fixed built error , because build path typo. 2.change to correct version number. Signed-off-by: Cho, Yu-Chen <acho@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9b43b56f79
commit
0d751eca3b
@ -142,4 +142,6 @@ source "drivers/staging/dwc2/Kconfig"
|
||||
|
||||
source "drivers/staging/lustre/Kconfig"
|
||||
|
||||
source "drivers/staging/btmtk_usb/Kconfig"
|
||||
|
||||
endif # STAGING
|
||||
|
@ -63,3 +63,4 @@ obj-$(CONFIG_ZCACHE) += zcache/
|
||||
obj-$(CONFIG_GOLDFISH) += goldfish/
|
||||
obj-$(CONFIG_USB_DWC2) += dwc2/
|
||||
obj-$(CONFIG_LUSTRE_FS) += lustre/
|
||||
obj-$(CONFIG_USB_BTMTK) += btmtk_usb/
|
||||
|
11
drivers/staging/btmtk_usb/Kconfig
Normal file
11
drivers/staging/btmtk_usb/Kconfig
Normal file
@ -0,0 +1,11 @@
|
||||
config USB_BTMTK
|
||||
tristate "Mediatek Bluetooth support"
|
||||
depends on USB && BT && m
|
||||
---help---
|
||||
Say Y here if you wish to control a MTK USB Bluetooth.
|
||||
|
||||
This option depends on 'USB' support being enabled
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called btmtk_usb.
|
||||
|
1
drivers/staging/btmtk_usb/Makefile
Normal file
1
drivers/staging/btmtk_usb/Makefile
Normal file
@ -0,0 +1 @@
|
||||
obj-$(CONFIG_USB_BTMTK) += btmtk_usb.o
|
14
drivers/staging/btmtk_usb/README
Normal file
14
drivers/staging/btmtk_usb/README
Normal file
@ -0,0 +1,14 @@
|
||||
-build driver modules
|
||||
make
|
||||
|
||||
-install driver modules
|
||||
make install
|
||||
|
||||
-remove driver modules
|
||||
make clean
|
||||
|
||||
-dynamic debug message
|
||||
turn on CONFIG_DYNAMIC_DEBUG compiler flag for current kernel
|
||||
mount -t debugfs none /sys/kernel/debug/
|
||||
echo "module module_name +p" > /sys/kernel/debug/dynamic_debug/control(turn on debug messages, module name such as btmtk_usb)
|
||||
echo "module module_name -p" > /sys/kernel/debug/dynamic_debug/control(turn off debug messages, module name such as btmtk_usb)
|
10
drivers/staging/btmtk_usb/TODO
Normal file
10
drivers/staging/btmtk_usb/TODO
Normal file
@ -0,0 +1,10 @@
|
||||
TODO:
|
||||
- checkpatch.pl clean
|
||||
- determine if the driver should not be using a duplicate
|
||||
version of the usb-bluetooth interface code, but should
|
||||
be merged into the drivers/bluetooth/ directory and
|
||||
infrastructure instead.
|
||||
- review by the bluetooth developer community
|
||||
|
||||
Please send any patches for this driver to Yu-Chen, Cho <acho@suse.com> and
|
||||
jay.hung@mediatek.com
|
1793
drivers/staging/btmtk_usb/btmtk_usb.c
Normal file
1793
drivers/staging/btmtk_usb/btmtk_usb.c
Normal file
File diff suppressed because it is too large
Load Diff
138
drivers/staging/btmtk_usb/btmtk_usb.h
Normal file
138
drivers/staging/btmtk_usb/btmtk_usb.h
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* MediaTek Bluetooth USB Driver
|
||||
*
|
||||
* Copyright (C) 2013, MediaTek co.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* or on the worldwide web at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BTMTK_USB_H__
|
||||
#define __BTMTK_USB_H_
|
||||
|
||||
/* Memory map for MTK BT */
|
||||
|
||||
/* SYS Control */
|
||||
#define SYSCTL 0x400000
|
||||
|
||||
/* WLAN */
|
||||
#define WLAN 0x410000
|
||||
|
||||
/* MCUCTL */
|
||||
#define INT_LEVEL 0x0718
|
||||
#define COM_REG0 0x0730
|
||||
#define SEMAPHORE_00 0x07B0
|
||||
#define SEMAPHORE_01 0x07B4
|
||||
#define SEMAPHORE_02 0x07B8
|
||||
#define SEMAPHORE_03 0x07BC
|
||||
|
||||
/* Chip definition */
|
||||
|
||||
#define CONTROL_TIMEOUT_JIFFIES ((300 * HZ) / 100)
|
||||
#define DEVICE_VENDOR_REQUEST_OUT 0x40
|
||||
#define DEVICE_VENDOR_REQUEST_IN 0xc0
|
||||
#define DEVICE_CLASS_REQUEST_OUT 0x20
|
||||
|
||||
#define BTUSB_MAX_ISOC_FRAMES 10
|
||||
#define BTUSB_INTR_RUNNING 0
|
||||
#define BTUSB_BULK_RUNNING 1
|
||||
#define BTUSB_ISOC_RUNNING 2
|
||||
#define BTUSB_SUSPENDING 3
|
||||
#define BTUSB_DID_ISO_RESUME 4
|
||||
|
||||
/* ROM Patch */
|
||||
#define PATCH_HCI_HEADER_SIZE 4
|
||||
#define PATCH_WMT_HEADER_SIZE 5
|
||||
#define PATCH_HEADER_SIZE (PATCH_HCI_HEADER_SIZE + PATCH_WMT_HEADER_SIZE)
|
||||
#define UPLOAD_PATCH_UNIT 2048
|
||||
#define PATCH_INFO_SIZE 30
|
||||
#define PATCH_PHASE1 1
|
||||
#define PATCH_PHASE2 2
|
||||
#define PATCH_PHASE3 3
|
||||
|
||||
struct btmtk_usb_data {
|
||||
struct hci_dev *hdev;
|
||||
struct usb_device *udev;
|
||||
struct usb_interface *intf;
|
||||
struct usb_interface *isoc;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
unsigned long flags;
|
||||
struct work_struct work;
|
||||
struct work_struct waker;
|
||||
|
||||
struct usb_anchor tx_anchor;
|
||||
struct usb_anchor intr_anchor;
|
||||
struct usb_anchor bulk_anchor;
|
||||
struct usb_anchor isoc_anchor;
|
||||
struct usb_anchor deferred;
|
||||
int tx_in_flight;
|
||||
spinlock_t txlock;
|
||||
|
||||
struct usb_endpoint_descriptor *intr_ep;
|
||||
struct usb_endpoint_descriptor *bulk_tx_ep;
|
||||
struct usb_endpoint_descriptor *bulk_rx_ep;
|
||||
struct usb_endpoint_descriptor *isoc_tx_ep;
|
||||
struct usb_endpoint_descriptor *isoc_rx_ep;
|
||||
|
||||
__u8 cmdreq_type;
|
||||
|
||||
unsigned int sco_num;
|
||||
int isoc_altsetting;
|
||||
int suspend_count;
|
||||
|
||||
/* request for different io operation */
|
||||
u8 w_request;
|
||||
u8 r_request;
|
||||
|
||||
/* io buffer for usb control transfer */
|
||||
char *io_buf;
|
||||
|
||||
struct semaphore fw_upload_sem;
|
||||
|
||||
/* unsigned char *fw_image; */
|
||||
/* unsigned char *rom_patch; */
|
||||
const struct firmware *firmware;
|
||||
u32 chip_id;
|
||||
u8 need_load_fw;
|
||||
u8 need_load_rom_patch;
|
||||
u32 rom_patch_offset;
|
||||
u32 rom_patch_len;
|
||||
};
|
||||
|
||||
static inline int is_mt7630(struct btmtk_usb_data *data)
|
||||
{
|
||||
return ((data->chip_id & 0xffff0000) == 0x76300000);
|
||||
}
|
||||
|
||||
static inline int is_mt7650(struct btmtk_usb_data *data)
|
||||
{
|
||||
return ((data->chip_id & 0xffff0000) == 0x76500000);
|
||||
}
|
||||
|
||||
static inline int is_mt7632(struct btmtk_usb_data *data)
|
||||
{
|
||||
return ((data->chip_id & 0xffff0000) == 0x76320000);
|
||||
}
|
||||
|
||||
static inline int is_mt7662(struct btmtk_usb_data *data)
|
||||
{
|
||||
return ((data->chip_id & 0xffff0000) == 0x76620000);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user