Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Realtek Bluetooth USB driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  the Free Software Foundation; either version 2 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *  You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/cdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/version.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/pm_runtime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/firmware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/suspend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <net/bluetooth/bluetooth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <net/bluetooth/hci_core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <net/bluetooth/hci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* #define HCI_VERSION_CODE KERNEL_VERSION(3, 14, 41) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define HCI_VERSION_CODE LINUX_VERSION_CODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #ifdef CONFIG_BTCOEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define BTCOEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /***********************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) ** Realtek - For rtk_btusb driver **
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) ***********************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #ifdef CONFIG_BTUSB_WAKEUP_HOST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define BTUSB_WAKEUP_HOST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define URB_CANCELING_DELAY_MS	10	// Added by Realtek
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #if HCI_VERSION_CODE > KERNEL_VERSION(2, 6, 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define HDEV_BUS		hdev->bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define HDEV_BUS		hdev->type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #if HCI_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define NUM_REASSEMBLY 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define GET_DRV_DATA(x)		hci_get_drvdata(x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define GET_DRV_DATA(x)		x->driver_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #if HCI_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define SCO_NUM    hdev->conn_hash.sco_num
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define SCO_NUM     hci_conn_num(hdev, SCO_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) int patch_add(struct usb_interface *intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) void patch_remove(struct usb_interface *intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) int download_patch(struct usb_interface *intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) int set_btoff(struct usb_interface *intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) void print_event(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) void print_command(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) void print_acl(struct sk_buff *skb, int dataOut);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) int btusb_send_frame(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #define BTUSB_MAX_ISOC_FRAMES	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define BTUSB_INTR_RUNNING		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define BTUSB_BULK_RUNNING		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #define BTUSB_ISOC_RUNNING		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define BTUSB_SUSPENDING		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #define BTUSB_DID_ISO_RESUME	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) struct btusb_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct hci_dev *hdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct usb_device *udev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct usb_interface *intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	struct usb_interface *isoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct work_struct waker;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct usb_anchor tx_anchor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct usb_anchor intr_anchor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct usb_anchor bulk_anchor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct usb_anchor isoc_anchor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	struct usb_anchor deferred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	int tx_in_flight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	spinlock_t txlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	spinlock_t rxlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	struct sk_buff *evt_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct sk_buff *acl_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct sk_buff *sco_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct usb_endpoint_descriptor *intr_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct usb_endpoint_descriptor *bulk_tx_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct usb_endpoint_descriptor *bulk_rx_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct usb_endpoint_descriptor *isoc_tx_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct usb_endpoint_descriptor *isoc_rx_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	__u8 cmdreq_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	unsigned int sco_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #if HCI_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	unsigned int air_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	int isoc_altsetting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	int suspend_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	int (*recv_bulk) (struct btusb_data * data, void *buffer, int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct notifier_block pm_notifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	void *context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) };