11da177e4SLinus Torvalds /* 20372a662SMarcel Holtmann * 30372a662SMarcel Holtmann * Bluetooth HCI UART driver 40372a662SMarcel Holtmann * 50372a662SMarcel Holtmann * Copyright (C) 2000-2001 Qualcomm Incorporated 60372a662SMarcel Holtmann * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> 70372a662SMarcel Holtmann * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> 80372a662SMarcel Holtmann * 90372a662SMarcel Holtmann * 100372a662SMarcel Holtmann * This program is free software; you can redistribute it and/or modify 110372a662SMarcel Holtmann * it under the terms of the GNU General Public License as published by 120372a662SMarcel Holtmann * the Free Software Foundation; either version 2 of the License, or 130372a662SMarcel Holtmann * (at your option) any later version. 140372a662SMarcel Holtmann * 150372a662SMarcel Holtmann * This program is distributed in the hope that it will be useful, 160372a662SMarcel Holtmann * but WITHOUT ANY WARRANTY; without even the implied warranty of 170372a662SMarcel Holtmann * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 180372a662SMarcel Holtmann * GNU General Public License for more details. 190372a662SMarcel Holtmann * 200372a662SMarcel Holtmann * You should have received a copy of the GNU General Public License 210372a662SMarcel Holtmann * along with this program; if not, write to the Free Software 220372a662SMarcel Holtmann * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 230372a662SMarcel Holtmann * 241da177e4SLinus Torvalds */ 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds #ifndef N_HCI 271da177e4SLinus Torvalds #define N_HCI 15 281da177e4SLinus Torvalds #endif 291da177e4SLinus Torvalds 301da177e4SLinus Torvalds /* Ioctls */ 311da177e4SLinus Torvalds #define HCIUARTSETPROTO _IOW('U', 200, int) 321da177e4SLinus Torvalds #define HCIUARTGETPROTO _IOR('U', 201, int) 33d2158744SMarcel Holtmann #define HCIUARTGETDEVICE _IOR('U', 202, int) 3463c7d09cSJohan Hedberg #define HCIUARTSETFLAGS _IOW('U', 203, int) 3563c7d09cSJohan Hedberg #define HCIUARTGETFLAGS _IOR('U', 204, int) 361da177e4SLinus Torvalds 371da177e4SLinus Torvalds /* UART protocols */ 38e9a2dd26SMarcel Holtmann #define HCI_UART_MAX_PROTO 8 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds #define HCI_UART_H4 0 411da177e4SLinus Torvalds #define HCI_UART_BCSP 1 421da177e4SLinus Torvalds #define HCI_UART_3WIRE 2 431da177e4SLinus Torvalds #define HCI_UART_H4DS 3 44166d2f6aSOhad Ben-Cohen #define HCI_UART_LL 4 45b3190df6SSuraj Sumangala #define HCI_UART_ATH3K 5 4616e3887fSMarcel Holtmann #define HCI_UART_INTEL 6 47e9a2dd26SMarcel Holtmann #define HCI_UART_BCM 7 481da177e4SLinus Torvalds 4963c7d09cSJohan Hedberg #define HCI_UART_RAW_DEVICE 0 50a55e1f38SMarcel Holtmann #define HCI_UART_RESET_ON_INIT 1 518a7a3fd6SMarcel Holtmann #define HCI_UART_CREATE_AMP 2 529f2aee84SJohan Hedberg #define HCI_UART_INIT_PENDING 3 536afd04adSMarcel Holtmann #define HCI_UART_EXT_CONFIG 4 54fb2ce8d1SMarcel Holtmann #define HCI_UART_VND_DETECT 5 5563c7d09cSJohan Hedberg 561da177e4SLinus Torvalds struct hci_uart; 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds struct hci_uart_proto { 591da177e4SLinus Torvalds unsigned int id; 607c40fb8dSMarcel Holtmann const char *name; 617721383fSFrederic Danis unsigned int init_speed; 627721383fSFrederic Danis unsigned int oper_speed; 631da177e4SLinus Torvalds int (*open)(struct hci_uart *hu); 641da177e4SLinus Torvalds int (*close)(struct hci_uart *hu); 651da177e4SLinus Torvalds int (*flush)(struct hci_uart *hu); 666ae4fddfSMarcel Holtmann int (*setup)(struct hci_uart *hu); 677721383fSFrederic Danis int (*set_baudrate)(struct hci_uart *hu, unsigned int speed); 689d1c40ebSMarcel Holtmann int (*recv)(struct hci_uart *hu, const void *data, int len); 691da177e4SLinus Torvalds int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb); 701da177e4SLinus Torvalds struct sk_buff *(*dequeue)(struct hci_uart *hu); 711da177e4SLinus Torvalds }; 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds struct hci_uart { 741da177e4SLinus Torvalds struct tty_struct *tty; 751da177e4SLinus Torvalds struct hci_dev *hdev; 761da177e4SLinus Torvalds unsigned long flags; 7763c7d09cSJohan Hedberg unsigned long hdev_flags; 781da177e4SLinus Torvalds 799f2aee84SJohan Hedberg struct work_struct init_ready; 80da64c27dSFelipe Balbi struct work_struct write_work; 819f2aee84SJohan Hedberg 824ee7ef19SMarcel Holtmann const struct hci_uart_proto *proto; 831da177e4SLinus Torvalds void *priv; 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds struct sk_buff *tx_skb; 861da177e4SLinus Torvalds unsigned long tx_state; 871da177e4SLinus Torvalds spinlock_t rx_lock; 881da177e4SLinus Torvalds }; 891da177e4SLinus Torvalds 9063c7d09cSJohan Hedberg /* HCI_UART proto flag bits */ 911da177e4SLinus Torvalds #define HCI_UART_PROTO_SET 0 929f2aee84SJohan Hedberg #define HCI_UART_REGISTERED 1 931da177e4SLinus Torvalds 941da177e4SLinus Torvalds /* TX states */ 951da177e4SLinus Torvalds #define HCI_UART_SENDING 1 961da177e4SLinus Torvalds #define HCI_UART_TX_WAKEUP 2 971da177e4SLinus Torvalds 984ee7ef19SMarcel Holtmann int hci_uart_register_proto(const struct hci_uart_proto *p); 994ee7ef19SMarcel Holtmann int hci_uart_unregister_proto(const struct hci_uart_proto *p); 1001da177e4SLinus Torvalds int hci_uart_tx_wakeup(struct hci_uart *hu); 1019f2aee84SJohan Hedberg int hci_uart_init_ready(struct hci_uart *hu); 1027721383fSFrederic Danis void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed); 1031da177e4SLinus Torvalds 1040372a662SMarcel Holtmann #ifdef CONFIG_BT_HCIUART_H4 1050372a662SMarcel Holtmann int h4_init(void); 1060372a662SMarcel Holtmann int h4_deinit(void); 107e1a38d70SMarcel Holtmann 10879b8df93SMarcel Holtmann struct h4_recv_pkt { 10979b8df93SMarcel Holtmann u8 type; /* Packet type */ 11079b8df93SMarcel Holtmann u8 hlen; /* Header length */ 11179b8df93SMarcel Holtmann u8 loff; /* Data length offset in header */ 11279b8df93SMarcel Holtmann u8 lsize; /* Data length field size */ 11379b8df93SMarcel Holtmann u16 maxlen; /* Max overall packet length */ 11479b8df93SMarcel Holtmann int (*recv)(struct hci_dev *hdev, struct sk_buff *skb); 11579b8df93SMarcel Holtmann }; 11679b8df93SMarcel Holtmann 11779b8df93SMarcel Holtmann #define H4_RECV_ACL \ 11879b8df93SMarcel Holtmann .type = HCI_ACLDATA_PKT, \ 11979b8df93SMarcel Holtmann .hlen = HCI_ACL_HDR_SIZE, \ 12079b8df93SMarcel Holtmann .loff = 2, \ 12179b8df93SMarcel Holtmann .lsize = 2, \ 12279b8df93SMarcel Holtmann .maxlen = HCI_MAX_FRAME_SIZE \ 12379b8df93SMarcel Holtmann 12479b8df93SMarcel Holtmann #define H4_RECV_SCO \ 12579b8df93SMarcel Holtmann .type = HCI_SCODATA_PKT, \ 12679b8df93SMarcel Holtmann .hlen = HCI_SCO_HDR_SIZE, \ 12779b8df93SMarcel Holtmann .loff = 2, \ 12879b8df93SMarcel Holtmann .lsize = 1, \ 12979b8df93SMarcel Holtmann .maxlen = HCI_MAX_SCO_SIZE 13079b8df93SMarcel Holtmann 13179b8df93SMarcel Holtmann #define H4_RECV_EVENT \ 13279b8df93SMarcel Holtmann .type = HCI_EVENT_PKT, \ 13379b8df93SMarcel Holtmann .hlen = HCI_EVENT_HDR_SIZE, \ 13479b8df93SMarcel Holtmann .loff = 1, \ 13579b8df93SMarcel Holtmann .lsize = 1, \ 13679b8df93SMarcel Holtmann .maxlen = HCI_MAX_EVENT_SIZE 13779b8df93SMarcel Holtmann 138e1a38d70SMarcel Holtmann struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb, 13979b8df93SMarcel Holtmann const unsigned char *buffer, int count, 14079b8df93SMarcel Holtmann const struct h4_recv_pkt *pkts, int pkts_count); 1410372a662SMarcel Holtmann #endif 1420372a662SMarcel Holtmann 1430372a662SMarcel Holtmann #ifdef CONFIG_BT_HCIUART_BCSP 1440372a662SMarcel Holtmann int bcsp_init(void); 1450372a662SMarcel Holtmann int bcsp_deinit(void); 1460372a662SMarcel Holtmann #endif 147166d2f6aSOhad Ben-Cohen 148166d2f6aSOhad Ben-Cohen #ifdef CONFIG_BT_HCIUART_LL 149166d2f6aSOhad Ben-Cohen int ll_init(void); 150166d2f6aSOhad Ben-Cohen int ll_deinit(void); 151166d2f6aSOhad Ben-Cohen #endif 152b3190df6SSuraj Sumangala 153b3190df6SSuraj Sumangala #ifdef CONFIG_BT_HCIUART_ATH3K 154b3190df6SSuraj Sumangala int ath_init(void); 155b3190df6SSuraj Sumangala int ath_deinit(void); 156b3190df6SSuraj Sumangala #endif 1577dec65c8SJohan Hedberg 1587dec65c8SJohan Hedberg #ifdef CONFIG_BT_HCIUART_3WIRE 1597dec65c8SJohan Hedberg int h5_init(void); 1607dec65c8SJohan Hedberg int h5_deinit(void); 1617dec65c8SJohan Hedberg #endif 16216e3887fSMarcel Holtmann 163bdd8818eSMarcel Holtmann #ifdef CONFIG_BT_HCIUART_BCM 164bdd8818eSMarcel Holtmann int bcm_init(void); 165bdd8818eSMarcel Holtmann int bcm_deinit(void); 166bdd8818eSMarcel Holtmann #endif 167