Commit | Line | Data |
---|---|---|
8b8d2e08 EL |
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 | |
98b32dec | 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
8b8d2e08 EL |
16 | */ |
17 | ||
18 | #ifndef __LOCAL_HCI_H | |
19 | #define __LOCAL_HCI_H | |
20 | ||
b5faa648 EL |
21 | #include <net/nfc/hci.h> |
22 | ||
8b8d2e08 EL |
23 | struct gate_pipe_map { |
24 | u8 gate; | |
25 | u8 pipe; | |
26 | }; | |
27 | ||
28 | struct hcp_message { | |
29 | u8 header; /* type -cmd,evt,rsp- + instruction */ | |
30 | u8 data[]; | |
31 | } __packed; | |
32 | ||
33 | struct hcp_packet { | |
34 | u8 header; /* cbit+pipe */ | |
35 | struct hcp_message message; | |
36 | } __packed; | |
37 | ||
8b8d2e08 EL |
38 | struct hcp_exec_waiter { |
39 | wait_queue_head_t *wq; | |
40 | bool exec_complete; | |
41 | int exec_result; | |
42 | struct sk_buff *result_skb; | |
43 | }; | |
44 | ||
45 | struct hci_msg { | |
46 | struct list_head msg_l; | |
47 | struct sk_buff_head msg_frags; | |
48 | bool wait_response; | |
b5faa648 | 49 | data_exchange_cb_t cb; |
8b8d2e08 EL |
50 | void *cb_context; |
51 | unsigned long completion_delay; | |
52 | }; | |
53 | ||
54 | struct hci_create_pipe_params { | |
55 | u8 src_gate; | |
56 | u8 dest_host; | |
57 | u8 dest_gate; | |
58 | } __packed; | |
59 | ||
60 | struct hci_create_pipe_resp { | |
61 | u8 src_host; | |
62 | u8 src_gate; | |
63 | u8 dest_host; | |
64 | u8 dest_gate; | |
65 | u8 pipe; | |
66 | } __packed; | |
67 | ||
615b524a CR |
68 | struct hci_delete_pipe_noti { |
69 | u8 pipe; | |
70 | } __packed; | |
71 | ||
72 | struct hci_all_pipe_cleared_noti { | |
73 | u8 host; | |
74 | } __packed; | |
75 | ||
8b8d2e08 EL |
76 | #define NFC_HCI_FRAGMENT 0x7f |
77 | ||
78 | #define HCP_HEADER(type, instr) ((((type) & 0x03) << 6) | ((instr) & 0x3f)) | |
79 | #define HCP_MSG_GET_TYPE(header) ((header & 0xc0) >> 6) | |
80 | #define HCP_MSG_GET_CMD(header) (header & 0x3f) | |
81 | ||
82 | int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe, | |
83 | u8 type, u8 instruction, | |
84 | const u8 *payload, size_t payload_len, | |
b5faa648 | 85 | data_exchange_cb_t cb, void *cb_context, |
8b8d2e08 EL |
86 | unsigned long completion_delay); |
87 | ||
8b8d2e08 EL |
88 | void nfc_hci_hcp_message_rx(struct nfc_hci_dev *hdev, u8 pipe, u8 type, |
89 | u8 instruction, struct sk_buff *skb); | |
90 | ||
91 | /* HCP headers */ | |
92 | #define NFC_HCI_HCP_PACKET_HEADER_LEN 1 | |
93 | #define NFC_HCI_HCP_MESSAGE_HEADER_LEN 1 | |
94 | #define NFC_HCI_HCP_HEADER_LEN 2 | |
95 | ||
96 | /* HCP types */ | |
97 | #define NFC_HCI_HCP_COMMAND 0x00 | |
98 | #define NFC_HCI_HCP_EVENT 0x01 | |
99 | #define NFC_HCI_HCP_RESPONSE 0x02 | |
100 | ||
101 | /* Generic commands */ | |
102 | #define NFC_HCI_ANY_SET_PARAMETER 0x01 | |
103 | #define NFC_HCI_ANY_GET_PARAMETER 0x02 | |
104 | #define NFC_HCI_ANY_OPEN_PIPE 0x03 | |
105 | #define NFC_HCI_ANY_CLOSE_PIPE 0x04 | |
106 | ||
107 | /* Reader RF commands */ | |
108 | #define NFC_HCI_WR_XCHG_DATA 0x10 | |
109 | ||
110 | /* Admin commands */ | |
111 | #define NFC_HCI_ADM_CREATE_PIPE 0x10 | |
112 | #define NFC_HCI_ADM_DELETE_PIPE 0x11 | |
113 | #define NFC_HCI_ADM_NOTIFY_PIPE_CREATED 0x12 | |
114 | #define NFC_HCI_ADM_NOTIFY_PIPE_DELETED 0x13 | |
115 | #define NFC_HCI_ADM_CLEAR_ALL_PIPE 0x14 | |
116 | #define NFC_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15 | |
117 | ||
118 | /* Generic responses */ | |
119 | #define NFC_HCI_ANY_OK 0x00 | |
120 | #define NFC_HCI_ANY_E_NOT_CONNECTED 0x01 | |
121 | #define NFC_HCI_ANY_E_CMD_PAR_UNKNOWN 0x02 | |
122 | #define NFC_HCI_ANY_E_NOK 0x03 | |
123 | #define NFC_HCI_ANY_E_PIPES_FULL 0x04 | |
124 | #define NFC_HCI_ANY_E_REG_PAR_UNKNOWN 0x05 | |
125 | #define NFC_HCI_ANY_E_PIPE_NOT_OPENED 0x06 | |
126 | #define NFC_HCI_ANY_E_CMD_NOT_SUPPORTED 0x07 | |
127 | #define NFC_HCI_ANY_E_INHIBITED 0x08 | |
128 | #define NFC_HCI_ANY_E_TIMEOUT 0x09 | |
129 | #define NFC_HCI_ANY_E_REG_ACCESS_DENIED 0x0a | |
130 | #define NFC_HCI_ANY_E_PIPE_ACCESS_DENIED 0x0b | |
131 | ||
8b8d2e08 | 132 | #endif /* __LOCAL_HCI_H */ |