aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-05-29 15:45:21 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-06-04 15:34:32 -0400
commitd7f3345d3af568394080890ca3136c4ea1021cba (patch)
tree3e610e64c8a5c68533052034220019414c6cd0e4 /drivers/nfc
parent34a85bfcfb84fe673833290ee071de0a10dd1cac (diff)
NFC: Add passive initiator data for pn533
When trying to enable a DEP link as a passive initiator, pn533 needs to provide the polling request command payload. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index d9763440b8e..806ab3da641 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -256,7 +256,7 @@ struct pn533_cmd_jump_dep {
256 u8 active; 256 u8 active;
257 u8 baud; 257 u8 baud;
258 u8 next; 258 u8 next;
259 u8 gt[]; 259 u8 data[];
260} __packed; 260} __packed;
261 261
262struct pn533_cmd_jump_dep_response { 262struct pn533_cmd_jump_dep_response {
@@ -1582,12 +1582,14 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1582 return 0; 1582 return 0;
1583} 1583}
1584 1584
1585#define PASSIVE_DATA_LEN 5
1585static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, 1586static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
1586 u8 comm_mode, u8* gb, size_t gb_len) 1587 u8 comm_mode, u8* gb, size_t gb_len)
1587{ 1588{
1588 struct pn533 *dev = nfc_get_drvdata(nfc_dev); 1589 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
1589 struct pn533_cmd_jump_dep *cmd; 1590 struct pn533_cmd_jump_dep *cmd;
1590 u8 cmd_len; 1591 u8 cmd_len, *data_ptr;
1592 u8 passive_data[PASSIVE_DATA_LEN] = {0x00, 0xff, 0xff, 0x00, 0x3};
1591 int rc; 1593 int rc;
1592 1594
1593 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 1595 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
@@ -1605,6 +1607,9 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
1605 } 1607 }
1606 1608
1607 cmd_len = sizeof(struct pn533_cmd_jump_dep) + gb_len; 1609 cmd_len = sizeof(struct pn533_cmd_jump_dep) + gb_len;
1610 if (comm_mode == NFC_COMM_PASSIVE)
1611 cmd_len += PASSIVE_DATA_LEN;
1612
1608 cmd = kzalloc(cmd_len, GFP_KERNEL); 1613 cmd = kzalloc(cmd_len, GFP_KERNEL);
1609 if (cmd == NULL) 1614 if (cmd == NULL)
1610 return -ENOMEM; 1615 return -ENOMEM;
@@ -1612,10 +1617,18 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
1612 pn533_tx_frame_init(dev->out_frame, PN533_CMD_IN_JUMP_FOR_DEP); 1617 pn533_tx_frame_init(dev->out_frame, PN533_CMD_IN_JUMP_FOR_DEP);
1613 1618
1614 cmd->active = !comm_mode; 1619 cmd->active = !comm_mode;
1615 cmd->baud = 0; 1620 cmd->next = 0;
1621 cmd->baud = 2;
1622 data_ptr = cmd->data;
1623 if (comm_mode == NFC_COMM_PASSIVE && cmd->baud > 0) {
1624 memcpy(data_ptr, passive_data, PASSIVE_DATA_LEN);
1625 cmd->next |= 1;
1626 data_ptr += PASSIVE_DATA_LEN;
1627 }
1628
1616 if (gb != NULL && gb_len > 0) { 1629 if (gb != NULL && gb_len > 0) {
1617 cmd->next = 4; /* We have some Gi */ 1630 cmd->next |= 4; /* We have some Gi */
1618 memcpy(cmd->gt, gb, gb_len); 1631 memcpy(data_ptr, gb, gb_len);
1619 } else { 1632 } else {
1620 cmd->next = 0; 1633 cmd->next = 0;
1621 } 1634 }