1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 26a2968aaSIlan Elias /* 36a2968aaSIlan Elias * The NFC Controller Interface is the communication protocol between an 46a2968aaSIlan Elias * NFC Controller (NFCC) and a Device Host (DH). 56a2968aaSIlan Elias * 6cfdbeeafSVincent Cuissard * Copyright (C) 2014 Marvell International Ltd. 76a2968aaSIlan Elias * Copyright (C) 2011 Texas Instruments, Inc. 86a2968aaSIlan Elias * 96a2968aaSIlan Elias * Written by Ilan Elias <ilane@ti.com> 106a2968aaSIlan Elias * 116a2968aaSIlan Elias * Acknowledgements: 126a2968aaSIlan Elias * This file is based on hci.h, which was written 136a2968aaSIlan Elias * by Maxim Krasnyansky. 146a2968aaSIlan Elias */ 156a2968aaSIlan Elias 166a2968aaSIlan Elias #ifndef __NCI_H 176a2968aaSIlan Elias #define __NCI_H 186a2968aaSIlan Elias 19a99903ecSJulien Lefrique #include <net/nfc/nfc.h> 20a99903ecSJulien Lefrique 216a2968aaSIlan Elias /* NCI constants */ 226a2968aaSIlan Elias #define NCI_MAX_NUM_MAPPING_CONFIGS 10 236a2968aaSIlan Elias #define NCI_MAX_NUM_RF_CONFIGS 10 246a2968aaSIlan Elias #define NCI_MAX_NUM_CONN 10 257e035230SIlan Elias #define NCI_MAX_PARAM_LEN 251 26b5b3e23eSVincent Cuissard #define NCI_MAX_PAYLOAD_SIZE 255 279961127dSVincent Cuissard #define NCI_MAX_PACKET_SIZE 258 28*bcd684aaSBongsu Jeon #define NCI_MAX_LARGE_PARAMS_NCI_v2 15 29*bcd684aaSBongsu Jeon #define NCI_VER_2_MASK 0x20 306a2968aaSIlan Elias 316a2968aaSIlan Elias /* NCI Status Codes */ 326a2968aaSIlan Elias #define NCI_STATUS_OK 0x00 336a2968aaSIlan Elias #define NCI_STATUS_REJECTED 0x01 34e8c0dacdSIlan Elias #define NCI_STATUS_RF_FRAME_CORRUPTED 0x02 35e8c0dacdSIlan Elias #define NCI_STATUS_FAILED 0x03 36e8c0dacdSIlan Elias #define NCI_STATUS_NOT_INITIALIZED 0x04 37e8c0dacdSIlan Elias #define NCI_STATUS_SYNTAX_ERROR 0x05 38e8c0dacdSIlan Elias #define NCI_STATUS_SEMANTIC_ERROR 0x06 39e8c0dacdSIlan Elias #define NCI_STATUS_UNKNOWN_GID 0x07 40e8c0dacdSIlan Elias #define NCI_STATUS_UNKNOWN_OID 0x08 41e8c0dacdSIlan Elias #define NCI_STATUS_INVALID_PARAM 0x09 42e8c0dacdSIlan Elias #define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0a 436a2968aaSIlan Elias /* Discovery Specific Status Codes */ 446a2968aaSIlan Elias #define NCI_STATUS_DISCOVERY_ALREADY_STARTED 0xa0 456a2968aaSIlan Elias #define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED 0xa1 46e8c0dacdSIlan Elias #define NCI_STATUS_DISCOVERY_TEAR_DOWN 0xa2 476a2968aaSIlan Elias /* RF Interface Specific Status Codes */ 486a2968aaSIlan Elias #define NCI_STATUS_RF_TRANSMISSION_ERROR 0xb0 496a2968aaSIlan Elias #define NCI_STATUS_RF_PROTOCOL_ERROR 0xb1 506a2968aaSIlan Elias #define NCI_STATUS_RF_TIMEOUT_ERROR 0xb2 516a2968aaSIlan Elias /* NFCEE Interface Specific Status Codes */ 52637d85a7SIlan Elias #define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED 0xc0 53637d85a7SIlan Elias #define NCI_STATUS_NFCEE_TRANSMISSION_ERROR 0xc1 54637d85a7SIlan Elias #define NCI_STATUS_NFCEE_PROTOCOL_ERROR 0xc2 55637d85a7SIlan Elias #define NCI_STATUS_NFCEE_TIMEOUT_ERROR 0xc3 566a2968aaSIlan Elias 578277f693SChristophe Ricard /* NFCEE Interface/Protocols */ 588277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_APDU 0x00 598277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_HCI_ACCESS 0x01 608277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_TYPE3_CMD_SET 0x02 618277f693SChristophe Ricard #define NCI_NFCEE_INTERFACE_TRANSPARENT 0x03 628277f693SChristophe Ricard 638277f693SChristophe Ricard /* Destination type */ 648277f693SChristophe Ricard #define NCI_DESTINATION_NFCC_LOOPBACK 0x01 658277f693SChristophe Ricard #define NCI_DESTINATION_REMOTE_NFC_ENDPOINT 0x02 668277f693SChristophe Ricard #define NCI_DESTINATION_NFCEE 0x03 678277f693SChristophe Ricard 688277f693SChristophe Ricard /* Destination-specific parameters type */ 698277f693SChristophe Ricard #define NCI_DESTINATION_SPECIFIC_PARAM_RF_TYPE 0x00 708277f693SChristophe Ricard #define NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE 0x01 718277f693SChristophe Ricard 728277f693SChristophe Ricard /* NFCEE Discovery Action */ 738277f693SChristophe Ricard #define NCI_NFCEE_DISCOVERY_ACTION_DISABLE 0x00 748277f693SChristophe Ricard #define NCI_NFCEE_DISCOVERY_ACTION_ENABLE 0x01 758277f693SChristophe Ricard 766a2968aaSIlan Elias /* NCI RF Technology and Mode */ 776a2968aaSIlan Elias #define NCI_NFC_A_PASSIVE_POLL_MODE 0x00 786a2968aaSIlan Elias #define NCI_NFC_B_PASSIVE_POLL_MODE 0x01 796a2968aaSIlan Elias #define NCI_NFC_F_PASSIVE_POLL_MODE 0x02 806a2968aaSIlan Elias #define NCI_NFC_A_ACTIVE_POLL_MODE 0x03 816a2968aaSIlan Elias #define NCI_NFC_F_ACTIVE_POLL_MODE 0x05 82cfdbeeafSVincent Cuissard #define NCI_NFC_V_PASSIVE_POLL_MODE 0x06 836a2968aaSIlan Elias #define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80 846a2968aaSIlan Elias #define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81 856a2968aaSIlan Elias #define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82 866a2968aaSIlan Elias #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 876a2968aaSIlan Elias #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 886a2968aaSIlan Elias 89a99903ecSJulien Lefrique #define NCI_RF_TECH_MODE_LISTEN_MASK 0x80 90a99903ecSJulien Lefrique 91e8c0dacdSIlan Elias /* NCI RF Technologies */ 92e8c0dacdSIlan Elias #define NCI_NFC_RF_TECHNOLOGY_A 0x00 93e8c0dacdSIlan Elias #define NCI_NFC_RF_TECHNOLOGY_B 0x01 94e8c0dacdSIlan Elias #define NCI_NFC_RF_TECHNOLOGY_F 0x02 95cfdbeeafSVincent Cuissard #define NCI_NFC_RF_TECHNOLOGY_V 0x03 96e8c0dacdSIlan Elias 97e8c0dacdSIlan Elias /* NCI Bit Rates */ 98e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_106 0x00 99e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_212 0x01 100e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_424 0x02 101e8c0dacdSIlan Elias #define NCI_NFC_BIT_RATE_848 0x03 102637d85a7SIlan Elias #define NCI_NFC_BIT_RATE_1695 0x04 103637d85a7SIlan Elias #define NCI_NFC_BIT_RATE_3390 0x05 104637d85a7SIlan Elias #define NCI_NFC_BIT_RATE_6780 0x06 105cfdbeeafSVincent Cuissard #define NCI_NFC_BIT_RATE_26 0x20 106e8c0dacdSIlan Elias 1076a2968aaSIlan Elias /* NCI RF Protocols */ 1086a2968aaSIlan Elias #define NCI_RF_PROTOCOL_UNKNOWN 0x00 1096a2968aaSIlan Elias #define NCI_RF_PROTOCOL_T1T 0x01 1106a2968aaSIlan Elias #define NCI_RF_PROTOCOL_T2T 0x02 1116a2968aaSIlan Elias #define NCI_RF_PROTOCOL_T3T 0x03 1126a2968aaSIlan Elias #define NCI_RF_PROTOCOL_ISO_DEP 0x04 1136a2968aaSIlan Elias #define NCI_RF_PROTOCOL_NFC_DEP 0x05 114cfdbeeafSVincent Cuissard #define NCI_RF_PROTOCOL_T5T 0x06 1156a2968aaSIlan Elias 1166a2968aaSIlan Elias /* NCI RF Interfaces */ 117e8c0dacdSIlan Elias #define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 1186a2968aaSIlan Elias #define NCI_RF_INTERFACE_FRAME 0x01 1196a2968aaSIlan Elias #define NCI_RF_INTERFACE_ISO_DEP 0x02 1206a2968aaSIlan Elias #define NCI_RF_INTERFACE_NFC_DEP 0x03 1216a2968aaSIlan Elias 1227e035230SIlan Elias /* NCI Configuration Parameter Tags */ 1237e035230SIlan Elias #define NCI_PN_ATR_REQ_GEN_BYTES 0x29 124529ee066SJulien Lefrique #define NCI_LN_ATR_RES_GEN_BYTES 0x61 12590d78c13SJulien Lefrique #define NCI_LA_SEL_INFO 0x32 12690d78c13SJulien Lefrique #define NCI_LF_PROTOCOL_TYPE 0x50 12790d78c13SJulien Lefrique #define NCI_LF_CON_BITR_F 0x54 12890d78c13SJulien Lefrique 12990d78c13SJulien Lefrique /* NCI Configuration Parameters masks */ 13090d78c13SJulien Lefrique #define NCI_LA_SEL_INFO_ISO_DEP_MASK 0x20 13190d78c13SJulien Lefrique #define NCI_LA_SEL_INFO_NFC_DEP_MASK 0x40 13290d78c13SJulien Lefrique #define NCI_LF_PROTOCOL_TYPE_NFC_DEP_MASK 0x02 13390d78c13SJulien Lefrique #define NCI_LF_CON_BITR_F_212 0x02 13490d78c13SJulien Lefrique #define NCI_LF_CON_BITR_F_424 0x04 1357e035230SIlan Elias 136*bcd684aaSBongsu Jeon /* NCI 2.x Feature Enable Bit */ 137*bcd684aaSBongsu Jeon #define NCI_FEATURE_DISABLE 0x00 138*bcd684aaSBongsu Jeon 139e8c0dacdSIlan Elias /* NCI Reset types */ 140e8c0dacdSIlan Elias #define NCI_RESET_TYPE_KEEP_CONFIG 0x00 141e8c0dacdSIlan Elias #define NCI_RESET_TYPE_RESET_CONFIG 0x01 142e8c0dacdSIlan Elias 143e8c0dacdSIlan Elias /* NCI Static RF connection ID */ 144e8c0dacdSIlan Elias #define NCI_STATIC_RF_CONN_ID 0x00 145e8c0dacdSIlan Elias 146db98c829SIlan Elias /* NCI Data Flow Control */ 147db98c829SIlan Elias #define NCI_DATA_FLOW_CONTROL_NOT_USED 0xff 148db98c829SIlan Elias 1496a2968aaSIlan Elias /* NCI RF_DISCOVER_MAP_CMD modes */ 1506a2968aaSIlan Elias #define NCI_DISC_MAP_MODE_POLL 0x01 1516a2968aaSIlan Elias #define NCI_DISC_MAP_MODE_LISTEN 0x02 1526a2968aaSIlan Elias 153019c4fbaSIlan Elias /* NCI Discover Notification Type */ 154019c4fbaSIlan Elias #define NCI_DISCOVER_NTF_TYPE_LAST 0x00 155019c4fbaSIlan Elias #define NCI_DISCOVER_NTF_TYPE_LAST_NFCC 0x01 156019c4fbaSIlan Elias #define NCI_DISCOVER_NTF_TYPE_MORE 0x02 157019c4fbaSIlan Elias 1586a2968aaSIlan Elias /* NCI Deactivation Type */ 1596a2968aaSIlan Elias #define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 1606a2968aaSIlan Elias #define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 1616a2968aaSIlan Elias #define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE 0x02 162e8c0dacdSIlan Elias #define NCI_DEACTIVATE_TYPE_DISCOVERY 0x03 1636a2968aaSIlan Elias 1646a2968aaSIlan Elias /* Message Type (MT) */ 1656a2968aaSIlan Elias #define NCI_MT_DATA_PKT 0x00 1666a2968aaSIlan Elias #define NCI_MT_CMD_PKT 0x01 1676a2968aaSIlan Elias #define NCI_MT_RSP_PKT 0x02 1686a2968aaSIlan Elias #define NCI_MT_NTF_PKT 0x03 1696a2968aaSIlan Elias 1706a2968aaSIlan Elias #define nci_mt(hdr) (((hdr)[0]>>5)&0x07) 1716a2968aaSIlan Elias #define nci_mt_set(hdr, mt) ((hdr)[0] |= (__u8)(((mt)&0x07)<<5)) 1726a2968aaSIlan Elias 1736a2968aaSIlan Elias /* Packet Boundary Flag (PBF) */ 1746a2968aaSIlan Elias #define NCI_PBF_LAST 0x00 1756a2968aaSIlan Elias #define NCI_PBF_CONT 0x01 1766a2968aaSIlan Elias 1776a2968aaSIlan Elias #define nci_pbf(hdr) (__u8)(((hdr)[0]>>4)&0x01) 1786a2968aaSIlan Elias #define nci_pbf_set(hdr, pbf) ((hdr)[0] |= (__u8)(((pbf)&0x01)<<4)) 1796a2968aaSIlan Elias 1806a2968aaSIlan Elias /* Control Opcode manipulation */ 1816a2968aaSIlan Elias #define nci_opcode_pack(gid, oid) (__u16)((((__u16)((gid)&0x0f))<<8)|\ 1826a2968aaSIlan Elias ((__u16)((oid)&0x3f))) 1836a2968aaSIlan Elias #define nci_opcode(hdr) nci_opcode_pack(hdr[0], hdr[1]) 1846a2968aaSIlan Elias #define nci_opcode_gid(op) (__u8)(((op)&0x0f00)>>8) 1856a2968aaSIlan Elias #define nci_opcode_oid(op) (__u8)((op)&0x003f) 1866a2968aaSIlan Elias 1876a2968aaSIlan Elias /* Payload Length */ 1886a2968aaSIlan Elias #define nci_plen(hdr) (__u8)((hdr)[2]) 1896a2968aaSIlan Elias 1906a2968aaSIlan Elias /* Connection ID */ 1916a2968aaSIlan Elias #define nci_conn_id(hdr) (__u8)(((hdr)[0])&0x0f) 1926a2968aaSIlan Elias 1936a2968aaSIlan Elias /* GID values */ 1946a2968aaSIlan Elias #define NCI_GID_CORE 0x0 1956a2968aaSIlan Elias #define NCI_GID_RF_MGMT 0x1 1966a2968aaSIlan Elias #define NCI_GID_NFCEE_MGMT 0x2 1976a2968aaSIlan Elias #define NCI_GID_PROPRIETARY 0xf 1986a2968aaSIlan Elias 199fa544fffSEric Lapuyade /* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */ 200fa544fffSEric Lapuyade #define NCI_SPI_HDR_LEN 4 201fa544fffSEric Lapuyade #define NCI_SPI_CRC_LEN 2 202fa544fffSEric Lapuyade 2036a2968aaSIlan Elias /* ---- NCI Packet structures ---- */ 2046a2968aaSIlan Elias #define NCI_CTRL_HDR_SIZE 3 2056a2968aaSIlan Elias #define NCI_DATA_HDR_SIZE 3 2066a2968aaSIlan Elias 2076a2968aaSIlan Elias struct nci_ctrl_hdr { 2086a2968aaSIlan Elias __u8 gid; /* MT & PBF & GID */ 2096a2968aaSIlan Elias __u8 oid; 2106a2968aaSIlan Elias __u8 plen; 2116a2968aaSIlan Elias } __packed; 2126a2968aaSIlan Elias 2136a2968aaSIlan Elias struct nci_data_hdr { 2146a2968aaSIlan Elias __u8 conn_id; /* MT & PBF & ConnID */ 2156a2968aaSIlan Elias __u8 rfu; 2166a2968aaSIlan Elias __u8 plen; 2176a2968aaSIlan Elias } __packed; 2186a2968aaSIlan Elias 2196a2968aaSIlan Elias /* ------------------------ */ 2206a2968aaSIlan Elias /* ----- NCI Commands ---- */ 2216a2968aaSIlan Elias /* ------------------------ */ 2226a2968aaSIlan Elias #define NCI_OP_CORE_RESET_CMD nci_opcode_pack(NCI_GID_CORE, 0x00) 223e8c0dacdSIlan Elias struct nci_core_reset_cmd { 224e8c0dacdSIlan Elias __u8 reset_type; 225e8c0dacdSIlan Elias } __packed; 2266a2968aaSIlan Elias 2276a2968aaSIlan Elias #define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) 228*bcd684aaSBongsu Jeon /* To support NCI 2.x */ 229*bcd684aaSBongsu Jeon struct nci_core_init_v2_cmd { 230*bcd684aaSBongsu Jeon u8 feature1; 231*bcd684aaSBongsu Jeon u8 feature2; 232*bcd684aaSBongsu Jeon }; 2336a2968aaSIlan Elias 2347e035230SIlan Elias #define NCI_OP_CORE_SET_CONFIG_CMD nci_opcode_pack(NCI_GID_CORE, 0x02) 2357e035230SIlan Elias struct set_config_param { 2367e035230SIlan Elias __u8 id; 2377e035230SIlan Elias __u8 len; 2387e035230SIlan Elias __u8 val[NCI_MAX_PARAM_LEN]; 2397e035230SIlan Elias } __packed; 2407e035230SIlan Elias 2417e035230SIlan Elias struct nci_core_set_config_cmd { 2427e035230SIlan Elias __u8 num_params; 2437e035230SIlan Elias struct set_config_param param; /* support 1 param per cmd is enough */ 2447e035230SIlan Elias } __packed; 2457e035230SIlan Elias 246736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CREATE_CMD nci_opcode_pack(NCI_GID_CORE, 0x04) 247b16ae716SChristophe Ricard #define DEST_SPEC_PARAMS_ID_INDEX 0 248b16ae716SChristophe Ricard #define DEST_SPEC_PARAMS_PROTOCOL_INDEX 1 249736bb957SChristophe Ricard struct dest_spec_params { 250736bb957SChristophe Ricard __u8 id; 251736bb957SChristophe Ricard __u8 protocol; 252736bb957SChristophe Ricard } __packed; 253736bb957SChristophe Ricard 254736bb957SChristophe Ricard struct core_conn_create_dest_spec_params { 255736bb957SChristophe Ricard __u8 type; 256736bb957SChristophe Ricard __u8 length; 257da60fbe7SGustavo A. R. Silva __u8 value[]; 258736bb957SChristophe Ricard } __packed; 259736bb957SChristophe Ricard 260736bb957SChristophe Ricard struct nci_core_conn_create_cmd { 261736bb957SChristophe Ricard __u8 destination_type; 262736bb957SChristophe Ricard __u8 number_destination_params; 263da60fbe7SGustavo A. R. Silva struct core_conn_create_dest_spec_params params[]; 264736bb957SChristophe Ricard } __packed; 265736bb957SChristophe Ricard 266736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CLOSE_CMD nci_opcode_pack(NCI_GID_CORE, 0x05) 267736bb957SChristophe Ricard 2686a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_MAP_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) 2696a2968aaSIlan Elias struct disc_map_config { 2706a2968aaSIlan Elias __u8 rf_protocol; 2716a2968aaSIlan Elias __u8 mode; 272637d85a7SIlan Elias __u8 rf_interface; 2736a2968aaSIlan Elias } __packed; 2746a2968aaSIlan Elias 2756a2968aaSIlan Elias struct nci_rf_disc_map_cmd { 2766a2968aaSIlan Elias __u8 num_mapping_configs; 2776a2968aaSIlan Elias struct disc_map_config mapping_configs 2786a2968aaSIlan Elias [NCI_MAX_NUM_MAPPING_CONFIGS]; 2796a2968aaSIlan Elias } __packed; 2806a2968aaSIlan Elias 2816a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) 2826a2968aaSIlan Elias struct disc_config { 283637d85a7SIlan Elias __u8 rf_tech_and_mode; 2846a2968aaSIlan Elias __u8 frequency; 2856a2968aaSIlan Elias } __packed; 2866a2968aaSIlan Elias 2876a2968aaSIlan Elias struct nci_rf_disc_cmd { 2886a2968aaSIlan Elias __u8 num_disc_configs; 2896a2968aaSIlan Elias struct disc_config disc_configs[NCI_MAX_NUM_RF_CONFIGS]; 2906a2968aaSIlan Elias } __packed; 2916a2968aaSIlan Elias 292019c4fbaSIlan Elias #define NCI_OP_RF_DISCOVER_SELECT_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x04) 293019c4fbaSIlan Elias struct nci_rf_discover_select_cmd { 294019c4fbaSIlan Elias __u8 rf_discovery_id; 295019c4fbaSIlan Elias __u8 rf_protocol; 296019c4fbaSIlan Elias __u8 rf_interface; 297019c4fbaSIlan Elias } __packed; 298019c4fbaSIlan Elias 2996a2968aaSIlan Elias #define NCI_OP_RF_DEACTIVATE_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 3006a2968aaSIlan Elias struct nci_rf_deactivate_cmd { 3016a2968aaSIlan Elias __u8 type; 3026a2968aaSIlan Elias } __packed; 3036a2968aaSIlan Elias 3048277f693SChristophe Ricard #define NCI_OP_NFCEE_DISCOVER_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00) 3058277f693SChristophe Ricard struct nci_nfcee_discover_cmd { 3068277f693SChristophe Ricard __u8 discovery_action; 3078277f693SChristophe Ricard } __packed; 3088277f693SChristophe Ricard 309f7f793f3SChristophe Ricard #define NCI_OP_NFCEE_MODE_SET_CMD nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01) 310f7f793f3SChristophe Ricard #define NCI_NFCEE_DISABLE 0x00 311f7f793f3SChristophe Ricard #define NCI_NFCEE_ENABLE 0x01 312f7f793f3SChristophe Ricard struct nci_nfcee_mode_set_cmd { 313f7f793f3SChristophe Ricard __u8 nfcee_id; 314f7f793f3SChristophe Ricard __u8 nfcee_mode; 315f7f793f3SChristophe Ricard } __packed; 316f7f793f3SChristophe Ricard 317a9433c11SRobert Dolca #define NCI_OP_CORE_GET_CONFIG_CMD nci_opcode_pack(NCI_GID_CORE, 0x03) 318a9433c11SRobert Dolca 3196a2968aaSIlan Elias /* ----------------------- */ 3206a2968aaSIlan Elias /* ---- NCI Responses ---- */ 3216a2968aaSIlan Elias /* ----------------------- */ 3226a2968aaSIlan Elias #define NCI_OP_CORE_RESET_RSP nci_opcode_pack(NCI_GID_CORE, 0x00) 3236a2968aaSIlan Elias struct nci_core_reset_rsp { 3246a2968aaSIlan Elias __u8 status; 3256a2968aaSIlan Elias __u8 nci_ver; 326e8c0dacdSIlan Elias __u8 config_status; 3276a2968aaSIlan Elias } __packed; 3286a2968aaSIlan Elias 3296a2968aaSIlan Elias #define NCI_OP_CORE_INIT_RSP nci_opcode_pack(NCI_GID_CORE, 0x01) 3306a2968aaSIlan Elias struct nci_core_init_rsp_1 { 3316a2968aaSIlan Elias __u8 status; 3326a2968aaSIlan Elias __le32 nfcc_features; 3336a2968aaSIlan Elias __u8 num_supported_rf_interfaces; 334da60fbe7SGustavo A. R. Silva __u8 supported_rf_interfaces[]; /* variable size array */ 3356a2968aaSIlan Elias /* continuted in nci_core_init_rsp_2 */ 3366a2968aaSIlan Elias } __packed; 3376a2968aaSIlan Elias 3386a2968aaSIlan Elias struct nci_core_init_rsp_2 { 3396a2968aaSIlan Elias __u8 max_logical_connections; 3406a2968aaSIlan Elias __le16 max_routing_table_size; 341e8c0dacdSIlan Elias __u8 max_ctrl_pkt_payload_len; 342e8c0dacdSIlan Elias __le16 max_size_for_large_params; 343e8c0dacdSIlan Elias __u8 manufact_id; 344e8c0dacdSIlan Elias __le32 manufact_specific_info; 3456a2968aaSIlan Elias } __packed; 3466a2968aaSIlan Elias 347*bcd684aaSBongsu Jeon /* To support NCI ver 2.x */ 348*bcd684aaSBongsu Jeon struct nci_core_init_rsp_nci_ver2 { 349*bcd684aaSBongsu Jeon u8 status; 350*bcd684aaSBongsu Jeon __le32 nfcc_features; 351*bcd684aaSBongsu Jeon u8 max_logical_connections; 352*bcd684aaSBongsu Jeon __le16 max_routing_table_size; 353*bcd684aaSBongsu Jeon u8 max_ctrl_pkt_payload_len; 354*bcd684aaSBongsu Jeon u8 max_data_pkt_hci_payload_len; 355*bcd684aaSBongsu Jeon u8 number_of_hci_credit; 356*bcd684aaSBongsu Jeon __le16 max_nfc_v_frame_size; 357*bcd684aaSBongsu Jeon u8 num_supported_rf_interfaces; 358*bcd684aaSBongsu Jeon u8 supported_rf_interfaces[]; 359*bcd684aaSBongsu Jeon } __packed; 360*bcd684aaSBongsu Jeon 3617e035230SIlan Elias #define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02) 3627e035230SIlan Elias struct nci_core_set_config_rsp { 3637e035230SIlan Elias __u8 status; 3647e035230SIlan Elias __u8 num_params; 365da60fbe7SGustavo A. R. Silva __u8 params_id[]; /* variable size array */ 3667e035230SIlan Elias } __packed; 3677e035230SIlan Elias 368736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CREATE_RSP nci_opcode_pack(NCI_GID_CORE, 0x04) 369736bb957SChristophe Ricard struct nci_core_conn_create_rsp { 370736bb957SChristophe Ricard __u8 status; 371736bb957SChristophe Ricard __u8 max_ctrl_pkt_payload_len; 3723ba5c846SChristophe Ricard __u8 credits_cnt; 373736bb957SChristophe Ricard __u8 conn_id; 374736bb957SChristophe Ricard } __packed; 375736bb957SChristophe Ricard 376736bb957SChristophe Ricard #define NCI_OP_CORE_CONN_CLOSE_RSP nci_opcode_pack(NCI_GID_CORE, 0x05) 377736bb957SChristophe Ricard 3786a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_MAP_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) 3796a2968aaSIlan Elias 3806a2968aaSIlan Elias #define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) 3816a2968aaSIlan Elias 382019c4fbaSIlan Elias #define NCI_OP_RF_DISCOVER_SELECT_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x04) 383019c4fbaSIlan Elias 3846a2968aaSIlan Elias #define NCI_OP_RF_DEACTIVATE_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 3856a2968aaSIlan Elias 3868277f693SChristophe Ricard #define NCI_OP_NFCEE_DISCOVER_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00) 3878277f693SChristophe Ricard struct nci_nfcee_discover_rsp { 3888277f693SChristophe Ricard __u8 status; 3898277f693SChristophe Ricard __u8 num_nfcee; 3908277f693SChristophe Ricard } __packed; 3918277f693SChristophe Ricard 392f7f793f3SChristophe Ricard #define NCI_OP_NFCEE_MODE_SET_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01) 393a9433c11SRobert Dolca 394a9433c11SRobert Dolca #define NCI_OP_CORE_GET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x03) 395a9433c11SRobert Dolca 3966a2968aaSIlan Elias /* --------------------------- */ 3976a2968aaSIlan Elias /* ---- NCI Notifications ---- */ 3986a2968aaSIlan Elias /* --------------------------- */ 399*bcd684aaSBongsu Jeon #define NCI_OP_CORE_RESET_NTF nci_opcode_pack(NCI_GID_CORE, 0x00) 400*bcd684aaSBongsu Jeon struct nci_core_reset_ntf { 401*bcd684aaSBongsu Jeon u8 reset_trigger; 402*bcd684aaSBongsu Jeon u8 config_status; 403*bcd684aaSBongsu Jeon u8 nci_ver; 404*bcd684aaSBongsu Jeon u8 manufact_id; 405*bcd684aaSBongsu Jeon u8 manufacturer_specific_len; 406*bcd684aaSBongsu Jeon __le32 manufact_specific_info; 407*bcd684aaSBongsu Jeon } __packed; 408*bcd684aaSBongsu Jeon 409637d85a7SIlan Elias #define NCI_OP_CORE_CONN_CREDITS_NTF nci_opcode_pack(NCI_GID_CORE, 0x06) 4106a2968aaSIlan Elias struct conn_credit_entry { 4116a2968aaSIlan Elias __u8 conn_id; 4126a2968aaSIlan Elias __u8 credits; 4136a2968aaSIlan Elias } __packed; 4146a2968aaSIlan Elias 4156a2968aaSIlan Elias struct nci_core_conn_credit_ntf { 4166a2968aaSIlan Elias __u8 num_entries; 4176a2968aaSIlan Elias struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN]; 4186a2968aaSIlan Elias } __packed; 4196a2968aaSIlan Elias 420019c4fbaSIlan Elias #define NCI_OP_CORE_GENERIC_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x07) 421019c4fbaSIlan Elias 422004161cbSIlan Elias #define NCI_OP_CORE_INTF_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x08) 423004161cbSIlan Elias struct nci_core_intf_error_ntf { 424004161cbSIlan Elias __u8 status; 425004161cbSIlan Elias __u8 conn_id; 426004161cbSIlan Elias } __packed; 427004161cbSIlan Elias 428019c4fbaSIlan Elias #define NCI_OP_RF_DISCOVER_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) 4296a2968aaSIlan Elias struct rf_tech_specific_params_nfca_poll { 4306a2968aaSIlan Elias __u16 sens_res; 4316a2968aaSIlan Elias __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ 432a99903ecSJulien Lefrique __u8 nfcid1[NFC_NFCID1_MAXSIZE]; 4336a2968aaSIlan Elias __u8 sel_res_len; /* 0 or 1 Bytes */ 4346a2968aaSIlan Elias __u8 sel_res; 4356a2968aaSIlan Elias } __packed; 4366a2968aaSIlan Elias 437d5a2ca60SIlan Elias struct rf_tech_specific_params_nfcb_poll { 438d5a2ca60SIlan Elias __u8 sensb_res_len; 439a99903ecSJulien Lefrique __u8 sensb_res[NFC_SENSB_RES_MAXSIZE]; /* 11 or 12 Bytes */ 440d5a2ca60SIlan Elias } __packed; 441d5a2ca60SIlan Elias 442d5a2ca60SIlan Elias struct rf_tech_specific_params_nfcf_poll { 443d5a2ca60SIlan Elias __u8 bit_rate; 444d5a2ca60SIlan Elias __u8 sensf_res_len; 445a99903ecSJulien Lefrique __u8 sensf_res[NFC_SENSF_RES_MAXSIZE]; /* 16 or 18 Bytes */ 446d5a2ca60SIlan Elias } __packed; 447d5a2ca60SIlan Elias 448cfdbeeafSVincent Cuissard struct rf_tech_specific_params_nfcv_poll { 449cfdbeeafSVincent Cuissard __u8 res_flags; 450cfdbeeafSVincent Cuissard __u8 dsfid; 451a99903ecSJulien Lefrique __u8 uid[NFC_ISO15693_UID_MAXSIZE]; /* 8 Bytes */ 452a99903ecSJulien Lefrique } __packed; 453a99903ecSJulien Lefrique 454a99903ecSJulien Lefrique struct rf_tech_specific_params_nfcf_listen { 455a99903ecSJulien Lefrique __u8 local_nfcid2_len; 456a99903ecSJulien Lefrique __u8 local_nfcid2[NFC_NFCID2_MAXSIZE]; /* 0 or 8 Bytes */ 457cfdbeeafSVincent Cuissard } __packed; 458cfdbeeafSVincent Cuissard 459019c4fbaSIlan Elias struct nci_rf_discover_ntf { 460019c4fbaSIlan Elias __u8 rf_discovery_id; 461019c4fbaSIlan Elias __u8 rf_protocol; 462019c4fbaSIlan Elias __u8 rf_tech_and_mode; 463019c4fbaSIlan Elias __u8 rf_tech_specific_params_len; 464019c4fbaSIlan Elias 465019c4fbaSIlan Elias union { 466019c4fbaSIlan Elias struct rf_tech_specific_params_nfca_poll nfca_poll; 467019c4fbaSIlan Elias struct rf_tech_specific_params_nfcb_poll nfcb_poll; 468019c4fbaSIlan Elias struct rf_tech_specific_params_nfcf_poll nfcf_poll; 469cfdbeeafSVincent Cuissard struct rf_tech_specific_params_nfcv_poll nfcv_poll; 470019c4fbaSIlan Elias } rf_tech_specific_params; 471019c4fbaSIlan Elias 472019c4fbaSIlan Elias __u8 ntf_type; 473019c4fbaSIlan Elias } __packed; 474019c4fbaSIlan Elias 475019c4fbaSIlan Elias #define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) 4766a2968aaSIlan Elias struct activation_params_nfca_poll_iso_dep { 4776a2968aaSIlan Elias __u8 rats_res_len; 4786a2968aaSIlan Elias __u8 rats_res[20]; 4796a2968aaSIlan Elias }; 4806a2968aaSIlan Elias 481d5a2ca60SIlan Elias struct activation_params_nfcb_poll_iso_dep { 482d5a2ca60SIlan Elias __u8 attrib_res_len; 483d5a2ca60SIlan Elias __u8 attrib_res[50]; 484d5a2ca60SIlan Elias }; 485d5a2ca60SIlan Elias 486ac206838SIlan Elias struct activation_params_poll_nfc_dep { 487ac206838SIlan Elias __u8 atr_res_len; 488a99903ecSJulien Lefrique __u8 atr_res[NFC_ATR_RES_MAXSIZE - 2]; /* ATR_RES from byte 3 */ 489a99903ecSJulien Lefrique }; 490a99903ecSJulien Lefrique 491a99903ecSJulien Lefrique struct activation_params_listen_nfc_dep { 492a99903ecSJulien Lefrique __u8 atr_req_len; 493a99903ecSJulien Lefrique __u8 atr_req[NFC_ATR_REQ_MAXSIZE - 2]; /* ATR_REQ from byte 3 */ 494ac206838SIlan Elias }; 495ac206838SIlan Elias 496e8c0dacdSIlan Elias struct nci_rf_intf_activated_ntf { 497e8c0dacdSIlan Elias __u8 rf_discovery_id; 498637d85a7SIlan Elias __u8 rf_interface; 4996a2968aaSIlan Elias __u8 rf_protocol; 500e8c0dacdSIlan Elias __u8 activation_rf_tech_and_mode; 501637d85a7SIlan Elias __u8 max_data_pkt_payload_size; 502637d85a7SIlan Elias __u8 initial_num_credits; 5036a2968aaSIlan Elias __u8 rf_tech_specific_params_len; 5046a2968aaSIlan Elias 5056a2968aaSIlan Elias union { 5066a2968aaSIlan Elias struct rf_tech_specific_params_nfca_poll nfca_poll; 507d5a2ca60SIlan Elias struct rf_tech_specific_params_nfcb_poll nfcb_poll; 508d5a2ca60SIlan Elias struct rf_tech_specific_params_nfcf_poll nfcf_poll; 509cfdbeeafSVincent Cuissard struct rf_tech_specific_params_nfcv_poll nfcv_poll; 510a99903ecSJulien Lefrique struct rf_tech_specific_params_nfcf_listen nfcf_listen; 5116a2968aaSIlan Elias } rf_tech_specific_params; 5126a2968aaSIlan Elias 513e8c0dacdSIlan Elias __u8 data_exch_rf_tech_and_mode; 514e8c0dacdSIlan Elias __u8 data_exch_tx_bit_rate; 515e8c0dacdSIlan Elias __u8 data_exch_rx_bit_rate; 5166a2968aaSIlan Elias __u8 activation_params_len; 5176a2968aaSIlan Elias 5186a2968aaSIlan Elias union { 5196a2968aaSIlan Elias struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep; 520d5a2ca60SIlan Elias struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep; 521ac206838SIlan Elias struct activation_params_poll_nfc_dep poll_nfc_dep; 522a99903ecSJulien Lefrique struct activation_params_listen_nfc_dep listen_nfc_dep; 5236a2968aaSIlan Elias } activation_params; 5246a2968aaSIlan Elias 5256a2968aaSIlan Elias } __packed; 5266a2968aaSIlan Elias 5276a2968aaSIlan Elias #define NCI_OP_RF_DEACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 528e8c0dacdSIlan Elias struct nci_rf_deactivate_ntf { 529e8c0dacdSIlan Elias __u8 type; 530e8c0dacdSIlan Elias __u8 reason; 531e8c0dacdSIlan Elias } __packed; 5326a2968aaSIlan Elias 533a41bb844SChristophe Ricard #define NCI_OP_RF_NFCEE_ACTION_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x09) 534a41bb844SChristophe Ricard struct nci_rf_nfcee_action_ntf { 535a41bb844SChristophe Ricard __u8 nfcee_id; 536a41bb844SChristophe Ricard __u8 trigger; 537a41bb844SChristophe Ricard __u8 supported_data_length; 538da60fbe7SGustavo A. R. Silva __u8 supported_data[]; 539a41bb844SChristophe Ricard } __packed; 540a41bb844SChristophe Ricard 5418277f693SChristophe Ricard #define NCI_OP_NFCEE_DISCOVER_NTF nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x00) 5428277f693SChristophe Ricard struct nci_nfcee_supported_protocol { 5438277f693SChristophe Ricard __u8 num_protocol; 544da60fbe7SGustavo A. R. Silva __u8 supported_protocol[]; 5458277f693SChristophe Ricard } __packed; 5468277f693SChristophe Ricard 5478277f693SChristophe Ricard struct nci_nfcee_information_tlv { 5488277f693SChristophe Ricard __u8 num_tlv; 549da60fbe7SGustavo A. R. Silva __u8 information_tlv[]; 5508277f693SChristophe Ricard } __packed; 5518277f693SChristophe Ricard 5528277f693SChristophe Ricard struct nci_nfcee_discover_ntf { 5538277f693SChristophe Ricard __u8 nfcee_id; 5548277f693SChristophe Ricard __u8 nfcee_status; 5558277f693SChristophe Ricard struct nci_nfcee_supported_protocol supported_protocols; 5568277f693SChristophe Ricard struct nci_nfcee_information_tlv information_tlv; 5578277f693SChristophe Ricard } __packed; 5588277f693SChristophe Ricard 559a9433c11SRobert Dolca #define NCI_OP_CORE_RESET_NTF nci_opcode_pack(NCI_GID_CORE, 0x00) 560a9433c11SRobert Dolca 5616a2968aaSIlan Elias #endif /* __NCI_H */ 562