NFC: trf7970a: Add VIN voltage override support
authorMark A. Greer <mgreer@animalcreek.com>
Fri, 8 Aug 2014 00:41:41 +0000 (17:41 -0700)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 31 Aug 2014 22:06:55 +0000 (00:06 +0200)
The trf7970a driver uses the voltage from the
power/regulator subsystem to determine what the
voltage on the VIN pin is.  Normally, this is
the right thing to do but sometimes the board
that the trf7970a is on may change the voltage.
This is the case for the trf7970atb board from
Texas Instruments where it boosts the VIN voltage
from 3.3V to 5V (see http://www.ti.com/tool/trf7970atb).

To handle this, add support for the 'vin-voltage-override'
device tree property which overrides the voltage value
given by the regulator subsystem.  When the DT property
is not present, the value from the regulator subsystem
is used.

The value of 'vin-voltage-override' is in uVolts.

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

index 3b78b031e617df51e98101a231519a000cd159ed..5355d0e4c045ab727f6f7067f2e838c53f270226 100644 (file)
@@ -1251,6 +1251,12 @@ static int trf7970a_get_autosuspend_delay(struct device_node *np)
        return autosuspend_delay;
 }
 
+static int trf7970a_get_vin_voltage_override(struct device_node *np,
+               u32 *vin_uvolts)
+{
+       return of_property_read_u32(np, "vin-voltage-override", vin_uvolts);
+}
+
 static int trf7970a_probe(struct spi_device *spi)
 {
        struct device_node *np = spi->dev.of_node;
@@ -1326,7 +1332,9 @@ static int trf7970a_probe(struct spi_device *spi)
                goto err_destroy_lock;
        }
 
-       uvolts = regulator_get_voltage(trf->regulator);
+       ret = trf7970a_get_vin_voltage_override(np, &uvolts);
+       if (ret)
+               uvolts = regulator_get_voltage(trf->regulator);
 
        if (uvolts > 4000000)
                trf->chip_status_ctrl = TRF7970A_CHIP_STATUS_VRS5_3;
This page took 0.025692 seconds and 5 git commands to generate.