summaryrefslogtreecommitdiff
path: root/drivers/nfc/trf7970a.c
AgeCommit message (Collapse)Author
2014-09-07NFC: trf7970a: Disable SYS_CLK OutputMark A. Greer
Currently, support for providing the external SYS_CLK signal on pin 27 is not supported so turn it off by writing to the 'Modulator and SYS_CLK Control' register immediately after reset. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: Remove unnecessary sleepMark A. Greer
There is no need to sleep for 1-2 ms before transmitting a new command. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: FIFO Size is really 127 bytesMark A. Greer
Despite what the manual says, the FIFO size on the trf7970a is really 127 bytes so make the code respect that. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: Ignore Overflow bit in FIFO Status RegisterMark A. Greer
The Overflow bit in the 'FIFO Status Register' has proven to be untrustworthy so ignore it. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: Use spi_sync() instead of spi_write_then_read()Mark A. Greer
To more efficiently handle long continuous reads, use spi_sync() instead of spi_write_then_read(). Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: Call spi_setup() to configure SPI communicationMark A. Greer
Call spi_setup() to configure SPI communication with the trf7970a. This will ensure that the correct SPI parameters are used. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: Remove trf7970a_tg_listen_mdaa()Mark A. Greer
Currently, the digital layer 'tg_listen_mdaa' hook is not used and it isn't necessary to have a stub routine so remove it. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-07NFC: trf7970a: Remove incorrect of_node_put() callMark A. Greer
of_property_read_u32() does not take a reference to the specified OF node so don't call of_node_put() in trf7970a_get_autosuspend_delay(). Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-01NFC: trf7970a: Make gpio labels more readableMark A. Greer
Make the labels for the two gpio enable lines more user friendly by prefixing them with the driver name. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-01NFC: trf7970a: Add quirk to keep EN2 lowMark A. Greer
A bug has been discovered in the trf7970a where it will generate an RF field even in passive target mode when EN2 is asserted. To work around this, add support for the 'en2-rf-quirk' device tree property which indicates that EN2 must remain low. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-09-01NFC: trf7970a: Move IRQ Status Read quirk to device treeMark A. Greer
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>
2014-09-01NFC: trf7970a: Add VIN voltage override supportMark A. Greer
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>
2014-05-26NFC: trf7970a: Add support for Felica Type 3 tagsMark A. Greer
Add support for the Felica protocol and Type 3 tags. Both 212 and 424 kbps are supported. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Add support for the ISO/IEC 14443-B and Type 4B tagsMark A. Greer
Now that the NFC digital layer has support for the ISO/IEC 14443-B protocol and type 4B tags, add the corresponding support to the trf7970a driver. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Add 'autosuspend-delay' DTS propertyMark A. Greer
The trf7970a driver currently uses a fixed autosuspend delay of 30 seconds. To enable users to customize the delay as they see fit, add support for the new 'autosuspend-delay' DTS property (part of the nfc node) which can override the default 30 seconds. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Don't return value from trf7970a_switch_rf_on()Mark A. Greer
trf7970a_switch_rf_on() no longer returns anything other than 0 so make it void and clean up the code that checks for errors when its called. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Add pm_runtime supportMark A. Greer
Add pm_runtime support by moving the code that enables the trf7970a to the pm_runtime hook routines. The pm_runtime 'autosuspend' feature is used so that the device isn't disabled until at least 30 seconds have passed since trf7970a_switch_rf_off() was last called. The result is that when trf7970a_switch_rf_on() is called, the device will be enabled and initialized (if it isn't already). When trf7970a_switch_rf_off() is called, it will turn off the RF immediately but leave the device enabled for at least 30 seconds. If 30 seconds have passed and the pm_runtime facility decides to suspend the driver, the device will be disabled then. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Turn RF on after hardware is configuredMark A. Greer
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>
2014-04-22NFC: trf7970a: Set correct Vin voltage in Chip Status Control registerMark A. Greer
Currently, the trf7970a driver assumes that the Vin voltage is 5V when it writes to the 'Chip Status Control' register. That may not be correct so use the regulator facility to get the Vin voltage and set the VRS5_3 bit correctly when writing to that register. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Allow different Modulator and SYS_CLK Control register valuesMark A. Greer
Currently the driver writes the same value to the 'Modulator and SYS_CLK Control' register no matter what RF technology is being used. That works for now but new RF technologies (e.g., ISO/IEC 14443-B) will require different values to be written to that register. To support this, add a member to the trf7970a structure which is set by the RF technology handling code and used by the framing code when it writes to that register. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Set 'Modulator and SYS_CLK Control' after 'ISO Control'Mark A. Greer
Writing to the 'ISO Control' register may cause the contents of the 'Modulator and SYS_CLK Control' register to change so be sure to write to 'Modulator and SYS_CLK Control' after writing to 'ISO Control'. Note that writing to the 'Modulator and SYS_CLK Control' register shouldn't be necessary at all according to the trf790a manual but testing shows that it is necessary. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Only write 'ISO Control' when its changingMark A. Greer
The current code always writes to the 'ISO Control' register when the RF framing is set. That's not necessary since the register's value doesn't always change. Instead, only write to it when its value is actually being changed. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Reset FIFO when 'End of TX' Interrupt OccursMark A. Greer
Sometimes after sending a frame there is tx data leftover in the FIFO which the driver will think is part of the receive frame. That data can be cleared when an 'End of TX' interrupt is received by issuing the 'FIFO Reset' command. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Clear 'NFC Target Detection Level' registerMark A. Greer
Due to a trf7970a erratum, the 'NFC Target Detection Level' register (0x18) must be cleared after power-up. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Only abort a command if one is activeMark A. Greer
Only initiate the abort command process when there is an active command. If the abort process were started and there wasn't an active command then the next command issued by the digital layer would be incorrectly aborted. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-04-22NFC: trf7970a: Increase TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT to 20 msMark A. Greer
After further testing periods of ~16 ms have been observed between interrupts indicating that there is receive data in the FIFO. To accomodate that, increase the time the driver waits before deciding there is no more data to receive to 20 ms. The macro that represents that delay is 'TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT'. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-03-11NFC: trf7970a: Add ISO/IEC 15693 and Type 5 tag SupportMark A. Greer
Add support for ISO/IEC 15693 RF technology and Type 5 tags. Note that Type 5 tags used to be referred to as Type V tags. CC: Erick Macias <emacias@ti.com> CC: Felipe Balbi <balbi@ti.com> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-03-11NFC: trf7970a: Add support for Type 4A TagsMark A. Greer
Add support for Type 4A Tags which includes supporting the underlying ISO/IEC 14443-A protocol. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-03-11NFC: trf7970a: Add driver with ISO/IEC 14443 Type 2 Tag SupportMark A. Greer
Add a driver for the Texas Instruments TRF7970a RFID/NFC/15693 transceiver. The driver currently supports ISO/IEC 14443 Type 2 tags only (MIFARE Ultralight and Ultralight C but not Classic). CC: Erick Macias <emacias@ti.com> CC: Felipe Balbi <balbi@ti.com> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>