Commit cfdbeeaf authored by Vincent Cuissard's avatar Vincent Cuissard Committed by Samuel Ortiz

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: default avatarVincent Cuissard <cuissard@marvell.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent f23b7352
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* The NFC Controller Interface is the communication protocol between an * The NFC Controller Interface is the communication protocol between an
* NFC Controller (NFCC) and a Device Host (DH). * NFC Controller (NFCC) and a Device Host (DH).
* *
* Copyright (C) 2014 Marvell International Ltd.
* Copyright (C) 2011 Texas Instruments, Inc. * Copyright (C) 2011 Texas Instruments, Inc.
* *
* Written by Ilan Elias <ilane@ti.com> * Written by Ilan Elias <ilane@ti.com>
...@@ -65,19 +66,18 @@ ...@@ -65,19 +66,18 @@
#define NCI_NFC_F_PASSIVE_POLL_MODE 0x02 #define NCI_NFC_F_PASSIVE_POLL_MODE 0x02
#define NCI_NFC_A_ACTIVE_POLL_MODE 0x03 #define NCI_NFC_A_ACTIVE_POLL_MODE 0x03
#define NCI_NFC_F_ACTIVE_POLL_MODE 0x05 #define NCI_NFC_F_ACTIVE_POLL_MODE 0x05
#define NCI_NFC_15693_PASSIVE_POLL_MODE 0x06 #define NCI_NFC_V_PASSIVE_POLL_MODE 0x06
#define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80 #define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80
#define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81 #define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81
#define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82 #define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82
#define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83
#define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85
#define NCI_NFC_15693_PASSIVE_LISTEN_MODE 0x86
/* NCI RF Technologies */ /* NCI RF Technologies */
#define NCI_NFC_RF_TECHNOLOGY_A 0x00 #define NCI_NFC_RF_TECHNOLOGY_A 0x00
#define NCI_NFC_RF_TECHNOLOGY_B 0x01 #define NCI_NFC_RF_TECHNOLOGY_B 0x01
#define NCI_NFC_RF_TECHNOLOGY_F 0x02 #define NCI_NFC_RF_TECHNOLOGY_F 0x02
#define NCI_NFC_RF_TECHNOLOGY_15693 0x03 #define NCI_NFC_RF_TECHNOLOGY_V 0x03
/* NCI Bit Rates */ /* NCI Bit Rates */
#define NCI_NFC_BIT_RATE_106 0x00 #define NCI_NFC_BIT_RATE_106 0x00
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
#define NCI_NFC_BIT_RATE_1695 0x04 #define NCI_NFC_BIT_RATE_1695 0x04
#define NCI_NFC_BIT_RATE_3390 0x05 #define NCI_NFC_BIT_RATE_3390 0x05
#define NCI_NFC_BIT_RATE_6780 0x06 #define NCI_NFC_BIT_RATE_6780 0x06
#define NCI_NFC_BIT_RATE_26 0x20
/* NCI RF Protocols */ /* NCI RF Protocols */
#define NCI_RF_PROTOCOL_UNKNOWN 0x00 #define NCI_RF_PROTOCOL_UNKNOWN 0x00
...@@ -95,6 +96,7 @@ ...@@ -95,6 +96,7 @@
#define NCI_RF_PROTOCOL_T3T 0x03 #define NCI_RF_PROTOCOL_T3T 0x03
#define NCI_RF_PROTOCOL_ISO_DEP 0x04 #define NCI_RF_PROTOCOL_ISO_DEP 0x04
#define NCI_RF_PROTOCOL_NFC_DEP 0x05 #define NCI_RF_PROTOCOL_NFC_DEP 0x05
#define NCI_RF_PROTOCOL_T5T 0x06
/* NCI RF Interfaces */ /* NCI RF Interfaces */
#define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 #define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00
...@@ -328,6 +330,12 @@ struct rf_tech_specific_params_nfcf_poll { ...@@ -328,6 +330,12 @@ struct rf_tech_specific_params_nfcf_poll {
__u8 sensf_res[18]; /* 16 or 18 Bytes */ __u8 sensf_res[18]; /* 16 or 18 Bytes */
} __packed; } __packed;
struct rf_tech_specific_params_nfcv_poll {
__u8 res_flags;
__u8 dsfid;
__u8 uid[8]; /* 8 Bytes */
} __packed;
struct nci_rf_discover_ntf { struct nci_rf_discover_ntf {
__u8 rf_discovery_id; __u8 rf_discovery_id;
__u8 rf_protocol; __u8 rf_protocol;
...@@ -338,6 +346,7 @@ struct nci_rf_discover_ntf { ...@@ -338,6 +346,7 @@ struct nci_rf_discover_ntf {
struct rf_tech_specific_params_nfca_poll nfca_poll; struct rf_tech_specific_params_nfca_poll nfca_poll;
struct rf_tech_specific_params_nfcb_poll nfcb_poll; struct rf_tech_specific_params_nfcb_poll nfcb_poll;
struct rf_tech_specific_params_nfcf_poll nfcf_poll; struct rf_tech_specific_params_nfcf_poll nfcf_poll;
struct rf_tech_specific_params_nfcv_poll nfcv_poll;
} rf_tech_specific_params; } rf_tech_specific_params;
__u8 ntf_type; __u8 ntf_type;
...@@ -372,6 +381,7 @@ struct nci_rf_intf_activated_ntf { ...@@ -372,6 +381,7 @@ struct nci_rf_intf_activated_ntf {
struct rf_tech_specific_params_nfca_poll nfca_poll; struct rf_tech_specific_params_nfca_poll nfca_poll;
struct rf_tech_specific_params_nfcb_poll nfcb_poll; struct rf_tech_specific_params_nfcb_poll nfcb_poll;
struct rf_tech_specific_params_nfcf_poll nfcf_poll; struct rf_tech_specific_params_nfcf_poll nfcf_poll;
struct rf_tech_specific_params_nfcv_poll nfcv_poll;
} rf_tech_specific_params; } rf_tech_specific_params;
__u8 data_exch_rf_tech_and_mode; __u8 data_exch_rf_tech_and_mode;
......
...@@ -231,6 +231,14 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) ...@@ -231,6 +231,14 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
cmd.num_disc_configs++; cmd.num_disc_configs++;
} }
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
(protocols & NFC_PROTO_ISO15693_MASK)) {
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_V_PASSIVE_POLL_MODE;
cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
cmd.num_disc_configs++;
}
nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD,
(1 + (cmd.num_disc_configs * sizeof(struct disc_config))), (1 + (cmd.num_disc_configs * sizeof(struct disc_config))),
&cmd); &cmd);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* The NFC Controller Interface is the communication protocol between an * The NFC Controller Interface is the communication protocol between an
* NFC Controller (NFCC) and a Device Host (DH). * NFC Controller (NFCC) and a Device Host (DH).
* *
* Copyright (C) 2014 Marvell International Ltd.
* Copyright (C) 2011 Texas Instruments, Inc. * Copyright (C) 2011 Texas Instruments, Inc.
* *
* Written by Ilan Elias <ilane@ti.com> * 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,6 +156,17 @@ static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,
return data; return data;
} }
static __u8 *nci_extract_rf_params_nfcv_passive_poll(struct nci_dev *ndev,
struct rf_tech_specific_params_nfcv_poll *nfcv_poll,
__u8 *data)
{
++data;
nfcv_poll->dsfid = *data++;
memcpy(nfcv_poll->uid, data, NFC_ISO15693_UID_MAXSIZE);
data += NFC_ISO15693_UID_MAXSIZE;
return data;
}
static int nci_add_new_protocol(struct nci_dev *ndev, static int nci_add_new_protocol(struct nci_dev *ndev,
struct nfc_target *target, struct nfc_target *target,
__u8 rf_protocol, __u8 rf_protocol,
...@@ -164,6 +176,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, ...@@ -164,6 +176,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
struct rf_tech_specific_params_nfca_poll *nfca_poll; struct rf_tech_specific_params_nfca_poll *nfca_poll;
struct rf_tech_specific_params_nfcb_poll *nfcb_poll; struct rf_tech_specific_params_nfcb_poll *nfcb_poll;
struct rf_tech_specific_params_nfcf_poll *nfcf_poll; struct rf_tech_specific_params_nfcf_poll *nfcf_poll;
struct rf_tech_specific_params_nfcv_poll *nfcv_poll;
__u32 protocol; __u32 protocol;
if (rf_protocol == NCI_RF_PROTOCOL_T1T) if (rf_protocol == NCI_RF_PROTOCOL_T1T)
...@@ -179,6 +192,8 @@ static int nci_add_new_protocol(struct nci_dev *ndev, ...@@ -179,6 +192,8 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
protocol = NFC_PROTO_FELICA_MASK; protocol = NFC_PROTO_FELICA_MASK;
else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP)
protocol = NFC_PROTO_NFC_DEP_MASK; protocol = NFC_PROTO_NFC_DEP_MASK;
else if (rf_protocol == NCI_RF_PROTOCOL_T5T)
protocol = NFC_PROTO_ISO15693_MASK;
else else
protocol = 0; protocol = 0;
...@@ -213,6 +228,12 @@ static int nci_add_new_protocol(struct nci_dev *ndev, ...@@ -213,6 +228,12 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
memcpy(target->sensf_res, nfcf_poll->sensf_res, memcpy(target->sensf_res, nfcf_poll->sensf_res,
target->sensf_res_len); target->sensf_res_len);
} }
} else if (rf_tech_and_mode == NCI_NFC_V_PASSIVE_POLL_MODE) {
nfcv_poll = (struct rf_tech_specific_params_nfcv_poll *)params;
target->is_iso15693 = 1;
target->iso15693_dsfid = nfcv_poll->dsfid;
memcpy(target->iso15693_uid, nfcv_poll->uid, NFC_ISO15693_UID_MAXSIZE);
} else { } else {
pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
return -EPROTO; return -EPROTO;
...@@ -305,6 +326,11 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, ...@@ -305,6 +326,11 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
&(ntf.rf_tech_specific_params.nfcf_poll), data); &(ntf.rf_tech_specific_params.nfcf_poll), data);
break; break;
case NCI_NFC_V_PASSIVE_POLL_MODE:
data = nci_extract_rf_params_nfcv_passive_poll(ndev,
&(ntf.rf_tech_specific_params.nfcv_poll), data);
break;
default: default:
pr_err("unsupported rf_tech_and_mode 0x%x\n", pr_err("unsupported rf_tech_and_mode 0x%x\n",
ntf.rf_tech_and_mode); ntf.rf_tech_and_mode);
...@@ -455,6 +481,11 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, ...@@ -455,6 +481,11 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
&(ntf.rf_tech_specific_params.nfcf_poll), data); &(ntf.rf_tech_specific_params.nfcf_poll), data);
break; break;
case NCI_NFC_V_PASSIVE_POLL_MODE:
data = nci_extract_rf_params_nfcv_passive_poll(ndev,
&(ntf.rf_tech_specific_params.nfcv_poll), data);
break;
default: default:
pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
ntf.activation_rf_tech_and_mode); ntf.activation_rf_tech_and_mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment