Commit 01d719a2 authored by Samuel Ortiz's avatar Samuel Ortiz Committed by John W. Linville

NFC: Add ISO 14443 type B protocol

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: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent a1fbbf18
...@@ -535,9 +535,10 @@ static int nfcwilink_probe(struct platform_device *pdev) ...@@ -535,9 +535,10 @@ static int nfcwilink_probe(struct platform_device *pdev)
drv->pdev = pdev; drv->pdev = pdev;
protocols = NFC_PROTO_JEWEL_MASK protocols = NFC_PROTO_JEWEL_MASK
| NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK
| NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_MASK
| NFC_PROTO_NFC_DEP_MASK; | NFC_PROTO_ISO14443_B_MASK
| NFC_PROTO_NFC_DEP_MASK;
drv->ndev = nci_allocate_device(&nfcwilink_ops, drv->ndev = nci_allocate_device(&nfcwilink_ops,
protocols, protocols,
......
...@@ -49,13 +49,15 @@ ...@@ -49,13 +49,15 @@
#define PN533_DEVICE_STD 0x1 #define PN533_DEVICE_STD 0x1
#define PN533_DEVICE_PASORI 0x2 #define PN533_DEVICE_PASORI 0x2
#define PN533_ALL_PROTOCOLS (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK \ #define PN533_ALL_PROTOCOLS (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK |\
| NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK \ NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK |\
| NFC_PROTO_NFC_DEP_MASK) NFC_PROTO_NFC_DEP_MASK |\
NFC_PROTO_ISO14443_B_MASK)
#define PN533_NO_TYPE_B_PROTOCOLS (NFC_PROTO_JEWEL_MASK | \ #define PN533_NO_TYPE_B_PROTOCOLS (NFC_PROTO_JEWEL_MASK | \
NFC_PROTO_MIFARE_MASK | \ NFC_PROTO_MIFARE_MASK | \
NFC_PROTO_FELICA_MASK | \ NFC_PROTO_FELICA_MASK | \
NFC_PROTO_ISO14443_MASK | \
NFC_PROTO_NFC_DEP_MASK) NFC_PROTO_NFC_DEP_MASK)
static const struct usb_device_id pn533_table[] = { 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, ...@@ -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)) if (!pn533_target_type_b_is_valid(tgt_type_b, tgt_data_len))
return -EPROTO; return -EPROTO;
nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK; nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_B_MASK;
return 0; return 0;
} }
...@@ -1094,7 +1096,7 @@ static void pn533_poll_create_mod_list(struct pn533 *dev, ...@@ -1094,7 +1096,7 @@ static void pn533_poll_create_mod_list(struct pn533 *dev,
if (im_protocols & NFC_PROTO_JEWEL_MASK) if (im_protocols & NFC_PROTO_JEWEL_MASK)
pn533_poll_add_mod(dev, PN533_POLL_MOD_106KBPS_JEWEL); 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); pn533_poll_add_mod(dev, PN533_POLL_MOD_847KBPS_B);
if (tm_protocols) if (tm_protocols)
......
...@@ -869,6 +869,7 @@ static int __devinit pn544_hci_probe(struct i2c_client *client, ...@@ -869,6 +869,7 @@ static int __devinit pn544_hci_probe(struct i2c_client *client,
NFC_PROTO_MIFARE_MASK | NFC_PROTO_MIFARE_MASK |
NFC_PROTO_FELICA_MASK | NFC_PROTO_FELICA_MASK |
NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_MASK |
NFC_PROTO_ISO14443_B_MASK |
NFC_PROTO_NFC_DEP_MASK; NFC_PROTO_NFC_DEP_MASK;
info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops, info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops,
......
...@@ -136,8 +136,9 @@ enum nfc_attrs { ...@@ -136,8 +136,9 @@ enum nfc_attrs {
#define NFC_PROTO_FELICA 3 #define NFC_PROTO_FELICA 3
#define NFC_PROTO_ISO14443 4 #define NFC_PROTO_ISO14443 4
#define NFC_PROTO_NFC_DEP 5 #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 */ /* NFC communication modes */
#define NFC_COMM_ACTIVE 0 #define NFC_COMM_ACTIVE 0
...@@ -149,11 +150,12 @@ enum nfc_attrs { ...@@ -149,11 +150,12 @@ enum nfc_attrs {
#define NFC_RF_NONE 2 #define NFC_RF_NONE 2
/* NFC protocols masks used in bitsets */ /* NFC protocols masks used in bitsets */
#define NFC_PROTO_JEWEL_MASK (1 << NFC_PROTO_JEWEL) #define NFC_PROTO_JEWEL_MASK (1 << NFC_PROTO_JEWEL)
#define NFC_PROTO_MIFARE_MASK (1 << NFC_PROTO_MIFARE) #define NFC_PROTO_MIFARE_MASK (1 << NFC_PROTO_MIFARE)
#define NFC_PROTO_FELICA_MASK (1 << NFC_PROTO_FELICA) #define NFC_PROTO_FELICA_MASK (1 << NFC_PROTO_FELICA)
#define NFC_PROTO_ISO14443_MASK (1 << NFC_PROTO_ISO14443) #define NFC_PROTO_ISO14443_MASK (1 << NFC_PROTO_ISO14443)
#define NFC_PROTO_NFC_DEP_MASK (1 << NFC_PROTO_NFC_DEP) #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 { struct sockaddr_nfc {
sa_family_t sa_family; sa_family_t sa_family;
......
...@@ -230,7 +230,7 @@ static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) ...@@ -230,7 +230,7 @@ static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate)
} }
break; break;
case NFC_HCI_RF_READER_B_GATE: case NFC_HCI_RF_READER_B_GATE:
targets->supported_protocols = NFC_PROTO_ISO14443_MASK; targets->supported_protocols = NFC_PROTO_ISO14443_B_MASK;
break; break;
default: default:
if (hdev->ops->target_from_gate) if (hdev->ops->target_from_gate)
......
...@@ -194,7 +194,7 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) ...@@ -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) && 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 = 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;
...@@ -486,7 +486,8 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, ...@@ -486,7 +486,8 @@ static int nci_activate_target(struct nfc_dev *nfc_dev,
param.rf_protocol = NCI_RF_PROTOCOL_T2T; param.rf_protocol = NCI_RF_PROTOCOL_T2T;
else if (protocol == NFC_PROTO_FELICA) else if (protocol == NFC_PROTO_FELICA)
param.rf_protocol = NCI_RF_PROTOCOL_T3T; 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; param.rf_protocol = NCI_RF_PROTOCOL_ISO_DEP;
else else
param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP; param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP;
......
...@@ -170,7 +170,10 @@ static int nci_add_new_protocol(struct nci_dev *ndev, ...@@ -170,7 +170,10 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
if (rf_protocol == NCI_RF_PROTOCOL_T2T) if (rf_protocol == NCI_RF_PROTOCOL_T2T)
protocol = NFC_PROTO_MIFARE_MASK; protocol = NFC_PROTO_MIFARE_MASK;
else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) 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) else if (rf_protocol == NCI_RF_PROTOCOL_T3T)
protocol = NFC_PROTO_FELICA_MASK; protocol = NFC_PROTO_FELICA_MASK;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment