linux_dsm_epyc7002/net/nfc
Eric Lapuyade 2bed278517 NFC: NCI: Modify NCI SPI to implement CS/INT handshake per the spec
The NFC Forum NCI specification defines both a hardware and software
protocol when using a SPI physical transport to connect an NFC NCI
Chipset. The hardware requirement is that, after having raised the chip
select line, the SPI driver must wait for an INT line from the NFC
chipset to raise before it sends the data. The chip select must be
raised first though, because this is the signal that the NFC chipset
will detect to wake up and then raise its INT line. If the INT line
doesn't raise in a timely fashion, the SPI driver should abort
operation.

When data is transferred from Device host (DH) to NFC Controller (NFCC),
the signaling sequence is the following:

Data Transfer from DH to NFCC
• 1-Master asserts SPI_CSN
• 2-Slave asserts SPI_INT
• 3-Master sends NCI-over-SPI protocol header and payload data
• 4-Slave deasserts SPI_INT
• 5-Master deasserts SPI_CSN

When data must be transferred from NFCC to DH, things are a little bit
different.

Data Transfer from NFCC to DH
• 1-Slave asserts SPI_INT -> NFC chipset irq handler called -> process
reading from SPI
• 2-Master asserts SPI_CSN
• 3-Master send 2-octet NCI-over-SPI protocol header
• 4-Slave sends 2-octet NCI-over-SPI protocol payload length
• 5-Slave sends NCI-over-SPI protocol payload
• 6-Master deasserts SPI_CSN

In this case, SPI driver should function normally as it does today. Note
that the INT line can and will be lowered anytime between beginning of
step 3 and end of step 5. A low INT is therefore valid after chip select
has been raised.

This would be easily implemented in a single driver. Unfortunately, we
don't write the SPI driver and I had to imagine some workaround trick to
get the SPI and NFC drivers to work in a synchronized fashion. The trick
is the following:

- send an empty spi message: this will raise the chip select line, and
send nothing. We expect the /CS line will stay arisen because we asked
for it in the spi_transfer cs_change field
- wait for a completion, that will be completed by the NFC driver IRQ
handler when it knows we are in the process of sending data (NFC spec
says that we use SPI in a half duplex mode, so we are either sending or
receiving).
- when completed, proceed with the normal data send.

This has been tested and verified to work very consistently on a Nexus
10 (spi-s3c64xx driver). It may not work the same with other spi
drivers.

The previously defined nci_spi_ops{} whose intended purpose were to
address this problem are not used anymore and therefore totally removed.

The nci_spi_send() takes a new optional write_handshake_completion
completion pointer. If non NULL, the nci spi layer will run the above
trick when sending data to the NFC Chip. If NULL, the data is sent
normally all at once and it is then the NFC driver responsibility to
know what it's doing.

Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-09-25 14:59:56 +02:00
..
hci NFC: hci: Fix enable/disable confusion 2013-08-14 01:13:36 +02:00
nci NFC: NCI: Modify NCI SPI to implement CS/INT handshake per the spec 2013-09-25 14:59:56 +02:00
af_nfc.c NFC: Core code identation fixes 2012-03-06 15:16:25 -05:00
core.c NFC: Set active target upon DEP up event reception 2013-09-25 01:35:41 +02:00
digital_core.c NFC: digital: Add newline to pr_* calls 2013-09-25 02:02:34 +02:00
digital_dep.c NFC: digital: Add newline to pr_* calls 2013-09-25 02:02:34 +02:00
digital_technology.c NFC: digital: Fix sens_res endiannes handling 2013-09-25 02:02:42 +02:00
digital.h NFC: digital: Remove PR_ERR and PR_DBG macros 2013-09-25 02:02:32 +02:00
Kconfig NFC Digital: Add NFC-F technology support 2013-09-25 02:02:25 +02:00
llcp_commands.c NFC: Rename nfc_llcp_disconnect() to nfc_llcp_send_disconnect() 2013-06-14 13:45:04 +02:00
llcp_core.c NFC: llcp: Fix the well known services endianness 2013-06-14 13:45:10 +02:00
llcp_sock.c NFC: llcp: Fix non blocking sockets connections 2013-06-14 13:45:07 +02:00
llcp.h NFC: llcp: Fix non blocking sockets connections 2013-06-14 13:45:07 +02:00
Makefile NFC Digital: Add initiator NFC-DEP support 2013-09-25 02:02:27 +02:00
netlink.c NFC: netlink: SE API implementation 2013-09-25 02:35:05 +02:00
nfc.h NFC: netlink: Add result of firmware operation to completion event 2013-08-14 01:12:58 +02:00
rawsock.c NFC: rawsock: Fix a memory leak 2013-09-25 02:02:40 +02:00