aboutsummaryrefslogtreecommitdiff
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-04-11 11:45:41 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-11 16:29:11 +0200
commit60d9edd50b9b9c5b9cb434ebea7892057ae4b889 (patch)
tree29f538e83270277d47b5e822983a1e548f7f1328 /drivers/nfc
parent7757dc8a3e7658abb6e5fc7d825a38b27961d0c8 (diff)
NFC: pn533: Turn radio on and off when bringing the device up and down
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 3569b9e621e..8f6f2baa930 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -163,9 +163,13 @@ struct pn533_fw_version {
};
/* PN533_CMD_RF_CONFIGURATION */
-#define PN533_CFGITEM_TIMING 0x02
+#define PN533_CFGITEM_RF_FIELD 0x01
+#define PN533_CFGITEM_TIMING 0x02
#define PN533_CFGITEM_MAX_RETRIES 0x05
-#define PN533_CFGITEM_PASORI 0x82
+#define PN533_CFGITEM_PASORI 0x82
+
+#define PN533_CFGITEM_RF_FIELD_ON 0x1
+#define PN533_CFGITEM_RF_FIELD_OFF 0x0
#define PN533_CONFIG_TIMING_102 0xb
#define PN533_CONFIG_TIMING_204 0xc
@@ -2540,9 +2544,36 @@ static int pn533_acr122_poweron_rdr(struct pn533 *dev)
return arg.rc;
}
+static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf)
+{
+ struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+ u8 rf_field = !!rf;
+ int rc;
+
+ rc = pn533_set_configuration(dev, PN533_CFGITEM_RF_FIELD,
+ (u8 *)&rf_field, 1);
+ if (rc) {
+ nfc_dev_err(&dev->interface->dev,
+ "Error on setting RF field");
+ return rc;
+ }
+
+ return rc;
+}
+
+int pn533_dev_up(struct nfc_dev *nfc_dev)
+{
+ return pn533_rf_field(nfc_dev, 1);
+}
+
+int pn533_dev_down(struct nfc_dev *nfc_dev)
+{
+ return pn533_rf_field(nfc_dev, 0);
+}
+
static struct nfc_ops pn533_nfc_ops = {
- .dev_up = NULL,
- .dev_down = NULL,
+ .dev_up = pn533_dev_up,
+ .dev_down = pn533_dev_down,
.dep_link_up = pn533_dep_link_up,
.dep_link_down = pn533_dep_link_down,
.start_poll = pn533_start_poll,