Skip to content

Commit cfdbeea

Browse files
Vincent CuissardSamuel Ortiz
authored andcommitted
NFC: NCI: Add support of ISO15693
Update nci.h to respect latest NCI specification proposal (stop using proprietary opcodes). Handle ISO15693 parameters in NCI_RF_ACTIVATED_NTF handler. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent f23b735 commit cfdbeea

3 files changed

Lines changed: 52 additions & 3 deletions

File tree

‎include/net/nfc/nci.h‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* The NFC Controller Interface is the communication protocol between an
33
* NFC Controller (NFCC) and a Device Host (DH).
44
*
5+
* Copyright (C) 2014 Marvell International Ltd.
56
* Copyright (C) 2011 Texas Instruments, Inc.
67
*
78
* Written by Ilan Elias <ilane@ti.com>
@@ -65,19 +66,18 @@
6566
#define NCI_NFC_F_PASSIVE_POLL_MODE 0x02
6667
#define NCI_NFC_A_ACTIVE_POLL_MODE 0x03
6768
#define NCI_NFC_F_ACTIVE_POLL_MODE 0x05
68-
#define NCI_NFC_15693_PASSIVE_POLL_MODE 0x06
69+
#define NCI_NFC_V_PASSIVE_POLL_MODE 0x06
6970
#define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80
7071
#define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81
7172
#define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82
7273
#define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83
7374
#define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85
74-
#define NCI_NFC_15693_PASSIVE_LISTEN_MODE 0x86
7575

7676
/* NCI RF Technologies */
7777
#define NCI_NFC_RF_TECHNOLOGY_A 0x00
7878
#define NCI_NFC_RF_TECHNOLOGY_B 0x01
7979
#define NCI_NFC_RF_TECHNOLOGY_F 0x02
80-
#define NCI_NFC_RF_TECHNOLOGY_15693 0x03
80+
#define NCI_NFC_RF_TECHNOLOGY_V 0x03
8181

8282
/* NCI Bit Rates */
8383
#define NCI_NFC_BIT_RATE_106 0x00
@@ -87,6 +87,7 @@
8787
#define NCI_NFC_BIT_RATE_1695 0x04
8888
#define NCI_NFC_BIT_RATE_3390 0x05
8989
#define NCI_NFC_BIT_RATE_6780 0x06
90+
#define NCI_NFC_BIT_RATE_26 0x20
9091

9192
/* NCI RF Protocols */
9293
#define NCI_RF_PROTOCOL_UNKNOWN 0x00
@@ -95,6 +96,7 @@
9596
#define NCI_RF_PROTOCOL_T3T 0x03
9697
#define NCI_RF_PROTOCOL_ISO_DEP 0x04
9798
#define NCI_RF_PROTOCOL_NFC_DEP 0x05
99+
#define NCI_RF_PROTOCOL_T5T 0x06
98100

99101
/* NCI RF Interfaces */
100102
#define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00
@@ -328,6 +330,12 @@ struct rf_tech_specific_params_nfcf_poll {
328330
__u8 sensf_res[18]; /* 16 or 18 Bytes */
329331
} __packed;
330332

333+
struct rf_tech_specific_params_nfcv_poll {
334+
__u8 res_flags;
335+
__u8 dsfid;
336+
__u8 uid[8]; /* 8 Bytes */
337+
} __packed;
338+
331339
struct nci_rf_discover_ntf {
332340
__u8 rf_discovery_id;
333341
__u8 rf_protocol;
@@ -338,6 +346,7 @@ struct nci_rf_discover_ntf {
338346
struct rf_tech_specific_params_nfca_poll nfca_poll;
339347
struct rf_tech_specific_params_nfcb_poll nfcb_poll;
340348
struct rf_tech_specific_params_nfcf_poll nfcf_poll;
349+
struct rf_tech_specific_params_nfcv_poll nfcv_poll;
341350
} rf_tech_specific_params;
342351

343352
__u8 ntf_type;
@@ -372,6 +381,7 @@ struct nci_rf_intf_activated_ntf {
372381
struct rf_tech_specific_params_nfca_poll nfca_poll;
373382
struct rf_tech_specific_params_nfcb_poll nfcb_poll;
374383
struct rf_tech_specific_params_nfcf_poll nfcf_poll;
384+
struct rf_tech_specific_params_nfcv_poll nfcv_poll;
375385
} rf_tech_specific_params;
376386

377387
__u8 data_exch_rf_tech_and_mode;

‎net/nfc/nci/core.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
231231
cmd.num_disc_configs++;
232232
}
233233

