Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the |
| 16 | * Free Software Foundation, Inc., |
| 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __LOCAL_HCI_H |
| 21 | #define __LOCAL_HCI_H |
| 22 | |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 23 | #include <net/nfc/hci.h> |
| 24 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 25 | struct gate_pipe_map { |
| 26 | u8 gate; |
| 27 | u8 pipe; |
| 28 | }; |
| 29 | |
| 30 | struct hcp_message { |
| 31 | u8 header; /* type -cmd,evt,rsp- + instruction */ |
| 32 | u8 data[]; |
| 33 | } __packed; |
| 34 | |
| 35 | struct hcp_packet { |
| 36 | u8 header; /* cbit+pipe */ |
| 37 | struct hcp_message message; |
| 38 | } __packed; |
| 39 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 40 | struct hcp_exec_waiter { |
| 41 | wait_queue_head_t *wq; |
| 42 | bool exec_complete; |
| 43 | int exec_result; |
| 44 | struct sk_buff *result_skb; |
| 45 | }; |
| 46 | |
| 47 | struct hci_msg { |
| 48 | struct list_head msg_l; |
| 49 | struct sk_buff_head msg_frags; |
| 50 | bool wait_response; |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 51 | data_exchange_cb_t cb; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 52 | void *cb_context; |
| 53 | unsigned long completion_delay; |
| 54 | }; |
| 55 | |
| 56 | struct hci_create_pipe_params { |
| 57 | u8 src_gate; |
| 58 | u8 dest_host; |
| 59 | u8 dest_gate; |
| 60 | } __packed; |
| 61 | |
| 62 | struct hci_create_pipe_resp { |
| 63 | u8 src_host; |
| 64 | u8 src_gate; |
| 65 | u8 dest_host; |
| 66 | u8 dest_gate; |
| 67 | u8 pipe; |
| 68 | } __packed; |
| 69 | |
| 70 | #define NFC_HCI_FRAGMENT 0x7f |
| 71 | |
| 72 | #define HCP_HEADER(type, instr) ((((type) & 0x03) << 6) | ((instr) & 0x3f)) |
| 73 | #define HCP_MSG_GET_TYPE(header) ((header & 0xc0) >> 6) |
| 74 | #define HCP_MSG_GET_CMD(header) (header & 0x3f) |
| 75 | |
| 76 | int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe, |
| 77 | u8 type, u8 instruction, |
| 78 | const u8 *payload, size_t payload_len, |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 79 | data_exchange_cb_t cb, void *cb_context, |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 80 | unsigned long completion_delay); |
| 81 | |
| 82 | u8 nfc_hci_pipe2gate(struct nfc_hci_dev *hdev, u8 pipe); |
| 83 | |
| 84 | void nfc_hci_hcp_message_rx(struct nfc_hci_dev *hdev, u8 pipe, u8 type, |
| 85 | u8 instruction, struct sk_buff *skb); |
| 86 | |
| 87 | /* HCP headers */ |
| 88 | #define NFC_HCI_HCP_PACKET_HEADER_LEN 1 |
| 89 | #define NFC_HCI_HCP_MESSAGE_HEADER_LEN 1 |
| 90 | #define NFC_HCI_HCP_HEADER_LEN 2 |
| 91 | |
| 92 | /* HCP types */ |
| 93 | #define NFC_HCI_HCP_COMMAND 0x00 |
| 94 | #define NFC_HCI_HCP_EVENT 0x01 |
| 95 | #define NFC_HCI_HCP_RESPONSE 0x02 |
| 96 | |
| 97 | /* Generic commands */ |
| 98 | #define NFC_HCI_ANY_SET_PARAMETER 0x01 |
| 99 | #define NFC_HCI_ANY_GET_PARAMETER 0x02 |
| 100 | #define NFC_HCI_ANY_OPEN_PIPE 0x03 |
| 101 | #define NFC_HCI_ANY_CLOSE_PIPE 0x04 |
| 102 | |
| 103 | /* Reader RF commands */ |
| 104 | #define NFC_HCI_WR_XCHG_DATA 0x10 |
| 105 | |
| 106 | /* Admin commands */ |
| 107 | #define NFC_HCI_ADM_CREATE_PIPE 0x10 |
| 108 | #define NFC_HCI_ADM_DELETE_PIPE 0x11 |
| 109 | #define NFC_HCI_ADM_NOTIFY_PIPE_CREATED 0x12 |
| 110 | #define NFC_HCI_ADM_NOTIFY_PIPE_DELETED 0x13 |
| 111 | #define NFC_HCI_ADM_CLEAR_ALL_PIPE 0x14 |
| 112 | #define NFC_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15 |
| 113 | |
| 114 | /* Generic responses */ |
| 115 | #define NFC_HCI_ANY_OK 0x00 |
| 116 | #define NFC_HCI_ANY_E_NOT_CONNECTED 0x01 |
| 117 | #define NFC_HCI_ANY_E_CMD_PAR_UNKNOWN 0x02 |
| 118 | #define NFC_HCI_ANY_E_NOK 0x03 |
| 119 | #define NFC_HCI_ANY_E_PIPES_FULL 0x04 |
| 120 | #define NFC_HCI_ANY_E_REG_PAR_UNKNOWN 0x05 |
| 121 | #define NFC_HCI_ANY_E_PIPE_NOT_OPENED 0x06 |
| 122 | #define NFC_HCI_ANY_E_CMD_NOT_SUPPORTED 0x07 |
| 123 | #define NFC_HCI_ANY_E_INHIBITED 0x08 |
| 124 | #define NFC_HCI_ANY_E_TIMEOUT 0x09 |
| 125 | #define NFC_HCI_ANY_E_REG_ACCESS_DENIED 0x0a |
| 126 | #define NFC_HCI_ANY_E_PIPE_ACCESS_DENIED 0x0b |
| 127 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 128 | #endif /* __LOCAL_HCI_H */ |