]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFC: st21nfcb: Configure CLF with NCI proprietary command
authorChristophe Ricard <christophe.ricard@gmail.com>
Sat, 6 Jun 2015 11:16:52 +0000 (13:16 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 8 Jun 2015 22:34:26 +0000 (00:34 +0200)
In order to prevent any NFC feature when NFC is disable and
to save power, (down to 4uA) put the CLF in hibernate mode
with RF deactivated.
Add the equivalent to enable the NFC feature when initiating
the st21nfcb driver.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/st21nfcb/ndlc.c
drivers/nfc/st21nfcb/st21nfcb.c
drivers/nfc/st21nfcb/st21nfcb.h

index 3ee22b44cd99518268f51d1a4c0a92f69ed41868..91e81f37b3a69625791fdf3f15a5f40944caecd3 100644 (file)
@@ -66,9 +66,19 @@ EXPORT_SYMBOL(ndlc_open);
 
 void ndlc_close(struct llt_ndlc *ndlc)
 {
+       struct nci_mode_set_cmd cmd;
+
+       cmd.cmd_type = ST21NFCB_NCI_SET_NFC_MODE;
+       cmd.mode = 0;
+
        /* toggle reset pin */
-       ndlc->ops->disable(ndlc->phy_id);
+       ndlc->ops->enable(ndlc->phy_id);
+
+       nci_prop_cmd(ndlc->ndev, ST21NFCB_NCI_CORE_PROP,
+                    sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd);
+
        ndlc->powered = 0;
+       ndlc->ops->disable(ndlc->phy_id);
 }
 EXPORT_SYMBOL(ndlc_close);
 
index 50ad6d04f0f4dd2b656fde01b94733106043e822..a16c3a3d3fffa5ae75c6b2f25ec159e4e18fb1f3 100644 (file)
 
 #define ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 0x83
 
+static int st21nfcb_nci_init(struct nci_dev *ndev)
+{
+       struct nci_mode_set_cmd cmd;
+
+       cmd.cmd_type = ST21NFCB_NCI_SET_NFC_MODE;
+       cmd.mode = 1;
+
+       return nci_prop_cmd(ndev, ST21NFCB_NCI_CORE_PROP,
+                       sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd);
+}
+
 static int st21nfcb_nci_open(struct nci_dev *ndev)
 {
        struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
@@ -96,6 +107,7 @@ static struct nci_prop_ops st21nfcb_nci_prop_ops[] = {
 };
 
 static struct nci_ops st21nfcb_nci_ops = {
+       .init = st21nfcb_nci_init,
        .open = st21nfcb_nci_open,
        .close = st21nfcb_nci_close,
        .send = st21nfcb_nci_send,
index 7c12d9dd03d0ee355d465c311e2f5b405fc91fec..710636325c1f496b825941cc30086a47a4d707a9 100644 (file)
 #define ST21NFCB_NCI_RUNNING                   1
 
 #define ST21NFCB_NCI_CORE_PROP                0x01
+#define ST21NFCB_NCI_SET_NFC_MODE             0x02
+
+struct nci_mode_set_cmd {
+       u8 cmd_type;
+       u8 mode;
+} __packed;
 
 struct nci_mode_set_rsp {
        u8 status;