xref: /linux/drivers/bluetooth/btusb_qcom.h (revision 4dd10fbbeb9c33709edc89916e19c03c780a0751)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Qualcomm Bluetooth USB transport-specific support
4  *
5  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
6  */
7 
8 #ifndef __BTUSB_QCOM_H
9 #define __BTUSB_QCOM_H
10 
11 #include <linux/types.h>
12 #include <linux/mutex.h>
13 #include <linux/skbuff.h>
14 #include <linux/usb.h>
15 
16 #include <net/bluetooth/hci_core.h>
17 
18 #define QPERI_COMMAND_PKT	0x31
19 #define QPERI_ACLDATA_PKT	0x32
20 #define QPERI_EVENT_PKT		0x34
21 
22 struct btusb_qcom {
23 	__u16                 idVendor;
24 	__u16                 idProduct;
25 	struct usb_device    *udev;
26 	struct usb_interface *intf;
27 	struct gpio_desc     *reset_gpio;
28 
29 	/* serializes sending BT and vendor frames to the transport */
30 	struct mutex          tx_mutex;
31 
32 	void (*prepare_reset)(struct hci_dev *hdev);
33 	int (*recv_bt_frame)(struct hci_dev *hdev, struct sk_buff *skb);
34 	int (*send_bt_frame)(struct hci_dev *hdev, struct sk_buff *skb);
35 	int (*send_vendor_frame)(struct hci_dev *hdev, struct sk_buff *skb);
36 };
37 
38 #if IS_ENABLED(CONFIG_BT_HCIBTUSB_QCOM)
39 
40 int btusb_qcom_hdev_priv_size(void);
41 struct btusb_qcom *btusb_qcom_xport_data(struct hci_dev *hdev);
42 
43 int btusb_qcom_setup(struct hci_dev *hdev);
44 int btusb_qcom_disconnect(struct hci_dev *hdev);
45 int btusb_qcom_send_frame(struct hci_dev *hdev, struct sk_buff *skb);
46 
47 struct sk_buff *btusb_qcom_recv_intr(struct hci_dev *hdev, struct sk_buff *skb,
48 				     void *buffer, int count, int *err);
49 
50 struct sk_buff *btusb_qcom_recv_bulk(struct hci_dev *hdev, struct sk_buff *skb,
51 				     void *buffer, int count, int *err);
52 
53 #else
54 
55 static inline int btusb_qcom_hdev_priv_size(void)
56 {
57 	return 0;
58 }
59 
60 static inline struct btusb_qcom *btusb_qcom_xport_data(struct hci_dev *hdev)
61 {
62 	return NULL;
63 }
64 
65 static inline int btusb_qcom_setup(struct hci_dev *hdev)
66 {
67 	return -EOPNOTSUPP;
68 }
69 
70 static inline int btusb_qcom_disconnect(struct hci_dev *hdev)
71 {
72 	return -EOPNOTSUPP;
73 }
74 
75 static inline int btusb_qcom_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
76 {
77 	return -EOPNOTSUPP;
78 }
79 
80 static inline struct sk_buff *btusb_qcom_recv_intr(struct hci_dev *hdev,
81 						   struct sk_buff *skb,
82 						   void *buffer, int count,
83 						   int *err)
84 {
85 	*err = -EOPNOTSUPP;
86 	return NULL;
87 }
88 
89 static inline struct sk_buff *btusb_qcom_recv_bulk(struct hci_dev *hdev,
90 						   struct sk_buff *skb,
91 						   void *buffer, int count,
92 						   int *err)
93 {
94 	*err = -EOPNOTSUPP;
95 	return NULL;
96 }
97 
98 #endif
99 #endif
100