linux/include/net/nfc/nci.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 *  The NFC Controller Interface is the communication protocol between an
 *  NFC Controller (NFCC) and a Device Host (DH).
 *
 *  Copyright (C) 2014 Marvell International Ltd.
 *  Copyright (C) 2011 Texas Instruments, Inc.
 *
 *  Written by Ilan Elias <[email protected]>
 *
 *  Acknowledgements:
 *  This file is based on hci.h, which was written
 *  by Maxim Krasnyansky.
 */

#ifndef __NCI_H
#define __NCI_H

#include <net/nfc/nfc.h>

/* NCI constants */
#define NCI_MAX_NUM_MAPPING_CONFIGS
#define NCI_MAX_NUM_RF_CONFIGS
#define NCI_MAX_NUM_CONN
#define NCI_MAX_PARAM_LEN
#define NCI_MAX_PAYLOAD_SIZE
#define NCI_MAX_PACKET_SIZE
#define NCI_MAX_LARGE_PARAMS_NCI_v2
#define NCI_VER_2_MASK

/* NCI Status Codes */
#define NCI_STATUS_OK
#define NCI_STATUS_REJECTED
#define NCI_STATUS_RF_FRAME_CORRUPTED
#define NCI_STATUS_FAILED
#define NCI_STATUS_NOT_INITIALIZED
#define NCI_STATUS_SYNTAX_ERROR
#define NCI_STATUS_SEMANTIC_ERROR
#define NCI_STATUS_UNKNOWN_GID
#define NCI_STATUS_UNKNOWN_OID
#define NCI_STATUS_INVALID_PARAM
#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED
/* Discovery Specific Status Codes */
#define NCI_STATUS_DISCOVERY_ALREADY_STARTED
#define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED
#define NCI_STATUS_DISCOVERY_TEAR_DOWN
/* RF Interface Specific Status Codes */
#define NCI_STATUS_RF_TRANSMISSION_ERROR
#define NCI_STATUS_RF_PROTOCOL_ERROR
#define NCI_STATUS_RF_TIMEOUT_ERROR
/* NFCEE Interface Specific Status Codes */
#define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED
#define NCI_STATUS_NFCEE_TRANSMISSION_ERROR
#define NCI_STATUS_NFCEE_PROTOCOL_ERROR
#define NCI_STATUS_NFCEE_TIMEOUT_ERROR

/* NFCEE Interface/Protocols */
#define NCI_NFCEE_INTERFACE_APDU
#define NCI_NFCEE_INTERFACE_HCI_ACCESS
#define NCI_NFCEE_INTERFACE_TYPE3_CMD_SET
#define NCI_NFCEE_INTERFACE_TRANSPARENT

/* Destination type */
#define NCI_DESTINATION_NFCC_LOOPBACK
#define NCI_DESTINATION_REMOTE_NFC_ENDPOINT
#define NCI_DESTINATION_NFCEE

/* Destination-specific parameters type */
#define NCI_DESTINATION_SPECIFIC_PARAM_RF_TYPE
#define NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE

/* NFCEE Discovery Action */
#define NCI_NFCEE_DISCOVERY_ACTION_DISABLE
#define NCI_NFCEE_DISCOVERY_ACTION_ENABLE

/* NCI RF Technology and Mode */
#define NCI_NFC_A_PASSIVE_POLL_MODE
#define NCI_NFC_B_PASSIVE_POLL_MODE
#define NCI_NFC_F_PASSIVE_POLL_MODE
#define NCI_NFC_A_ACTIVE_POLL_MODE
#define NCI_NFC_F_ACTIVE_POLL_MODE
#define NCI_NFC_V_PASSIVE_POLL_MODE
#define NCI_NFC_A_PASSIVE_LISTEN_MODE
#define NCI_NFC_B_PASSIVE_LISTEN_MODE
#define NCI_NFC_F_PASSIVE_LISTEN_MODE
#define NCI_NFC_A_ACTIVE_LISTEN_MODE
#define NCI_NFC_F_ACTIVE_LISTEN_MODE

#define NCI_RF_TECH_MODE_LISTEN_MASK

/* NCI RF Technologies */
#define NCI_NFC_RF_TECHNOLOGY_A
#define NCI_NFC_RF_TECHNOLOGY_B
#define NCI_NFC_RF_TECHNOLOGY_F
#define NCI_NFC_RF_TECHNOLOGY_V

