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 */ 3816e3887fSMarcel Holtmann #define HCI_UART_MAX_PROTO 7 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 471da177e4SLinus Torvalds 4863c7d09cSJohan Hedberg #define HCI_UART_RAW_DEVICE 0 49a55e1f38SMarcel Holtmann #define HCI_UART_RESET_ON_INIT 1 508a7a3fd6SMarcel Holtmann #define HCI_UART_CREATE_AMP 2 519f2aee84SJohan Hedberg #define HCI_UART_INIT_PENDING 3 526afd04adSMarcel Holtmann #define HCI_UART_EXT_CONFIG 4 53fb2ce8d1SMarcel Holtmann #define HCI_UART_VND_DETECT 5 5463c7d09cSJohan Hedberg 551da177e4SLinus Torvalds struct hci_uart; 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds struct hci_uart_proto { 581da177e4SLinus Torvalds unsigned int id; 591da177e4SLinus Torvalds int (*open)(struct hci_uart *hu); 601da177e4SLinus Torvalds int (*close)(struct hci_uart *hu); 611da177e4SLinus Torvalds int (*flush)(struct hci_uart *hu); 621da177e4SLinus Torvalds int (*recv)(struct hci_uart *hu, void *data, int len); 631da177e4SLinus Torvalds int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb); 64eb173809SLoic Poulain int (*setup)(struct hci_uart *hu); 651da177e4SLinus Torvalds struct sk_buff *(*dequeue)(struct hci_uart *hu); 661da177e4SLinus Torvalds }; 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds struct hci_uart { 691da177e4SLinus Torvalds struct tty_struct *tty; 701da177e4SLinus Torvalds struct hci_dev *hdev; 711da177e4SLinus Torvalds unsigned long flags; 7263c7d09cSJohan Hedberg unsigned long hdev_flags; 731da177e4SLinus Torvalds 749f2aee84SJohan Hedberg struct work_struct init_ready; 75da64c27dSFelipe Balbi struct work_struct write_work; 769f2aee84SJohan Hedberg 771da177e4SLinus Torvalds struct hci_uart_proto *proto; 781da177e4SLinus Torvalds void *priv; 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds struct sk_buff *tx_skb; 811da177e4SLinus Torvalds unsigned long tx_state; 821da177e4SLinus Torvalds spinlock_t rx_lock; 831da177e4SLinus Torvalds }; 841da177e4SLinus Torvalds 8563c7d09cSJohan Hedberg /* HCI_UART proto flag bits */ 861da177e4SLinus Torvalds #define HCI_UART_PROTO_SET 0 879f2aee84SJohan Hedberg #define HCI_UART_REGISTERED 1 881da177e4SLinus Torvalds 891da177e4SLinus Torvalds /* TX states */ 901da177e4SLinus Torvalds #define HCI_UART_SENDING 1 911da177e4SLinus Torvalds #define HCI_UART_TX_WAKEUP 2 921da177e4SLinus Torvalds 931da177e4SLinus Torvalds int hci_uart_register_proto(struct hci_uart_proto *p); 941da177e4SLinus Torvalds int hci_uart_unregister_proto(struct hci_uart_proto *p); 951da177e4SLinus Torvalds int hci_uart_tx_wakeup(struct hci_uart *hu); 969f2aee84SJohan Hedberg int hci_uart_init_ready(struct hci_uart *hu); 971da177e4SLinus Torvalds 980372a662SMarcel Holtmann #ifdef CONFIG_BT_HCIUART_H4 990372a662SMarcel Holtmann int h4_init(void); 1000372a662SMarcel Holtmann int h4_deinit(void); 1010372a662SMarcel Holtmann #endif 1020372a662SMarcel Holtmann 1030372a662SMarcel Holtmann #ifdef CONFIG_BT_HCIUART_BCSP 1040372a662SMarcel Holtmann int bcsp_init(void); 1050372a662SMarcel Holtmann int bcsp_deinit(void); 1060372a662SMarcel Holtmann #endif 107166d2f6aSOhad Ben-Cohen 108166d2f6aSOhad Ben-Cohen #ifdef CONFIG_BT_HCIUART_LL 109166d2f6aSOhad Ben-Cohen int ll_init(void); 110166d2f6aSOhad Ben-Cohen int ll_deinit(void); 111166d2f6aSOhad Ben-Cohen #endif 112b3190df6SSuraj Sumangala 113b3190df6SSuraj Sumangala #ifdef CONFIG_BT_HCIUART_ATH3K 114b3190df6SSuraj Sumangala int ath_init(void); 115b3190df6SSuraj Sumangala int ath_deinit(void); 116b3190df6SSuraj Sumangala #endif 1177dec65c8SJohan Hedberg 1187dec65c8SJohan Hedberg #ifdef CONFIG_BT_HCIUART_3WIRE 1197dec65c8SJohan Hedberg int h5_init(void); 1207dec65c8SJohan Hedberg int h5_deinit(void); 1217dec65c8SJohan Hedberg #endif 12216e3887fSMarcel Holtmann 12316e3887fSMarcel Holtmann #ifdef CONFIG_BT_HCIUART_INTEL 12416e3887fSMarcel Holtmann int intel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); 12516e3887fSMarcel Holtmann #endif 126