aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/nci
diff options
context:
space:
mode:
authorJulien Lefrique <lefrique@marvell.com>2014-10-21 10:52:44 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2014-11-28 08:07:51 -0500
commit772dccf4a73bdb51a7628263a42347973a06a295 (patch)
tree6794a8ced9dc38df0031fb084afc92fc4b21a983 /net/nfc/nci
parent413df10bbf09e8ab1e2659126af849b4c9f3a3e3 (diff)
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>
Diffstat (limited to 'net/nfc/nci')
-rw-r--r--net/nfc/nci/core.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 90b16cb40058..d376e4abe0f2 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -3,6 +3,7 @@
3 * NFC Controller (NFCC) and a Device Host (DH). 3 * NFC Controller (NFCC) and a Device Host (DH).
4 * 4 *
5 * Copyright (C) 2011 Texas Instruments, Inc. 5 * Copyright (C) 2011 Texas Instruments, Inc.
6 * Copyright (C) 2014 Marvell International Ltd.
6 * 7 *
7 * Written by Ilan Elias <ilane@ti.com> 8 * Written by Ilan Elias <ilane@ti.com>
8 * 9 *
@@ -196,18 +197,24 @@ static void nci_set_config_req(struct nci_dev *ndev, unsigned long opt)
196 nci_send_cmd(ndev, NCI_OP_CORE_SET_CONFIG_CMD, (3 + param->len), &cmd); 197 nci_send_cmd(ndev, NCI_OP_CORE_SET_CONFIG_CMD, (3 + param->len), &cmd);
197} 198}
198 199
200struct nci_rf_discover_param {
201 __u32 im_protocols;
202 __u32 tm_protocols;
203};
204
199static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) 205static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
200{ 206{
207 struct nci_rf_discover_param *param =
208 (struct nci_rf_discover_param *)opt;
201 struct nci_rf_disc_cmd cmd; 209 struct nci_rf_disc_cmd cmd;
202 __u32 protocols = opt;
203 210
204 cmd.num_disc_configs = 0; 211 cmd.num_disc_configs = 0;
205 212
206 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && 213 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
207 (protocols & NFC_PROTO_JEWEL_MASK || 214 (param->im_protocols & NFC_PROTO_JEWEL_MASK ||
208 protocols & NFC_PROTO_MIFARE_MASK || 215 param->im_protocols & NFC_PROTO_MIFARE_MASK ||
209 protocols & NFC_PROTO_ISO14443_MASK || 216 param->im_protocols & NFC_PROTO_ISO14443_MASK ||
210 protocols & NFC_PROTO_NFC_DEP_MASK)) { 217 param->im_protocols & NFC_PROTO_NFC_DEP_MASK)) {
211 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = 218 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
212 NCI_NFC_A_PASSIVE_POLL_MODE; 219 NCI_NFC_A_PASSIVE_POLL_MODE;
213 cmd.disc_configs[cmd.num_disc_configs].frequency = 1; 220 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)
215 } 222 }
216 223
217 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && 224 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
218 (protocols & NFC_PROTO_ISO14443_B_MASK)) { 225 (param->im_protocols & NFC_PROTO_ISO14443_B_MASK)) {
219 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = 226 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
220 NCI_NFC_B_PASSIVE_POLL_MODE; 227 NCI_NFC_B_PASSIVE_POLL_MODE;
221 cmd.disc_configs[cmd.num_disc_configs].frequency = 1; 228 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)
223 } 230 }
224 231
225 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && 232 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
226 (protocols & NFC_PROTO_FELICA_MASK || 233 (param->im_protocols & NFC_PROTO_FELICA_MASK ||
227 protocols & NFC_PROTO_NFC_DEP_MASK)) { 234 param->im_protocols & NFC_PROTO_NFC_DEP_MASK)) {
228 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = 235 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
229 NCI_NFC_F_PASSIVE_POLL_MODE; 236 NCI_NFC_F_PASSIVE_POLL_MODE;
230 cmd.disc_configs[cmd.num_disc_configs].frequency = 1; 237 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)
232 } 239 }
233 240
234 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && 241 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
235 (protocols & NFC_PROTO_ISO15693_MASK)) { 242 (param->im_protocols & NFC_PROTO_ISO15693_MASK)) {
236 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = 243 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
237 NCI_NFC_V_PASSIVE_POLL_MODE; 244 NCI_NFC_V_PASSIVE_POLL_MODE;
238 cmd.disc_configs[cmd.num_disc_configs].frequency = 1; 245 cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
239 cmd.num_disc_configs++; 246 cmd.num_disc_configs++;
240 } 247 }
241 248
249 if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS - 1) &&
250 (param->tm_protocols & NFC_PROTO_NFC_DEP_MASK)) {
251 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
252 NCI_NFC_A_PASSIVE_LISTEN_MODE;
253 cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
254 cmd.num_disc_configs++;
255 cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
256 NCI_NFC_F_PASSIVE_LISTEN_MODE;
257 cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
258 cmd.num_disc_configs++;
259 }
260
242 nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, 261 nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD,
243 (1 + (cmd.num_disc_configs * sizeof(struct disc_config))), 262 (1 + (cmd.num_disc_configs * sizeof(struct disc_config))),
244 &cmd); 263 &cmd);
@@ -459,6 +478,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev,
459 __u32 im_protocols, __u32 tm_protocols) 478 __u32 im_protocols, __u32 tm_protocols)
460{ 479{
461 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 480 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
481 struct nci_rf_discover_param param;
462 int rc; 482 int rc;
463 483
464 if ((atomic_read(&ndev->state) == NCI_DISCOVERY) || 484 if ((atomic_read(&ndev->state) == NCI_DISCOVERY) ||
@@ -490,7 +510,9 @@ static int nci_start_poll(struct nfc_dev *nfc_dev,
490 } 510 }
491 } 511 }
492 512
493 rc = nci_request(ndev, nci_rf_discover_req, im_protocols, 513 param.im_protocols = im_protocols;
514 param.tm_protocols = tm_protocols;
515 rc = nci_request(ndev, nci_rf_discover_req, (unsigned long)&param,
494 msecs_to_jiffies(NCI_RF_DISC_TIMEOUT)); 516 msecs_to_jiffies(NCI_RF_DISC_TIMEOUT));
495 517
496 if (!rc) 518 if (!rc)