/* NCI Bit Rates */
#define NCI_NFC_BIT_RATE_106
#define NCI_NFC_BIT_RATE_212
#define NCI_NFC_BIT_RATE_424
#define NCI_NFC_BIT_RATE_848
#define NCI_NFC_BIT_RATE_1695
#define NCI_NFC_BIT_RATE_3390
#define NCI_NFC_BIT_RATE_6780
#define NCI_NFC_BIT_RATE_26

/* NCI RF Protocols */
#define NCI_RF_PROTOCOL_UNKNOWN
#define NCI_RF_PROTOCOL_T1T
#define NCI_RF_PROTOCOL_T2T
#define NCI_RF_PROTOCOL_T3T
#define NCI_RF_PROTOCOL_ISO_DEP
#define NCI_RF_PROTOCOL_NFC_DEP
#define NCI_RF_PROTOCOL_T5T

/* NCI RF Interfaces */
#define NCI_RF_INTERFACE_NFCEE_DIRECT
#define NCI_RF_INTERFACE_FRAME
#define NCI_RF_INTERFACE_ISO_DEP
#define NCI_RF_INTERFACE_NFC_DEP

/* NCI Configuration Parameter Tags */
#define NCI_PN_ATR_REQ_GEN_BYTES
#define NCI_LN_ATR_RES_GEN_BYTES
#define NCI_LA_SEL_INFO
#define NCI_LF_PROTOCOL_TYPE
#define NCI_LF_CON_BITR_F

/* NCI Configuration Parameters masks */
#define NCI_LA_SEL_INFO_ISO_DEP_MASK
#define NCI_LA_SEL_INFO_NFC_DEP_MASK
#define NCI_LF_PROTOCOL_TYPE_NFC_DEP_MASK
#define NCI_LF_CON_BITR_F_212
#define NCI_LF_CON_BITR_F_424

/* NCI 2.x Feature Enable Bit */
#define NCI_FEATURE_DISABLE

/* NCI Reset types */
#define NCI_RESET_TYPE_KEEP_CONFIG
#define NCI_RESET_TYPE_RESET_CONFIG

/* NCI Static RF connection ID */
#define NCI_STATIC_RF_CONN_ID

/* NCI Data Flow Control */
#define NCI_DATA_FLOW_CONTROL_NOT_USED

/* NCI RF_DISCOVER_MAP_CMD modes */
#define NCI_DISC_MAP_MODE_POLL
#define NCI_DISC_MAP_MODE_LISTEN

/* NCI Discover Notification Type */
#define NCI_DISCOVER_NTF_TYPE_LAST
#define NCI_DISCOVER_NTF_TYPE_LAST_NFCC
#define NCI_DISCOVER_NTF_TYPE_MORE

/* NCI Deactivation Type */
#define NCI_DEACTIVATE_TYPE_IDLE_MODE
#define NCI_DEACTIVATE_TYPE_SLEEP_MODE
#define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE
#define NCI_DEACTIVATE_TYPE_DISCOVERY

/* Message Type (MT) */
#define NCI_MT_DATA_PKT
#define NCI_MT_CMD_PKT
#define NCI_MT_RSP_PKT
#define NCI_MT_NTF_PKT

#define nci_mt(hdr)
#define nci_mt_set(hdr, mt)

/* Packet Boundary Flag (PBF) */
#define NCI_PBF_LAST
#define NCI_PBF_CONT

#define nci_pbf(hdr)
#define nci_pbf_set(hdr, pbf)

/* Control Opcode manipulation */
#define nci_opcode_pack(gid, oid)
#define nci_opcode(hdr)
#define nci_opcode_gid(op)
#define nci_opcode_oid(op)

/* Payload Length */
#define nci_plen(hdr)

/* Connection ID */
#define nci_conn_id(hdr)

/* GID values */
#define NCI_GID_CORE
#define NCI_GID_RF_MGMT
#define NCI_GID_NFCEE_MGMT
#define NCI_GID_PROPRIETARY

/* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
#define NCI_SPI_HDR_LEN
#define NCI_SPI_CRC_LEN

/* ---- NCI Packet structures ---- */
#define NCI_CTRL_HDR_SIZE
#define NCI_DATA_HDR_SIZE

struct nci_ctrl_hdr {} __packed;

struct nci_data_hdr {} __packed;

/* ------------------------ */
/* -----  NCI Commands ---- */
/* ------------------------ */
#define NCI_OP_CORE_RESET_CMD
struct nci_core_reset_cmd {} __packed;

#define NCI_OP_CORE_INIT_CMD
/* To support NCI 2.x */
struct nci_core_init_v2_cmd {};

#define NCI_OP_CORE_SET_CONFIG_CMD
struct set_config_param {} __packed;

struct nci_core_set_config_cmd {} __packed;

