aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorArron Wang <arron.wang@intel.com>2012-09-27 05:32:54 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-26 12:26:45 -0400
commit7e2afc9d072b9f84b314b208a125c2b1ce36b685 (patch)
tree971d9da17a072fbfcf87c4d844294e51154430da /drivers/nfc
parent9b34f40c20111ba658f88e1669598db494be1fbc (diff)
NFC: Set local gb and DEP registries
Set the local general bytes and default value for NFCIP1 Target/Initiator registries if the protocol is NFC-DEP Signed-off-by: Arron Wang <arron.wang@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn544_hci.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/nfc/pn544_hci.c b/drivers/nfc/pn544_hci.c
index c9c8570273ab..8b21a8efd751 100644
--- a/drivers/nfc/pn544_hci.c
+++ b/drivers/nfc/pn544_hci.c
@@ -100,6 +100,10 @@ enum pn544_state {
100#define PN544_SYS_MGMT_INFO_NOTIFICATION 0x02 100#define PN544_SYS_MGMT_INFO_NOTIFICATION 0x02
101 101
102#define PN544_POLLING_LOOP_MGMT_GATE 0x94 102#define PN544_POLLING_LOOP_MGMT_GATE 0x94
103#define PN544_DEP_MODE 0x01
104#define PN544_DEP_ATR_REQ 0x02
105#define PN544_DEP_ATR_RES 0x03
106#define PN544_DEP_MERGE 0x0D
103#define PN544_PL_RDPHASES 0x06 107#define PN544_PL_RDPHASES 0x06
104#define PN544_PL_EMULATION 0x07 108#define PN544_PL_EMULATION 0x07
105#define PN544_PL_NFCT_DEACTIVATED 0x09 109#define PN544_PL_NFCT_DEACTIVATED 0x09
@@ -630,6 +634,9 @@ static int pn544_hci_start_poll(struct nfc_hci_dev *hdev,
630 int r; 634 int r;
631 u8 duration[2]; 635 u8 duration[2];
632 u8 activated; 636 u8 activated;
637 u8 i_mode = 0x3f; /* Enable all supported modes */
638 u8 t_mode = 0x0f;
639 u8 t_merge = 0x01; /* Enable merge by default */
633 640
634 pr_info(DRIVER_DESC ": %s protocols 0x%x 0x%x\n", 641 pr_info(DRIVER_DESC ": %s protocols 0x%x 0x%x\n",
635 __func__, im_protocols, tm_protocols); 642 __func__, im_protocols, tm_protocols);
@@ -667,6 +674,61 @@ static int pn544_hci_start_poll(struct nfc_hci_dev *hdev,
667 if (r < 0) 674 if (r < 0)
668 return r; 675 return r;
669 676
677 if ((im_protocols | tm_protocols) & NFC_PROTO_NFC_DEP_MASK) {
678 hdev->gb = nfc_get_local_general_bytes(hdev->ndev,
679 &hdev->gb_len);
680 pr_debug("generate local bytes %p", hdev->gb);
681 if (hdev->gb == NULL || hdev->gb_len == 0) {
682 im_protocols &= ~NFC_PROTO_NFC_DEP_MASK;
683 tm_protocols &= ~NFC_PROTO_NFC_DEP_MASK;
684 }
685 }
686
687 if (im_protocols & NFC_PROTO_NFC_DEP_MASK) {
688 r = nfc_hci_send_event(hdev,
689 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
690 NFC_HCI_EVT_END_OPERATION, NULL, 0);
691 if (r < 0)
692 return r;
693
694 r = nfc_hci_set_param(hdev,
695 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
696 PN544_DEP_MODE, &i_mode, 1);
697 if (r < 0)
698 return r;
699
700 r = nfc_hci_set_param(hdev,
701 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
702 PN544_DEP_ATR_REQ, hdev->gb, hdev->gb_len);
703 if (r < 0)
704 return r;
705
706 r = nfc_hci_send_event(hdev,
707 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
708 NFC_HCI_EVT_READER_REQUESTED, NULL, 0);
709 if (r < 0)
710 nfc_hci_send_event(hdev,
711 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
712 NFC_HCI_EVT_END_OPERATION, NULL, 0);
713 }
714
715 if (tm_protocols & NFC_PROTO_NFC_DEP_MASK) {
716 r = nfc_hci_set_param(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
717 PN544_DEP_MODE, &t_mode, 1);
718 if (r < 0)
719 return r;
720
721 r = nfc_hci_set_param(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
722 PN544_DEP_ATR_RES, hdev->gb, hdev->gb_len);
723 if (r < 0)
724 return r;
725
726 r = nfc_hci_set_param(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
727 PN544_DEP_MERGE, &t_merge, 1);
728 if (r < 0)
729 return r;
730 }
731
670 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, 732 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
671 NFC_HCI_EVT_READER_REQUESTED, NULL, 0); 733 NFC_HCI_EVT_READER_REQUESTED, NULL, 0);
672 if (r < 0) 734 if (r < 0)