NFC: Add ISO 14443 type B protocol
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 3 Jul 2012 22:14:04 +0000 (00:14 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 9 Jul 2012 20:42:24 +0000 (16:42 -0400)
Some devices (e.g. Sony's PaSoRi) can not do type B polling, so we have
to make a distinction between ISO14443 type A and B poll modes.

Cc: Eric Lapuyade <eric.lapuyade@intel.com>
Cc: Ilan Elias <ilane@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/nfcwilink.c
drivers/nfc/pn533.c
drivers/nfc/pn544_hci.c
include/linux/nfc.h
net/nfc/hci/core.c
net/nfc/nci/core.c
net/nfc/nci/ntf.c

index 1f74a77d040df4c5b9b93589cf786c4deea12c4d..e7fd4938f9bc2e36191de06f38fa30fd807eb307 100644 (file)
@@ -535,9 +535,10 @@ static int nfcwilink_probe(struct platform_device *pdev)
        drv->pdev = pdev;
 
        protocols = NFC_PROTO_JEWEL_MASK
-                       | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK
-                       | NFC_PROTO_ISO14443_MASK
-                       | NFC_PROTO_NFC_DEP_MASK;
+               | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK
+               | NFC_PROTO_ISO14443_MASK
+               | NFC_PROTO_ISO14443_B_MASK
+               | NFC_PROTO_NFC_DEP_MASK;
 
        drv->ndev = nci_allocate_device(&nfcwilink_ops,
                                        protocols,
index 84d8175db8183e298512f619576fe310dd1a22d2..d606f52fec842d5a613cff3f63719a97827178b4 100644 (file)
 #define PN533_DEVICE_STD    0x1
 #define PN533_DEVICE_PASORI 0x2
 
-#define PN533_ALL_PROTOCOLS (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK \
-                            | NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK \
-                            | NFC_PROTO_NFC_DEP_MASK)
+#define PN533_ALL_PROTOCOLS (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK |\
+                            NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK |\
+                            NFC_PROTO_NFC_DEP_MASK |\
+                            NFC_PROTO_ISO14443_B_MASK)
 
 #define PN533_NO_TYPE_B_PROTOCOLS (NFC_PROTO_JEWEL_MASK | \
                                   NFC_PROTO_MIFARE_MASK | \
                                   NFC_PROTO_FELICA_MASK | \
+                                  NFC_PROTO_ISO14443_MASK | \
                                   NFC_PROTO_NFC_DEP_MASK)
 
 static const struct usb_device_id pn533_table[] = {
@@ -987,7 +989,7 @@ static int pn533_target_found_type_b(struct nfc_target *nfc_tgt, u8 *tgt_data,
        if (!pn533_target_type_b_is_valid(tgt_type_b, tgt_data_len))
                return -EPROTO;
 
-       nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK;
+       nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_B_MASK;
 
        return 0;
 }
@@ -1094,7 +1096,7 @@ static void pn533_poll_create_mod_list(struct pn533 *dev,
        if (im_protocols & NFC_PROTO_JEWEL_MASK)
                pn533_poll_add_mod(dev, PN533_POLL_MOD_106KBPS_JEWEL);
 
-       if (im_protocols & NFC_PROTO_ISO14443_MASK)
+       if (im_protocols & NFC_PROTO_ISO14443_B_MASK)
                pn533_poll_add_mod(dev, PN533_POLL_MOD_847KBPS_B);
 
        if (tm_protocols)
index c67b55e224e0b10fc3eea740ba95968bb639de98..aa71807189ba3235a0720fc1660049507bf19039 100644 (file)
@@ -869,6 +869,7 @@ static int __devinit pn544_hci_probe(struct i2c_client *client,
                    NFC_PROTO_MIFARE_MASK |
                    NFC_PROTO_FELICA_MASK |
                    NFC_PROTO_ISO14443_MASK |
+                   NFC_PROTO_ISO14443_B_MASK |
                    NFC_PROTO_NFC_DEP_MASK;
 
        info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops,
index f4e6dd915b1c63c8c9d3bbf62ab545909d13ccd8..6189f27e305b551a3d47bbbc8d9935041917e246 100644 (file)
@@ -136,8 +136,9 @@ enum nfc_attrs {
 #define NFC_PROTO_FELICA       3
 #define NFC_PROTO_ISO14443     4
 #define NFC_PROTO_NFC_DEP      5
+#define NFC_PROTO_ISO14443_B   6
 
-#define NFC_PROTO_MAX          6
+#define NFC_PROTO_MAX          7
 
 /* NFC communication modes */
 #define NFC_COMM_ACTIVE  0
@@ -149,11 +150,12 @@ enum nfc_attrs {
 #define NFC_RF_NONE      2
 
 /* NFC protocols masks used in bitsets */
-#define NFC_PROTO_JEWEL_MASK   (1 << NFC_PROTO_JEWEL)
-#define NFC_PROTO_MIFARE_MASK  (1 << NFC_PROTO_MIFARE)
-#define NFC_PROTO_FELICA_MASK  (1 << NFC_PROTO_FELICA)
-#define NFC_PROTO_ISO14443_MASK        (1 << NFC_PROTO_ISO14443)
-#define NFC_PROTO_NFC_DEP_MASK (1 << NFC_PROTO_NFC_DEP)
+#define NFC_PROTO_JEWEL_MASK      (1 << NFC_PROTO_JEWEL)
+#define NFC_PROTO_MIFARE_MASK     (1 << NFC_PROTO_MIFARE)
+#define NFC_PROTO_FELICA_MASK    (1 << NFC_PROTO_FELICA)
+#define NFC_PROTO_ISO14443_MASK          (1 << NFC_PROTO_ISO14443)
+#define NFC_PROTO_NFC_DEP_MASK   (1 << NFC_PROTO_NFC_DEP)
+#define NFC_PROTO_ISO14443_B_MASK (1 << NFC_PROTO_ISO14443_B)
 
 struct sockaddr_nfc {
        sa_family_t sa_family;
index 4ccc518f56ebf8f69b9ac718ada0dd7c16347dc3..36717cebfbb6d4b1938e79b3a06f7f5e7038fab9 100644 (file)
@@ -230,7 +230,7 @@ static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate)
                }
                break;
        case NFC_HCI_RF_READER_B_GATE:
-               targets->supported_protocols = NFC_PROTO_ISO14443_MASK;
+               targets->supported_protocols = NFC_PROTO_ISO14443_B_MASK;
                break;
        default:
                if (hdev->ops->target_from_gate)
index 766a02b1dfa148fb521cc120f07623c00ac88e60..5bb4da6804271efe61ce7a8451fa73e0daed4cff 100644 (file)
@@ -194,7 +194,7 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
        }
 
        if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
-           (protocols & NFC_PROTO_ISO14443_MASK)) {
+           (protocols & NFC_PROTO_ISO14443_B_MASK)) {
                cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
                        NCI_NFC_B_PASSIVE_POLL_MODE;
                cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
@@ -486,7 +486,8 @@ static int nci_activate_target(struct nfc_dev *nfc_dev,
                        param.rf_protocol = NCI_RF_PROTOCOL_T2T;
                else if (protocol == NFC_PROTO_FELICA)
                        param.rf_protocol = NCI_RF_PROTOCOL_T3T;
-               else if (protocol == NFC_PROTO_ISO14443)
+               else if (protocol == NFC_PROTO_ISO14443 ||
+                        protocol == NFC_PROTO_ISO14443_B)
                        param.rf_protocol = NCI_RF_PROTOCOL_ISO_DEP;
                else
                        param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP;
index 2ab196a9f228ac873238c2a060685bacea62b87a..af7a93b04393a1ff3cbc088390f4972592dd3b1c 100644 (file)
@@ -170,7 +170,10 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
        if (rf_protocol == NCI_RF_PROTOCOL_T2T)
                protocol = NFC_PROTO_MIFARE_MASK;
        else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP)
-               protocol = NFC_PROTO_ISO14443_MASK;
+               if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE)
+                       protocol = NFC_PROTO_ISO14443_MASK;
+               else
+                       protocol = NFC_PROTO_ISO14443_B_MASK;
        else if (rf_protocol == NCI_RF_PROTOCOL_T3T)
                protocol = NFC_PROTO_FELICA_MASK;
        else