#define NCI_OP_CORE_CONN_CREATE_CMD
#define DEST_SPEC_PARAMS_ID_INDEX
#define DEST_SPEC_PARAMS_PROTOCOL_INDEX
struct dest_spec_params {} __packed;

struct core_conn_create_dest_spec_params {} __packed;

struct nci_core_conn_create_cmd {} __packed;

#define NCI_OP_CORE_CONN_CLOSE_CMD

#define NCI_OP_RF_DISCOVER_MAP_CMD
struct disc_map_config {} __packed;

struct nci_rf_disc_map_cmd {} __packed;

#define NCI_OP_RF_DISCOVER_CMD
struct disc_config {} __packed;

struct nci_rf_disc_cmd {} __packed;

#define NCI_OP_RF_DISCOVER_SELECT_CMD
struct nci_rf_discover_select_cmd {} __packed;

#define NCI_OP_RF_DEACTIVATE_CMD
struct nci_rf_deactivate_cmd {} __packed;

#define NCI_OP_NFCEE_DISCOVER_CMD
struct nci_nfcee_discover_cmd {} __packed;

#define NCI_OP_NFCEE_MODE_SET_CMD
#define NCI_NFCEE_DISABLE
#define NCI_NFCEE_ENABLE
struct nci_nfcee_mode_set_cmd {} __packed;

#define NCI_OP_CORE_GET_CONFIG_CMD

/* ----------------------- */
/* ---- NCI Responses ---- */
/* ----------------------- */
#define NCI_OP_CORE_RESET_RSP
struct nci_core_reset_rsp {} __packed;

#define NCI_OP_CORE_INIT_RSP
struct nci_core_init_rsp_1 {} __packed;

struct nci_core_init_rsp_2 {} __packed;

/* To support NCI ver 2.x */
struct nci_core_init_rsp_nci_ver2 {} __packed;

#define NCI_OP_CORE_SET_CONFIG_RSP
struct nci_core_set_config_rsp {} __packed;

#define NCI_OP_CORE_CONN_CREATE_RSP
struct nci_core_conn_create_rsp {} __packed;

#define NCI_OP_CORE_CONN_CLOSE_RSP

#define NCI_OP_RF_DISCOVER_MAP_RSP

#define NCI_OP_RF_DISCOVER_RSP

#define NCI_OP_RF_DISCOVER_SELECT_RSP

#define NCI_OP_RF_DEACTIVATE_RSP

#define NCI_OP_NFCEE_DISCOVER_RSP
struct nci_nfcee_discover_rsp {} __packed;

#define NCI_OP_NFCEE_MODE_SET_RSP

#define NCI_OP_CORE_GET_CONFIG_RSP

/* --------------------------- */
/* ---- NCI Notifications ---- */
/* --------------------------- */
#define NCI_OP_CORE_RESET_NTF
struct nci_core_reset_ntf {} __packed;

#define NCI_OP_CORE_CONN_CREDITS_NTF
struct conn_credit_entry {} __packed;

struct nci_core_conn_credit_ntf {} __packed;

#define NCI_OP_CORE_GENERIC_ERROR_NTF

#define NCI_OP_CORE_INTF_ERROR_NTF
struct nci_core_intf_error_ntf {} __packed;

#define NCI_OP_RF_DISCOVER_NTF
struct rf_tech_specific_params_nfca_poll {} __packed;

struct rf_tech_specific_params_nfcb_poll {} __packed;

struct rf_tech_specific_params_nfcf_poll {} __packed;

struct rf_tech_specific_params_nfcv_poll {} __packed;

struct rf_tech_specific_params_nfcf_listen {} __packed;

struct nci_rf_discover_ntf {} __packed;

#define NCI_OP_RF_INTF_ACTIVATED_NTF
struct activation_params_nfca_poll_iso_dep {};

struct activation_params_nfcb_poll_iso_dep {};

struct activation_params_poll_nfc_dep {};

struct activation_params_listen_nfc_dep {};

struct nci_rf_intf_activated_ntf {} __packed;

#define NCI_OP_RF_DEACTIVATE_NTF
struct nci_rf_deactivate_ntf {} __packed;

#define NCI_OP_RF_NFCEE_ACTION_NTF
struct nci_rf_nfcee_action_ntf {} __packed;

#define NCI_OP_NFCEE_DISCOVER_NTF
struct nci_nfcee_supported_protocol {} __packed;

struct nci_nfcee_information_tlv {} __packed;

struct nci_nfcee_discover_ntf {} __packed;

#define NCI_OP_CORE_RESET_NTF

#endif /* __NCI_H */