linux/drivers/bluetooth/btusb.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *
 *  Generic Bluetooth USB driver
 *
 *  Copyright (C) 2005-2008  Marcel Holtmann <[email protected]>
 */

#include <linux/dmi.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/quirks.h>
#include <linux/firmware.h>
#include <linux/iopoll.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/suspend.h>
#include <linux/gpio/consumer.h>
#include <linux/debugfs.h>
#include <asm/unaligned.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>

#include "btintel.h"
#include "btbcm.h"
#include "btrtl.h"
#include "btmtk.h"

#define VERSION

static bool disable_scofix;
static bool force_scofix;
static bool enable_autosuspend = IS_ENABLED();
static bool enable_poll_sync = IS_ENABLED();
static bool reset =;

static struct usb_driver btusb_driver;

#define BTUSB_IGNORE
#define BTUSB_DIGIANSWER
#define BTUSB_CSR
#define BTUSB_SNIFFER
#define BTUSB_BCM92035
#define BTUSB_BROKEN_ISOC
#define BTUSB_WRONG_SCO_MTU
#define BTUSB_ATH3012
#define BTUSB_INTEL_COMBINED
#define BTUSB_INTEL_BOOT
#define BTUSB_BCM_PATCHRAM
#define BTUSB_MARVELL
#define BTUSB_SWAVE
#define BTUSB_AMP
#define BTUSB_QCA_ROME
#define BTUSB_BCM_APPLE
#define BTUSB_REALTEK
#define BTUSB_BCM2045
#define BTUSB_IFNUM_2
#define BTUSB_CW6622
#define BTUSB_MEDIATEK
#define BTUSB_WIDEBAND_SPEECH
#define BTUSB_VALID_LE_STATES
#define BTUSB_QCA_WCN6855
#define BTUSB_INTEL_BROKEN_SHUTDOWN_LED
#define BTUSB_INTEL_BROKEN_INITIAL_NCMD
#define BTUSB_INTEL_NO_WBS_SUPPORT
#define BTUSB_ACTIONS_SEMI

static const struct usb_device_id btusb_table[] =;

MODULE_DEVICE_TABLE(usb, btusb_table);

static const struct usb_device_id quirks_table[] =;

/* The Bluetooth USB module build into some devices needs to be reset on resume,
 * this is a problem with the platform (likely shutting off all power) not with
 * the module itself. So we use a DMI list to match known broken platforms.
 */
static const struct dmi_system_id btusb_needs_reset_resume_table[] =;

struct qca_dump_info {};

#define BTUSB_MAX_ISOC_FRAMES

#define BTUSB_INTR_RUNNING
#define BTUSB_BULK_RUNNING
#define BTUSB_ISOC_RUNNING
#define BTUSB_SUSPENDING
#define BTUSB_DID_ISO_RESUME
#define BTUSB_BOOTLOADER
#define BTUSB_DOWNLOADING
#define BTUSB_FIRMWARE_LOADED
#define BTUSB_FIRMWARE_FAILED
#define BTUSB_BOOTING
#define BTUSB_DIAG_RUNNING
#define BTUSB_OOB_WAKE_ENABLED
#define BTUSB_HW_RESET_ACTIVE
#define BTUSB_TX_WAIT_VND_EVT
#define BTUSB_WAKEUP_AUTOSUSPEND
#define BTUSB_USE_ALT3_FOR_WBS
#define BTUSB_ALT6_CONTINUOUS_TX
#define BTUSB_HW_SSR_ACTIVE

struct btusb_data {};

static void btusb_reset(struct hci_dev *hdev)
{}

static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
{}

#define RTK_DEVCOREDUMP_CODE_MEMDUMP
#define RTK_DEVCOREDUMP_CODE_HW_ERR
#define RTK_DEVCOREDUMP_CODE_CMD_TIMEOUT

#define RTK_SUB_EVENT_CODE_COREDUMP

struct rtk_dev_coredump_hdr {} __packed;

static inline void btusb_rtl_alloc_devcoredump(struct hci_dev *hdev,
		struct rtk_dev_coredump_hdr *hdr, u8 *buf, u32 len)
{}

