]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
NFC: trf7970a: Turn RF on after hardware is configured
authorMark A. Greer <mgreer@animalcreek.com>
Tue, 25 Mar 2014 15:54:37 +0000 (08:54 -0700)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 21 Apr 2014 22:37:27 +0000 (00:37 +0200)
The NFC digital layer calls the 'switch_rf' hook to turn the RF on before
it configures the RF technology and framing. There is potential to confuse
a tag doing it this way so don't enable the RF until the RF technology and
initial framing have been configured.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/trf7970a.c

index 203d86fb1d548cab773db01b032ec4d974d57526..0a46348f9af67f945f527e97009bc78974ffc663 100644 (file)
@@ -779,11 +779,6 @@ static int trf7970a_init(struct trf7970a *trf)
 
        trf->special_fcn_reg1 = 0;
 
-       ret = trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL,
-                       trf->chip_status_ctrl | TRF7970A_CHIP_STATUS_RF_ON);
-       if (ret)
-               goto err_out;
-
        trf->iso_ctrl = 0xff;
        return 0;
 
@@ -796,6 +791,10 @@ static void trf7970a_switch_rf_off(struct trf7970a *trf)
 {
        dev_dbg(trf->dev, "Switching rf off\n");
 
+       trf->chip_status_ctrl &= ~TRF7970A_CHIP_STATUS_RF_ON;
+
+       trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL, trf->chip_status_ctrl);
+
        gpio_set_value(trf->en_gpio, 0);
        gpio_set_value(trf->en2_gpio, 0);
 
@@ -948,6 +947,18 @@ static int trf7970a_config_framing(struct trf7970a *trf, int framing)
                        return ret;
        }
 
+       if (!(trf->chip_status_ctrl & TRF7970A_CHIP_STATUS_RF_ON)) {
+               ret = trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL,
+                               trf->chip_status_ctrl |
+                                       TRF7970A_CHIP_STATUS_RF_ON);
+               if (ret)
+                       return ret;
+
+               trf->chip_status_ctrl |= TRF7970A_CHIP_STATUS_RF_ON;
+
+               usleep_range(5000, 6000);
+       }
+
        return 0;
 }