1/******************************************************************************
2 *
3 *  Copyright (C) 2009-2014 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 *  This file contains the Near Field Communication (NFC) Tags related
22 *  definitions from the specification.
23 *
24 ******************************************************************************/
25
26#ifndef TAGS_DEFS_H
27#define TAGS_DEFS_H
28
29/* Manufacturer ID */
30/* BROADCOM CORPORATION                           */
31#define TAG_BRCM_MID 0x2E
32/* MIFARE                                         */
33#define TAG_MIFARE_MID 0x04
34/* KOVIO                                          */
35#define TAG_KOVIO_MID 0x37
36/* Infineon Technologies                          */
37#define TAG_INFINEON_MID 0x05
38
39/* TLV types present in Type1 and Type 2 Tags */
40/* May be used for padding. SHALL ignore this     */
41#define TAG_NULL_TLV 0
42/* Defines details of the lock bytes              */
43#define TAG_LOCK_CTRL_TLV 1
44/* Identifies reserved memory areas               */
45#define TAG_MEM_CTRL_TLV 2
46/* Contains the NDEF message                      */
47#define TAG_NDEF_TLV 3
48/* Tag proprietary information                    */
49#define TAG_PROPRIETARY_TLV 0xFD
50/* Last TLV block in the data area                */
51#define TAG_TERMINATOR_TLV 0xFE
52/* Number of bits in every tag byte               */
53#define TAG_BITS_PER_BYTE 0x08
54/* Max UID Len of type 1 and type 2 tag           */
55#define TAG_MAX_UID_LEN 0x0A
56
57/* Byte 0 Length field to indicate LNDEF  */
58#define TAG_LONG_NDEF_LEN_FIELD_BYTE0 0xFF
59/* Tlv len for LOCK_CTRL/MEM TLV per spec */
60#define TAG_DEFAULT_TLV_LEN 3
61
62/* Type 1 Tag related definitions */
63
64/* block 0 to Block E                             */
65#define T1T_STATIC_BLOCKS 0x0F
66/* T1T Block size in bytes                        */
67#define T1T_BLOCK_SIZE 0x08
68
69#define T1T_STATIC_SIZE \
70  T1T_STATIC_BLOCKS* T1T_BLOCK_SIZE /* Static Tag size   */
71
72/* Size of Type 1 Tag segment in bytes            */
73#define T1T_SEGMENT_SIZE 0x80
74/* Maximum segment supported by Type 1 Tag        */
75#define T1T_MAX_SEGMENTS 0x10
76/* Number of blocks present in a segment          */
77#define T1T_BLOCKS_PER_SEGMENT 0x10
78/* No.of default OTP,staticlocks,res bytes in tag */
79#define T1T_OTP_LOCK_RES_BYTES 0x10
80
81/* HRO value to indicate static Tag               */
82#define T1T_STATIC_HR0 0x11
83/* 0x1y, as long as (y!=1)                        */
84/* HR0 value is 0x1y, indicates NDEF supported    */
85#define T1T_NDEF_SUPPORTED 0x10
86/* UID block                                      */
87#define T1T_UID_BLOCK 0x00
88/* Reserved block                                 */
89#define T1T_RES_BLOCK 0x0D
90/* Static lock block                              */
91#define T1T_LOCK_BLOCK 0x0E
92/* Static lock offset                             */
93#define T1T_LOCK_0_OFFSET 0x70
94/* Block F - typically used for dynamic locks     */
95#define T1T_DYNAMIC_LOCK_BYTES 0x08
96
97/* the len of reserved byte in T1T block 0        */
98#define T1T_RES_BYTE_LEN 1
99
100/* Capability Container definitions */
101/* Capability container block                     */
102#define T1T_CC_BLOCK 1
103/* the len of CC used in T1T tag                  */
104#define T1T_CC_LEN 4
105/* CC offset */
106/* Offset for NDEF magic number in CC             */
107#define T1T_CC_NMN_OFFSET 0x00
108/* Offset for Read/Write access in CC             */
109#define T1T_CC_RWA_OFFSET 0x03
110/* NDEF Magic Number byte number                  */
111#define T1T_CC_NMN_BYTE 0x08
112/* Version Number byte number                     */
113#define T1T_CC_VNO_BYTE 0x09
114/* Tag Memory Size byte number                    */
115#define T1T_CC_TMS_BYTE 0x0A
116/* Read Write Access byte number                  */
117#define T1T_CC_RWA_BYTE 0x0B
118/* NDEF Magic Number                              */
119#define T1T_CC_NMN 0xE1
120/* Supported Legacy Version                       */
121#define T1T_CC_LEGACY_VNO 0x10
122/* Version Number                                 */
123#define T1T_CC_VNO 0x11
124/* RWA - Read/write allowed                       */
125#define T1T_CC_RWA_RW 0x00
126/* RWA - Read only                                */
127#define T1T_CC_RWA_RO 0x0F
128
129/* Tlv len for LOCK_CTRL/MEM TLV per spec         */
130#define T1T_DEFAULT_TLV_LEN 3
131/* Tlv type identifier len                        */
132#define T1T_TLV_TYPE_LEN 1
133/* Length field size of  lock/mem tlv     */
134#define T1T_DEFAULT_TLV_LEN_FIELD_LEN 1
135
136/* the len of HR used in Type 1 Tag               */
137#define T1T_HR_LEN 2
138/* the len of UID used in Type 1 Tag Commands     */
139#define T1T_CMD_UID_LEN 4
140/* the len of UID used in Type 1 Tag              */
141#define T1T_UID_LEN 7
142#define T1T_ADD_LEN 1
143
144/* Length Field size of short NDEF Message    */
145#define T1T_SHORT_NDEF_LEN_FIELD_LEN 1
146/* Length Field size of Long NDEF Message     */
147#define T1T_LONG_NDEF_LEN_FIELD_LEN 3
148/* Byte 0 in Length field to indicate LNDEF*/
149#define T1T_LONG_NDEF_LEN_FIELD_BYTE0 0xFF
150/* Min. len of NDEF to qualify as LNDEF  */
151
152/* Type 1 Tag Commands (7 bits) */
153/* read id                                      */
154#define T1T_CMD_RID 0x78
155/* read all bytes                               */
156#define T1T_CMD_RALL 0x00
157/* read (1 byte)                                */
158#define T1T_CMD_READ 0x01
159/* write with erase (1 byte)                    */
160#define T1T_CMD_WRITE_E 0x53
161/* write no erase (1 byte)                      */
162#define T1T_CMD_WRITE_NE 0x1A
163/* dynamic memory only */
164/* read segment                                 */
165#define T1T_CMD_RSEG 0x10
166/* read (8 byte)                                */
167#define T1T_CMD_READ8 0x02
168/* write with erase (8 byte)                    */
169#define T1T_CMD_WRITE_E8 0x54
170/* write no erase (8 byte)                      */
171#define T1T_CMD_WRITE_NE8 0x1B
172
173/* Lock */
174/* Number of static lock bytes in tag   */
175#define T1T_NUM_STATIC_LOCK_BYTES 2
176/* Bytes locked by one static lock bit  */
177
178/* Type 2 Tag related definitions */
179#define T2T_STATIC_SIZE 64
180#define T2T_BLOCK_SIZE 4
181#define T2T_HEADER_SIZE 16
182#define T2T_SECTOR_SIZE 1024
183#define T2T_BLOCKS_PER_SECTOR 0x100
184
185#define T2T_UID_LEN 4        /* the len of UID used in T2T tag */
186/* the len of Serial number used in T2T tag */
187#define T2T_INTERNAL_BYTES_LEN 2 /* the len of internal used in T2T tag */
188/* Static Lock Bytes */
189#define T2T_STATIC_LOCK0 0x0A /* Static Lock 0 offset */
190#define T2T_STATIC_LOCK1 0x0B /* Static Lock 1 offset */
191
192/* Capability Container definitions */
193#define T2T_CC_BLOCK 0x03     /* Capability container block */
194#define T2T_CC0_NMN_BYTE 0x0C /* NDEF Magic Number byte number */
195#define T2T_CC1_VNO_BYTE 0x0D /* Version Number byte number*/
196#define T2T_CC2_TMS_BYTE 0x0E /* Tag Memory Size byte number */
197#define T2T_CC3_RWA_BYTE 0x0F /* Read Write Access byte number */
198
199#define T2T_CC0_NMN 0xE1        /* NDEF Magic Number */
200#define T2T_CC1_VNO 0x11        /* Version Number */
201#define T2T_CC1_LEGACY_VNO 0x10 /* Legacy Version Number */
202#define T2T_CC1_NEW_VNO 0x12    /* Another supported Version Number */
203#define T2T_CC2_TMS_STATIC 0x06 /* TMS static memory - (4 * (n+1)). */
204#define T2T_CC3_RWA_RW 0x00     /* RWA - Read/write allowed */
205#define T2T_CC3_RWA_RO 0x0F     /* RWA - Read only */
206
207/* Factor to multiply to get tag data size from TMS */
208#define T2T_TMS_TAG_FACTOR 0x08
209/* Bytes locked per lock bit of default locks */
210#define T2T_DEFAULT_LOCK_BLPB 0x08
211
212/* Type 2 Tag Commands  */
213#define T2T_CMD_READ 0x30    /* read  4 blocks (16 bytes) */
214#define T2T_CMD_WRITE 0xA2   /* write 1 block  (4 bytes)  */
215#define T2T_CMD_SEC_SEL 0xC2 /* Sector select             */
216#define T2T_RSP_ACK 0xA
217
218#define T2T_STATUS_OK_1_BIT 0x11
219#define T2T_STATUS_OK_7_BIT 0x17
220
221#define T2T_FIRST_DATA_BLOCK 4
222#define T2T_READ_BLOCKS 4
223#define T2T_BLOCK_LEN 4
224#define T2T_READ_DATA_LEN (T2T_BLOCK_LEN * T2T_READ_BLOCKS)
225#define T2T_WRITE_DATA_LEN 4
226
227/* Type 2 TLV definitions */
228/* May be used for padding. SHALL ignore this */
229#define T2T_TLV_TYPE_LOCK_CTRL 1      /* Defines details of the lock bytes */
230
231/* Tag len for LOCK_CTRL TLV per spec */
232#define T2T_TLEN_LOCK_CTRL_TLV 3
233
234/* Maximum number of sectors supported */
235#if (APPL_DTA_MODE == TRUE)
236#define T2T_MAX_SECTOR 3
237#else
238#define T2T_MAX_SECTOR 2
239#endif
240/* Tlv type identifier len                */
241#define T2T_TLV_TYPE_LEN 1
242
243/* Length Field size of short NDEF Message    */
244#define T2T_SHORT_NDEF_LEN_FIELD_LEN 1
245/* Length Field size of Long NDEF Message     */
246#define T2T_LONG_NDEF_LEN_FIELD_LEN 3
247/* Byte 0 in Length field to indicate LNDEF*/
248#define T2T_LONG_NDEF_LEN_FIELD_BYTE0 0xFF
249/* Min. len of NDEF to qualify as LNDEF  */
250#define T2T_LONG_NDEF_MIN_LEN 0x00FF
251
252/* Lock */
253/* Number of static lock bytes in tag   */
254#define T2T_NUM_STATIC_LOCK_BYTES 2
255
256/*
257**
258**  Type 3 Tag Definitions
259**
260*/
261
262#define T3T_SYSTEM_CODE_NDEF 0x12FC /* System Code for NDEF tags */
263/* System Code for felica-lite tags */
264#define T3T_SYSTEM_CODE_FELICA_LITE 0x88B4
265#define T3T_MAX_SYSTEM_CODES 16
266/* Maximum number of blocks for NDEF message for Felica Lite tags */
267#define T3T_FELICALITE_NMAXB 13
268
269/* Block descriptor, used to describe a block to check/update */
270typedef struct {
271  uint16_t service_code; /* Block service code. Set to T3T_SERVICE_CODE_NDEF
272                            (0x000B) for NDEF data */
273  uint16_t block_number; /* Block number */
274} tT3T_BLOCK_DESC;
275
276/* Poll RC (request code) definitions */
277#define T3T_POLL_RC_SC 1   /* System code requested in SENSF_RES */
278typedef uint8_t tT3T_POLL_RC;
279
280/* Definitions for constructing t3t command messages */
281
282/* NFC Forum / Felica commands */
283#define T3T_MSG_OPC_CHECK_CMD 0x06
284#define T3T_MSG_OPC_CHECK_RSP 0x07
285#define T3T_MSG_OPC_UPDATE_CMD 0x08
286#define T3T_MSG_OPC_UPDATE_RSP 0x09
287
288/* Felica commands (not specified in NFC-Forum Type 3 tag specifications) */
289#define T3T_MSG_OPC_POLL_CMD 0x00
290#define T3T_MSG_OPC_POLL_RSP 0x01
291#define T3T_MSG_OPC_REQ_SERVICE_CMD 0x02
292#define T3T_MSG_OPC_REQ_RESPONSE_CMD 0x04
293#define T3T_MSG_OPC_REQ_RESPONSE_RSP 0x05
294#define T3T_MSG_OPC_REQ_SYSTEMCODE_CMD 0x0C
295#define T3T_MSG_OPC_REQ_SYSTEMCODE_RSP 0x0D
296
297/* Service code: read-only NDEF */
298#define T3T_MSG_NDEF_SC_RO 0x000B
299/* Service code: read/write NDEF */
300#define T3T_MSG_NDEF_SC_RW 0x0009
301#define T3T_MSG_NDEF_VERSION 0x10 /* NDEF Mapping Version 1.0 */
302#define T3T_MSG_NDEF_WRITEF_OFF 0x00
303#define T3T_MSG_NDEF_WRITEF_ON 0x0F
304#define T3T_MSG_NDEF_RWFLAG_RO 0x00
305#define T3T_MSG_NDEF_RWFLAG_RW 0x01
306/* Size of NDEF attribute info block (minus checksum) */
307#define T3T_MSG_NDEF_ATTR_INFO_SIZE 14
308
309/* len flag for Block List Element */
310#define T3T_MSG_MASK_TWO_BYTE_BLOCK_DESC_FORMAT 0x80
311/* service code list mask */
312#define T3T_MSG_SERVICE_LIST_MASK 0x0F
313#define T3T_MSG_SERVICE_LIST_MAX 16
314
315/* Max Number of Blocks per UPDATE command */
316#define T3T_MSG_NUM_BLOCKS_UPDATE_MAX 13
317/* Max Number of Blocks per CHECK command */
318#define T3T_MSG_NUM_BLOCKS_CHECK_MAX 15
319
320/* Data block size for UPDATE and CHECK commands */
321#define T3T_MSG_BLOCKSIZE 16
322
323/* Common header definitions for T3t commands */
324/* Common header: SoD + cmdcode + NFCID2 + num_services */
325#define T3T_MSG_CMD_COMMON_HDR_LEN 11
326
327/* Common header definition for T3t responses */
328/* Common header: rspcode + NFCID2 + StatusFlag1 + StatusFlag2  */
329#define T3T_MSG_RSP_COMMON_HDR_LEN 11
330/* Offset for Response code */
331#define T3T_MSG_RSP_OFFSET_RSPCODE 0
332/* Offset for Manufacturer ID */
333#define T3T_MSG_RSP_OFFSET_IDM 1
334/* Offset for Status Flag1 */
335#define T3T_MSG_RSP_OFFSET_STATUS1 9
336/* Offset for NumberOfBlocks (in CHECK response) */
337#define T3T_MSG_RSP_OFFSET_NUMBLOCKS 11
338/* Offset for Block Data (in CHECK response) */
339#define T3T_MSG_RSP_OFFSET_CHECK_DATA 12
340
341#define T3T_MSG_RSP_STATUS_OK 0x00
342#define T3T_MSG_RSP_STATUS_ERROR 0x01
343
344#define T3T_MSG_RSP_STATUS2_ERROR_MEMORY 0x70
345#define T3T_MSG_RSP_STATUS2_ERROR_PROCESSING 0xFF
346
347
348/* Felica Lite defintions */
349/* Block ID for MC (memory configuration)                       */
350#define T3T_MSG_FELICALITE_BLOCK_ID_MC 0x88
351
352/* Memory Configuration Block offset: MC_SP (Memory Configuration for scratch
353 * pad)   */
354#define T3T_MSG_FELICALITE_MC_OFFSET_MC_SP 0x00
355/* Memory Configuration Block offset: SYS_OP (System Option) */
356#define T3T_MSG_FELICALITE_MC_OFFSET_SYS_OP 0x03
357/* Memory Configuration Block offset: RF_PRM (Memory Configuration for RF
358 * Parameter) */
359#define T3T_MSG_FELICALITE_MC_OFFSET_RF_PRM 0x04
360
361/*
362**
363**  Type 4 Tag Definitions
364**
365*/
366#define T4T_CMD_MIN_HDR_SIZE 4 /* CLA, INS, P1, P2 */
367#define T4T_CMD_MAX_HDR_SIZE 5 /* CLA, INS, P1, P2, Lc */
368
369#define T4T_VERSION_2_0 0x20 /* version 2.0 */
370#define T4T_VERSION_1_0 0x10 /* version 1.0 */
371#define T4T_MY_VERSION T4T_VERSION_2_0
372#define T4T_GET_MAJOR_VERSION(x) ((x) >> 4)
373
374#define T4T_CMD_CLASS 0x00
375#define T4T_CMD_INS_SELECT 0xA4
376#define T4T_CMD_INS_READ_BINARY 0xB0
377#define T4T_CMD_INS_UPDATE_BINARY 0xD6
378#define T4T_CMD_DES_CLASS 0x90
379#define T4T_CMD_INS_GET_HW_VERSION 0x60
380#define T4T_CMD_CREATE_AID 0xCA
381#define T4T_CMD_SELECT_APP 0x5A
382#define T4T_CMD_CREATE_DATAFILE 0xCD
383#define T4T_CMD_DES_WRITE 0x3D
384#define T4T_CMD_P1_SELECT_BY_NAME 0x04
385#define T4T_CMD_P1_SELECT_BY_FILE_ID 0x00
386#define T4T_CMD_P2_FIRST_OR_ONLY_00H 0x00
387#define T4T_CMD_P2_FIRST_OR_ONLY_0CH 0x0C
388
389/* Max number of bytes to be read from file in ReadBinary Command */
390#define T4T_MAX_LENGTH_LE 0xFF
391/* Max number of bytes written to NDEF file in UpdateBinary Command */
392#define T4T_MAX_LENGTH_LC 0xFF
393
394#define T4T_RSP_STATUS_WORDS_SIZE 0x02
395
396#define T4T_RSP_CMD_CMPLTED 0x9000
397#define T4T_RSP_NOT_FOUND 0x6A82
398#define T4T_RSP_WRONG_PARAMS 0x6B00
399#define T4T_RSP_CLASS_NOT_SUPPORTED 0x6E00
400#define T4T_RSP_WRONG_LENGTH 0x6700
401#define T4T_RSP_INSTR_NOT_SUPPORTED 0x6D00
402#define T4T_RSP_CMD_NOT_ALLOWED 0x6986
403
404/* V1.0 Type 4 Tag Applicaiton ID length */
405#define T4T_V10_NDEF_TAG_AID_LEN 0x07
406/* V2.0 Type 4 Tag Applicaiton ID length */
407#define T4T_V20_NDEF_TAG_AID_LEN 0x07
408
409/* Min of Max R-APDU data size */
410#define T4T_MIN_MLE 0x000F
411
412#define T4T_FILE_ID_SIZE 0x02
413#define T4T_CC_FILE_ID 0xE103
414#define T4T_CC_FILE_MIN_LEN 0x000F
415
416#define T4T_VERSION_OFFSET_IN_CC 0x02
417#define T4T_FC_TLV_OFFSET_IN_CC 0x07
418/* Offset of Write access byte from type field in CC */
419#define T4T_FC_WRITE_ACCESS_OFFSET_IN_TLV 0x07
420
421#define T4T_NDEF_FILE_CONTROL_TYPE 0x04 /* NDEF File Control Type */
422
423/* size of T(1),L(1),V(6) for file control */
424#define T4T_FILE_CONTROL_TLV_SIZE 0x08
425/* size of V(6) for file control */
426#define T4T_FILE_CONTROL_LENGTH 0x06
427
428/* read access granted without any security */
429#define T4T_FC_READ_ACCESS 0x00
430/* write access granted without any security */
431#define T4T_FC_WRITE_ACCESS 0x00
432/* proprietary write access range start */
433#define T4T_FC_WRITE_ACCESS_PROP_START 0x80
434/* no write access granted at all (read-only) */
435#define T4T_FC_NO_WRITE_ACCESS 0xFF
436
437#define T4T_FILE_LENGTH_SIZE 0x02
438#define T4T_ADDI_FRAME_RESP 0xAFU
439#define T4T_SIZE_IDENTIFIER_2K 0x16U
440#define T4T_SIZE_IDENTIFIER_4K 0x18U
441#define T4T_SIZE_IDENTIFIER_8K 0x1AU
442#define T4T_DESEV1_MAJOR_VERSION 0x01U
443#define T4T_TYPE_DESFIRE_EV1 0x01U
444#define T4T_DESEV0_MAJOR_VERSION 0x00U
445#define T4T_DESEV0_MINOR_VERSION 0x06U
446#define T4T_DES_EV1_NFC_APP_ID 0x010000
447#define T4T_DES_EV0_NFC_APP_ID 0x10EEEE
448
449/*
450**
451**  ISO 15693 Tag Definitions
452**
453*/
454
455/* A single sub-carrier frequency shall be used by VICC */
456#define I93_FLAG_SUB_CARRIER_SINGLE 0x00
457
458/* High data rate shall be used */
459#define I93_FLAG_DATA_RATE_HIGH 0x02
460
461/* Flags 5 to 8 meaning is according to table 5 */
462#define I93_FLAG_INVENTORY_SET 0x04
463
464/* No protocol format extension                         */
465#define I93_FLAG_PROT_EXT_NO 0x00
466/* Protocol format is extended. Reserved for future use */
467#define I93_FLAG_PROT_EXT_YES 0x08
468
469/* Request is addressed. UID field is included. It shall be executed only by
470 * VICC */
471#define I93_FLAG_ADDRESS_SET 0x20
472/* whose UID matches the UID specified in the request */
473
474/* AFI field is present     */
475#define I93_FLAG_AFI_PRESENT 0x10
476
477#define I93_FLAG_SLOT_ONE 0x20  /* 1 slot   */
478
479/* It shall be set to 0 if not otherwise defined by command */
480/* Meaning is defined by the command description. */
481#define I93_FLAG_OPTION_SET 0x40
482
483/* Error detected, Error code is in the "Error" field */
484#define I93_FLAG_ERROR_DETECTED 0x01
485
486/* Response error code */
487/* The command option is not supported                                   */
488#define I93_ERROR_CODE_OPTION_NOT_SUPPORTED 0x03
489/* The specific block is was not successfully programmed                 */
490#define I93_ERROR_CODE_BLOCK_FAIL_TO_WRITE 0x13
491/* The specific block is was not successfully locked                     */
492
493/* UID length in bytes                  */
494#define I93_UID_BYTE_LEN 8
495/* Data Storage Format is not supported */
496#define I93_DFS_UNSUPPORTED 0x00
497/* Block is locked                      */
498#define I93_BLOCK_LOCKED 0x01
499
500/* ISO 15693 Mandatory commands */
501#define I93_CMD_INVENTORY 0x01  /* Inventory  */
502#define I93_CMD_STAY_QUIET 0x02 /* Stay Quiet */
503
504/* ISO 15693 Optional commands */
505#define I93_CMD_READ_SINGLE_BLOCK 0x20  /* Read single block     */
506#define I93_CMD_EXT_READ_SINGLE_BLOCK 0x30 /* Extended Read single block */
507#define I93_CMD_WRITE_SINGLE_BLOCK 0x21 /* Write single block    */
508#define I93_CMD_EXT_WRITE_SINGLE_BLOCK 0x31 /* Extended Write single block */
509#define I93_CMD_LOCK_BLOCK 0x22         /* Lock block            */
510#define I93_CMD_EXT_LOCK_BLOCK 0x32     /* Extended Lock block            */
511#define I93_CMD_READ_MULTI_BLOCK 0x23   /* Read multiple blocks  */
512#define I93_CMD_EXT_READ_MULTI_BLOCK 0x33 /* Extended Read multiple blocks  */
513#define I93_CMD_WRITE_MULTI_BLOCK 0x24  /* Write multiple blocks */
514#define I93_CMD_EXT_WRITE_MULTI_BLOCK 0x34 /* Write multiple blocks */
515#define I93_CMD_SELECT 0x25             /* Select                */
516#define I93_CMD_RESET_TO_READY 0x26     /* Reset to ready        */
517#define I93_CMD_WRITE_AFI 0x27          /* Wreite AFI            */
518#define I93_CMD_LOCK_AFI 0x28           /* Lock AFI              */
519#define I93_CMD_WRITE_DSFID 0x29        /* Write DSFID           */
520#define I93_CMD_LOCK_DSFID 0x2A         /* Lock DSFID            */
521/* Get system information             */
522#define I93_CMD_GET_SYS_INFO 0x2B
523/* Get extended system information    */
524#define I93_CMD_EXT_GET_SYS_INFO 0x3B
525/* Get multiple block security status */
526#define I93_CMD_GET_MULTI_BLK_SEC 0x2C
527/* Get extended multiple block security status */
528#define I93_CMD_EXT_GET_MULTI_BLK_SEC 0x3C
529
530/* Information flags definition */
531/* DSFID is supported and DSFID field is present */
532#define I93_INFO_FLAG_DSFID 0x01
533/* AFI is supported and AFI field is present     */
534#define I93_INFO_FLAG_AFI 0x02
535/* VICC memory size field is present             */
536#define I93_INFO_FLAG_MEM_SIZE 0x04
537/* IC reference field is present                 */
538#define I93_INFO_FLAG_IC_REF 0x08
539/* Memory coded in 2 bytes address               */
540#define I93_INFO_FLAG_MOI 0x10
541
542/* Max block size in bytes */
543#define I93_MAX_BLOCK_LENGH 32
544
545/* ICODE Capability Container(CC) definition */
546#define I93_ICODE_CC_MAGIC_NUMER_E1 0xE1 /* magic number in CC[0]  */
547#define I93_ICODE_CC_MAGIC_NUMER_E2 0xE2 /* magic number in CC[0]  */
548/* read access condition in CC[1]        */
549#define I93_ICODE_CC_READ_ACCESS_MASK 0x0C
550/* read access granted without security  */
551#define I93_ICODE_CC_READ_ACCESS_GRANTED 0x00
552/* write access condition in CC[1]       */
553#define I93_ICODE_CC_WRITE_ACCESS_MASK 0x03
554/* write access granted without security */
555#define I93_ICODE_CC_WRITE_ACCESS_GRANTED 0x00
556/* write access not granted at all       */
557#define I93_ICODE_CC_READ_ONLY 0x03
558/* read multi block supported in CC[3]   */
559#define I93_ICODE_CC_MBREAD_MASK 0x01
560/* inventory page read supported in CC[3] */
561#define I93_ICODE_CC_IPREAD_MASK 0x02
562/* More than 2040 bytes are supported in CC[3] */
563#define I93_STM_CC_OVERFLOW_MASK 0x04
564
565/* ICODE TLV type */
566#define I93_ICODE_TLV_TYPE_NULL 0x00 /* NULL TLV         */
567#define I93_ICODE_TLV_TYPE_NDEF 0x03 /* NDEF message TLV */
568#define I93_ICODE_TLV_TYPE_PROP 0xFD /* Proprietary TLV  */
569#define I93_ICODE_TLV_TYPE_TERM 0xFE /* Terminator TLV   */
570
571/* UID Coding (UID Bit 64-57), First byte of ISO 15693 UID */
572#define I93_UID_FIRST_BYTE 0xE0
573
574/* UID Coding (UID Bit 56-49), IC manufacturer code */
575#define I93_UID_IC_MFG_CODE_STM 0x02
576#define I93_UID_IC_MFG_CODE_NXP 0x04
577#define I93_UID_IC_MFG_CODE_TI 0x07
578
579/* NXP, UID Coding of ICODE type (UID Bit 48-41) */
580/* ICODE SLI, SLIX     */
581#define I93_UID_ICODE_SLI 0x01
582/* ICODE SLI-S, SLIX-S */
583#define I93_UID_ICODE_SLI_S 0x02
584/* ICODE SLI-L, SLIX-L */
585#define I93_UID_ICODE_SLI_L 0x03
586
587/* IC Reference for ICODE SLI-L */
588#define I93_IC_REF_ICODE_SLI_L 0x03
589/* read multi block supported check bit */
590#define I93_ICODE_IC_REF_MBREAD_MASK 0x02
591
592/* TI, UID Coding of product version (UID Bit 48-42) */
593/* upper 7 bits                     */
594#define I93_UID_TAG_IT_HF_I_PRODUCT_ID_MASK 0xFE
595/* Tag-it HF-I Plus Inlay           */
596#define I93_UID_TAG_IT_HF_I_PLUS_INLAY 0x00
597/* Tag-it HF-I Plus Chip            */
598#define I93_UID_TAG_IT_HF_I_PLUS_CHIP 0x80
599/* Tag-it HF-I Standard Chip/Inlyas */
600#define I93_UID_TAG_IT_HF_I_STD_CHIP_INLAY 0xC0
601/* Tag-it HF-I Pro Chip/Inlyas      */
602#define I93_UID_TAG_IT_HF_I_PRO_CHIP_INLAY 0xC4
603
604#define I93_TAG_IT_HF_I_STD_CHIP_INLAY_NUM_TOTAL_BLK 11
605#define I93_TAG_IT_HF_I_PRO_CHIP_INLAY_NUM_TOTAL_BLK 12
606
607#define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_BLK_SIZE 4
608#define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_NUM_USER_BLK 8
609/* LSB in Block 0x0A */
610#define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_AFI_LOCATION 40
611
612/* STM, product version (IC manufacturer code) */
613/* IC Reference mask for STM */
614#define I93_IC_REF_STM_MASK 0xFC
615/* IC Reference for LRI1K:      010000xx(b), blockSize: 4, numberBlocks: 0x20 */
616#define I93_IC_REF_STM_LRI1K 0x40
617/* IC Reference for LRI2K:      001000xx(b), blockSize: 4, numberBlocks: 0x40 */
618#define I93_IC_REF_STM_LRI2K 0x20
619/* IC Reference for LRIS2K:     001010xx(b), blockSize: 4, numberBlocks: 0x40 */
620#define I93_IC_REF_STM_LRIS2K 0x28
621/* IC Reference for LRIS64K:    010001xx(b), blockSize: 4, numberBlocks: 0x800
622 */
623#define I93_IC_REF_STM_LRIS64K 0x44
624/* IC Reference for M24LR64-R:  001011xx(b), blockSize: 4, numberBlocks: 0x800
625 */
626#define I93_IC_REF_STM_M24LR64_R 0x2C
627/* IC Reference for M24LR04E-R: 01011010(b), blockSize: 4, numberBlocks: 0x80 */
628#define I93_IC_REF_STM_M24LR04E_R 0x5A
629/* IC Reference for M24LR16E-R: 01001110(b), blockSize: 4, numberBlocks: 0x200
630 */
631#define I93_IC_REF_STM_M24LR16E_R 0x4E
632/* IC Reference for M24LR64E-R: 01011110(b), blockSize: 4, numberBlocks: 0x800
633 */
634#define I93_IC_REF_STM_M24LR64E_R 0x5E
635/* IC Reference for ST25DV04K: 00100100(b), blockSize: 4, numberBlocks: 0x80
636 */
637#define I93_IC_REF_STM_ST25DV04K 0x24
638/* IC Reference for ST25DVHIK: 00100110(b), blockSize: 4, numberBlocks: 0x800
639 * or 0x200
640 */
641#define I93_IC_REF_STM_ST25DVHIK 0x26
642
643#define I93_STM_BLOCKS_PER_SECTOR 32
644#define I93_STM_MAX_BLOCKS_PER_READ 32
645
646#endif /* TAGS_DEFS_H */
647