nfc-pn544.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Kernel driver for the NXP Semiconductors PN544 Near Field
  2. Communication chip
  3. Author: Jari Vanhala
  4. Contact: Matti Aaltonen (matti.j.aaltonen at nokia.com)
  5. General
  6. -------
  7. The PN544 is an integrated transmission module for contactless
  8. communication. The driver goes under drives/nfc/ and is compiled as a
  9. module named "pn544". It registers a misc device and creates a device
  10. file named "/dev/pn544".
  11. Host Interfaces: I2C, SPI and HSU, this driver supports currently only I2C.
  12. The Interface
  13. -------------
  14. The driver offers a sysfs interface for a hardware test and an IOCTL
  15. interface for selecting between two operating modes. There are read,
  16. write and poll functions for transferring messages. The two operating
  17. modes are the normal (HCI) mode and the firmware update mode.
  18. PN544 is controlled by sending messages from the userspace to the
  19. chip. The main function of the driver is just to pass those messages
  20. without caring about the message content.
  21. Protocols
  22. ---------
  23. In the normal (HCI) mode and in the firmware update mode read and
  24. write functions behave a bit differently because the message formats
  25. or the protocols are different.
  26. In the normal (HCI) mode the protocol used is derived from the ETSI
  27. HCI specification. The firmware is updated using a specific protocol,
  28. which is different from HCI.
  29. HCI messages consist of an eight bit header and the message body. The
  30. header contains the message length. Maximum size for an HCI message is
  31. 33. In HCI mode sent messages are tested for a correct
  32. checksum. Firmware update messages have the length in the second (MSB)
  33. and third (LSB) bytes of the message. The maximum FW message length is
  34. 1024 bytes.
  35. For the ETSI HCI specification see
  36. http://www.etsi.org/WebSite/Technologies/ProtocolSpecification.aspx
  37. The Hardware Test
  38. -----------------
  39. The idea of the test is that it can performed by reading from the
  40. corresponding sysfs file. The test is implemented in the board file
  41. and it should test that PN544 can be put into the firmware update
  42. mode. If the test is not implemented the sysfs file does not get
  43. created.
  44. Example:
  45. > cat /sys/module/pn544/drivers/i2c\:pn544/3-002b/nfc_test
  46. 1
  47. Normal Operation
  48. ----------------
  49. PN544 is powered up when the device file is opened, otherwise it's
  50. turned off. Only one instance can use the device at a time.
  51. Userspace applications control PN544 with HCI messages. The hardware
  52. sends an interrupt when data is available for reading. Data is
  53. physically read when the read function is called by a userspace
  54. application. Poll() checks the read interrupt state. Configuration and
  55. self testing are also done from the userspace using read and write.
  56. Example platform data:
  57. static int rx71_pn544_nfc_request_resources(struct i2c_client *client)
  58. {
  59. /* Get and setup the HW resources for the device */
  60. }
  61. static void rx71_pn544_nfc_free_resources(void)
  62. {
  63. /* Release the HW resources */
  64. }
  65. static void rx71_pn544_nfc_enable(int fw)
  66. {
  67. /* Turn the device on */
  68. }
  69. static int rx71_pn544_nfc_test(void)
  70. {
  71. /*
  72. * Put the device into the FW update mode
  73. * and then back to the normal mode.
  74. * Check the behavior and return one on success,
  75. * zero on failure.
  76. */
  77. }
  78. static void rx71_pn544_nfc_disable(void)
  79. {
  80. /* turn the power off */
  81. }
  82. static struct pn544_nfc_platform_data rx71_nfc_data = {
  83. .request_resources = rx71_pn544_nfc_request_resources,
  84. .free_resources = rx71_pn544_nfc_free_resources,
  85. .enable = rx71_pn544_nfc_enable,
  86. .test = rx71_pn544_nfc_test,
  87. .disable = rx71_pn544_nfc_disable,
  88. };