diff options
| author | Vincent Cuissard <cuissard@marvell.com> | 2014-07-22 13:48:38 -0400 |
|---|---|---|
| committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-09-01 08:40:31 -0400 |
| commit | cfdbeeafdbbdbc006f700e92cbad2cb5d4529f3d (patch) | |
| tree | ecf3fc7d4cf0203573369febdedd3baced9a1593 | |
| parent | f23b73526b82ca2ef333362e704a51d817c1ffc1 (diff) | |
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>
| -rw-r--r-- | include/net/nfc/nci.h | 16 | ||||
| -rw-r--r-- | net/nfc/nci/core.c | 8 | ||||
| -rw-r--r-- | net/nfc/nci/ntf.c | 31 |
3 files changed, 52 insertions, 3 deletions
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index fbfa4e471abb..9eca9ae2280c 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | * The NFC Controller Interface is the communication protocol between an | 2 | * The NFC Controller Interface is the communication protocol between an |
| 3 | * NFC Controller (NFCC) and a Device Host (DH). | 3 | * NFC Controller (NFCC) and a Device Host (DH). |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 2014 Marvell International Ltd. | ||
| 5 | * Copyright (C) 2011 Texas Instruments, Inc. | 6 | * Copyright (C) 2011 Texas Instruments, Inc. |
| 6 | * | 7 | * |
| 7 | * Written by Ilan Elias <ilane@ti.com> | 8 | * Written by Ilan Elias <ilane@ti.com> |
| @@ -65,19 +66,18 @@ | |||
| 65 | #define NCI_NFC_F_PASSIVE_POLL_MODE 0x02 | 66 | #define NCI_NFC_F_PASSIVE_POLL_MODE 0x02 |
| 66 | #define NCI_NFC_A_ACTIVE_POLL_MODE 0x03 | 67 | #define NCI_NFC_A_ACTIVE_POLL_MODE 0x03 |
| 67 | #define NCI_NFC_F_ACTIVE_POLL_MODE 0x05 | 68 | #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 |
| 69 | #define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80 | 70 | #define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80 |
| 70 | #define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81 | 71 | #define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81 |
| 71 | #define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82 | 72 | #define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82 |
| 72 | #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 | 73 | #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 |
| 73 | #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 | 74 | #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 |
| 74 | #define NCI_NFC_15693_PASSIVE_LISTEN_MODE 0x86 | ||
| 75 | 75 | ||
| 76 | /* NCI RF Technologies */ | 76 | /* NCI RF Technologies */ |
| 77 | #define NCI_NFC_RF_TECHNOLOGY_A 0x00 | 77 | #define NCI_NFC_RF_TECHNOLOGY_A 0x00 |
| 78 | #define NCI_NFC_RF_TECHNOLOGY_B 0x01 | 78 | #define NCI_NFC_RF_TECHNOLOGY_B 0x01 |
| 79 | #define NCI_NFC_RF_TECHNOLOGY_F 0x02 | 79 | #define NCI_NFC_RF_TECHNOLOGY_F 0x02 |
| 80 | #define NCI_NFC_RF_TECHNOLOGY_15693 0x03 | 80 | #define NCI_NFC_RF_TECHNOLOGY_V 0x03 |
| 81 | 81 | ||
| 82 | /* NCI Bit Rates */ | 82 | /* NCI Bit Rates */ |
| 83 | #define NCI_NFC_BIT_RATE_106 0x00 | 83 | #define NCI_NFC_BIT_RATE_106 0x00 |
| @@ -87,6 +87,7 @@ | |||
| 87 | #define NCI_NFC_BIT_RATE_1695 0x04 | 87 | #define NCI_NFC_BIT_RATE_1695 0x04 |
| 88 | #define NCI_NFC_BIT_RATE_3390 0x05 | 88 | #define NCI_NFC_BIT_RATE_3390 0x05 |
| 89 | #define NCI_NFC_BIT_RATE_6780 0x06 | 89 | #define NCI_NFC_BIT_RATE_6780 0x06 |
| 90 | #define NCI_NFC_BIT_RATE_26 0x20 | ||
| 90 | 91 | ||
| 91 | /* NCI RF Protocols */ | 92 | /* NCI RF Protocols */ |
| 92 | #define NCI_RF_PROTOCOL_UNKNOWN 0x00 | 93 | #define NCI_RF_PROTOCOL_UNKNOWN 0x00 |
| @@ -95,6 +96,7 @@ | |||
| 95 | #define NCI_RF_PROTOCOL_T3T 0x03 | 96 | #define NCI_RF_PROTOCOL_T3T 0x03 |
| 96 | #define NCI_RF_PROTOCOL_ISO_DEP 0x04 | 97 | #define NCI_RF_PROTOCOL_ISO_DEP 0x04 |
| 97 | #define NCI_RF_PROTOCOL_NFC_DEP 0x05 | 98 | #define NCI_RF_PROTOCOL_NFC_DEP 0x05 |
| 99 | #define NCI_RF_PROTOCOL_T5T 0x06 | ||
| 98 | 100 | ||
| 99 | /* NCI RF Interfaces */ | 101 | /* NCI RF Interfaces */ |
| 100 | #define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 | 102 | #define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 |
| @@ -328,6 +330,12 @@ struct rf_tech_specific_params_nfcf_poll { | |||
| 328 | __u8 sensf_res[18]; /* 16 or 18 Bytes */ | 330 | __u8 sensf_res[18]; /* 16 or 18 Bytes */ |
| 329 | } __packed; | 331 | } __packed; |
| 330 | 332 | ||
| 333 | struct rf_tech_specific_params_nfcv_poll { | ||
| 334 | __u8 res_flags; | ||
| 335 | __u8 dsfid; | ||
| 336 | __u8 uid[8]; /* 8 Bytes */ | ||
| 337 | } __packed; | ||
| 338 | |||
| 331 | struct nci_rf_discover_ntf { | 339 | struct nci_rf_discover_ntf { |
| 332 | __u8 rf_discovery_id; | 340 | __u8 rf_discovery_id; |
| 333 | __u8 rf_protocol; | 341 | __u8 rf_protocol; |
| @@ -338,6 +346,7 @@ struct nci_rf_discover_ntf { | |||
| 338 | struct rf_tech_specific_params_nfca_poll nfca_poll; | 346 | struct rf_tech_specific_params_nfca_poll nfca_poll; |
| 339 | struct rf_tech_specific_params_nfcb_poll nfcb_poll; | 347 | struct rf_tech_specific_params_nfcb_poll nfcb_poll; |
| 340 | struct rf_tech_specific_params_nfcf_poll nfcf_poll; | 348 | struct rf_tech_specific_params_nfcf_poll nfcf_poll; |
| 349 | struct rf_tech_specific_params_nfcv_poll nfcv_poll; | ||
| 341 | } rf_tech_specific_params; | 350 | } rf_tech_specific_params; |
| 342 | 351 | ||
| 343 | __u8 ntf_type; | 352 | __u8 ntf_type; |
| @@ -372,6 +381,7 @@ struct nci_rf_intf_activated_ntf { | |||
| 372 | struct rf_tech_specific_params_nfca_poll nfca_poll; | 381 | struct rf_tech_specific_params_nfca_poll nfca_poll; |
| 373 | struct rf_tech_specific_params_nfcb_poll nfcb_poll; | 382 | struct rf_tech_specific_params_nfcb_poll nfcb_poll; |
| 374 | struct rf_tech_specific_params_nfcf_poll nfcf_poll; | 383 | struct rf_tech_specific_params_nfcf_poll nfcf_poll; |
| 384 | struct rf_tech_specific_params_nfcv_poll nfcv_poll; | ||
| 375 | } rf_tech_specific_params; | 385 | } rf_tech_specific_params; |
| 376 | 386 | ||
| 377 | __u8 data_exch_rf_tech_and_mode; | 387 | __u8 data_exch_rf_tech_and_mode; |
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 2b400e1a8695..860080803a3e 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
| @@ -231,6 +231,14 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) | |||
| 231 | cmd.num_disc_configs++; | 231 | cmd.num_disc_configs++; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 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 | |||
| 234 | nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, | 242 | nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, |
| 235 | (1 + (cmd.num_disc_configs * sizeof(struct disc_config))), | 243 | (1 + (cmd.num_disc_configs * sizeof(struct disc_config))), |
| 236 | &cmd); | 244 | &cmd); |
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index df91bb95b12a..25e44cebd60a 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | * The NFC Controller Interface is the communication protocol between an | 2 | * The NFC Controller Interface is the communication protocol between an |
| 3 | * NFC Controller (NFCC) and a Device Host (DH). | 3 | * NFC Controller (NFCC) and a Device Host (DH). |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 2014 Marvell International Ltd. | ||
| 5 | * Copyright (C) 2011 Texas Instruments, Inc. | 6 | * Copyright (C) 2011 Texas Instruments, Inc. |
| 6 | * | 7 | * |
| 7 | * Written by Ilan Elias <ilane@ti.com> | 8 | * Written by Ilan Elias <ilane@ti.com> |
| @@ -155,6 +156,17 @@ static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, | |||
| 155 | return data; | 156 | return data; |
| 156 | } | 157 | } |
| 157 | 158 | ||
| 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 | |||
| 158 | static int nci_add_new_protocol(struct nci_dev *ndev, | 170 | static int nci_add_new_protocol(struct nci_dev *ndev, |
| 159 | struct nfc_target *target, | 171 | struct nfc_target *target, |
| 160 | __u8 rf_protocol, | 172 | __u8 rf_protocol, |
| @@ -164,6 +176,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
| 164 | struct rf_tech_specific_params_nfca_poll *nfca_poll; | 176 | struct rf_tech_specific_params_nfca_poll *nfca_poll; |
| 165 | struct rf_tech_specific_params_nfcb_poll *nfcb_poll; | 177 | struct rf_tech_specific_params_nfcb_poll *nfcb_poll; |
| 166 | struct rf_tech_specific_params_nfcf_poll *nfcf_poll; | 178 | struct rf_tech_specific_params_nfcf_poll *nfcf_poll; |
| 179 | struct rf_tech_specific_params_nfcv_poll *nfcv_poll; | ||
| 167 | __u32 protocol; | 180 | __u32 protocol; |
| 168 | 181 | ||
| 169 | if (rf_protocol == NCI_RF_PROTOCOL_T1T) | 182 | if (rf_protocol == NCI_RF_PROTOCOL_T1T) |
| @@ -179,6 +192,8 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
| 179 | protocol = NFC_PROTO_FELICA_MASK; | 192 | protocol = NFC_PROTO_FELICA_MASK; |
| 180 | else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) | 193 | else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) |
| 181 | protocol = NFC_PROTO_NFC_DEP_MASK; | 194 | protocol = NFC_PROTO_NFC_DEP_MASK; |
| 195 | else if (rf_protocol == NCI_RF_PROTOCOL_T5T) | ||
| 196 | protocol = NFC_PROTO_ISO15693_MASK; | ||
| 182 | else | 197 | else |
| 183 | protocol = 0; | 198 | protocol = 0; |
| 184 | 199 | ||
| @@ -213,6 +228,12 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
| 213 | memcpy(target->sensf_res, nfcf_poll->sensf_res, | 228 | memcpy(target->sensf_res, nfcf_poll->sensf_res, |
| 214 | target->sensf_res_len); | 229 | target->sensf_res_len); |
| 215 | } | 230 | } |
| 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); | ||
| 216 | } else { | 237 | } else { |
| 217 | pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); | 238 | pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); |
| 218 | return -EPROTO; | 239 | return -EPROTO; |
| @@ -305,6 +326,11 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, | |||
| 305 | &(ntf.rf_tech_specific_params.nfcf_poll), data); | 326 | &(ntf.rf_tech_specific_params.nfcf_poll), data); |
| 306 | break; | 327 | break; |
| 307 | 328 | ||
| 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 | |||
| 308 | default: | 334 | default: |
| 309 | pr_err("unsupported rf_tech_and_mode 0x%x\n", | 335 | pr_err("unsupported rf_tech_and_mode 0x%x\n", |
| 310 | ntf.rf_tech_and_mode); | 336 | ntf.rf_tech_and_mode); |
| @@ -455,6 +481,11 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, | |||
| 455 | &(ntf.rf_tech_specific_params.nfcf_poll), data); | 481 | &(ntf.rf_tech_specific_params.nfcf_poll), data); |
| 456 | break; | 482 | break; |
| 457 | 483 | ||
| 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 | |||
| 458 | default: | 489 | default: |
| 459 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", | 490 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", |
| 460 | ntf.activation_rf_tech_and_mode); | 491 | ntf.activation_rf_tech_and_mode); |
