0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef N_HCI
0012 #define N_HCI 15
0013 #endif
0014
0015
0016 #define HCIUARTSETPROTO _IOW('U', 200, int)
0017 #define HCIUARTGETPROTO _IOR('U', 201, int)
0018 #define HCIUARTGETDEVICE _IOR('U', 202, int)
0019 #define HCIUARTSETFLAGS _IOW('U', 203, int)
0020 #define HCIUARTGETFLAGS _IOR('U', 204, int)
0021
0022
0023 #define HCI_UART_MAX_PROTO 12
0024
0025 #define HCI_UART_H4 0
0026 #define HCI_UART_BCSP 1
0027 #define HCI_UART_3WIRE 2
0028 #define HCI_UART_H4DS 3
0029 #define HCI_UART_LL 4
0030 #define HCI_UART_ATH3K 5
0031 #define HCI_UART_INTEL 6
0032 #define HCI_UART_BCM 7
0033 #define HCI_UART_QCA 8
0034 #define HCI_UART_AG6XX 9
0035 #define HCI_UART_NOKIA 10
0036 #define HCI_UART_MRVL 11
0037
0038 #define HCI_UART_RAW_DEVICE 0
0039 #define HCI_UART_RESET_ON_INIT 1
0040 #define HCI_UART_CREATE_AMP 2
0041 #define HCI_UART_INIT_PENDING 3
0042 #define HCI_UART_EXT_CONFIG 4
0043 #define HCI_UART_VND_DETECT 5
0044
0045 struct hci_uart;
0046 struct serdev_device;
0047
0048 struct hci_uart_proto {
0049 unsigned int id;
0050 const char *name;
0051 unsigned int manufacturer;
0052 unsigned int init_speed;
0053 unsigned int oper_speed;
0054 int (*open)(struct hci_uart *hu);
0055 int (*close)(struct hci_uart *hu);
0056 int (*flush)(struct hci_uart *hu);
0057 int (*setup)(struct hci_uart *hu);
0058 int (*set_baudrate)(struct hci_uart *hu, unsigned int speed);
0059 int (*recv)(struct hci_uart *hu, const void *data, int len);
0060 int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb);
0061 struct sk_buff *(*dequeue)(struct hci_uart *hu);
0062 };
0063
0064 struct hci_uart {
0065 struct tty_struct *tty;
0066 struct serdev_device *serdev;
0067 struct hci_dev *hdev;
0068 unsigned long flags;
0069 unsigned long hdev_flags;
0070
0071 struct work_struct init_ready;
0072 struct work_struct write_work;
0073
0074 const struct hci_uart_proto *proto;
0075 struct percpu_rw_semaphore proto_lock;
0076 void *priv;
0077
0078 struct sk_buff *tx_skb;
0079 unsigned long tx_state;
0080
0081 unsigned int init_speed;
0082 unsigned int oper_speed;
0083
0084 u8 alignment;
0085 u8 padding;
0086 };
0087
0088
0089 #define HCI_UART_PROTO_SET 0
0090 #define HCI_UART_REGISTERED 1
0091 #define HCI_UART_PROTO_READY 2
0092 #define HCI_UART_NO_SUSPEND_NOTIFIER 3
0093
0094
0095 #define HCI_UART_SENDING 1
0096 #define HCI_UART_TX_WAKEUP 2
0097
0098 int hci_uart_register_proto(const struct hci_uart_proto *p);
0099 int hci_uart_unregister_proto(const struct hci_uart_proto *p);
0100 int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p);
0101 void hci_uart_unregister_device(struct hci_uart *hu);
0102
0103 int hci_uart_tx_wakeup(struct hci_uart *hu);
0104 int hci_uart_wait_until_sent(struct hci_uart *hu);
0105 int hci_uart_init_ready(struct hci_uart *hu);
0106 void hci_uart_init_work(struct work_struct *work);
0107 void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed);
0108 bool hci_uart_has_flow_control(struct hci_uart *hu);
0109 void hci_uart_set_flow_control(struct hci_uart *hu, bool enable);
0110 void hci_uart_set_speeds(struct hci_uart *hu, unsigned int init_speed,
0111 unsigned int oper_speed);
0112
0113 #ifdef CONFIG_BT_HCIUART_H4
0114 int h4_init(void);
0115 int h4_deinit(void);
0116
0117 struct h4_recv_pkt {
0118 u8 type;
0119 u8 hlen;
0120 u8 loff;
0121 u8 lsize;
0122 u16 maxlen;
0123 int (*recv)(struct hci_dev *hdev, struct sk_buff *skb);
0124 };
0125
0126 #define H4_RECV_ACL \
0127 .type = HCI_ACLDATA_PKT, \
0128 .hlen = HCI_ACL_HDR_SIZE, \
0129 .loff = 2, \
0130 .lsize = 2, \
0131 .maxlen = HCI_MAX_FRAME_SIZE \
0132
0133 #define H4_RECV_SCO \
0134 .type = HCI_SCODATA_PKT, \
0135 .hlen = HCI_SCO_HDR_SIZE, \
0136 .loff = 2, \
0137 .lsize = 1, \
0138 .maxlen = HCI_MAX_SCO_SIZE
0139
0140 #define H4_RECV_EVENT \
0141 .type = HCI_EVENT_PKT, \
0142 .hlen = HCI_EVENT_HDR_SIZE, \
0143 .loff = 1, \
0144 .lsize = 1, \
0145 .maxlen = HCI_MAX_EVENT_SIZE
0146
0147 #define H4_RECV_ISO \
0148 .type = HCI_ISODATA_PKT, \
0149 .hlen = HCI_ISO_HDR_SIZE, \
0150 .loff = 2, \
0151 .lsize = 2, \
0152 .maxlen = HCI_MAX_FRAME_SIZE \
0153
0154 struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
0155 const unsigned char *buffer, int count,
0156 const struct h4_recv_pkt *pkts, int pkts_count);
0157 #endif
0158
0159 #ifdef CONFIG_BT_HCIUART_BCSP
0160 int bcsp_init(void);
0161 int bcsp_deinit(void);
0162 #endif
0163
0164 #ifdef CONFIG_BT_HCIUART_LL
0165 int ll_init(void);
0166 int ll_deinit(void);
0167 #endif
0168
0169 #ifdef CONFIG_BT_HCIUART_ATH3K
0170 int ath_init(void);
0171 int ath_deinit(void);
0172 #endif
0173
0174 #ifdef CONFIG_BT_HCIUART_3WIRE
0175 int h5_init(void);
0176 int h5_deinit(void);
0177 #endif
0178
0179 #ifdef CONFIG_BT_HCIUART_INTEL
0180 int intel_init(void);
0181 int intel_deinit(void);
0182 #endif
0183
0184 #ifdef CONFIG_BT_HCIUART_BCM
0185 int bcm_init(void);
0186 int bcm_deinit(void);
0187 #endif
0188
0189 #ifdef CONFIG_BT_HCIUART_QCA
0190 int qca_init(void);
0191 int qca_deinit(void);
0192 #endif
0193
0194 #ifdef CONFIG_BT_HCIUART_AG6XX
0195 int ag6xx_init(void);
0196 int ag6xx_deinit(void);
0197 #endif
0198
0199 #ifdef CONFIG_BT_HCIUART_MRVL
0200 int mrvl_init(void);
0201 int mrvl_deinit(void);
0202 #endif