NFC: NCI: Add passive Listen modes in discover request

The Target mode protocols are given to the nci_start_poll() function
but were previously ignored.
To enable P2P Target, when NFC-DEP is requested as a Target mode protocol, add
NFC-A and NFC-F Passive Listen modes in RF_DISCOVER_CMD command.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Julien Lefrique 2014-10-21 16:52:44 +02:00 committed by Samuel Ortiz
parent 413df10bbf
commit 772dccf4a7

View File

@ -3,6 +3,7 @@
* NFC Controller (NFCC) and a Device Host (DH). * NFC Controller (NFCC) and a Device Host (DH).
* *
* Copyright (C) 2011 Texas Instruments, Inc. * Copyright (C) 2011 Texas Instruments, Inc.
* Copyright (C) 2014 Marvell International Ltd.
* *
* Written by Ilan Elias <ilane@ti.com> * Written by Ilan Elias <ilane@ti.com>
* *
@ -196,18 +197,24 @@ static void nci_set_config_req(struct nci_dev *ndev, unsigned long opt)
nci_send_cmd(ndev, NCI_OP_CORE_SET_CONFIG_CMD, (3 + param->len), &cmd); nci_send_cmd(ndev, NCI_OP_CORE_SET_CONFIG_CMD, (3 + param->len), &cmd);
} }
struct nci_rf_discover_param {
__u32 im_protocols;
__u32 tm_protocols;
};
static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
{ {
struct nci_rf_discover_param *param =
(struct nci_rf_discover_param *)opt;
struct nci_rf_disc_cmd cmd; struct nci_rf_disc_cmd cmd;
__u32 protocols = opt;
cmd.num_disc_configs = 0; cmd.num_disc_configs = 0;
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
(protocols & NFC_PROTO_JEWEL_MASK || (param->im_protocols & NFC_PROTO_JEWEL_MASK ||
protocols & NFC_PROTO_MIFARE_MASK || param->im_protocols & NFC_PROTO_MIFARE_MASK ||
protocols & NFC_PROTO_ISO14443_MASK || param->im_protocols & NFC_PROTO_ISO14443_MASK ||
protocols & NFC_PROTO_NFC_DEP_MASK)) { param->im_protocols & NFC_PROTO_NFC_DEP_MASK)) {
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_A_PASSIVE_POLL_MODE; NCI_NFC_A_PASSIVE_POLL_MODE;
cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
@ -215,7 +222,7 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
} }
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
(protocols & NFC_PROTO_ISO14443_B_MASK)) { (param->im_protocols & NFC_PROTO_ISO14443_B_MASK)) {
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_B_PASSIVE_POLL_MODE; NCI_NFC_B_PASSIVE_POLL_MODE;
cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
@ -223,8 +230,8 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
} }
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
(protocols & NFC_PROTO_FELICA_MASK || (param->im_protocols & NFC_PROTO_FELICA_MASK ||
protocols & NFC_PROTO_NFC_DEP_MASK)) { param->im_protocols & NFC_PROTO_NFC_DEP_MASK)) {
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_F_PASSIVE_POLL_MODE; NCI_NFC_F_PASSIVE_POLL_MODE;
cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
@ -232,13 +239,25 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
} }
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
(protocols & NFC_PROTO_ISO15693_MASK)) { (param->im_protocols & NFC_PROTO_ISO15693_MASK)) {
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_V_PASSIVE_POLL_MODE; NCI_NFC_V_PASSIVE_POLL_MODE;
cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
cmd.num_disc_configs++; cmd.num_disc_configs++;
} }
if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS - 1) &&
(param->tm_protocols & NFC_PROTO_NFC_DEP_MASK)) {
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_A_PASSIVE_LISTEN_MODE;
cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
cmd.num_disc_configs++;
cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
NCI_NFC_F_PASSIVE_LISTEN_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);
@ -459,6 +478,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev,
__u32 im_protocols, __u32 tm_protocols) __u32 im_protocols, __u32 tm_protocols)
{ {
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
struct nci_rf_discover_param param;
int rc; int rc;
if ((atomic_read(&ndev->state) == NCI_DISCOVERY) || if ((atomic_read(&ndev->state) == NCI_DISCOVERY) ||
@ -490,7 +510,9 @@ static int nci_start_poll(struct nfc_dev *nfc_dev,
} }
} }
rc = nci_request(ndev, nci_rf_discover_req, im_protocols, param.im_protocols = im_protocols;
param.tm_protocols = tm_protocols;
rc = nci_request(ndev, nci_rf_discover_req, (unsigned long)&param,
msecs_to_jiffies(NCI_RF_DISC_TIMEOUT)); msecs_to_jiffies(NCI_RF_DISC_TIMEOUT));
if (!rc) if (!rc)