1. 02 12月, 2014 5 次提交
  2. 28 11月, 2014 9 次提交
  3. 24 9月, 2014 1 次提交
    • C
      NFC: nci: Add support for proprietary RF Protocols · 9e87f9a9
      Christophe Ricard 提交于
      In NFC Forum NCI specification, some RF Protocol values are
      reserved for proprietary use (from 0x80 to 0xfe).
      Some CLF vendor may need to use one value within this range
      for specific technology.
      Furthermore, some CLF may not becompliant with NFC Froum NCI
      specification 2.0 and therefore will not support RF Protocol
      value 0x06 for PROTOCOL_T5T as mention in a draft specification
      and in a recent push.
      
      Adding get_rf_protocol handle to the nci_ops structure will
      help to set the correct technology to target.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      9e87f9a9
  4. 01 9月, 2014 1 次提交
  5. 23 7月, 2014 3 次提交
  6. 21 7月, 2014 1 次提交
  7. 20 5月, 2014 1 次提交
  8. 22 4月, 2014 2 次提交
  9. 11 3月, 2014 1 次提交
  10. 17 2月, 2014 2 次提交
  11. 07 1月, 2014 2 次提交
  12. 04 1月, 2014 1 次提交
  13. 07 12月, 2013 1 次提交
  14. 25 9月, 2013 10 次提交
    • E
      NFC: NCI: Modify NCI SPI to implement CS/INT handshake per the spec · 2bed2785
      Eric Lapuyade 提交于
      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: NEric Lapuyade <eric.lapuyade@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      2bed2785
    • E
      NFC: NCI: nci_spi_recv_frame() now returns (not forward) the read frame · 22d4aae5
      Eric Lapuyade 提交于
      Previously, nci_spi_recv_frame() would directly transmit incoming frames
      to the NCI Core. However, it turns out that some NFC NCI Chips will add
      additional proprietary headers that must be handled/removed before NCI
      Core gets a chance to handle the frame. With this modification, the chip
      phy or driver are now responsible to transmit incoming frames to NCI
      Core after proper treatment, and NCI SPI becomes a driver helper instead
      of sitting between the NFC driver and NCI Core.
      
      As a general rule in NFC, *_recv_frame() APIs are used to deliver an
      incoming frame to an upper layer. To better suit the actual purpose of
      nci_spi_recv_frame(), and go along with its nci_spi_send()
      counterpart, the function is renamed to nci_spi_read()
      
      The skb is returned as the function result
      Signed-off-by: NEric Lapuyade <eric.lapuyade@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      22d4aae5
    • S
      NFC: Define secure element IO API and commands · 72b70b6e
      Samuel Ortiz 提交于
      In order to send and receive ISO7816 APDUs to and from NFC embedded
      secure elements, we define a specific netlink command.
      On a typical SE use case, host applications will send very few APDUs
      (Less than 10) per transaction. This is why we decided to go for a
      simple netlink API. Defining another NFC socket protocol for such low
      traffic would have been overengineered.
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      72b70b6e
    • S
      NFC: Document NFC targets sens_res field · b9c0c678
      Samuel Ortiz 提交于
      SENS_RES has no specific endiannes attached to it, the kernel ABI is the
      following one: Byte 2 (As described by the NFC Forum Digital spec) is
      the u16 most significant byte.
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      b9c0c678
    • T
      NFC Digital: Add NFC-A technology support · 2c66daec
      Thierry Escande 提交于
      This adds support for NFC-A technology at 106 kbits/s. The stack can
      detect tags of type 1 and 2. There is no support for collision
      detection. Tags can be read and written by using a user space
      application or a daemon like neard.
      
      The flow of polling operations for NFC-A detection is as follow:
      
      1 - The digital stack sends the SENS_REQ command to the NFC device.
      2 - The NFC device receives a SENS_RES response from a peer device and
          passes it to the digital stack.
      3   - If the SENS_RES response identifies a type 1 tag, detection ends.
            NFC core is notified through nfc_targets_found().
      4   - Otherwise, the digital stack sets the cascade level of NFCID1 to
            CL1 and sends the SDD_REQ command.
      5 - The digital stack selects SEL_CMD and SEL_PAR according to the
          cascade level and sends the SDD_REQ command.
      4 - The digital stack receives a SDD_RES response for the cascade level
          passed in the SDD_REQ command.
      5 - The digital stack analyses (part of) NFCID1 and verify BCC.
      6 - The digital stack sends the SEL_REQ command with the NFCID1
          received in the SDD_RES.
      6 - The peer device replies with a SEL_RES response
      7   - Detection ends if NFCID1 is complete. NFC core notified of new
            target by nfc_targets_found().
      8   - If NFCID1 is not complete, the cascade level is incremented (up
            to and including CL3) and the execution continues at step 5 to
            get the remaining bytes of NFCID1.
      
      Once target detection is done, type 1 and 2 tag commands must be
      handled by a user space application (i.e neard) through the NFC core.
      Responses for type 1 tag are returned directly to user space via NFC
      core.
      Responses of type 2 commands are handled differently. The digital stack
      doesn't analyse the type of commands sent through im_transceive() and
      must differentiate valid responses from error ones.
      The response process flow is as follow:
      
      1 - If the response length is 16 bytes, it is a valid response of a
          READ command. the packet is returned to the NFC core through the
          callback passed to im_transceive(). Processing stops.
      2 - If the response is 1 byte long and is a ACK byte (0x0A), it is a
          valid response of a WRITE command for example. First packet byte
          is set to 0 for no-error and passed back to the NFC core.
          Processing stops.
      3 - Any other response is treated as an error and -EIO error code is
          returned to the NFC core through the response callback.
      
      Moreover, since the driver can't differentiate success response from a
      NACK response, the digital stack has to handle CRC calculation.
      
      Thus, this patch also adds support for CRC calculation. If the driver
      doesn't handle it, the digital stack will calculate CRC and will add it
      to sent frames. CRC will also be checked and removed from received
      frames. Pointers to the correct CRC calculation functions are stored in
      the digital stack device structure when a target is detected. This
      avoids the need to check the current target type for every call to
      im_transceive() and for every response received from a peer device.
      Signed-off-by: NThierry Escande <thierry.escande@linux.intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      2c66daec
    • T
      NFC Digital: Implement driver commands mechanism · 59ee2361
      Thierry Escande 提交于
      This implements the mechanism used to send commands to the driver in
      initiator mode through in_send_cmd().
      
      Commands are serialized and sent to the driver by using a work item
      on the system workqueue. Responses are handled asynchronously by
      another work item. Once the digital stack receives the response through
      the command_complete callback, the next command is sent to the driver.
      
      This also implements the polling mechanism. It's handled by a work item
      cycling on all supported protocols. The start poll command for a given
      protocol is sent to the driver using the mechanism described above.
      The process continues until a peer is discovered or stop_poll is
      called. This patch implements the poll function for NFC-A that sends a
      SENS_REQ command and waits for the SENS_RES response.
      Signed-off-by: NThierry Escande <thierry.escande@linux.intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      59ee2361
    • T
      NFC: Digital Protocol stack implementation · 4b10884e
      Thierry Escande 提交于
      This is the initial commit of the NFC Digital Protocol stack
      implementation.
      
      It offers an interface for devices that don't have an embedded NFC
      Digital protocol stack. The driver instantiates the digital stack by
      calling nfc_digital_allocate_device(). Within the nfc_digital_ops
      structure, the driver specifies a set of function pointers for driver
      operations. These functions must be implemented by the driver and are:
      
      in_configure_hw:
      Hardware configuration for RF technology and communication framing in
      initiator mode. This is a synchronous function.
      
      in_send_cmd:
      Initiator mode data exchange using RF technology and framing previously
      set with in_configure_hw. The peer response is returned through
      callback cb. If an io error occurs or the peer didn't reply within the
      specified timeout (ms), the error code is passed back through the resp
      pointer. This is an asynchronous function.
      
      tg_configure_hw:
      Hardware configuration for RF technology and communication framing in
      target mode. This is a synchronous function.
      
      tg_send_cmd:
      Target mode data exchange using RF technology and framing previously
      set with tg_configure_hw. The peer next command is returned through
      callback cb. If an io error occurs or the peer didn't reply within the
      specified timeout (ms), the error code is passed back through the resp
      pointer. This is an asynchronous function.
      
      tg_listen:
      Put the device in listen mode waiting for data from the peer device.
      This is an asynchronous function.
      
      tg_listen_mdaa:
      If supported, put the device in automatic listen mode with mode
      detection and automatic anti-collision. In this mode, the device
      automatically detects the RF technology and executes the
      anti-collision detection using the command responses specified in
      mdaa_params. The mdaa_params structure contains SENS_RES, NFCID1, and
      SEL_RES for 106A RF tech. NFCID2 and system code (sc) for 212F and
      424F. The driver returns the NFC-DEP ATR_REQ command through cb. The
      digital stack deducts the RF tech by analyzing the SoD of the frame
      containing the ATR_REQ command. This is an asynchronous function.
      
      switch_rf:
      Turns device radio on or off. The stack does not call explicitly
      switch_rf to turn the radio on. A call to in|tg_configure_hw must turn
      the device radio on.
      
      abort_cmd:
      Discard the last sent command.
      
      Then the driver registers itself against the digital stack by using
      nfc_digital_register_device() which in turn registers the digital stack
      against the NFC core layer. The digital stack implements common NFC
      operations like dev_up(), dev_down(), start_poll(), stop_poll(), etc.
      
      This patch is only a skeleton and NFC operations are just stubs.
      Signed-off-by: NThierry Escande <thierry.escande@linux.intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      4b10884e
    • E
      NFC: NCI: Simplify NCI SPI to become a simple framing/checking layer · fa544fff
      Eric Lapuyade 提交于
      NCI SPI layer should not manage the nci dev, this is the job of the nci
      chipset driver. This layer should be limited to frame/deframe nci
      packets, and optionnaly check integrity (crc) and manage the ack/nak
      protocol.
      
      The NCI SPI must not be mixed up with an NCI dev. spi_[dev|device] are
      therefore renamed to a simple spi for more clarity.
      The header and crc sizes are moved to nci.h so that drivers can use
      them to reserve space in outgoing skbs.
      nci_spi_send() is exported to be accessible by drivers.
      Signed-off-by: NEric Lapuyade <eric.lapuyade@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      fa544fff
    • E
      NFC: Move struct nfc_phy_ops out of HCI up to nfc core level · 08f13acf
      Eric Lapuyade 提交于
      struct nfc_phy_ops is not an HCI structure only, it can also be used by
      NCI or direct NFC Core drivers.
      Signed-off-by: NEric Lapuyade <eric.lapuyade@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      08f13acf
    • E
      NFC: NCI: Rename spi ndev -> nsdev and nci_dev -> ndev for consistency · d5937511
      Eric Lapuyade 提交于
      An hci dev is an hdev. An nci dev is an ndev. Calling an nci spi dev an
      ndev is misleading since it's not the same thing. The nci dev contained
      in the nci spi dev is also named inconsistently.
      Signed-off-by: NEric Lapuyade <eric.lapuyade@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      d5937511