Skip to content

Commit

Permalink
NFC: Driver for NXP Semiconductors PN544 NFC chip.
Browse files Browse the repository at this point in the history
Creates a new "Near Field Communication" subsystem in drivers/nfc.
http://en.wikipedia.org/wiki/Near_Field_Communication is useful ;)

This is a driver for the pn544 NFC device. The driver transfers
ETSI messages between the device and the user space.

Signed-off-by: Matti J. Aaltonen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Matti J. Aaltonen authored and torvalds committed Jan 13, 2011
1 parent 6164281 commit 0329326
Show file tree
Hide file tree
Showing 7 changed files with 1,140 additions and 1 deletion.
114 changes: 114 additions & 0 deletions Documentation/nfc/nfc-pn544.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Kernel driver for the NXP Semiconductors PN544 Near Field
Communication chip

Author: Jari Vanhala
Contact: Matti Aaltonen (matti.j.aaltonen at nokia.com)

General
-------

The PN544 is an integrated transmission module for contactless
communication. The driver goes under drives/nfc/ and is compiled as a
module named "pn544". It registers a misc device and creates a device
file named "/dev/pn544".

Host Interfaces: I2C, SPI and HSU, this driver supports currently only I2C.

The Interface
-------------

The driver offers a sysfs interface for a hardware test and an IOCTL
interface for selecting between two operating modes. There are read,
write and poll functions for transferring messages. The two operating
modes are the normal (HCI) mode and the firmware update mode.

PN544 is controlled by sending messages from the userspace to the
chip. The main function of the driver is just to pass those messages
without caring about the message content.


Protocols
---------

In the normal (HCI) mode and in the firmware update mode read and
write functions behave a bit differently because the message formats
or the protocols are different.

In the normal (HCI) mode the protocol used is derived from the ETSI
HCI specification. The firmware is updated using a specific protocol,
which is different from HCI.

HCI messages consist of an eight bit header and the message body. The
header contains the message length. Maximum size for an HCI message is
33. In HCI mode sent messages are tested for a correct
checksum. Firmware update messages have the length in the second (MSB)
and third (LSB) bytes of the message. The maximum FW message length is
1024 bytes.

For the ETSI HCI specification see
http://www.etsi.org/WebSite/Technologies/ProtocolSpecification.aspx

The Hardware Test
-----------------

The idea of the test is that it can performed by reading from the
corresponding sysfs file. The test is implemented in the board file
and it should test that PN544 can be put into the firmware update
mode. If the test is not implemented the sysfs file does not get
created.

Example:
> cat /sys/module/pn544/drivers/i2c\:pn544/3-002b/nfc_test
1

Normal Operation
----------------

PN544 is powered up when the device file is opened, otherwise it's
turned off. Only one instance can use the device at a time.

Userspace applications control PN544 with HCI messages. The hardware
sends an interrupt when data is available for reading. Data is
physically read when the read function is called by a userspace
application. Poll() checks the read interrupt state. Configuration and
self testing are also done from the userspace using read and write.

Example platform data:

static int rx71_pn544_nfc_request_resources(struct i2c_client *client)
{
/* Get and setup the HW resources for the device */
}

static void rx71_pn544_nfc_free_resources(void)
{
/* Release the HW resources */
}

static void rx71_pn544_nfc_enable(int fw)
{
/* Turn the device on */
}

static int rx71_pn544_nfc_test(void)
{
/*
* Put the device into the FW update mode
* and then back to the normal mode.
* Check the behavior and return one on success,
* zero on failure.
*/
}

static void rx71_pn544_nfc_disable(void)
{
/* turn the power off */
}

static struct pn544_nfc_platform_data rx71_nfc_data = {
.request_resources = rx71_pn544_nfc_request_resources,
.free_resources = rx71_pn544_nfc_free_resources,
.enable = rx71_pn544_nfc_enable,
.test = rx71_pn544_nfc_test,
.disable = rx71_pn544_nfc_disable,
};
2 changes: 2 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ source "drivers/memstick/Kconfig"

source "drivers/leds/Kconfig"

source "drivers/nfc/Kconfig"

source "drivers/accessibility/Kconfig"

source "drivers/infiniband/Kconfig"
Expand Down
2 changes: 1 addition & 1 deletion drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ obj-$(CONFIG_FB_INTEL) += video/intelfb/

obj-y += serial/
obj-$(CONFIG_PARPORT) += parport/
obj-y += base/ block/ misc/ mfd/
obj-y += base/ block/ misc/ mfd/ nfc/
obj-$(CONFIG_NUBUS) += nubus/
obj-y += macintosh/
obj-$(CONFIG_IDE) += ide/
Expand Down
30 changes: 30 additions & 0 deletions drivers/nfc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Near Field Communication (NFC) devices
#

menuconfig NFC_DEVICES
bool "NFC devices"
default n
---help---
You'll have to say Y if your computer contains an NFC device that
you want to use under Linux.

You can say N here if you don't have any Near Field Communication
devices connected to your computer.

if NFC_DEVICES

config PN544_NFC
tristate "PN544 NFC driver"
depends on I2C
select CRC_CCITT
default n
---help---
Say yes if you want PN544 Near Field Communication driver.
This is for i2c connected version. If unsure, say N here.

To compile this driver as a module, choose m here. The module will
be called pn544.


endif # NFC_DEVICES
5 changes: 5 additions & 0 deletions drivers/nfc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Makefile for nfc devices
#

obj-$(CONFIG_PN544_NFC) += pn544.o
Loading

0 comments on commit 0329326

Please sign in to comment.