[go: nahoru, domu]

History log of /drivers/nfc/trf7970a.c
Revision Date Author Comments
fc0ae24386142299db14dfea7f32a20022d94d90 23-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Unlock mutex before exiting _trf7970a_tg_listen()

The recently added _trf7970a_tg_listen() routine
has some return paths that don't unlock the mutex
that is locked when the routine is entered. Fix
this by always unlocking the mutex before returning.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
b9e3016a5369839bf923c8d2bec9d1552e50f3f3 23-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Unlock mutex before exiting trf7970a_irq()

Recent changes to trf7970a_irq() added a couple return
paths that don't unlock the mutex that is locked when
the routine is entered. Fix this by ensuring the mutex
is always unlocked before returning.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
55ef2e75ccf0d91f7b2f4251dc3b9e56df840928 23-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Remove unnecessary local variable initialization

There is no need to initialize the 'ret' variable
in trf7970a_resume().

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
671970f531378e2a22ba0168d85dfca1f4e082c4 23-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Remove useless local variable

The trf7970a_suspend() routine always returns
zero so don't use a local return variable to
hold the return value. This fixes up a smatch
warning.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
cb174aba86fe10ddac8b692c90a9480526c02953 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add Target Mode Detection Support

Add the ability to detect the mode (i.e., RF technology)
used by the initiator. The RF technology that was
detected can be retrieved by calling the 'tg_get_rf_tech'
driver hook.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13b4272a8264220ec043a922fd1fa05da72d57ae 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add Target Mode Support

Add target mode support to the trf7970a
NFC driver. This effectively enables full
Peer-to-Peer support.

To handle changing framing between sending
a response frame and receiving the subsequent
request frame, most of the framing changes
take effect in the interrupt handler and not
in trf7970a_tg_config_framing().

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1961843ceeca0d3e55744bba7ae8d9e23d04cf6a 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Handle timeout values of zero