static void btusb_rtl_cmd_timeout(struct hci_dev *hdev)
{}

static void btusb_rtl_hw_error(struct hci_dev *hdev, u8 code)
{}

static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
{}

static inline void btusb_free_frags(struct btusb_data *data)
{}

static int btusb_recv_event(struct btusb_data *data, struct sk_buff *skb)
{}

static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
{}

static int btusb_recv_acl(struct btusb_data *data, struct sk_buff *skb)
{}

static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
{}

static bool btusb_validate_sco_handle(struct hci_dev *hdev,
				      struct hci_sco_hdr *hdr)
{}

static int btusb_recv_isoc(struct btusb_data *data, void *buffer, int count)
{}

static void btusb_intr_complete(struct urb *urb)
{}

static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
{}

static void btusb_bulk_complete(struct urb *urb)
{}

static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
{}

static void btusb_isoc_complete(struct urb *urb)
{}

static inline void __fill_isoc_descriptor_msbc(struct urb *urb, int len,
					       int mtu, struct btusb_data *data)
{}

static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
{}

static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
{}

static void btusb_diag_complete(struct urb *urb)
{}

static int btusb_submit_diag_urb(struct hci_dev *hdev, gfp_t mem_flags)
{}

static void btusb_tx_complete(struct urb *urb)
{}

static void btusb_isoc_tx_complete(struct urb *urb)
{}

static int btusb_open(struct hci_dev *hdev)
{}

static void btusb_stop_traffic(struct btusb_data *data)
{}

static int btusb_close(struct hci_dev *hdev)
{}

static int btusb_flush(struct hci_dev *hdev)
{}

static struct urb *alloc_ctrl_urb(struct hci_dev *hdev, struct sk_buff *skb)
{}

static struct urb *alloc_bulk_urb(struct hci_dev *hdev, struct sk_buff *skb)
{}

static struct urb *alloc_isoc_urb(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int submit_tx_urb(struct hci_dev *hdev, struct urb *urb)
{}

static int submit_or_queue_tx_urb(struct hci_dev *hdev, struct urb *urb)
{}

static int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{}

static void btusb_notify(struct hci_dev *hdev, unsigned int evt)
{}

static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
{}

static int btusb_switch_alt_setting(struct hci_dev *hdev, int new_alts)
{}

static struct usb_host_interface *btusb_find_altsetting(struct btusb_data *data,
							int alt)
{}

static void btusb_work(struct work_struct *work)
{}

static void btusb_waker(struct work_struct *work)
{}

static void btusb_rx_work(struct work_struct *work)
{}

static int btusb_setup_bcm92035(struct hci_dev *hdev)
{}

static int btusb_setup_csr(struct hci_dev *hdev)
{}

static int inject_cmd_complete(struct hci_dev *hdev, __u16 opcode)
{}

static int btusb_recv_bulk_intel(struct btusb_data *data, void *buffer,
				 int count)
{}

static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int btusb_setup_realtek(struct hci_dev *hdev)
{}

static int btusb_recv_event_realtek(struct hci_dev *hdev, struct sk_buff *skb)
{}

static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
{}

static void btusb_mtk_release_iso_intf(struct btusb_data *data)
{}

static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
{}

static int btusb_send_frame_mtk(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int btusb_mtk_setup(struct hci_dev *hdev)
{}

static int btusb_mtk_shutdown(struct hci_dev *hdev)
{}

#ifdef CONFIG_PM
/* Configure an out-of-band gpio as wake-up pin, if specified in device tree */
static int marvell_config_oob_wake(struct hci_dev *hdev)
{}
#endif

static int btusb_set_bdaddr_marvell(struct hci_dev *hdev,
				    const bdaddr_t *bdaddr)
{}

static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev,
				    const bdaddr_t *bdaddr)
{}

static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
				const bdaddr_t *bdaddr)
{}

