summaryrefslogtreecommitdiffstats
path: root/Documentation/nfc/nfc-pn544.txt
blob: 2fcac9f5996e32386459c1c066c2447227d79a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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,
};
OpenPOWER on IntegriCloud