234+
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
235+
(protocols & NFC_PROTO_ISO15693_MASK)) {
236+
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
237+
NCI_NFC_V_PASSIVE_POLL_MODE;
238+
cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
239+
cmd.num_disc_configs++;
240+
}
241+
234242
nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD,
235243
(1 + (cmd.num_disc_configs * sizeof(struct disc_config))),
236244
&cmd);

‎net/nfc/nci/ntf.c‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* The NFC Controller Interface is the communication protocol between an
33
* NFC Controller (NFCC) and a Device Host (DH).
44
*
5+
* Copyright (C) 2014 Marvell International Ltd.
56
* Copyright (C) 2011 Texas Instruments, Inc.
67
*
78
* Written by Ilan Elias <ilane@ti.com>
@@ -155,6 +156,17 @@ static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,
155156
return data;
156157
}
157158

159+
static __u8 *nci_extract_rf_params_nfcv_passive_poll(struct nci_dev *ndev,
160+
struct rf_tech_specific_params_nfcv_poll *nfcv_poll,
161+
__u8 *data)
162+
{
163+
++data;
164+
nfcv_poll->dsfid = *data++;
165+
memcpy(nfcv_poll->uid, data, NFC_ISO15693_UID_MAXSIZE);
166+
data += NFC_ISO15693_UID_MAXSIZE;
167+
return data;
168+
}
169+
158170
static int nci_add_new_protocol(struct nci_dev *ndev,
159171
struct nfc_target *target,
160172
__u8 rf_protocol,
@@ -164,6 +176,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
164176
struct rf_tech_specific_params_nfca_poll *nfca_poll;
165177
struct rf_tech_specific_params_nfcb_poll *nfcb_poll;
166178
struct rf_tech_specific_params_nfcf_poll *nfcf_poll;
179+
struct rf_tech_specific_params_nfcv_poll *nfcv_poll;
167180
__u32 protocol;
168181

169182
if (rf_protocol == NCI_RF_PROTOCOL_T1T)
@@ -179,6 +192,8 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
179192
protocol = NFC_PROTO_FELICA_MASK;
180193
else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP)
181194
protocol = NFC_PROTO_NFC_DEP_MASK;
195+
else if (rf_protocol == NCI_RF_PROTOCOL_T5T)
196+
protocol = NFC_PROTO_ISO15693_MASK;
182197
else
183198
protocol = 0;
184199

@@ -213,6 +228,12 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
213228
memcpy(target->sensf_res, nfcf_poll->sensf_res,
214229
target->sensf_res_len);
215230
}
231+
} else if (rf_tech_and_mode == NCI_NFC_V_PASSIVE_POLL_MODE) {
232+
nfcv_poll = (struct rf_tech_specific_params_nfcv_poll *)params;
233+
234+
target->is_iso15693 = 1;
235+
target->iso15693_dsfid = nfcv_poll->dsfid;
236+
memcpy(target->iso15693_uid, nfcv_poll->uid, NFC_ISO15693_UID_MAXSIZE);
216237
} else {
217238
pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
218239
return -EPROTO;
@@ -305,6 +326,11 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
305326
&(ntf.rf_tech_specific_params.nfcf_poll), data);
306327
break;
307328

329+
case NCI_NFC_V_PASSIVE_POLL_MODE:
330+
data = nci_extract_rf_params_nfcv_passive_poll(ndev,
331+
&(ntf.rf_tech_specific_params.nfcv_poll), data);
332+
break;
333+
308334
default:
309335
pr_err("unsupported rf_tech_and_mode 0x%x\n",
310336
ntf.rf_tech_and_mode);
@@ -455,6 +481,11 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
455481
&(ntf.rf_tech_specific_params.nfcf_poll), data);
456482
break;
457483

484+
case NCI_NFC_V_PASSIVE_POLL_MODE:
485+
data = nci_extract_rf_params_nfcv_passive_poll(ndev,
486+
&(ntf.rf_tech_specific_params.nfcv_poll), data);
487+
break;
488+
458489
default:
459490
pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
460491
ntf.activation_rf_tech_and_mode);

0 commit comments

Comments
 (0)