xref: /openbmc/linux/include/net/nfc/nci.h (revision a9433c11b1aa0639cc6e4842fff52af2422af06d)
16a2968aaSIlan Elias /*
26a2968aaSIlan Elias  *  The NFC Controller Interface is the communication protocol between an
36a2968aaSIlan Elias  *  NFC Controller (NFCC) and a Device Host (DH).
46a2968aaSIlan Elias  *
5cfdbeeafSVincent Cuissard  *  Copyright (C) 2014 Marvell International Ltd.
66a2968aaSIlan Elias  *  Copyright (C) 2011 Texas Instruments, Inc.
76a2968aaSIlan Elias  *
86a2968aaSIlan Elias  *  Written by Ilan Elias <ilane@ti.com>
96a2968aaSIlan Elias  *
106a2968aaSIlan Elias  *  Acknowledgements:
116a2968aaSIlan Elias  *  This file is based on hci.h, which was written
126a2968aaSIlan Elias  *  by Maxim Krasnyansky.
136a2968aaSIlan Elias  *
146a2968aaSIlan Elias  *  This program is free software; you can redistribute it and/or modify
156a2968aaSIlan Elias  *  it under the terms of the GNU General Public License version 2
166a2968aaSIlan Elias  *  as published by the Free Software Foundation
176a2968aaSIlan Elias  *
186a2968aaSIlan Elias  *  This program is distributed in the hope that it will be useful,
196a2968aaSIlan Elias  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
206a2968aaSIlan Elias  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
216a2968aaSIlan Elias  *  GNU General Public License for more details.
226a2968aaSIlan Elias  *
236a2968aaSIlan Elias  *  You should have received a copy of the GNU General Public License
24a6227e26SJeff Kirsher  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
256a2968aaSIlan Elias  *
266a2968aaSIlan Elias  */
276a2968aaSIlan Elias 
286a2968aaSIlan Elias #ifndef __NCI_H
296a2968aaSIlan Elias #define __NCI_H
306a2968aaSIlan Elias 
31a99903ecSJulien Lefrique #include <net/nfc/nfc.h>
32a99903ecSJulien Lefrique 
336a2968aaSIlan Elias /* NCI constants */
346a2968aaSIlan Elias #define NCI_MAX_NUM_MAPPING_CONFIGS				10
356a2968aaSIlan Elias #define NCI_MAX_NUM_RF_CONFIGS					10
366a2968aaSIlan Elias #define NCI_MAX_NUM_CONN					10
377e035230SIlan Elias #define NCI_MAX_PARAM_LEN					251
389961127dSVincent Cuissard #define NCI_MAX_PACKET_SIZE					258
396a2968aaSIlan Elias 
406a2968aaSIlan Elias /* NCI Status Codes */
416a2968aaSIlan Elias #define NCI_STATUS_OK						0x00
426a2968aaSIlan Elias #define NCI_STATUS_REJECTED					0x01
43e8c0dacdSIlan Elias #define NCI_STATUS_RF_FRAME_CORRUPTED				0x02
44e8c0dacdSIlan Elias #define NCI_STATUS_FAILED					0x03
45e8c0dacdSIlan Elias #define NCI_STATUS_NOT_INITIALIZED				0x04
46e8c0dacdSIlan Elias #define NCI_STATUS_SYNTAX_ERROR					0x05
47e8c0dacdSIlan Elias #define NCI_STATUS_SEMANTIC_ERROR				0x06
48e8c0dacdSIlan Elias #define NCI_STATUS_UNKNOWN_GID					0x07
49e8c0dacdSIlan Elias #define NCI_STATUS_UNKNOWN_OID					0x08
50e8c0dacdSIlan Elias #define NCI_STATUS_INVALID_PARAM				0x09
51e8c0dacdSIlan Elias #define NCI_STATUS_MESSAGE_SIZE_EXCEEDED			0x0a
526a2968aaSIlan Elias /* Discovery Specific Status Codes */
536a2968aaSIlan Elias #define NCI_STATUS_DISCOVERY_ALREADY_STARTED			0xa0
546a2968aaSIlan Elias #define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED		0xa1
55e8c0dacdSIlan Elias #define NCI_STATUS_DISCOVERY_TEAR_DOWN				0xa2
566a2968aaSIlan Elias /* RF Interface Specific Status Codes */
576a2968aaSIlan Elias #define NCI_STATUS_RF_TRANSMISSION_ERROR			0xb0
586a2968aaSIlan Elias #define NCI_STATUS_RF_PROTOCOL_ERROR				0xb1
596a2968aaSIlan Elias #define NCI_STATUS_RF_TIMEOUT_ERROR				0xb2
606a2968aaSIlan Elias /* NFCEE Interface Specific Status Codes */
61637d85a7SIlan Elias #define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED		0xc0
62637d85a7SIlan Elias #define NCI_STATUS_NFCEE_TRANSMISSION_ERROR			0xc1
63637d85a7SIlan Elias #define NCI_STATUS_NFCEE_PROTOCOL_ERROR				0xc2
64637d85a7SIlan Elias #define NCI_STATUS_NFCEE_TIMEOUT_ERROR				0xc3
656a2968aaSIlan Elias 
668277f693SChristophe Ricard /* NFCEE Interface/Protocols */
678277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_APDU           0x00
688277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_HCI_ACCESS     0x01
698277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_TYPE3_CMD_SET  0x02
708277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_TRANSPARENT        0x03
718277f693SChristophe Ricard 
728277f693SChristophe Ricard /* Destination type */
738277f693SChristophe Ricard #define NCI_DESTINATION_NFCC_LOOPBACK      0x01
748277f693SChristophe Ricard #define NCI_DESTINATION_REMOTE_NFC_ENDPOINT    0x02
758277f693SChristophe Ricard #define NCI_DESTINATION_NFCEE              0x03
768277f693SChristophe Ricard 
778277f693SChristophe Ricard /* Destination-specific parameters type */
788277f693SChristophe Ricard #define NCI_DESTINATION_SPECIFIC_PARAM_RF_TYPE     0x00
798277f693SChristophe Ricard #define NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE  0x01
808277f693SChristophe Ricard 
818277f693SChristophe Ricard /* NFCEE Discovery Action */
828277f693SChristophe Ricard #define NCI_NFCEE_DISCOVERY_ACTION_DISABLE			0x00
838277f693SChristophe Ricard #define NCI_NFCEE_DISCOVERY_ACTION_ENABLE			0x01
848277f693SChristophe Ricard 
856a2968aaSIlan Elias /* NCI RF Technology and Mode */
866a2968aaSIlan Elias #define NCI_NFC_A_PASSIVE_POLL_MODE				0x00
876a2968aaSIlan Elias #define NCI_NFC_B_PASSIVE_POLL_MODE				0x01
886a2968aaSIlan Elias #define NCI_NFC_F_PASSIVE_POLL_MODE				0x02
896a2968aaSIlan Elias #define NCI_NFC_A_ACTIVE_POLL_MODE				0x03
906a2968aaSIlan Elias #define NCI_NFC_F_ACTIVE_POLL_MODE				0x05
91cfdbeeafSVincent Cuissard #define NCI_NFC_V_PASSIVE_POLL_MODE				0x06
926a2968aaSIlan Elias #define NCI_NFC_A_PASSIVE_LISTEN_MODE				0x80
936a2968aaSIlan Elias #define NCI_NFC_B_PASSIVE_LISTEN_MODE				0x81
946a2968aaSIlan Elias #define NCI_NFC_F_PASSIVE_LISTEN_MODE				0x82
956a2968aaSIlan Elias #define NCI_NFC_A_ACTIVE_LISTEN_MODE				0x83
966a2968aaSIlan Elias #define NCI_NFC_F_ACTIVE_LISTEN_MODE				0x85
976a2968aaSIlan Elias 
98a99903ecSJulien Lefrique #define NCI_RF_TECH_MODE_LISTEN_MASK				0x80
99a99903ecSJulien Lefrique 
100e8c0dacdSIlan Elias /* NCI RF Technologies */
101e8c0dacdSIlan Elias #define NCI_NFC_RF_TECHNOLOGY_A					0x00
102e8c0dacdSIlan Elias #define NCI_NFC_RF_TECHNOLOGY_B					0x01
103e8c0dacdSIlan Elias #define NCI_NFC_RF_TECHNOLOGY_F					0x02
104cfdbeeafSVincent Cuissard #define NCI_NFC_RF_TECHNOLOGY_V					0x03
105e8c0dacdSIlan Elias 
106e8c0dacdSIlan Elias /* NCI Bit Rates */
107e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_106					0x00
108e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_212					0x01
109e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_424					0x02
110e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_848					0x03
111637d85a7SIlan Elias #define NCI_NFC_BIT_RATE_1695					0x04
112637d85a7SIlan Elias #define NCI_NFC_BIT_RATE_3390					0x05
113637d85a7SIlan Elias #define NCI_NFC_BIT_RATE_6780					0x06
114cfdbeeafSVincent Cuissard #define NCI_NFC_BIT_RATE_26					0x20
115e8c0dacdSIlan Elias 
1166a2968aaSIlan Elias /* NCI RF Protocols */
1176a2968aaSIlan Elias #define NCI_RF_PROTOCOL_UNKNOWN					0x00
1186a2968aaSIlan Elias #define NCI_RF_PROTOCOL_T1T					0x01
1196a2968aaSIlan Elias #define NCI_RF_PROTOCOL_T2T					0x02
1206a2968aaSIlan Elias #define NCI_RF_PROTOCOL_T3T					0x03
1216a2968aaSIlan Elias #define NCI_RF_PROTOCOL_ISO_DEP					0x04
1226a2968aaSIlan Elias #define NCI_RF_PROTOCOL_NFC_DEP					0x05
123cfdbeeafSVincent Cuissard #define NCI_RF_PROTOCOL_T5T					0x06
1246a2968aaSIlan Elias 
1256a2968aaSIlan Elias /* NCI RF Interfaces */
126e8c0dacdSIlan Elias #define NCI_RF_INTERFACE_NFCEE_DIRECT				0x00
1276a2968aaSIlan Elias #define NCI_RF_INTERFACE_FRAME					0x01
1286a2968aaSIlan Elias #define NCI_RF_INTERFACE_ISO_DEP				0x02
1296a2968aaSIlan Elias #define NCI_RF_INTERFACE_NFC_DEP				0x03
1306a2968aaSIlan Elias 
1317e035230SIlan Elias /* NCI Configuration Parameter Tags */
1327e035230SIlan Elias #define NCI_PN_ATR_REQ_GEN_BYTES				0x29
133529ee066SJulien Lefrique #define NCI_LN_ATR_RES_GEN_BYTES				0x61
13490d78c13SJulien Lefrique #define NCI_LA_SEL_INFO						0x32
13590d78c13SJulien Lefrique #define NCI_LF_PROTOCOL_TYPE					0x50
13690d78c13SJulien Lefrique #define NCI_LF_CON_BITR_F					0x54
13790d78c13SJulien Lefrique 
13890d78c13SJulien Lefrique /* NCI Configuration Parameters masks */
13990d78c13SJulien Lefrique #define NCI_LA_SEL_INFO_ISO_DEP_MASK				0x20
14090d78c13SJulien Lefrique #define NCI_LA_SEL_INFO_NFC_DEP_MASK				0x40
14190d78c13SJulien Lefrique #define NCI_LF_PROTOCOL_TYPE_NFC_DEP_MASK			0x02
14290d78c13SJulien Lefrique #define NCI_LF_CON_BITR_F_212					0x02
14390d78c13SJulien Lefrique #define NCI_LF_CON_BITR_F_424					0x04
1447e035230SIlan Elias 
145e8c0dacdSIlan Elias /* NCI Reset types */
146e8c0dacdSIlan Elias #define NCI_RESET_TYPE_KEEP_CONFIG				0x00
147e8c0dacdSIlan Elias #define NCI_RESET_TYPE_RESET_CONFIG				0x01
148e8c0dacdSIlan Elias 
149e8c0dacdSIlan Elias /* NCI Static RF connection ID */
150e8c0dacdSIlan Elias #define NCI_STATIC_RF_CONN_ID					0x00
151e8c0dacdSIlan Elias 
152db98c829SIlan Elias /* NCI Data Flow Control */
153db98c829SIlan Elias #define NCI_DATA_FLOW_CONTROL_NOT_USED				0xff
154db98c829SIlan Elias 
1556a2968aaSIlan Elias /* NCI RF_DISCOVER_MAP_CMD modes */
1566a2968aaSIlan Elias #define NCI_DISC_MAP_MODE_POLL					0x01
1576a2968aaSIlan Elias #define NCI_DISC_MAP_MODE_LISTEN				0x02
1586a2968aaSIlan Elias 
159019c4fbaSIlan Elias /* NCI Discover Notification Type */
160019c4fbaSIlan Elias #define NCI_DISCOVER_NTF_TYPE_LAST				0x00
161019c4fbaSIlan Elias #define NCI_DISCOVER_NTF_TYPE_LAST_NFCC				0x01
162019c4fbaSIlan Elias #define NCI_DISCOVER_NTF_TYPE_MORE				0x02
163019c4fbaSIlan Elias 
1646a2968aaSIlan Elias /* NCI Deactivation Type */
1656a2968aaSIlan Elias #define NCI_DEACTIVATE_TYPE_IDLE_MODE				0x00
1666a2968aaSIlan Elias #define NCI_DEACTIVATE_TYPE_SLEEP_MODE				0x01
1676a2968aaSIlan Elias #define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE			0x02
168e8c0dacdSIlan Elias #define NCI_DEACTIVATE_TYPE_DISCOVERY				0x03
1696a2968aaSIlan Elias 
1706a2968aaSIlan Elias /* Message Type (MT) */
1716a2968aaSIlan Elias #define NCI_MT_DATA_PKT						0x00
1726a2968aaSIlan Elias #define NCI_MT_CMD_PKT						0x01
1736a2968aaSIlan Elias #define NCI_MT_RSP_PKT						0x02
1746a2968aaSIlan Elias #define NCI_MT_NTF_PKT						0x03
1756a2968aaSIlan Elias 
1766a2968aaSIlan Elias #define nci_mt(hdr)			(((hdr)[0]>>5)&0x07)
1776a2968aaSIlan Elias #define nci_mt_set(hdr, mt)		((hdr)[0] |= (__u8)(((mt)&0x07)<<5))
1786a2968aaSIlan Elias 
1796a2968aaSIlan Elias /* Packet Boundary Flag (PBF) */
1806a2968aaSIlan Elias #define NCI_PBF_LAST						0x00
1816a2968aaSIlan Elias #define NCI_PBF_CONT						0x01
1826a2968aaSIlan Elias 
1836a2968aaSIlan Elias #define nci_pbf(hdr)			(__u8)(((hdr)[0]>>4)&0x01)
1846a2968aaSIlan Elias #define nci_pbf_set(hdr, pbf)		((hdr)[0] |= (__u8)(((pbf)&0x01)<<4))
1856a2968aaSIlan Elias 
1866a2968aaSIlan Elias /* Control Opcode manipulation */
1876a2968aaSIlan Elias #define nci_opcode_pack(gid, oid)	(__u16)((((__u16)((gid)&0x0f))<<8)|\
1886a2968aaSIlan Elias 					((__u16)((oid)&0x3f)))
1896a2968aaSIlan Elias #define nci_opcode(hdr)			nci_opcode_pack(hdr[0], hdr[1])
1906a2968aaSIlan Elias #define nci_opcode_gid(op)		(__u8)(((op)&0x0f00)>>8)
1916a2968aaSIlan Elias #define nci_opcode_oid(op)		(__u8)((op)&0x003f)
1926a2968aaSIlan Elias 
1936a2968aaSIlan Elias /* Payload Length */
1946a2968aaSIlan Elias #define nci_plen(hdr)			(__u8)((hdr)[2])
1956a2968aaSIlan Elias 
1966a2968aaSIlan Elias /* Connection ID */
1976a2968aaSIlan Elias #define nci_conn_id(hdr)		(__u8)(((hdr)[0])&0x0f)
1986a2968aaSIlan Elias 
1996a2968aaSIlan Elias /* GID values */
2006a2968aaSIlan Elias #define NCI_GID_CORE						0x0
2016a2968aaSIlan Elias #define NCI_GID_RF_MGMT						0x1
2026a2968aaSIlan Elias #define NCI_GID_NFCEE_MGMT					0x2
2036a2968aaSIlan Elias #define NCI_GID_PROPRIETARY					0xf
2046a2968aaSIlan Elias 
205fa544fffSEric Lapuyade /* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
206fa544fffSEric Lapuyade #define NCI_SPI_HDR_LEN						4
207fa544fffSEric Lapuyade #define NCI_SPI_CRC_LEN						2
208fa544fffSEric Lapuyade 
2096a2968aaSIlan Elias /* ---- NCI Packet structures ---- */
2106a2968aaSIlan Elias #define NCI_CTRL_HDR_SIZE					3
2116a2968aaSIlan Elias #define NCI_DATA_HDR_SIZE					3
2126a2968aaSIlan Elias 
2136a2968aaSIlan Elias struct nci_ctrl_hdr {
2146a2968aaSIlan Elias 	__u8	gid;		/* MT & PBF & GID */
2156a2968aaSIlan Elias 	__u8	oid;
2166a2968aaSIlan Elias 	__u8	plen;
2176a2968aaSIlan Elias } __packed;
2186a2968aaSIlan Elias 
2196a2968aaSIlan Elias struct nci_data_hdr {
2206a2968aaSIlan Elias 	__u8	conn_id;	/* MT & PBF & ConnID */
2216a2968aaSIlan Elias 	__u8	rfu;
2226a2968aaSIlan Elias 	__u8	plen;
2236a2968aaSIlan Elias } __packed;
2246a2968aaSIlan Elias 
2256a2968aaSIlan Elias /* ------------------------ */
2266a2968aaSIlan Elias /* -----  NCI Commands ---- */
2276a2968aaSIlan Elias /* ------------------------ */
2286a2968aaSIlan Elias #define NCI_OP_CORE_RESET_CMD		nci_opcode_pack(NCI_GID_CORE, 0x00)
229e8c0dacdSIlan Elias struct nci_core_reset_cmd {
230e8c0dacdSIlan Elias 	__u8	reset_type;
231e8c0dacdSIlan Elias } __packed;
2326a2968aaSIlan Elias 
2336a2968aaSIlan Elias #define NCI_OP_CORE_INIT_CMD		nci_opcode_pack(NCI_GID_CORE, 0x01)
2346a2968aaSIlan Elias 
2357e035230SIlan Elias #define NCI_OP_CORE_SET_CONFIG_CMD	nci_opcode_pack(NCI_GID_CORE, 0x02)
2367e035230SIlan Elias struct set_config_param {
2377e035230SIlan Elias 	__u8	id;
2387e035230SIlan Elias 	__u8	len;
2397e035230SIlan Elias 	__u8	val[NCI_MAX_PARAM_LEN];
2407e035230SIlan Elias } __packed;
2417e035230SIlan Elias 
2427e035230SIlan Elias struct nci_core_set_config_cmd {
2437e035230SIlan Elias 	__u8	num_params;
2447e035230SIlan Elias 	struct	set_config_param param; /* support 1 param per cmd is enough */
2457e035230SIlan Elias } __packed;
2467e035230SIlan Elias 
247736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CREATE_CMD	nci_opcode_pack(NCI_GID_CORE, 0x04)
248b16ae716SChristophe Ricard #define DEST_SPEC_PARAMS_ID_INDEX	0
249b16ae716SChristophe Ricard #define DEST_SPEC_PARAMS_PROTOCOL_INDEX	1
250736bb957SChristophe Ricard struct dest_spec_params {
251736bb957SChristophe Ricard 	__u8    id;
252736bb957SChristophe Ricard 	__u8    protocol;
253736bb957SChristophe Ricard } __packed;
254736bb957SChristophe Ricard 
255736bb957SChristophe Ricard struct core_conn_create_dest_spec_params {
256736bb957SChristophe Ricard 	__u8    type;
257736bb957SChristophe Ricard 	__u8    length;
258b16ae716SChristophe Ricard 	__u8    value[0];
259736bb957SChristophe Ricard } __packed;
260736bb957SChristophe Ricard 
261736bb957SChristophe Ricard struct nci_core_conn_create_cmd {
262736bb957SChristophe Ricard 	__u8    destination_type;
263736bb957SChristophe Ricard 	__u8    number_destination_params;
264b16ae716SChristophe Ricard 	struct core_conn_create_dest_spec_params params[0];
265736bb957SChristophe Ricard } __packed;
266736bb957SChristophe Ricard 
267736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CLOSE_CMD	nci_opcode_pack(NCI_GID_CORE, 0x05)
268736bb957SChristophe Ricard 
2696a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_MAP_CMD	nci_opcode_pack(NCI_GID_RF_MGMT, 0x00)
2706a2968aaSIlan Elias struct disc_map_config {
2716a2968aaSIlan Elias 	__u8	rf_protocol;
2726a2968aaSIlan Elias 	__u8	mode;
273637d85a7SIlan Elias 	__u8	rf_interface;
2746a2968aaSIlan Elias } __packed;
2756a2968aaSIlan Elias 
2766a2968aaSIlan Elias struct nci_rf_disc_map_cmd {
2776a2968aaSIlan Elias 	__u8				num_mapping_configs;
2786a2968aaSIlan Elias 	struct disc_map_config		mapping_configs
2796a2968aaSIlan Elias 					[NCI_MAX_NUM_MAPPING_CONFIGS];
2806a2968aaSIlan Elias } __packed;
2816a2968aaSIlan Elias 
2826a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_CMD		nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
2836a2968aaSIlan Elias struct disc_config {
284637d85a7SIlan Elias 	__u8	rf_tech_and_mode;
2856a2968aaSIlan Elias 	__u8	frequency;
2866a2968aaSIlan Elias } __packed;
2876a2968aaSIlan Elias 
2886a2968aaSIlan Elias struct nci_rf_disc_cmd {
2896a2968aaSIlan Elias 	__u8				num_disc_configs;
2906a2968aaSIlan Elias 	struct disc_config		disc_configs[NCI_MAX_NUM_RF_CONFIGS];
2916a2968aaSIlan Elias } __packed;
2926a2968aaSIlan Elias 
293019c4fbaSIlan Elias #define NCI_OP_RF_DISCOVER_SELECT_CMD	nci_opcode_pack(NCI_GID_RF_MGMT, 0x04)
294019c4fbaSIlan Elias struct nci_rf_discover_select_cmd {
295019c4fbaSIlan Elias 	__u8	rf_discovery_id;
296019c4fbaSIlan Elias 	__u8	rf_protocol;
297019c4fbaSIlan Elias 	__u8	rf_interface;
298019c4fbaSIlan Elias } __packed;
299019c4fbaSIlan Elias 
3006a2968aaSIlan Elias #define NCI_OP_RF_DEACTIVATE_CMD	nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
3016a2968aaSIlan Elias struct nci_rf_deactivate_cmd {
3026a2968aaSIlan Elias 	__u8	type;
3036a2968aaSIlan Elias } __packed;
3046a2968aaSIlan Elias 
3058277f693SChristophe Ricard #define NCI_OP_NFCEE_DISCOVER_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00)
3068277f693SChristophe Ricard struct nci_nfcee_discover_cmd {
3078277f693SChristophe Ricard 	__u8	discovery_action;
3088277f693SChristophe Ricard } __packed;
3098277f693SChristophe Ricard 
310f7f793f3SChristophe Ricard #define NCI_OP_NFCEE_MODE_SET_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01)
311f7f793f3SChristophe Ricard #define NCI_NFCEE_DISABLE	0x00
312f7f793f3SChristophe Ricard #define NCI_NFCEE_ENABLE	0x01
313f7f793f3SChristophe Ricard struct nci_nfcee_mode_set_cmd {
314f7f793f3SChristophe Ricard 	__u8	nfcee_id;
315f7f793f3SChristophe Ricard 	__u8	nfcee_mode;
316f7f793f3SChristophe Ricard } __packed;
317f7f793f3SChristophe Ricard 
318*a9433c11SRobert Dolca #define NCI_OP_CORE_GET_CONFIG_CMD	nci_opcode_pack(NCI_GID_CORE, 0x03)
319*a9433c11SRobert Dolca 
3206a2968aaSIlan Elias /* ----------------------- */
3216a2968aaSIlan Elias /* ---- NCI Responses ---- */
3226a2968aaSIlan Elias /* ----------------------- */
3236a2968aaSIlan Elias #define NCI_OP_CORE_RESET_RSP		nci_opcode_pack(NCI_GID_CORE, 0x00)
3246a2968aaSIlan Elias struct nci_core_reset_rsp {
3256a2968aaSIlan Elias 	__u8	status;
3266a2968aaSIlan Elias 	__u8	nci_ver;
327e8c0dacdSIlan Elias 	__u8	config_status;
3286a2968aaSIlan Elias } __packed;
3296a2968aaSIlan Elias 
3306a2968aaSIlan Elias #define NCI_OP_CORE_INIT_RSP		nci_opcode_pack(NCI_GID_CORE, 0x01)
3316a2968aaSIlan Elias struct nci_core_init_rsp_1 {
3326a2968aaSIlan Elias 	__u8	status;
3336a2968aaSIlan Elias 	__le32	nfcc_features;
3346a2968aaSIlan Elias 	__u8	num_supported_rf_interfaces;
3356a2968aaSIlan Elias 	__u8	supported_rf_interfaces[0];	/* variable size array */
3366a2968aaSIlan Elias 	/* continuted in nci_core_init_rsp_2 */
3376a2968aaSIlan Elias } __packed;
3386a2968aaSIlan Elias 
3396a2968aaSIlan Elias struct nci_core_init_rsp_2 {
3406a2968aaSIlan Elias 	__u8	max_logical_connections;
3416a2968aaSIlan Elias 	__le16	max_routing_table_size;
342e8c0dacdSIlan Elias 	__u8	max_ctrl_pkt_payload_len;
343e8c0dacdSIlan Elias 	__le16	max_size_for_large_params;
344e8c0dacdSIlan Elias 	__u8	manufact_id;
345e8c0dacdSIlan Elias 	__le32	manufact_specific_info;
3466a2968aaSIlan Elias } __packed;
3476a2968aaSIlan Elias 
3487e035230SIlan Elias #define NCI_OP_CORE_SET_CONFIG_RSP	nci_opcode_pack(NCI_GID_CORE, 0x02)
3497e035230SIlan Elias struct nci_core_set_config_rsp {
3507e035230SIlan Elias 	__u8	status;
3517e035230SIlan Elias 	__u8	num_params;
3527e035230SIlan Elias 	__u8	params_id[0];	/* variable size array */
3537e035230SIlan Elias } __packed;
3547e035230SIlan Elias 
355736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CREATE_RSP	nci_opcode_pack(NCI_GID_CORE, 0x04)
356736bb957SChristophe Ricard struct nci_core_conn_create_rsp {
357736bb957SChristophe Ricard 	__u8	status;
358736bb957SChristophe Ricard 	__u8	max_ctrl_pkt_payload_len;
3593ba5c846SChristophe Ricard 	__u8    credits_cnt;
360736bb957SChristophe Ricard 	__u8	conn_id;
361736bb957SChristophe Ricard } __packed;
362736bb957SChristophe Ricard 
363736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CLOSE_RSP	nci_opcode_pack(NCI_GID_CORE, 0x05)
364736bb957SChristophe Ricard 
3656a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_MAP_RSP	nci_opcode_pack(NCI_GID_RF_MGMT, 0x00)
3666a2968aaSIlan Elias 
3676a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_RSP		nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
3686a2968aaSIlan Elias 
369019c4fbaSIlan Elias #define NCI_OP_RF_DISCOVER_SELECT_RSP	nci_opcode_pack(NCI_GID_RF_MGMT, 0x04)
370019c4fbaSIlan Elias 
3716a2968aaSIlan Elias #define NCI_OP_RF_DEACTIVATE_RSP	nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
3726a2968aaSIlan Elias 
3738277f693SChristophe Ricard #define NCI_OP_NFCEE_DISCOVER_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00)
3748277f693SChristophe Ricard struct nci_nfcee_discover_rsp {
3758277f693SChristophe Ricard 	__u8	status;
3768277f693SChristophe Ricard 	__u8	num_nfcee;
3778277f693SChristophe Ricard } __packed;
3788277f693SChristophe Ricard 
379f7f793f3SChristophe Ricard #define NCI_OP_NFCEE_MODE_SET_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01)
380*a9433c11SRobert Dolca 
381*a9433c11SRobert Dolca #define NCI_OP_CORE_GET_CONFIG_RSP	nci_opcode_pack(NCI_GID_CORE, 0x03)
382*a9433c11SRobert Dolca 
3836a2968aaSIlan Elias /* --------------------------- */
3846a2968aaSIlan Elias /* ---- NCI Notifications ---- */
3856a2968aaSIlan Elias /* --------------------------- */
386637d85a7SIlan Elias #define NCI_OP_CORE_CONN_CREDITS_NTF	nci_opcode_pack(NCI_GID_CORE, 0x06)
3876a2968aaSIlan Elias struct conn_credit_entry {
3886a2968aaSIlan Elias 	__u8	conn_id;
3896a2968aaSIlan Elias 	__u8	credits;
3906a2968aaSIlan Elias } __packed;
3916a2968aaSIlan Elias 
3926a2968aaSIlan Elias struct nci_core_conn_credit_ntf {
3936a2968aaSIlan Elias 	__u8				num_entries;
3946a2968aaSIlan Elias 	struct conn_credit_entry	conn_entries[NCI_MAX_NUM_CONN];
3956a2968aaSIlan Elias } __packed;
3966a2968aaSIlan Elias 
397019c4fbaSIlan Elias #define NCI_OP_CORE_GENERIC_ERROR_NTF	nci_opcode_pack(NCI_GID_CORE, 0x07)
398019c4fbaSIlan Elias 
399004161cbSIlan Elias #define NCI_OP_CORE_INTF_ERROR_NTF	nci_opcode_pack(NCI_GID_CORE, 0x08)
400004161cbSIlan Elias struct nci_core_intf_error_ntf {
401004161cbSIlan Elias 	__u8	status;
402004161cbSIlan Elias 	__u8	conn_id;
403004161cbSIlan Elias } __packed;
404004161cbSIlan Elias 
405019c4fbaSIlan Elias #define NCI_OP_RF_DISCOVER_NTF		nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
4066a2968aaSIlan Elias struct rf_tech_specific_params_nfca_poll {
4076a2968aaSIlan Elias 	__u16	sens_res;
4086a2968aaSIlan Elias 	__u8	nfcid1_len;	/* 0, 4, 7, or 10 Bytes */
409a99903ecSJulien Lefrique 	__u8	nfcid1[NFC_NFCID1_MAXSIZE];
4106a2968aaSIlan Elias 	__u8	sel_res_len;	/* 0 or 1 Bytes */
4116a2968aaSIlan Elias 	__u8	sel_res;
4126a2968aaSIlan Elias } __packed;
4136a2968aaSIlan Elias 
414d5a2ca60SIlan Elias struct rf_tech_specific_params_nfcb_poll {
415d5a2ca60SIlan Elias 	__u8	sensb_res_len;
416a99903ecSJulien Lefrique 	__u8	sensb_res[NFC_SENSB_RES_MAXSIZE];	/* 11 or 12 Bytes */
417d5a2ca60SIlan Elias } __packed;
418d5a2ca60SIlan Elias 
419d5a2ca60SIlan Elias struct rf_tech_specific_params_nfcf_poll {
420d5a2ca60SIlan Elias 	__u8	bit_rate;
421d5a2ca60SIlan Elias 	__u8	sensf_res_len;
422a99903ecSJulien Lefrique 	__u8	sensf_res[NFC_SENSF_RES_MAXSIZE];	/* 16 or 18 Bytes */
423d5a2ca60SIlan Elias } __packed;
424d5a2ca60SIlan Elias 
425cfdbeeafSVincent Cuissard struct rf_tech_specific_params_nfcv_poll {
426cfdbeeafSVincent Cuissard 	__u8	res_flags;
427cfdbeeafSVincent Cuissard 	__u8	dsfid;
428a99903ecSJulien Lefrique 	__u8	uid[NFC_ISO15693_UID_MAXSIZE];	/* 8 Bytes */
429a99903ecSJulien Lefrique } __packed;
430a99903ecSJulien Lefrique 
431a99903ecSJulien Lefrique struct rf_tech_specific_params_nfcf_listen {
432a99903ecSJulien Lefrique 	__u8	local_nfcid2_len;
433a99903ecSJulien Lefrique 	__u8	local_nfcid2[NFC_NFCID2_MAXSIZE];	/* 0 or 8 Bytes */
434cfdbeeafSVincent Cuissard } __packed;
435cfdbeeafSVincent Cuissard 
436019c4fbaSIlan Elias struct nci_rf_discover_ntf {
437019c4fbaSIlan Elias 	__u8	rf_discovery_id;
438019c4fbaSIlan Elias 	__u8	rf_protocol;
439019c4fbaSIlan Elias 	__u8	rf_tech_and_mode;
440019c4fbaSIlan Elias 	__u8	rf_tech_specific_params_len;
441019c4fbaSIlan Elias 
442019c4fbaSIlan Elias 	union {
443019c4fbaSIlan Elias 		struct rf_tech_specific_params_nfca_poll nfca_poll;
444019c4fbaSIlan Elias 		struct rf_tech_specific_params_nfcb_poll nfcb_poll;
445019c4fbaSIlan Elias 		struct rf_tech_specific_params_nfcf_poll nfcf_poll;
446cfdbeeafSVincent Cuissard 		struct rf_tech_specific_params_nfcv_poll nfcv_poll;
447019c4fbaSIlan Elias 	} rf_tech_specific_params;
448019c4fbaSIlan Elias 
449019c4fbaSIlan Elias 	__u8	ntf_type;
450019c4fbaSIlan Elias } __packed;
451019c4fbaSIlan Elias 
452019c4fbaSIlan Elias #define NCI_OP_RF_INTF_ACTIVATED_NTF	nci_opcode_pack(NCI_GID_RF_MGMT, 0x05)
4536a2968aaSIlan Elias struct activation_params_nfca_poll_iso_dep {
4546a2968aaSIlan Elias 	__u8	rats_res_len;
4556a2968aaSIlan Elias 	__u8	rats_res[20];
4566a2968aaSIlan Elias };
4576a2968aaSIlan Elias 
458d5a2ca60SIlan Elias struct activation_params_nfcb_poll_iso_dep {
459d5a2ca60SIlan Elias 	__u8	attrib_res_len;
460d5a2ca60SIlan Elias 	__u8	attrib_res[50];
461d5a2ca60SIlan Elias };
462d5a2ca60SIlan Elias 
463ac206838SIlan Elias struct activation_params_poll_nfc_dep {
464ac206838SIlan Elias 	__u8	atr_res_len;
465a99903ecSJulien Lefrique 	__u8	atr_res[NFC_ATR_RES_MAXSIZE - 2]; /* ATR_RES from byte 3 */
466a99903ecSJulien Lefrique };
467a99903ecSJulien Lefrique 
468a99903ecSJulien Lefrique struct activation_params_listen_nfc_dep {
469a99903ecSJulien Lefrique 	__u8	atr_req_len;
470a99903ecSJulien Lefrique 	__u8	atr_req[NFC_ATR_REQ_MAXSIZE - 2]; /* ATR_REQ from byte 3 */
471ac206838SIlan Elias };
472ac206838SIlan Elias 
473e8c0dacdSIlan Elias struct nci_rf_intf_activated_ntf {
474e8c0dacdSIlan Elias 	__u8	rf_discovery_id;
475637d85a7SIlan Elias 	__u8	rf_interface;
4766a2968aaSIlan Elias 	__u8	rf_protocol;
477e8c0dacdSIlan Elias 	__u8	activation_rf_tech_and_mode;
478637d85a7SIlan Elias 	__u8	max_data_pkt_payload_size;
479637d85a7SIlan Elias 	__u8	initial_num_credits;
4806a2968aaSIlan Elias 	__u8	rf_tech_specific_params_len;
4816a2968aaSIlan Elias 
4826a2968aaSIlan Elias 	union {
4836a2968aaSIlan Elias 		struct rf_tech_specific_params_nfca_poll nfca_poll;
484d5a2ca60SIlan Elias 		struct rf_tech_specific_params_nfcb_poll nfcb_poll;
485d5a2ca60SIlan Elias 		struct rf_tech_specific_params_nfcf_poll nfcf_poll;
486cfdbeeafSVincent Cuissard 		struct rf_tech_specific_params_nfcv_poll nfcv_poll;
487a99903ecSJulien Lefrique 		struct rf_tech_specific_params_nfcf_listen nfcf_listen;
4886a2968aaSIlan Elias 	} rf_tech_specific_params;
4896a2968aaSIlan Elias 
490e8c0dacdSIlan Elias 	__u8	data_exch_rf_tech_and_mode;
491e8c0dacdSIlan Elias 	__u8	data_exch_tx_bit_rate;
492e8c0dacdSIlan Elias 	__u8	data_exch_rx_bit_rate;
4936a2968aaSIlan Elias 	__u8	activation_params_len;
4946a2968aaSIlan Elias 
4956a2968aaSIlan Elias 	union {
4966a2968aaSIlan Elias 		struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep;
497d5a2ca60SIlan Elias 		struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep;
498ac206838SIlan Elias 		struct activation_params_poll_nfc_dep poll_nfc_dep;
499a99903ecSJulien Lefrique 		struct activation_params_listen_nfc_dep listen_nfc_dep;
5006a2968aaSIlan Elias 	} activation_params;
5016a2968aaSIlan Elias 
5026a2968aaSIlan Elias } __packed;
5036a2968aaSIlan Elias 
5046a2968aaSIlan Elias #define NCI_OP_RF_DEACTIVATE_NTF	nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
505e8c0dacdSIlan Elias struct nci_rf_deactivate_ntf {
506e8c0dacdSIlan Elias 	__u8	type;
507e8c0dacdSIlan Elias 	__u8	reason;
508e8c0dacdSIlan Elias } __packed;
5096a2968aaSIlan Elias 
510a41bb844SChristophe Ricard #define NCI_OP_RF_NFCEE_ACTION_NTF	nci_opcode_pack(NCI_GID_RF_MGMT, 0x09)
511a41bb844SChristophe Ricard struct nci_rf_nfcee_action_ntf {
512a41bb844SChristophe Ricard 	__u8 nfcee_id;
513a41bb844SChristophe Ricard 	__u8 trigger;
514a41bb844SChristophe Ricard 	__u8 supported_data_length;
515a41bb844SChristophe Ricard 	__u8 supported_data[0];
516a41bb844SChristophe Ricard } __packed;
517a41bb844SChristophe Ricard 
5188277f693SChristophe Ricard #define NCI_OP_NFCEE_DISCOVER_NTF nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00)
5198277f693SChristophe Ricard struct nci_nfcee_supported_protocol {
5208277f693SChristophe Ricard 	__u8	num_protocol;
5218277f693SChristophe Ricard 	__u8	supported_protocol[0];
5228277f693SChristophe Ricard } __packed;
5238277f693SChristophe Ricard 
5248277f693SChristophe Ricard struct nci_nfcee_information_tlv {
5258277f693SChristophe Ricard 	__u8	num_tlv;
5268277f693SChristophe Ricard 	__u8	information_tlv[0];
5278277f693SChristophe Ricard } __packed;
5288277f693SChristophe Ricard 
5298277f693SChristophe Ricard struct nci_nfcee_discover_ntf {
5308277f693SChristophe Ricard 	__u8	nfcee_id;
5318277f693SChristophe Ricard 	__u8	nfcee_status;
5328277f693SChristophe Ricard 	struct nci_nfcee_supported_protocol supported_protocols;
5338277f693SChristophe Ricard 	struct nci_nfcee_information_tlv	information_tlv;
5348277f693SChristophe Ricard } __packed;
5358277f693SChristophe Ricard 
536*a9433c11SRobert Dolca #define NCI_OP_CORE_RESET_NTF		nci_opcode_pack(NCI_GID_CORE, 0x00)
537*a9433c11SRobert Dolca 
5386a2968aaSIlan Elias #endif /* __NCI_H */
539