aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-05-15 09:57:06 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-06-04 15:34:29 -0400
commitfe7c580073280c15bb4eb4f82bf20dddc1a68383 (patch)
tree0b71c488d1b3cdd87dd5e05ccd0224b496fec2f9 /drivers/nfc
parentab73b751303bc60d7d9fba875c958dedfe14754c (diff)
NFC: Add target mode protocols to the polling loop startup routine
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c39
-rw-r--r--drivers/nfc/pn544_hci.c10
2 files changed, 35 insertions, 14 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 19110f0eb15f..38a523c62132 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -1078,27 +1078,23 @@ stop_poll:
1078 return 0; 1078 return 0;
1079} 1079}
1080 1080
1081static int pn533_start_poll(struct nfc_dev *nfc_dev, u32 protocols) 1081static int pn533_init_target(struct nfc_dev *nfc_dev, u32 protocols)
1082{
1083 return 0;
1084}
1085
1086static int pn533_start_im_poll(struct nfc_dev *nfc_dev, u32 protocols)
1082{ 1087{
1083 struct pn533 *dev = nfc_get_drvdata(nfc_dev); 1088 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
1084 struct pn533_poll_modulations *start_mod; 1089 struct pn533_poll_modulations *start_mod;
1085 int rc; 1090 int rc;
1086 1091
1087 nfc_dev_dbg(&dev->interface->dev, "%s - protocols=0x%x", __func__,
1088 protocols);
1089
1090 if (dev->poll_mod_count) { 1092 if (dev->poll_mod_count) {
1091 nfc_dev_err(&dev->interface->dev, "Polling operation already" 1093 nfc_dev_err(&dev->interface->dev, "Polling operation already"
1092 " active"); 1094 " active");
1093 return -EBUSY; 1095 return -EBUSY;
1094 } 1096 }
1095 1097
1096 if (dev->tgt_active_prot) {
1097 nfc_dev_err(&dev->interface->dev, "Cannot poll with a target"
1098 " already activated");
1099 return -EBUSY;
1100 }
1101
1102 pn533_poll_create_mod_list(dev, protocols); 1098 pn533_poll_create_mod_list(dev, protocols);
1103 1099
1104 if (!dev->poll_mod_count) { 1100 if (!dev->poll_mod_count) {
@@ -1135,6 +1131,29 @@ error:
1135 return rc; 1131 return rc;
1136} 1132}
1137 1133
1134static int pn533_start_poll(struct nfc_dev *nfc_dev,
1135 u32 im_protocols, u32 tm_protocols)
1136{
1137 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
1138
1139 nfc_dev_dbg(&dev->interface->dev,
1140 "%s: im protocols 0x%x tm protocols 0x%x",
1141 __func__, im_protocols, tm_protocols);
1142
1143 if (dev->tgt_active_prot) {
1144 nfc_dev_err(&dev->interface->dev,
1145 "Cannot poll with a target already activated");
1146 return -EBUSY;
1147 }
1148
1149 if (!tm_protocols)
1150 return pn533_start_im_poll(nfc_dev, im_protocols);
1151 else if (!im_protocols)
1152 return pn533_init_target(nfc_dev, tm_protocols);
1153 else
1154 return -EINVAL;
1155}
1156
1138static void pn533_stop_poll(struct nfc_dev *nfc_dev) 1157static void pn533_stop_poll(struct nfc_dev *nfc_dev)
1139{ 1158{
1140 struct pn533 *dev = nfc_get_drvdata(nfc_dev); 1159 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
diff --git a/drivers/nfc/pn544_hci.c b/drivers/nfc/pn544_hci.c
index 281f18c2fb82..457eac35dc74 100644
--- a/drivers/nfc/pn544_hci.c
+++ b/drivers/nfc/pn544_hci.c
@@ -576,7 +576,8 @@ static int pn544_hci_xmit(struct nfc_shdlc *shdlc, struct sk_buff *skb)
576 return pn544_hci_i2c_write(client, skb->data, skb->len); 576 return pn544_hci_i2c_write(client, skb->data, skb->len);
577} 577}
578 578
579static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, u32 protocols) 579static int pn544_hci_start_poll(struct nfc_shdlc *shdlc,
580 u32 im_protocols, u32 tm_protocols)
580{ 581{
581 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc); 582 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
582 u8 phases = 0; 583 u8 phases = 0;
@@ -584,7 +585,8 @@ static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, u32 protocols)
584 u8 duration[2]; 585 u8 duration[2];
585 u8 activated; 586 u8 activated;
586 587
587 pr_info(DRIVER_DESC ": %s protocols = %d\n", __func__, protocols); 588 pr_info(DRIVER_DESC ": %s protocols 0x%x 0x%x\n",
589 __func__, im_protocols, tm_protocols);
588 590
589 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, 591 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
590 NFC_HCI_EVT_END_OPERATION, NULL, 0); 592 NFC_HCI_EVT_END_OPERATION, NULL, 0);
@@ -604,10 +606,10 @@ static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, u32 protocols)
604 if (r < 0) 606 if (r < 0)
605 return r; 607 return r;
606 608
607 if (protocols & (NFC_PROTO_ISO14443_MASK | NFC_PROTO_MIFARE_MASK | 609 if (im_protocols & (NFC_PROTO_ISO14443_MASK | NFC_PROTO_MIFARE_MASK |
608 NFC_PROTO_JEWEL_MASK)) 610 NFC_PROTO_JEWEL_MASK))
609 phases |= 1; /* Type A */ 611 phases |= 1; /* Type A */
610 if (protocols & NFC_PROTO_FELICA_MASK) { 612 if (im_protocols & NFC_PROTO_FELICA_MASK) {
611 phases |= (1 << 2); /* Type F 212 */ 613 phases |= (1 << 2); /* Type F 212 */
612 phases |= (1 << 3); /* Type F 424 */ 614 phases |= (1 << 3); /* Type F 424 */
613 } 615 }