18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2011 Instituto Nokia de Tecnologia
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Authors:
58c2ecf20Sopenharmony_ci *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
68c2ecf20Sopenharmony_ci *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
98c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
108c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
138c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
148c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
158c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
168c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
178c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
188c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
198c2ecf20Sopenharmony_ci */
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef __LINUX_NFC_H
228c2ecf20Sopenharmony_ci#define __LINUX_NFC_H
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <linux/types.h>
258c2ecf20Sopenharmony_ci#include <linux/socket.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define NFC_GENL_NAME "nfc"
288c2ecf20Sopenharmony_ci#define NFC_GENL_VERSION 1
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define NFC_GENL_MCAST_EVENT_NAME "events"
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/**
338c2ecf20Sopenharmony_ci * enum nfc_commands - supported nfc commands
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * @NFC_CMD_UNSPEC: unspecified command
368c2ecf20Sopenharmony_ci *
378c2ecf20Sopenharmony_ci * @NFC_CMD_GET_DEVICE: request information about a device (requires
388c2ecf20Sopenharmony_ci *	%NFC_ATTR_DEVICE_INDEX) or dump request to get a list of all nfc devices
398c2ecf20Sopenharmony_ci * @NFC_CMD_DEV_UP: turn on the nfc device
408c2ecf20Sopenharmony_ci *	(requires %NFC_ATTR_DEVICE_INDEX)
418c2ecf20Sopenharmony_ci * @NFC_CMD_DEV_DOWN: turn off the nfc device
428c2ecf20Sopenharmony_ci *	(requires %NFC_ATTR_DEVICE_INDEX)
438c2ecf20Sopenharmony_ci * @NFC_CMD_START_POLL: start polling for targets using the given protocols
448c2ecf20Sopenharmony_ci *	(requires %NFC_ATTR_DEVICE_INDEX and %NFC_ATTR_PROTOCOLS)
458c2ecf20Sopenharmony_ci * @NFC_CMD_STOP_POLL: stop polling for targets (requires
468c2ecf20Sopenharmony_ci *	%NFC_ATTR_DEVICE_INDEX)
478c2ecf20Sopenharmony_ci * @NFC_CMD_GET_TARGET: dump all targets found by the previous poll (requires
488c2ecf20Sopenharmony_ci *	%NFC_ATTR_DEVICE_INDEX)
498c2ecf20Sopenharmony_ci * @NFC_EVENT_TARGETS_FOUND: event emitted when a new target is found
508c2ecf20Sopenharmony_ci *	(it sends %NFC_ATTR_DEVICE_INDEX)
518c2ecf20Sopenharmony_ci * @NFC_EVENT_DEVICE_ADDED: event emitted when a new device is registred
528c2ecf20Sopenharmony_ci *	(it sends %NFC_ATTR_DEVICE_NAME, %NFC_ATTR_DEVICE_INDEX and
538c2ecf20Sopenharmony_ci *	%NFC_ATTR_PROTOCOLS)
548c2ecf20Sopenharmony_ci * @NFC_EVENT_DEVICE_REMOVED: event emitted when a device is removed
558c2ecf20Sopenharmony_ci *	(it sends %NFC_ATTR_DEVICE_INDEX)
568c2ecf20Sopenharmony_ci * @NFC_EVENT_TM_ACTIVATED: event emitted when the adapter is activated in
578c2ecf20Sopenharmony_ci *      target mode.
588c2ecf20Sopenharmony_ci * @NFC_EVENT_DEVICE_DEACTIVATED: event emitted when the adapter is deactivated
598c2ecf20Sopenharmony_ci *      from target mode.
608c2ecf20Sopenharmony_ci * @NFC_CMD_LLC_GET_PARAMS: request LTO, RW, and MIUX parameters for a device
618c2ecf20Sopenharmony_ci * @NFC_CMD_LLC_SET_PARAMS: set one or more of LTO, RW, and MIUX parameters for
628c2ecf20Sopenharmony_ci *	a device. LTO must be set before the link is up otherwise -EINPROGRESS
638c2ecf20Sopenharmony_ci *	is returned. RW and MIUX can be set at anytime and will be passed in
648c2ecf20Sopenharmony_ci *	subsequent CONNECT and CC messages.
658c2ecf20Sopenharmony_ci *	If one of the passed parameters is wrong none is set and -EINVAL is
668c2ecf20Sopenharmony_ci *	returned.
678c2ecf20Sopenharmony_ci * @NFC_CMD_ENABLE_SE: Enable the physical link to a specific secure element.
688c2ecf20Sopenharmony_ci *	Once enabled a secure element will handle card emulation mode, i.e.
698c2ecf20Sopenharmony_ci *	starting a poll from a device which has a secure element enabled means
708c2ecf20Sopenharmony_ci *	we want to do SE based card emulation.
718c2ecf20Sopenharmony_ci * @NFC_CMD_DISABLE_SE: Disable the physical link to a specific secure element.
728c2ecf20Sopenharmony_ci * @NFC_CMD_FW_DOWNLOAD: Request to Load/flash firmware, or event to inform
738c2ecf20Sopenharmony_ci *	that some firmware was loaded
748c2ecf20Sopenharmony_ci * @NFC_EVENT_SE_ADDED: Event emitted when a new secure element is discovered.
758c2ecf20Sopenharmony_ci *	This typically will be sent whenever a new NFC controller with either
768c2ecf20Sopenharmony_ci *	an embedded SE or an UICC one connected to it through SWP.
778c2ecf20Sopenharmony_ci * @NFC_EVENT_SE_REMOVED: Event emitted when a secure element is removed from
788c2ecf20Sopenharmony_ci *	the system, as a consequence of e.g. an NFC controller being unplugged.
798c2ecf20Sopenharmony_ci * @NFC_EVENT_SE_CONNECTIVITY: This event is emitted whenever a secure element
808c2ecf20Sopenharmony_ci *	is requesting connectivity access. For example a UICC SE may need to
818c2ecf20Sopenharmony_ci *	talk with a sleeping modem and will notify this need by sending this
828c2ecf20Sopenharmony_ci *	event. It is then up to userspace to decide if it will wake the modem
838c2ecf20Sopenharmony_ci *	up or not.
848c2ecf20Sopenharmony_ci * @NFC_EVENT_SE_TRANSACTION: This event is sent when an application running on
858c2ecf20Sopenharmony_ci *	a specific SE notifies us about the end of a transaction. The parameter
868c2ecf20Sopenharmony_ci *	for this event is the application ID (AID).
878c2ecf20Sopenharmony_ci * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller.
888c2ecf20Sopenharmony_ci * @NFC_CMD_SE_IO: Send/Receive APDUs to/from the selected secure element.
898c2ecf20Sopenharmony_ci * @NFC_CMD_ACTIVATE_TARGET: Request NFC controller to reactivate target.
908c2ecf20Sopenharmony_ci * @NFC_CMD_VENDOR: Vendor specific command, to be implemented directly
918c2ecf20Sopenharmony_ci *	from the driver in order to support hardware specific operations.
928c2ecf20Sopenharmony_ci * @NFC_CMD_DEACTIVATE_TARGET: Request NFC controller to deactivate target.
938c2ecf20Sopenharmony_ci */
948c2ecf20Sopenharmony_cienum nfc_commands {
958c2ecf20Sopenharmony_ci	NFC_CMD_UNSPEC,
968c2ecf20Sopenharmony_ci	NFC_CMD_GET_DEVICE,
978c2ecf20Sopenharmony_ci	NFC_CMD_DEV_UP,
988c2ecf20Sopenharmony_ci	NFC_CMD_DEV_DOWN,
998c2ecf20Sopenharmony_ci	NFC_CMD_DEP_LINK_UP,
1008c2ecf20Sopenharmony_ci	NFC_CMD_DEP_LINK_DOWN,
1018c2ecf20Sopenharmony_ci	NFC_CMD_START_POLL,
1028c2ecf20Sopenharmony_ci	NFC_CMD_STOP_POLL,
1038c2ecf20Sopenharmony_ci	NFC_CMD_GET_TARGET,
1048c2ecf20Sopenharmony_ci	NFC_EVENT_TARGETS_FOUND,
1058c2ecf20Sopenharmony_ci	NFC_EVENT_DEVICE_ADDED,
1068c2ecf20Sopenharmony_ci	NFC_EVENT_DEVICE_REMOVED,
1078c2ecf20Sopenharmony_ci	NFC_EVENT_TARGET_LOST,
1088c2ecf20Sopenharmony_ci	NFC_EVENT_TM_ACTIVATED,
1098c2ecf20Sopenharmony_ci	NFC_EVENT_TM_DEACTIVATED,
1108c2ecf20Sopenharmony_ci	NFC_CMD_LLC_GET_PARAMS,
1118c2ecf20Sopenharmony_ci	NFC_CMD_LLC_SET_PARAMS,
1128c2ecf20Sopenharmony_ci	NFC_CMD_ENABLE_SE,
1138c2ecf20Sopenharmony_ci	NFC_CMD_DISABLE_SE,
1148c2ecf20Sopenharmony_ci	NFC_CMD_LLC_SDREQ,
1158c2ecf20Sopenharmony_ci	NFC_EVENT_LLC_SDRES,
1168c2ecf20Sopenharmony_ci	NFC_CMD_FW_DOWNLOAD,
1178c2ecf20Sopenharmony_ci	NFC_EVENT_SE_ADDED,
1188c2ecf20Sopenharmony_ci	NFC_EVENT_SE_REMOVED,
1198c2ecf20Sopenharmony_ci	NFC_EVENT_SE_CONNECTIVITY,
1208c2ecf20Sopenharmony_ci	NFC_EVENT_SE_TRANSACTION,
1218c2ecf20Sopenharmony_ci	NFC_CMD_GET_SE,
1228c2ecf20Sopenharmony_ci	NFC_CMD_SE_IO,
1238c2ecf20Sopenharmony_ci	NFC_CMD_ACTIVATE_TARGET,
1248c2ecf20Sopenharmony_ci	NFC_CMD_VENDOR,
1258c2ecf20Sopenharmony_ci	NFC_CMD_DEACTIVATE_TARGET,
1268c2ecf20Sopenharmony_ci/* private: internal use only */
1278c2ecf20Sopenharmony_ci	__NFC_CMD_AFTER_LAST
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci#define NFC_CMD_MAX (__NFC_CMD_AFTER_LAST - 1)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/**
1328c2ecf20Sopenharmony_ci * enum nfc_attrs - supported nfc attributes
1338c2ecf20Sopenharmony_ci *
1348c2ecf20Sopenharmony_ci * @NFC_ATTR_UNSPEC: unspecified attribute
1358c2ecf20Sopenharmony_ci *
1368c2ecf20Sopenharmony_ci * @NFC_ATTR_DEVICE_INDEX: index of nfc device
1378c2ecf20Sopenharmony_ci * @NFC_ATTR_DEVICE_NAME: device name, max 8 chars
1388c2ecf20Sopenharmony_ci * @NFC_ATTR_PROTOCOLS: nfc protocols - bitwise or-ed combination from
1398c2ecf20Sopenharmony_ci *	NFC_PROTO_*_MASK constants
1408c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_INDEX: index of the nfc target
1418c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID
1428c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the
1438c2ecf20Sopenharmony_ci *	target is not NFC-Forum compliant)
1448c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes
1458c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_SENSB_RES: NFC-B targets extra information, max 12 bytes
1468c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_SENSF_RES: NFC-F targets extra information, max 18 bytes
1478c2ecf20Sopenharmony_ci * @NFC_ATTR_COMM_MODE: Passive or active mode
1488c2ecf20Sopenharmony_ci * @NFC_ATTR_RF_MODE: Initiator or target
1498c2ecf20Sopenharmony_ci * @NFC_ATTR_IM_PROTOCOLS: Initiator mode protocols to poll for
1508c2ecf20Sopenharmony_ci * @NFC_ATTR_TM_PROTOCOLS: Target mode protocols to listen for
1518c2ecf20Sopenharmony_ci * @NFC_ATTR_LLC_PARAM_LTO: Link TimeOut parameter
1528c2ecf20Sopenharmony_ci * @NFC_ATTR_LLC_PARAM_RW: Receive Window size parameter
1538c2ecf20Sopenharmony_ci * @NFC_ATTR_LLC_PARAM_MIUX: MIU eXtension parameter
1548c2ecf20Sopenharmony_ci * @NFC_ATTR_SE: Available Secure Elements
1558c2ecf20Sopenharmony_ci * @NFC_ATTR_FIRMWARE_NAME: Free format firmware version
1568c2ecf20Sopenharmony_ci * @NFC_ATTR_SE_INDEX: Secure element index
1578c2ecf20Sopenharmony_ci * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED)
1588c2ecf20Sopenharmony_ci * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status
1598c2ecf20Sopenharmony_ci * @NFC_ATTR_APDU: Secure element APDU
1608c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_ISO15693_DSFID: ISO 15693 Data Storage Format Identifier
1618c2ecf20Sopenharmony_ci * @NFC_ATTR_TARGET_ISO15693_UID: ISO 15693 Unique Identifier
1628c2ecf20Sopenharmony_ci * @NFC_ATTR_SE_PARAMS: Parameters data from an evt_transaction
1638c2ecf20Sopenharmony_ci * @NFC_ATTR_VENDOR_ID: NFC manufacturer unique ID, typically an OUI
1648c2ecf20Sopenharmony_ci * @NFC_ATTR_VENDOR_SUBCMD: Vendor specific sub command
1658c2ecf20Sopenharmony_ci * @NFC_ATTR_VENDOR_DATA: Vendor specific data, to be optionally passed
1668c2ecf20Sopenharmony_ci *	to a vendor specific command implementation
1678c2ecf20Sopenharmony_ci */
1688c2ecf20Sopenharmony_cienum nfc_attrs {
1698c2ecf20Sopenharmony_ci	NFC_ATTR_UNSPEC,
1708c2ecf20Sopenharmony_ci	NFC_ATTR_DEVICE_INDEX,
1718c2ecf20Sopenharmony_ci	NFC_ATTR_DEVICE_NAME,
1728c2ecf20Sopenharmony_ci	NFC_ATTR_PROTOCOLS,
1738c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_INDEX,
1748c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_SENS_RES,
1758c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_SEL_RES,
1768c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_NFCID1,
1778c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_SENSB_RES,
1788c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_SENSF_RES,
1798c2ecf20Sopenharmony_ci	NFC_ATTR_COMM_MODE,
1808c2ecf20Sopenharmony_ci	NFC_ATTR_RF_MODE,
1818c2ecf20Sopenharmony_ci	NFC_ATTR_DEVICE_POWERED,
1828c2ecf20Sopenharmony_ci	NFC_ATTR_IM_PROTOCOLS,
1838c2ecf20Sopenharmony_ci	NFC_ATTR_TM_PROTOCOLS,
1848c2ecf20Sopenharmony_ci	NFC_ATTR_LLC_PARAM_LTO,
1858c2ecf20Sopenharmony_ci	NFC_ATTR_LLC_PARAM_RW,
1868c2ecf20Sopenharmony_ci	NFC_ATTR_LLC_PARAM_MIUX,
1878c2ecf20Sopenharmony_ci	NFC_ATTR_SE,
1888c2ecf20Sopenharmony_ci	NFC_ATTR_LLC_SDP,
1898c2ecf20Sopenharmony_ci	NFC_ATTR_FIRMWARE_NAME,
1908c2ecf20Sopenharmony_ci	NFC_ATTR_SE_INDEX,
1918c2ecf20Sopenharmony_ci	NFC_ATTR_SE_TYPE,
1928c2ecf20Sopenharmony_ci	NFC_ATTR_SE_AID,
1938c2ecf20Sopenharmony_ci	NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS,
1948c2ecf20Sopenharmony_ci	NFC_ATTR_SE_APDU,
1958c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_ISO15693_DSFID,
1968c2ecf20Sopenharmony_ci	NFC_ATTR_TARGET_ISO15693_UID,
1978c2ecf20Sopenharmony_ci	NFC_ATTR_SE_PARAMS,
1988c2ecf20Sopenharmony_ci	NFC_ATTR_VENDOR_ID,
1998c2ecf20Sopenharmony_ci	NFC_ATTR_VENDOR_SUBCMD,
2008c2ecf20Sopenharmony_ci	NFC_ATTR_VENDOR_DATA,
2018c2ecf20Sopenharmony_ci/* private: internal use only */
2028c2ecf20Sopenharmony_ci	__NFC_ATTR_AFTER_LAST
2038c2ecf20Sopenharmony_ci};
2048c2ecf20Sopenharmony_ci#define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1)
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cienum nfc_sdp_attr {
2078c2ecf20Sopenharmony_ci	NFC_SDP_ATTR_UNSPEC,
2088c2ecf20Sopenharmony_ci	NFC_SDP_ATTR_URI,
2098c2ecf20Sopenharmony_ci	NFC_SDP_ATTR_SAP,
2108c2ecf20Sopenharmony_ci/* private: internal use only */
2118c2ecf20Sopenharmony_ci	__NFC_SDP_ATTR_AFTER_LAST
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci#define NFC_SDP_ATTR_MAX (__NFC_SDP_ATTR_AFTER_LAST - 1)
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define NFC_DEVICE_NAME_MAXSIZE		8
2168c2ecf20Sopenharmony_ci#define NFC_NFCID1_MAXSIZE		10
2178c2ecf20Sopenharmony_ci#define NFC_NFCID2_MAXSIZE		8
2188c2ecf20Sopenharmony_ci#define NFC_NFCID3_MAXSIZE		10
2198c2ecf20Sopenharmony_ci#define NFC_SENSB_RES_MAXSIZE		12
2208c2ecf20Sopenharmony_ci#define NFC_SENSF_RES_MAXSIZE		18
2218c2ecf20Sopenharmony_ci#define NFC_ATR_REQ_MAXSIZE		64
2228c2ecf20Sopenharmony_ci#define NFC_ATR_RES_MAXSIZE		64
2238c2ecf20Sopenharmony_ci#define NFC_ATR_REQ_GB_MAXSIZE		48
2248c2ecf20Sopenharmony_ci#define NFC_ATR_RES_GB_MAXSIZE		47
2258c2ecf20Sopenharmony_ci#define NFC_GB_MAXSIZE			48
2268c2ecf20Sopenharmony_ci#define NFC_FIRMWARE_NAME_MAXSIZE	32
2278c2ecf20Sopenharmony_ci#define NFC_ISO15693_UID_MAXSIZE	8
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/* NFC protocols */
2308c2ecf20Sopenharmony_ci#define NFC_PROTO_JEWEL		1
2318c2ecf20Sopenharmony_ci#define NFC_PROTO_MIFARE	2
2328c2ecf20Sopenharmony_ci#define NFC_PROTO_FELICA	3
2338c2ecf20Sopenharmony_ci#define NFC_PROTO_ISO14443	4
2348c2ecf20Sopenharmony_ci#define NFC_PROTO_NFC_DEP	5
2358c2ecf20Sopenharmony_ci#define NFC_PROTO_ISO14443_B	6
2368c2ecf20Sopenharmony_ci#define NFC_PROTO_ISO15693	7
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci#define NFC_PROTO_MAX		8
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci/* NFC communication modes */
2418c2ecf20Sopenharmony_ci#define NFC_COMM_ACTIVE  0
2428c2ecf20Sopenharmony_ci#define NFC_COMM_PASSIVE 1
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci/* NFC RF modes */
2458c2ecf20Sopenharmony_ci#define NFC_RF_INITIATOR 0
2468c2ecf20Sopenharmony_ci#define NFC_RF_TARGET    1
2478c2ecf20Sopenharmony_ci#define NFC_RF_NONE      2
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci/* NFC protocols masks used in bitsets */
2508c2ecf20Sopenharmony_ci#define NFC_PROTO_JEWEL_MASK      (1 << NFC_PROTO_JEWEL)
2518c2ecf20Sopenharmony_ci#define NFC_PROTO_MIFARE_MASK     (1 << NFC_PROTO_MIFARE)
2528c2ecf20Sopenharmony_ci#define NFC_PROTO_FELICA_MASK	  (1 << NFC_PROTO_FELICA)
2538c2ecf20Sopenharmony_ci#define NFC_PROTO_ISO14443_MASK	  (1 << NFC_PROTO_ISO14443)
2548c2ecf20Sopenharmony_ci#define NFC_PROTO_NFC_DEP_MASK	  (1 << NFC_PROTO_NFC_DEP)
2558c2ecf20Sopenharmony_ci#define NFC_PROTO_ISO14443_B_MASK (1 << NFC_PROTO_ISO14443_B)
2568c2ecf20Sopenharmony_ci#define NFC_PROTO_ISO15693_MASK	  (1 << NFC_PROTO_ISO15693)
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci/* NFC Secure Elements */
2598c2ecf20Sopenharmony_ci#define NFC_SE_UICC     0x1
2608c2ecf20Sopenharmony_ci#define NFC_SE_EMBEDDED 0x2
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci#define NFC_SE_DISABLED 0x0
2638c2ecf20Sopenharmony_ci#define NFC_SE_ENABLED  0x1
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistruct sockaddr_nfc {
2668c2ecf20Sopenharmony_ci	__kernel_sa_family_t sa_family;
2678c2ecf20Sopenharmony_ci	__u32 dev_idx;
2688c2ecf20Sopenharmony_ci	__u32 target_idx;
2698c2ecf20Sopenharmony_ci	__u32 nfc_protocol;
2708c2ecf20Sopenharmony_ci};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci#define NFC_LLCP_MAX_SERVICE_NAME 63
2738c2ecf20Sopenharmony_cistruct sockaddr_nfc_llcp {
2748c2ecf20Sopenharmony_ci	__kernel_sa_family_t sa_family;
2758c2ecf20Sopenharmony_ci	__u32 dev_idx;
2768c2ecf20Sopenharmony_ci	__u32 target_idx;
2778c2ecf20Sopenharmony_ci	__u32 nfc_protocol;
2788c2ecf20Sopenharmony_ci	__u8 dsap; /* Destination SAP, if known */
2798c2ecf20Sopenharmony_ci	__u8 ssap; /* Source SAP to be bound to */
2808c2ecf20Sopenharmony_ci	char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */;
2818c2ecf20Sopenharmony_ci	__kernel_size_t service_name_len;
2828c2ecf20Sopenharmony_ci};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci/* NFC socket protocols */
2858c2ecf20Sopenharmony_ci#define NFC_SOCKPROTO_RAW	0
2868c2ecf20Sopenharmony_ci#define NFC_SOCKPROTO_LLCP	1
2878c2ecf20Sopenharmony_ci#define NFC_SOCKPROTO_MAX	2
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci#define NFC_HEADER_SIZE 1
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci/**
2928c2ecf20Sopenharmony_ci * Pseudo-header info for raw socket packets
2938c2ecf20Sopenharmony_ci * First byte is the adapter index
2948c2ecf20Sopenharmony_ci * Second byte contains flags
2958c2ecf20Sopenharmony_ci *  - 0x01 - Direction (0=RX, 1=TX)
2968c2ecf20Sopenharmony_ci *  - 0x02-0x04 - Payload type (000=LLCP, 001=NCI, 010=HCI, 011=Digital,
2978c2ecf20Sopenharmony_ci *                              100=Proprietary)
2988c2ecf20Sopenharmony_ci *  - 0x05-0x80 - Reserved
2998c2ecf20Sopenharmony_ci **/
3008c2ecf20Sopenharmony_ci#define NFC_RAW_HEADER_SIZE	2
3018c2ecf20Sopenharmony_ci#define NFC_DIRECTION_RX		0x00
3028c2ecf20Sopenharmony_ci#define NFC_DIRECTION_TX		0x01
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci#define RAW_PAYLOAD_LLCP 0
3058c2ecf20Sopenharmony_ci#define RAW_PAYLOAD_NCI	1
3068c2ecf20Sopenharmony_ci#define RAW_PAYLOAD_HCI	2
3078c2ecf20Sopenharmony_ci#define RAW_PAYLOAD_DIGITAL	3
3088c2ecf20Sopenharmony_ci#define RAW_PAYLOAD_PROPRIETARY	4
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci/* socket option names */
3118c2ecf20Sopenharmony_ci#define NFC_LLCP_RW		0
3128c2ecf20Sopenharmony_ci#define NFC_LLCP_MIUX		1
3138c2ecf20Sopenharmony_ci#define NFC_LLCP_REMOTE_MIU	2
3148c2ecf20Sopenharmony_ci#define NFC_LLCP_REMOTE_LTO	3
3158c2ecf20Sopenharmony_ci#define NFC_LLCP_REMOTE_RW	4
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci#endif /*__LINUX_NFC_H */
318