18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  The NFC Controller Interface is the communication protocol between an
48c2ecf20Sopenharmony_ci *  NFC Controller (NFCC) and a Device Host (DH).
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci *  Copyright (C) 2014 Marvell International Ltd.
78c2ecf20Sopenharmony_ci *  Copyright (C) 2011 Texas Instruments, Inc.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci *  Written by Ilan Elias <ilane@ti.com>
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci *  Acknowledgements:
128c2ecf20Sopenharmony_ci *  This file is based on hci.h, which was written
138c2ecf20Sopenharmony_ci *  by Maxim Krasnyansky.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifndef __NCI_H
178c2ecf20Sopenharmony_ci#define __NCI_H
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <net/nfc/nfc.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* NCI constants */
228c2ecf20Sopenharmony_ci#define NCI_MAX_NUM_MAPPING_CONFIGS				10
238c2ecf20Sopenharmony_ci#define NCI_MAX_NUM_RF_CONFIGS					10
248c2ecf20Sopenharmony_ci#define NCI_MAX_NUM_CONN					10
258c2ecf20Sopenharmony_ci#define NCI_MAX_PARAM_LEN					251
268c2ecf20Sopenharmony_ci#define NCI_MAX_PAYLOAD_SIZE					255
278c2ecf20Sopenharmony_ci#define NCI_MAX_PACKET_SIZE					258
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* NCI Status Codes */
308c2ecf20Sopenharmony_ci#define NCI_STATUS_OK						0x00
318c2ecf20Sopenharmony_ci#define NCI_STATUS_REJECTED					0x01
328c2ecf20Sopenharmony_ci#define NCI_STATUS_RF_FRAME_CORRUPTED				0x02
338c2ecf20Sopenharmony_ci#define NCI_STATUS_FAILED					0x03
348c2ecf20Sopenharmony_ci#define NCI_STATUS_NOT_INITIALIZED				0x04
358c2ecf20Sopenharmony_ci#define NCI_STATUS_SYNTAX_ERROR					0x05
368c2ecf20Sopenharmony_ci#define NCI_STATUS_SEMANTIC_ERROR				0x06
378c2ecf20Sopenharmony_ci#define NCI_STATUS_UNKNOWN_GID					0x07
388c2ecf20Sopenharmony_ci#define NCI_STATUS_UNKNOWN_OID					0x08
398c2ecf20Sopenharmony_ci#define NCI_STATUS_INVALID_PARAM				0x09
408c2ecf20Sopenharmony_ci#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED			0x0a
418c2ecf20Sopenharmony_ci/* Discovery Specific Status Codes */
428c2ecf20Sopenharmony_ci#define NCI_STATUS_DISCOVERY_ALREADY_STARTED			0xa0
438c2ecf20Sopenharmony_ci#define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED		0xa1
448c2ecf20Sopenharmony_ci#define NCI_STATUS_DISCOVERY_TEAR_DOWN				0xa2
458c2ecf20Sopenharmony_ci/* RF Interface Specific Status Codes */
468c2ecf20Sopenharmony_ci#define NCI_STATUS_RF_TRANSMISSION_ERROR			0xb0
478c2ecf20Sopenharmony_ci#define NCI_STATUS_RF_PROTOCOL_ERROR				0xb1
488c2ecf20Sopenharmony_ci#define NCI_STATUS_RF_TIMEOUT_ERROR				0xb2
498c2ecf20Sopenharmony_ci/* NFCEE Interface Specific Status Codes */
508c2ecf20Sopenharmony_ci#define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED		0xc0
518c2ecf20Sopenharmony_ci#define NCI_STATUS_NFCEE_TRANSMISSION_ERROR			0xc1
528c2ecf20Sopenharmony_ci#define NCI_STATUS_NFCEE_PROTOCOL_ERROR				0xc2
538c2ecf20Sopenharmony_ci#define NCI_STATUS_NFCEE_TIMEOUT_ERROR				0xc3
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* NFCEE Interface/Protocols */
568c2ecf20Sopenharmony_ci#define NCI_NFCEE_INTERFACE_APDU           0x00
578c2ecf20Sopenharmony_ci#define NCI_NFCEE_INTERFACE_HCI_ACCESS     0x01
588c2ecf20Sopenharmony_ci#define NCI_NFCEE_INTERFACE_TYPE3_CMD_SET  0x02
598c2ecf20Sopenharmony_ci#define NCI_NFCEE_INTERFACE_TRANSPARENT        0x03
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Destination type */
628c2ecf20Sopenharmony_ci#define NCI_DESTINATION_NFCC_LOOPBACK      0x01
638c2ecf20Sopenharmony_ci#define NCI_DESTINATION_REMOTE_NFC_ENDPOINT    0x02
648c2ecf20Sopenharmony_ci#define NCI_DESTINATION_NFCEE              0x03
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* Destination-specific parameters type */
678c2ecf20Sopenharmony_ci#define NCI_DESTINATION_SPECIFIC_PARAM_RF_TYPE     0x00
688c2ecf20Sopenharmony_ci#define NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE  0x01
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* NFCEE Discovery Action */
718c2ecf20Sopenharmony_ci#define NCI_NFCEE_DISCOVERY_ACTION_DISABLE			0x00
728c2ecf20Sopenharmony_ci#define NCI_NFCEE_DISCOVERY_ACTION_ENABLE			0x01
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/* NCI RF Technology and Mode */
758c2ecf20Sopenharmony_ci#define NCI_NFC_A_PASSIVE_POLL_MODE				0x00
768c2ecf20Sopenharmony_ci#define NCI_NFC_B_PASSIVE_POLL_MODE				0x01
778c2ecf20Sopenharmony_ci#define NCI_NFC_F_PASSIVE_POLL_MODE				0x02
788c2ecf20Sopenharmony_ci#define NCI_NFC_A_ACTIVE_POLL_MODE				0x03
798c2ecf20Sopenharmony_ci#define NCI_NFC_F_ACTIVE_POLL_MODE				0x05
808c2ecf20Sopenharmony_ci#define NCI_NFC_V_PASSIVE_POLL_MODE				0x06
818c2ecf20Sopenharmony_ci#define NCI_NFC_A_PASSIVE_LISTEN_MODE				0x80
828c2ecf20Sopenharmony_ci#define NCI_NFC_B_PASSIVE_LISTEN_MODE				0x81
838c2ecf20Sopenharmony_ci#define NCI_NFC_F_PASSIVE_LISTEN_MODE				0x82
848c2ecf20Sopenharmony_ci#define NCI_NFC_A_ACTIVE_LISTEN_MODE				0x83
858c2ecf20Sopenharmony_ci#define NCI_NFC_F_ACTIVE_LISTEN_MODE				0x85
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define NCI_RF_TECH_MODE_LISTEN_MASK				0x80
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* NCI RF Technologies */
908c2ecf20Sopenharmony_ci#define NCI_NFC_RF_TECHNOLOGY_A					0x00
918c2ecf20Sopenharmony_ci#define NCI_NFC_RF_TECHNOLOGY_B					0x01
928c2ecf20Sopenharmony_ci#define NCI_NFC_RF_TECHNOLOGY_F					0x02
938c2ecf20Sopenharmony_ci#define NCI_NFC_RF_TECHNOLOGY_V					0x03
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci/* NCI Bit Rates */
968c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_106					0x00
978c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_212					0x01
988c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_424					0x02
998c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_848					0x03
1008c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_1695					0x04
1018c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_3390					0x05
1028c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_6780					0x06
1038c2ecf20Sopenharmony_ci#define NCI_NFC_BIT_RATE_26					0x20
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/* NCI RF Protocols */
1068c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_UNKNOWN					0x00
1078c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_T1T					0x01
1088c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_T2T					0x02
1098c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_T3T					0x03
1108c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_ISO_DEP					0x04
1118c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_NFC_DEP					0x05
1128c2ecf20Sopenharmony_ci#define NCI_RF_PROTOCOL_T5T					0x06
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* NCI RF Interfaces */
1158c2ecf20Sopenharmony_ci#define NCI_RF_INTERFACE_NFCEE_DIRECT				0x00
1168c2ecf20Sopenharmony_ci#define NCI_RF_INTERFACE_FRAME					0x01
1178c2ecf20Sopenharmony_ci#define NCI_RF_INTERFACE_ISO_DEP				0x02
1188c2ecf20Sopenharmony_ci#define NCI_RF_INTERFACE_NFC_DEP				0x03
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/* NCI Configuration Parameter Tags */
1218c2ecf20Sopenharmony_ci#define NCI_PN_ATR_REQ_GEN_BYTES				0x29
1228c2ecf20Sopenharmony_ci#define NCI_LN_ATR_RES_GEN_BYTES				0x61
1238c2ecf20Sopenharmony_ci#define NCI_LA_SEL_INFO						0x32
1248c2ecf20Sopenharmony_ci#define NCI_LF_PROTOCOL_TYPE					0x50
1258c2ecf20Sopenharmony_ci#define NCI_LF_CON_BITR_F					0x54
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci/* NCI Configuration Parameters masks */
1288c2ecf20Sopenharmony_ci#define NCI_LA_SEL_INFO_ISO_DEP_MASK				0x20
1298c2ecf20Sopenharmony_ci#define NCI_LA_SEL_INFO_NFC_DEP_MASK				0x40
1308c2ecf20Sopenharmony_ci#define NCI_LF_PROTOCOL_TYPE_NFC_DEP_MASK			0x02
1318c2ecf20Sopenharmony_ci#define NCI_LF_CON_BITR_F_212					0x02
1328c2ecf20Sopenharmony_ci#define NCI_LF_CON_BITR_F_424					0x04
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci/* NCI Reset types */
1358c2ecf20Sopenharmony_ci#define NCI_RESET_TYPE_KEEP_CONFIG				0x00
1368c2ecf20Sopenharmony_ci#define NCI_RESET_TYPE_RESET_CONFIG				0x01
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/* NCI Static RF connection ID */
1398c2ecf20Sopenharmony_ci#define NCI_STATIC_RF_CONN_ID					0x00
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/* NCI Data Flow Control */
1428c2ecf20Sopenharmony_ci#define NCI_DATA_FLOW_CONTROL_NOT_USED				0xff
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* NCI RF_DISCOVER_MAP_CMD modes */
1458c2ecf20Sopenharmony_ci#define NCI_DISC_MAP_MODE_POLL					0x01
1468c2ecf20Sopenharmony_ci#define NCI_DISC_MAP_MODE_LISTEN				0x02
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci/* NCI Discover Notification Type */
1498c2ecf20Sopenharmony_ci#define NCI_DISCOVER_NTF_TYPE_LAST				0x00
1508c2ecf20Sopenharmony_ci#define NCI_DISCOVER_NTF_TYPE_LAST_NFCC				0x01
1518c2ecf20Sopenharmony_ci#define NCI_DISCOVER_NTF_TYPE_MORE				0x02
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/* NCI Deactivation Type */
1548c2ecf20Sopenharmony_ci#define NCI_DEACTIVATE_TYPE_IDLE_MODE				0x00
1558c2ecf20Sopenharmony_ci#define NCI_DEACTIVATE_TYPE_SLEEP_MODE				0x01
1568c2ecf20Sopenharmony_ci#define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE			0x02
1578c2ecf20Sopenharmony_ci#define NCI_DEACTIVATE_TYPE_DISCOVERY				0x03
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/* Message Type (MT) */
1608c2ecf20Sopenharmony_ci#define NCI_MT_DATA_PKT						0x00
1618c2ecf20Sopenharmony_ci#define NCI_MT_CMD_PKT						0x01
1628c2ecf20Sopenharmony_ci#define NCI_MT_RSP_PKT						0x02
1638c2ecf20Sopenharmony_ci#define NCI_MT_NTF_PKT						0x03
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci#define nci_mt(hdr)			(((hdr)[0]>>5)&0x07)
1668c2ecf20Sopenharmony_ci#define nci_mt_set(hdr, mt)		((hdr)[0] |= (__u8)(((mt)&0x07)<<5))
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/* Packet Boundary Flag (PBF) */
1698c2ecf20Sopenharmony_ci#define NCI_PBF_LAST						0x00
1708c2ecf20Sopenharmony_ci#define NCI_PBF_CONT						0x01
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#define nci_pbf(hdr)			(__u8)(((hdr)[0]>>4)&0x01)
1738c2ecf20Sopenharmony_ci#define nci_pbf_set(hdr, pbf)		((hdr)[0] |= (__u8)(((pbf)&0x01)<<4))
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/* Control Opcode manipulation */
1768c2ecf20Sopenharmony_ci#define nci_opcode_pack(gid, oid)	(__u16)((((__u16)((gid)&0x0f))<<8)|\
1778c2ecf20Sopenharmony_ci					((__u16)((oid)&0x3f)))
1788c2ecf20Sopenharmony_ci#define nci_opcode(hdr)			nci_opcode_pack(hdr[0], hdr[1])
1798c2ecf20Sopenharmony_ci#define nci_opcode_gid(op)		(__u8)(((op)&0x0f00)>>8)
1808c2ecf20Sopenharmony_ci#define nci_opcode_oid(op)		(__u8)((op)&0x003f)
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/* Payload Length */
1838c2ecf20Sopenharmony_ci#define nci_plen(hdr)			(__u8)((hdr)[2])
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/* Connection ID */
1868c2ecf20Sopenharmony_ci#define nci_conn_id(hdr)		(__u8)(((hdr)[0])&0x0f)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* GID values */
1898c2ecf20Sopenharmony_ci#define NCI_GID_CORE						0x0
1908c2ecf20Sopenharmony_ci#define NCI_GID_RF_MGMT						0x1
1918c2ecf20Sopenharmony_ci#define NCI_GID_NFCEE_MGMT					0x2
1928c2ecf20Sopenharmony_ci#define NCI_GID_PROPRIETARY					0xf
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
1958c2ecf20Sopenharmony_ci#define NCI_SPI_HDR_LEN						4
1968c2ecf20Sopenharmony_ci#define NCI_SPI_CRC_LEN						2
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/* ---- NCI Packet structures ---- */
1998c2ecf20Sopenharmony_ci#define NCI_CTRL_HDR_SIZE					3
2008c2ecf20Sopenharmony_ci#define NCI_DATA_HDR_SIZE					3
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_cistruct nci_ctrl_hdr {
2038c2ecf20Sopenharmony_ci	__u8	gid;		/* MT & PBF & GID */
2048c2ecf20Sopenharmony_ci	__u8	oid;
2058c2ecf20Sopenharmony_ci	__u8	plen;
2068c2ecf20Sopenharmony_ci} __packed;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cistruct nci_data_hdr {
2098c2ecf20Sopenharmony_ci	__u8	conn_id;	/* MT & PBF & ConnID */
2108c2ecf20Sopenharmony_ci	__u8	rfu;
2118c2ecf20Sopenharmony_ci	__u8	plen;
2128c2ecf20Sopenharmony_ci} __packed;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci/* ------------------------ */
2158c2ecf20Sopenharmony_ci/* -----  NCI Commands ---- */
2168c2ecf20Sopenharmony_ci/* ------------------------ */
2178c2ecf20Sopenharmony_ci#define NCI_OP_CORE_RESET_CMD		nci_opcode_pack(NCI_GID_CORE, 0x00)
2188c2ecf20Sopenharmony_cistruct nci_core_reset_cmd {
2198c2ecf20Sopenharmony_ci	__u8	reset_type;
2208c2ecf20Sopenharmony_ci} __packed;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci#define NCI_OP_CORE_INIT_CMD		nci_opcode_pack(NCI_GID_CORE, 0x01)
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci#define NCI_OP_CORE_SET_CONFIG_CMD	nci_opcode_pack(NCI_GID_CORE, 0x02)
2258c2ecf20Sopenharmony_cistruct set_config_param {
2268c2ecf20Sopenharmony_ci	__u8	id;
2278c2ecf20Sopenharmony_ci	__u8	len;
2288c2ecf20Sopenharmony_ci	__u8	val[NCI_MAX_PARAM_LEN];
2298c2ecf20Sopenharmony_ci} __packed;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_cistruct nci_core_set_config_cmd {
2328c2ecf20Sopenharmony_ci	__u8	num_params;
2338c2ecf20Sopenharmony_ci	struct	set_config_param param; /* support 1 param per cmd is enough */
2348c2ecf20Sopenharmony_ci} __packed;
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci#define NCI_OP_CORE_CONN_CREATE_CMD	nci_opcode_pack(NCI_GID_CORE, 0x04)
2378c2ecf20Sopenharmony_ci#define DEST_SPEC_PARAMS_ID_INDEX	0
2388c2ecf20Sopenharmony_ci#define DEST_SPEC_PARAMS_PROTOCOL_INDEX	1
2398c2ecf20Sopenharmony_cistruct dest_spec_params {
2408c2ecf20Sopenharmony_ci	__u8    id;
2418c2ecf20Sopenharmony_ci	__u8    protocol;
2428c2ecf20Sopenharmony_ci} __packed;
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_cistruct core_conn_create_dest_spec_params {
2458c2ecf20Sopenharmony_ci	__u8    type;
2468c2ecf20Sopenharmony_ci	__u8    length;
2478c2ecf20Sopenharmony_ci	__u8    value[];
2488c2ecf20Sopenharmony_ci} __packed;
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_cistruct nci_core_conn_create_cmd {
2518c2ecf20Sopenharmony_ci	__u8    destination_type;
2528c2ecf20Sopenharmony_ci	__u8    number_destination_params;
2538c2ecf20Sopenharmony_ci	struct core_conn_create_dest_spec_params params[];
2548c2ecf20Sopenharmony_ci} __packed;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci#define NCI_OP_CORE_CONN_CLOSE_CMD	nci_opcode_pack(NCI_GID_CORE, 0x05)
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_MAP_CMD	nci_opcode_pack(NCI_GID_RF_MGMT, 0x00)
2598c2ecf20Sopenharmony_cistruct disc_map_config {
2608c2ecf20Sopenharmony_ci	__u8	rf_protocol;
2618c2ecf20Sopenharmony_ci	__u8	mode;
2628c2ecf20Sopenharmony_ci	__u8	rf_interface;
2638c2ecf20Sopenharmony_ci} __packed;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistruct nci_rf_disc_map_cmd {
2668c2ecf20Sopenharmony_ci	__u8				num_mapping_configs;
2678c2ecf20Sopenharmony_ci	struct disc_map_config		mapping_configs
2688c2ecf20Sopenharmony_ci					[NCI_MAX_NUM_MAPPING_CONFIGS];
2698c2ecf20Sopenharmony_ci} __packed;
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_CMD		nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
2728c2ecf20Sopenharmony_cistruct disc_config {
2738c2ecf20Sopenharmony_ci	__u8	rf_tech_and_mode;
2748c2ecf20Sopenharmony_ci	__u8	frequency;
2758c2ecf20Sopenharmony_ci} __packed;
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistruct nci_rf_disc_cmd {
2788c2ecf20Sopenharmony_ci	__u8				num_disc_configs;
2798c2ecf20Sopenharmony_ci	struct disc_config		disc_configs[NCI_MAX_NUM_RF_CONFIGS];
2808c2ecf20Sopenharmony_ci} __packed;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_SELECT_CMD	nci_opcode_pack(NCI_GID_RF_MGMT, 0x04)
2838c2ecf20Sopenharmony_cistruct nci_rf_discover_select_cmd {
2848c2ecf20Sopenharmony_ci	__u8	rf_discovery_id;
2858c2ecf20Sopenharmony_ci	__u8	rf_protocol;
2868c2ecf20Sopenharmony_ci	__u8	rf_interface;
2878c2ecf20Sopenharmony_ci} __packed;
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci#define NCI_OP_RF_DEACTIVATE_CMD	nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
2908c2ecf20Sopenharmony_cistruct nci_rf_deactivate_cmd {
2918c2ecf20Sopenharmony_ci	__u8	type;
2928c2ecf20Sopenharmony_ci} __packed;
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci#define NCI_OP_NFCEE_DISCOVER_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00)
2958c2ecf20Sopenharmony_cistruct nci_nfcee_discover_cmd {
2968c2ecf20Sopenharmony_ci	__u8	discovery_action;
2978c2ecf20Sopenharmony_ci} __packed;
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci#define NCI_OP_NFCEE_MODE_SET_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01)
3008c2ecf20Sopenharmony_ci#define NCI_NFCEE_DISABLE	0x00
3018c2ecf20Sopenharmony_ci#define NCI_NFCEE_ENABLE	0x01
3028c2ecf20Sopenharmony_cistruct nci_nfcee_mode_set_cmd {
3038c2ecf20Sopenharmony_ci	__u8	nfcee_id;
3048c2ecf20Sopenharmony_ci	__u8	nfcee_mode;
3058c2ecf20Sopenharmony_ci} __packed;
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci#define NCI_OP_CORE_GET_CONFIG_CMD	nci_opcode_pack(NCI_GID_CORE, 0x03)
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/* ----------------------- */
3108c2ecf20Sopenharmony_ci/* ---- NCI Responses ---- */
3118c2ecf20Sopenharmony_ci/* ----------------------- */
3128c2ecf20Sopenharmony_ci#define NCI_OP_CORE_RESET_RSP		nci_opcode_pack(NCI_GID_CORE, 0x00)
3138c2ecf20Sopenharmony_cistruct nci_core_reset_rsp {
3148c2ecf20Sopenharmony_ci	__u8	status;
3158c2ecf20Sopenharmony_ci	__u8	nci_ver;
3168c2ecf20Sopenharmony_ci	__u8	config_status;
3178c2ecf20Sopenharmony_ci} __packed;
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci#define NCI_OP_CORE_INIT_RSP		nci_opcode_pack(NCI_GID_CORE, 0x01)
3208c2ecf20Sopenharmony_cistruct nci_core_init_rsp_1 {
3218c2ecf20Sopenharmony_ci	__u8	status;
3228c2ecf20Sopenharmony_ci	__le32	nfcc_features;
3238c2ecf20Sopenharmony_ci	__u8	num_supported_rf_interfaces;
3248c2ecf20Sopenharmony_ci	__u8	supported_rf_interfaces[];	/* variable size array */
3258c2ecf20Sopenharmony_ci	/* continuted in nci_core_init_rsp_2 */
3268c2ecf20Sopenharmony_ci} __packed;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistruct nci_core_init_rsp_2 {
3298c2ecf20Sopenharmony_ci	__u8	max_logical_connections;
3308c2ecf20Sopenharmony_ci	__le16	max_routing_table_size;
3318c2ecf20Sopenharmony_ci	__u8	max_ctrl_pkt_payload_len;
3328c2ecf20Sopenharmony_ci	__le16	max_size_for_large_params;
3338c2ecf20Sopenharmony_ci	__u8	manufact_id;
3348c2ecf20Sopenharmony_ci	__le32	manufact_specific_info;
3358c2ecf20Sopenharmony_ci} __packed;
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci#define NCI_OP_CORE_SET_CONFIG_RSP	nci_opcode_pack(NCI_GID_CORE, 0x02)
3388c2ecf20Sopenharmony_cistruct nci_core_set_config_rsp {
3398c2ecf20Sopenharmony_ci	__u8	status;
3408c2ecf20Sopenharmony_ci	__u8	num_params;
3418c2ecf20Sopenharmony_ci	__u8	params_id[];	/* variable size array */
3428c2ecf20Sopenharmony_ci} __packed;
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci#define NCI_OP_CORE_CONN_CREATE_RSP	nci_opcode_pack(NCI_GID_CORE, 0x04)
3458c2ecf20Sopenharmony_cistruct nci_core_conn_create_rsp {
3468c2ecf20Sopenharmony_ci	__u8	status;
3478c2ecf20Sopenharmony_ci	__u8	max_ctrl_pkt_payload_len;
3488c2ecf20Sopenharmony_ci	__u8    credits_cnt;
3498c2ecf20Sopenharmony_ci	__u8	conn_id;
3508c2ecf20Sopenharmony_ci} __packed;
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci#define NCI_OP_CORE_CONN_CLOSE_RSP	nci_opcode_pack(NCI_GID_CORE, 0x05)
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_MAP_RSP	nci_opcode_pack(NCI_GID_RF_MGMT, 0x00)
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_RSP		nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_SELECT_RSP	nci_opcode_pack(NCI_GID_RF_MGMT, 0x04)
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci#define NCI_OP_RF_DEACTIVATE_RSP	nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci#define NCI_OP_NFCEE_DISCOVER_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00)
3638c2ecf20Sopenharmony_cistruct nci_nfcee_discover_rsp {
3648c2ecf20Sopenharmony_ci	__u8	status;
3658c2ecf20Sopenharmony_ci	__u8	num_nfcee;
3668c2ecf20Sopenharmony_ci} __packed;
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci#define NCI_OP_NFCEE_MODE_SET_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01)
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci#define NCI_OP_CORE_GET_CONFIG_RSP	nci_opcode_pack(NCI_GID_CORE, 0x03)
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci/* --------------------------- */
3738c2ecf20Sopenharmony_ci/* ---- NCI Notifications ---- */
3748c2ecf20Sopenharmony_ci/* --------------------------- */
3758c2ecf20Sopenharmony_ci#define NCI_OP_CORE_CONN_CREDITS_NTF	nci_opcode_pack(NCI_GID_CORE, 0x06)
3768c2ecf20Sopenharmony_cistruct conn_credit_entry {
3778c2ecf20Sopenharmony_ci	__u8	conn_id;
3788c2ecf20Sopenharmony_ci	__u8	credits;
3798c2ecf20Sopenharmony_ci} __packed;
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_cistruct nci_core_conn_credit_ntf {
3828c2ecf20Sopenharmony_ci	__u8				num_entries;
3838c2ecf20Sopenharmony_ci	struct conn_credit_entry	conn_entries[NCI_MAX_NUM_CONN];
3848c2ecf20Sopenharmony_ci} __packed;
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci#define NCI_OP_CORE_GENERIC_ERROR_NTF	nci_opcode_pack(NCI_GID_CORE, 0x07)
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci#define NCI_OP_CORE_INTF_ERROR_NTF	nci_opcode_pack(NCI_GID_CORE, 0x08)
3898c2ecf20Sopenharmony_cistruct nci_core_intf_error_ntf {
3908c2ecf20Sopenharmony_ci	__u8	status;
3918c2ecf20Sopenharmony_ci	__u8	conn_id;
3928c2ecf20Sopenharmony_ci} __packed;
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci#define NCI_OP_RF_DISCOVER_NTF		nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
3958c2ecf20Sopenharmony_cistruct rf_tech_specific_params_nfca_poll {
3968c2ecf20Sopenharmony_ci	__u16	sens_res;
3978c2ecf20Sopenharmony_ci	__u8	nfcid1_len;	/* 0, 4, 7, or 10 Bytes */
3988c2ecf20Sopenharmony_ci	__u8	nfcid1[NFC_NFCID1_MAXSIZE];
3998c2ecf20Sopenharmony_ci	__u8	sel_res_len;	/* 0 or 1 Bytes */
4008c2ecf20Sopenharmony_ci	__u8	sel_res;
4018c2ecf20Sopenharmony_ci} __packed;
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistruct rf_tech_specific_params_nfcb_poll {
4048c2ecf20Sopenharmony_ci	__u8	sensb_res_len;
4058c2ecf20Sopenharmony_ci	__u8	sensb_res[NFC_SENSB_RES_MAXSIZE];	/* 11 or 12 Bytes */
4068c2ecf20Sopenharmony_ci} __packed;
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_cistruct rf_tech_specific_params_nfcf_poll {
4098c2ecf20Sopenharmony_ci	__u8	bit_rate;
4108c2ecf20Sopenharmony_ci	__u8	sensf_res_len;
4118c2ecf20Sopenharmony_ci	__u8	sensf_res[NFC_SENSF_RES_MAXSIZE];	/* 16 or 18 Bytes */
4128c2ecf20Sopenharmony_ci} __packed;
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_cistruct rf_tech_specific_params_nfcv_poll {
4158c2ecf20Sopenharmony_ci	__u8	res_flags;
4168c2ecf20Sopenharmony_ci	__u8	dsfid;
4178c2ecf20Sopenharmony_ci	__u8	uid[NFC_ISO15693_UID_MAXSIZE];	/* 8 Bytes */
4188c2ecf20Sopenharmony_ci} __packed;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cistruct rf_tech_specific_params_nfcf_listen {
4218c2ecf20Sopenharmony_ci	__u8	local_nfcid2_len;
4228c2ecf20Sopenharmony_ci	__u8	local_nfcid2[NFC_NFCID2_MAXSIZE];	/* 0 or 8 Bytes */
4238c2ecf20Sopenharmony_ci} __packed;
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_cistruct nci_rf_discover_ntf {
4268c2ecf20Sopenharmony_ci	__u8	rf_discovery_id;
4278c2ecf20Sopenharmony_ci	__u8	rf_protocol;
4288c2ecf20Sopenharmony_ci	__u8	rf_tech_and_mode;
4298c2ecf20Sopenharmony_ci	__u8	rf_tech_specific_params_len;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	union {
4328c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfca_poll nfca_poll;
4338c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcb_poll nfcb_poll;
4348c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcf_poll nfcf_poll;
4358c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcv_poll nfcv_poll;
4368c2ecf20Sopenharmony_ci	} rf_tech_specific_params;
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci	__u8	ntf_type;
4398c2ecf20Sopenharmony_ci} __packed;
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci#define NCI_OP_RF_INTF_ACTIVATED_NTF	nci_opcode_pack(NCI_GID_RF_MGMT, 0x05)
4428c2ecf20Sopenharmony_cistruct activation_params_nfca_poll_iso_dep {
4438c2ecf20Sopenharmony_ci	__u8	rats_res_len;
4448c2ecf20Sopenharmony_ci	__u8	rats_res[20];
4458c2ecf20Sopenharmony_ci};
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_cistruct activation_params_nfcb_poll_iso_dep {
4488c2ecf20Sopenharmony_ci	__u8	attrib_res_len;
4498c2ecf20Sopenharmony_ci	__u8	attrib_res[50];
4508c2ecf20Sopenharmony_ci};
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cistruct activation_params_poll_nfc_dep {
4538c2ecf20Sopenharmony_ci	__u8	atr_res_len;
4548c2ecf20Sopenharmony_ci	__u8	atr_res[NFC_ATR_RES_MAXSIZE - 2]; /* ATR_RES from byte 3 */
4558c2ecf20Sopenharmony_ci};
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_cistruct activation_params_listen_nfc_dep {
4588c2ecf20Sopenharmony_ci	__u8	atr_req_len;
4598c2ecf20Sopenharmony_ci	__u8	atr_req[NFC_ATR_REQ_MAXSIZE - 2]; /* ATR_REQ from byte 3 */
4608c2ecf20Sopenharmony_ci};
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cistruct nci_rf_intf_activated_ntf {
4638c2ecf20Sopenharmony_ci	__u8	rf_discovery_id;
4648c2ecf20Sopenharmony_ci	__u8	rf_interface;
4658c2ecf20Sopenharmony_ci	__u8	rf_protocol;
4668c2ecf20Sopenharmony_ci	__u8	activation_rf_tech_and_mode;
4678c2ecf20Sopenharmony_ci	__u8	max_data_pkt_payload_size;
4688c2ecf20Sopenharmony_ci	__u8	initial_num_credits;
4698c2ecf20Sopenharmony_ci	__u8	rf_tech_specific_params_len;
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_ci	union {
4728c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfca_poll nfca_poll;
4738c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcb_poll nfcb_poll;
4748c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcf_poll nfcf_poll;
4758c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcv_poll nfcv_poll;
4768c2ecf20Sopenharmony_ci		struct rf_tech_specific_params_nfcf_listen nfcf_listen;
4778c2ecf20Sopenharmony_ci	} rf_tech_specific_params;
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci	__u8	data_exch_rf_tech_and_mode;
4808c2ecf20Sopenharmony_ci	__u8	data_exch_tx_bit_rate;
4818c2ecf20Sopenharmony_ci	__u8	data_exch_rx_bit_rate;
4828c2ecf20Sopenharmony_ci	__u8	activation_params_len;
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci	union {
4858c2ecf20Sopenharmony_ci		struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep;
4868c2ecf20Sopenharmony_ci		struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep;
4878c2ecf20Sopenharmony_ci		struct activation_params_poll_nfc_dep poll_nfc_dep;
4888c2ecf20Sopenharmony_ci		struct activation_params_listen_nfc_dep listen_nfc_dep;
4898c2ecf20Sopenharmony_ci	} activation_params;
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci} __packed;
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci#define NCI_OP_RF_DEACTIVATE_NTF	nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
4948c2ecf20Sopenharmony_cistruct nci_rf_deactivate_ntf {
4958c2ecf20Sopenharmony_ci	__u8	type;
4968c2ecf20Sopenharmony_ci	__u8	reason;
4978c2ecf20Sopenharmony_ci} __packed;
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci#define NCI_OP_RF_NFCEE_ACTION_NTF	nci_opcode_pack(NCI_GID_RF_MGMT, 0x09)
5008c2ecf20Sopenharmony_cistruct nci_rf_nfcee_action_ntf {
5018c2ecf20Sopenharmony_ci	__u8 nfcee_id;
5028c2ecf20Sopenharmony_ci	__u8 trigger;
5038c2ecf20Sopenharmony_ci	__u8 supported_data_length;
5048c2ecf20Sopenharmony_ci	__u8 supported_data[];
5058c2ecf20Sopenharmony_ci} __packed;
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci#define NCI_OP_NFCEE_DISCOVER_NTF nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00)
5088c2ecf20Sopenharmony_cistruct nci_nfcee_supported_protocol {
5098c2ecf20Sopenharmony_ci	__u8	num_protocol;
5108c2ecf20Sopenharmony_ci	__u8	supported_protocol[];
5118c2ecf20Sopenharmony_ci} __packed;
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_cistruct nci_nfcee_information_tlv {
5148c2ecf20Sopenharmony_ci	__u8	num_tlv;
5158c2ecf20Sopenharmony_ci	__u8	information_tlv[];
5168c2ecf20Sopenharmony_ci} __packed;
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_cistruct nci_nfcee_discover_ntf {
5198c2ecf20Sopenharmony_ci	__u8	nfcee_id;
5208c2ecf20Sopenharmony_ci	__u8	nfcee_status;
5218c2ecf20Sopenharmony_ci	struct nci_nfcee_supported_protocol supported_protocols;
5228c2ecf20Sopenharmony_ci	struct nci_nfcee_information_tlv	information_tlv;
5238c2ecf20Sopenharmony_ci} __packed;
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci#define NCI_OP_CORE_RESET_NTF		nci_opcode_pack(NCI_GID_CORE, 0x00)
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ci#endif /* __NCI_H */
528