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