aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@animalcreek.com>2014-09-02 18:12:25 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2014-09-07 17:13:43 -0400
commit38b4eb1f7fa87079a5a40f5d2ec4b5c0c7f14a4b (patch)
treedf78df662950aa0c4f1d92a06bce1148f63a8523
parent4e64eff837fb682dfb2a1188fb036d75ec57375c (diff)
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>
-rw-r--r--drivers/nfc/trf7970a.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 22485e703849..b67946c18b40 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -83,6 +83,13 @@
83 * been received and there isn't an error). The delay is 20 ms since delays 83 * been received and there isn't an error). The delay is 20 ms since delays
84 * of ~16 ms have been observed during testing. 84 * of ~16 ms have been observed during testing.
85 * 85 *
86 * When transmitting a frame larger than the FIFO size (127 bytes), the
87 * driver will wait 20 ms for the FIFO to drain past the low-watermark
88 * and generate an interrupt. The low-watermark set to 32 bytes so the
89 * interrupt should fire after 127 - 32 = 95 bytes have been sent. At
90 * the lowest possible bit rate (6.62 kbps for 15693), it will take up
91 * to ~14.35 ms so 20 ms is used for the timeout.
92 *
86 * Type 2 write and sector select commands respond with a 4-bit ACK or NACK. 93 * Type 2 write and sector select commands respond with a 4-bit ACK or NACK.
87 * Having only 4 bits in the FIFO won't normally generate an interrupt so 94 * Having only 4 bits in the FIFO won't normally generate an interrupt so
88 * driver enables the '4_bit_RX' bit of the Special Functions register 1 95 * driver enables the '4_bit_RX' bit of the Special Functions register 1
@@ -105,7 +112,9 @@
105 * Note under Table 1-1 in section 1.6 of 112 * Note under Table 1-1 in section 1.6 of
106 * http://www.ti.com/lit/ug/scbu011/scbu011.pdf, that wait should be at least 113 * http://www.ti.com/lit/ug/scbu011/scbu011.pdf, that wait should be at least
107 * 10 ms for TI Tag-it HF-I tags; however testing has shown that is not long 114 * 10 ms for TI Tag-it HF-I tags; however testing has shown that is not long
108 * enough. For this reason, the driver waits 20 ms which seems to work 115 * enough so 20 ms is used. So the timer is set to 40 ms - 20 ms to drain
116 * up to 127 bytes in the FIFO at the lowest bit rate plus another 20 ms to
117 * ensure the wait is long enough before sending the EOF. This seems to work
109 * reliably. 118 * reliably.
110 */ 119 */
111 120
@@ -131,8 +140,8 @@
131#define TRF7970A_TX_MAX (4096 - 1) 140#define TRF7970A_TX_MAX (4096 - 1)
132 141
133#define TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT 20 142#define TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT 20
134#define TRF7970A_WAIT_FOR_FIFO_DRAIN_TIMEOUT 3 143#define TRF7970A_WAIT_FOR_FIFO_DRAIN_TIMEOUT 20
135#define TRF7970A_WAIT_TO_ISSUE_ISO15693_EOF 20 144#define TRF7970A_WAIT_TO_ISSUE_ISO15693_EOF 40
136 145
137/* Guard times for various RF technologies (in us) */ 146/* Guard times for various RF technologies (in us) */
138#define TRF7970A_GUARD_TIME_NFCA 5000 147#define TRF7970A_GUARD_TIME_NFCA 5000