The digital layer can try to send a command with a
timeout value of zero (e.g., digital_tg_send_psl_res().
The zero value is used as a flag to indicate that
the driver should not expect a response. To handle
this, the driver sets an internal timer because it
should still get an interrupt with the TX bit set
in the IRQ Status Register. When it gets that
interrupt, it returns a return value of '0'.
If it doesn't get the interrupt before timing out,
it returns ETIMEDOUT as usual.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
6fb9edcb43d0b1bf0ac2aaf6ba488d105c45f477 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Cancel timer when error encountered

Some paths leave a timer still running when
trf7970a_send_err_upstream() is called. This
can cause a timeout to occur in a subsequent
transaction making it fail. Fix this by ensuring
there is no timer running before sending an error
upstream.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
851ee3cbf850501104e76683e439a4061f378a96 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Don't turn on RF if there is already an RF field

Currently, the trf7970a driver blindly turns on its
RF field when configuring its framing. This isn't
a good idea if there is already a device generating
an RF field. Instead, check if there is already an
RF field present before turning on this device's RF
field and, if there is, return EBUSY.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
7149d6bfecadc255e9d964782a9fdd70f610f1ea 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: trf7970a_init() turns off the RF transmitter

When trf7970a_init() initializes the trf7970a it
implicitly turns off the RF transmitter. Track
this by clearing the TRF7970A_CHIP_STATUS_RF_ON
bit in the cached trf->chip_status_ctrl.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
cfc708dbe4022324bcd2bcb5817dd29f1f91299d 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Don't turn off RF if its already off

Don't try to turn off of RF transmitter is its
already off.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
307e5caf6fb1dac1b9cfa1d78138d77e46517b56 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add '_in_' to initiator routines

Rename trf7970a_config_rf_tech() and trf7970a_config_framing()
to trf7970a_in_config_rf_tech() and trf7970a_in_config_framing(),
respectively to avoid confusion when target support is added.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
4e007f810664541078e619d050f6290bf137aa61 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Delay after initialization

The trf7970a should be given at least 1 ms to
completely initialize after the 'Software Init'
and 'Idle' commands have been issued.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
77c9539dc1284677539af442ac3629c9baf01202 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add System Suspend/Resume support

Add system suspend/resume support by gracefully
shutting things down when suspending and bringing
the device back to full power when resuming.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
b528281b8b7a9c379baf37720191a799fbc9800c 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Create startup and shutdown routines

Encapsulate the code to start up and gracefully
shutdown the driver and trf7970a device. Doing
this makes adding system suspend/resume support
easier and the resulting code cleaner.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
ceccd6aa50887352e66d0edf68d8be510a639da6 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Don't assume CONFIG_PM_RUNTIME is enabled

The current code assumes that CONFIG_PM_RUNTIME
is always defined so it won't power up the trf7970a
when it isn't enabled. Fix this by moving the power
up/down code from the pm_runtime_resume/suspend
routines into their own routines and calling the
power up function from the probe routine. This
ensures the device is powered up even when
CONFIG_PM_RUNTIME is not defined.

In order to not power on/off a device that is
already powered on/off, create a new state to
indicate that the power is off (TRF7970A_ST_PWR_OFF).

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
b5e17d9b5bd7e53696bce21e38eec5b9bb8abb88 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Rename TRF7970A_ST_OFF to TRF7970A_ST_RF_OFF

Rename the 'TRF7970A_ST_OFF' state to 'TRF7970A_ST_RF_OFF'
to make it clear that this state means that the RF is
off and not the entire device.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
0a1de84205d3fe7baa3d013ebf703416b1919ecc 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Return error code when turning on RF fails

trf7970a_switch_rf_on() is currently a void function
but turning on the RF could fail so it should return
a return code. That return code should also be
propagated back to the entity that initiated the
action.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
afa5b5f13e0e2372e440f3ab44620d4e10fca496 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Ensure no more RX data before completing receive

Depending on the interrupt status value given by the
trf7970a, the driver may not know when a receive operation
is complete. To handle this, the driver waits for a period
of time in case the trf7970a interrupts it again indicating
there are more RX data in the FIFO. It is possible that the
timeout will occur when there are RX data in the FIFO but
before the trf7970a has generated an interrupt to tell the
driver about it. Handle this by calling trf7970a_drain_fifo()
(instead of trf7970a_send_upstream() which just passes up the
data gathered to far) to check if there are more data in the
FIFO. If so, gather that data into the receive buffer. If
not, pass the data collected so far upstream as before.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
5d8f759424d3d7da998a7a9eee702071c8e5d381 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Reread FIFO Status Register when draining FIFO

Receiving an interrupt whose Interrupt Status Register
value has only the SRX bit set is supposed to mean that
all of the data from the tag has been received. That
turns out to not be true so we need to reread the FIFO
Status Register to tell if there are any new bytes in
the FIFO. If there are, continue receiving them; if
there aren't, assume that the receive is complete and
pass the data up.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
bece3c544fee62ba7750f70b214d612fd02dcc8f 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Handle low-watermark IRQ when transmitting

Commit 4dd836e46c3d ("NFC: trf7970a: Reset FIFO when
'End of TX' Interrupt Occurs") fixes the issue that
it was meant to fix but adds the unfortunate side
effect of causing the driver to report an error
when the TX low-watermark level is passed during
transmits. This can be fixed by checking whether
the IRQ status indicates that the low-watermark
has been passed when transmitting. If it has been
passed and the FIFO is empty, then its safe to reset
the FIFO. Otherwise, silently continue since another
TX interrupt will be generated and the FIFO will be
reset then.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
0e840ed59ba79670b66bba8c1d50b6f67e72d3fb 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Only fill FIFO if there is space

Handle the case where trf7970a_fill_fifo() is
called but there is no room in the FIFO for
more TX data. When this happens, wait for
another interrupt indicating that there is
now space (and set a timer in case that
interrupt never occurs).

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
7a1e5552af61dce180f70c6fafe31553254b3728 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Prefix TX data when refilling FIFO

When refilling the FIFO with more TX data (using a new
SPI transaction), the driver must prefix the TX data with
a write to the FIFO I/O Register. This tells the trf7970a
that the following data is destined for the FIFO so it can
be transmitted.

To accomplish this, the driver cannot simply push the
prefix data just before the next set of TX data that
is to be transmitted because that will overwrite part
of the TX data provided by the digital layer. Instead,
separate the prefix data and the TX data when calling
trf7970a_transmit(). trf7970a_transmit() can then send
the prefix and TX data from different memory locations
with one spi_sync() operation. This also means that
the driver doesn't require any skb "tx_headroom" as
provided by the digital layer (see
nfc_digital_allocate_device() and digital_skb_alloc()).

Also ensure that the prefix is of type 'u8' and not
'char'.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
5974150dead6da1db415f04a232f79b922f412a0 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Remove unnecessary FIFO reset & RSSI read

It is no longer necessary to reset the FIFO and
read the 'RSSI Levels and Oscillator Status Register'
so remove that code.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
aff0564aa7b2118a1d76dc0118dfdbf4beaf4b8c 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Clear possible spurious interrupt before transmitting

The trf7970a occasionally generates spurious interrupts
which can confuse the driver. To help alleviate this,
clear any interrupts by reading the 'IRQ Status Register'
before starting a new transaction.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
38b4eb1f7fa87079a5a40f5d2ec4b5c0c7f14a4b 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Recalculate driver timeout values

Some of the timeout values used in the driver
are not long enough to handle worst-case scenarios
so they need to be recalculated.

The time to wait for the FIFO to drain past the
low-watermark is now 20 ms because it can take
around 14.35 ms to send 95 bytes (127 bytes in
full FIFO minus 32 bytes where the low-watermark
interrupt will fire). 95 bytes will take around
14.35 ms at 6.62 kbps (the lowest supported bit
rate used by ISO/IEC 15693) so 20 ms should be a
safe value.

The time to wait before issuing an EOF to complete
an ISO/IEC 15693 write or lock command is 40 ms--
20 ms to drain the FIFO and another 20 ms to ensure
the wait is long enough before sending an EOF.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
4e64eff837fb682dfb2a1188fb036d75ec57375c 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add RF technology specific guard times

When turning on the RF field, the driver must wait
an RF-technology-specific amount of time (known as
the guard time) before modulating the field.
Currently, the driver waits 5 ms but that is too
short for NFCF and too long for ISO/IEC 15693.
Fix this by determining the guard time when the
RF technology is set and delaying that amount
of time when turning on the RF field.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
a08e54549e743ea3704da939f92caf3eaa8471d3 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Initialize when enabling RF

Currently, the trf7970a is reset & initialized only
when the pm_runtime resume hook is called. Instead,
initialize it every time the RF is enabled to ensure
that the trf7970a is quiesced and in a known state
before being set up for another RF technology.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
6c08df422ede7db94776b8099a5f43597629234c 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Disable SYS_CLK Output

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>
17b2151733ecdc96ee4fecdf5fae973b8cb0fea7 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Remove unnecessary sleep

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>
1568bfef18a9150d83b0f91aa254cef7ebead4cd 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: FIFO Size is really 127 bytes

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>
4542e8345af6076c87d036c7bd3f9dfa30768b1e 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Ignore Overflow bit in FIFO Status Register

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>
3e7f335689ebfa0a68814dfe9f0588076fb9ad01 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Use spi_sync() instead of spi_write_then_read()

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>
24707296c762d1828c4a51aa1872dc275dc3fccc 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Call spi_setup() to configure SPI communication

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>
cc8d7158644c439d946bfc65778a507b6f12b10d 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Remove trf7970a_tg_listen_mdaa()

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>
d3a6d33a7f72fa4d3bb0224da0839a5ca871d7a4 03-Sep-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Remove incorrect of_node_put() call

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>
f23b73526b82ca2ef333362e704a51d817c1ffc1 08-Aug-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Make gpio labels more readable

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>
95064bd95a822659f4a606b485aba5009d70fc88 08-Aug-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add quirk to keep EN2 low

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>
772079eb77587e0242752fa67685a8132d899f79 08-Aug-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Move IRQ Status Read quirk to device tree

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>
3bd14233aa0733fbc6c3f75ec928f1a393522644 08-Aug-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add VIN voltage override support

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>
6857bb96271cd40ffb38825d43897d716310e3db 14-Apr-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add support for Felica Type 3 tags

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>
742b1f9fa292a1b8f5c8368464e114c9b71c2a81 01-Apr-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add support for the ISO/IEC 14443-B and Type 4B tags

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>
fd0c8280cf47104e87dc10828ded541b4e84deda 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add 'autosuspend-delay' DTS property

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>
18422e686ef043b9abe004326ac9ffa1e38b81ec 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Don't return value from trf7970a_switch_rf_on()

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>
e6403b7c756f9d694332870ba0c2be7a4aa0b8c0 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add pm_runtime support

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>
a1d2dc5b407ae18b59b7a129c93c8eb5ad7b1c80 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Turn RF on after hardware is configured

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>
ebcc5a0d08e6a680558ed74f5dd724427ff5a29b 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Set correct Vin voltage in Chip Status Control register

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>
12e9ade309db51e7ea26be3b4fd5bc6057ddc175 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Allow different Modulator and SYS_CLK Control register values

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>
a0822a7e3b7333689b1c8cb92782e299791c2795 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Set 'Modulator and SYS_CLK Control' after 'ISO Control'

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>
49d19cc794e73c3383283a5366ff31572d71a795 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Only write 'ISO Control' when its changing

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>
4dd836e46c3ddcb2020646c867be589658440be0 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Reset FIFO when 'End of TX' Interrupt Occurs

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>
b887eb09d3cbda145d9fff4b9a56c384edd07ed7 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Clear 'NFC Target Detection Level' register

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>
5876bc75e2d3174cd1cd944ee33edc77cd1173ca 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Only abort a command if one is active

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>
5fa3af352b991e2e5c674728411d1cc4a4923e4d 25-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Increase TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT to 20 ms

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>
9d9304b32154be5908a3abbb46215297b9ce0a4c 10-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add ISO/IEC 15693 and Type 5 tag Support

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>
8006289108fa9635d16a65d9db16da06d7dce201 10-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add support for Type 4A Tags

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>
165063f1dac43e48ceb907490fff0a8413b9a32d 10-Mar-2014 Mark A. Greer <mgreer@animalcreek.com> NFC: trf7970a: Add driver with ISO/IEC 14443 Type 2 Tag Support

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>