#define QCA_MEMDUMP_ACL_HANDLE
#define QCA_MEMDUMP_SIZE_MAX
#define QCA_MEMDUMP_VSE_CLASS
#define QCA_MEMDUMP_MSG_TYPE
#define QCA_MEMDUMP_PKT_SIZE
#define QCA_LAST_SEQUENCE_NUM

struct qca_dump_hdr {} __packed;


static void btusb_dump_hdr_qca(struct hci_dev *hdev, struct sk_buff *skb)
{}

static void btusb_coredump_qca(struct hci_dev *hdev)
{}

/*
 * ==0: not a dump pkt.
 * < 0: fails to handle a dump pkt
 * > 0: otherwise.
 */
static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int btusb_recv_evt_qca(struct hci_dev *hdev, struct sk_buff *skb)
{}


#define QCA_DFU_PACKET_LEN

#define QCA_GET_TARGET_VERSION
#define QCA_CHECK_STATUS
#define QCA_DFU_DOWNLOAD

#define QCA_SYSCFG_UPDATED
#define QCA_PATCH_UPDATED
#define QCA_DFU_TIMEOUT
#define QCA_FLAG_MULTI_NVM
#define QCA_BT_RESET_WAIT_MS

#define WCN6855_2_0_RAM_VERSION_GF
#define WCN6855_2_1_RAM_VERSION_GF

struct qca_version {} __packed;

struct qca_rampatch_version {} __packed;

struct qca_device_info {};

static const struct qca_device_info qca_devices_table[] =;

static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request,
				     void *data, u16 size)
{}

static int btusb_setup_qca_download_fw(struct hci_dev *hdev,
				       const struct firmware *firmware,
				       size_t hdr_size)
{}

static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
					 struct qca_version *ver,
					 const struct qca_device_info *info)
{}

static void btusb_generate_qca_nvm_name(char *fwname, size_t max_size,
					const struct qca_version *ver)
{}

static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
				    struct qca_version *ver,
				    const struct qca_device_info *info)
{}

/* identify the ROM version and check whether patches are needed */
static bool btusb_qca_need_patch(struct usb_device *udev)
{}

static int btusb_setup_qca(struct hci_dev *hdev)
{}

static inline int __set_diag_interface(struct hci_dev *hdev)
{}

static struct urb *alloc_diag_urb(struct hci_dev *hdev, bool enable)
{}

static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable)
{}

#ifdef CONFIG_PM
static irqreturn_t btusb_oob_wake_handler(int irq, void *priv)
{}

static const struct of_device_id btusb_match_table[] =;
MODULE_DEVICE_TABLE(of, btusb_match_table);

/* Use an oob wakeup pin? */
static int btusb_config_oob_wake(struct hci_dev *hdev)
{}
#endif

static void btusb_check_needs_reset_resume(struct usb_interface *intf)
{}

static bool btusb_wakeup(struct hci_dev *hdev)
{}

static int btusb_shutdown_qca(struct hci_dev *hdev)
{}

static ssize_t force_poll_sync_read(struct file *file, char __user *user_buf,
				    size_t count, loff_t *ppos)
{}

static ssize_t force_poll_sync_write(struct file *file,
				     const char __user *user_buf,
				     size_t count, loff_t *ppos)
{}

static const struct file_operations force_poll_sync_fops =;

static int btusb_probe(struct usb_interface *intf,
		       const struct usb_device_id *id)
{}

static void btusb_disconnect(struct usb_interface *intf)
{}

#ifdef CONFIG_PM
static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
{}

static void play_deferred(struct btusb_data *data)
{}

static int btusb_resume(struct usb_interface *intf)
{}
#endif

#ifdef CONFIG_DEV_COREDUMP
static void btusb_coredump(struct device *dev)
{}
#endif

static struct usb_driver btusb_driver =;

module_usb_driver();

module_param(disable_scofix, bool, 0644);
MODULE_PARM_DESC();

module_param(force_scofix, bool, 0644);
MODULE_PARM_DESC();

module_param(enable_autosuspend, bool, 0644);
MODULE_PARM_DESC();

module_param(reset, bool, 0644);
MODULE_PARM_DESC();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_VERSION();
MODULE_LICENSE();