NFC: trf7970a: Move IRQ Status Read quirk to device tree
authorMark A. Greer <mgreer@animalcreek.com>
Fri, 8 Aug 2014 00:41:43 +0000 (17:41 -0700)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 31 Aug 2014 22:06:55 +0000 (00:06 +0200)
The quirk indicating whether the trf7970a has
the "IRQ Status Read" erratum or not is currently
implemented using the 'driver_data' member of the
'spi_device_id' structure.  That requires the
driver to be modified to turn the quirk off when
a version of the trf7970a that doesn't have the
erratum is being used.  To fix that, create a
new device tree property called
'irq-status-read-quirk' that indicates that the
trf7970a being used has the erratum.

While at it, rename 'TRF7970A_QUIRK_IRQ_STATUS_READ_ERRATA'
to 'TRF7970A_QUIRK_IRQ_STATUS_READ' to make it
less of an eyesore.

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

index 5355d0e4c045ab727f6f7067f2e838c53f270226..3cc7001d7d2f491e17275bc8c44c4813f840ffd2 100644 (file)
 /* Erratum: When reading IRQ Status register on trf7970a, we must issue a
  * read continuous command for IRQ Status and Collision Position registers.
  */
-#define TRF7970A_QUIRK_IRQ_STATUS_READ_ERRATA  BIT(0)
+#define TRF7970A_QUIRK_IRQ_STATUS_READ         BIT(0)
 
 /* Direct commands */
 #define TRF7970A_CMD_IDLE                      0x00
@@ -424,7 +424,7 @@ static int trf7970a_read_irqstatus(struct trf7970a *trf, u8 *status)
 
        addr = TRF7970A_IRQ_STATUS | TRF7970A_CMD_BIT_RW;
 
-       if (trf->quirks & TRF7970A_QUIRK_IRQ_STATUS_READ_ERRATA) {
+       if (trf->quirks & TRF7970A_QUIRK_IRQ_STATUS_READ) {
                addr |= TRF7970A_CMD_BIT_CONTINUOUS;
                ret = spi_write_then_read(trf->spi, &addr, 1, buf, 2);
        } else {
@@ -1260,7 +1260,6 @@ static int trf7970a_get_vin_voltage_override(struct device_node *np,
 static int trf7970a_probe(struct spi_device *spi)
 {
        struct device_node *np = spi->dev.of_node;
-       const struct spi_device_id *id = spi_get_device_id(spi);
        struct trf7970a *trf;
        int uvolts, autosuspend_delay, ret;
 
@@ -1276,11 +1275,13 @@ static int trf7970a_probe(struct spi_device *spi)
        trf->state = TRF7970A_ST_OFF;
        trf->dev = &spi->dev;
        trf->spi = spi;
-       trf->quirks = id->driver_data;
 
        spi->mode = SPI_MODE_1;
        spi->bits_per_word = 8;
 
+       if (of_property_read_bool(np, "irq-status-read-quirk"))
+               trf->quirks |= TRF7970A_QUIRK_IRQ_STATUS_READ;
+
        /* There are two enable pins - both must be present */
        trf->en_gpio = of_get_named_gpio(np, "ti,enable-gpios", 0);
        if (!gpio_is_valid(trf->en_gpio)) {
@@ -1478,7 +1479,7 @@ static const struct dev_pm_ops trf7970a_pm_ops = {
 };
 
 static const struct spi_device_id trf7970a_id_table[] = {
-       { "trf7970a", TRF7970A_QUIRK_IRQ_STATUS_READ_ERRATA },
+       { "trf7970a", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(spi, trf7970a_id_table);