Skip to content

Commit 0329326

Browse files
Matti J. Aaltonentorvalds
authored andcommitted
NFC: Driver for NXP Semiconductors PN544 NFC chip.
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 <matti.j.aaltonen@nokia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6164281 commit 0329326

7 files changed

Lines changed: 1140 additions & 1 deletion

File tree

‎Documentation/nfc/nfc-pn544.txt‎

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

‎drivers/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ source "drivers/memstick/Kconfig"
8888

8989
source "drivers/leds/Kconfig"
9090

91+
source "drivers/nfc/Kconfig"
92+
9193
source "drivers/accessibility/Kconfig"
9294

9395
source "drivers/infiniband/Kconfig"

‎drivers/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ obj-$(CONFIG_FB_INTEL) += video/intelfb/
4040

4141
obj-y += serial/
4242
obj-$(CONFIG_PARPORT) += parport/
43-
obj-y += base/ block/ misc/ mfd/
43+
obj-y += base/ block/ misc/ mfd/ nfc/
4444
obj-$(CONFIG_NUBUS) += nubus/
4545
obj-y += macintosh/
4646
obj-$(CONFIG_IDE) += ide/

‎drivers/nfc/Kconfig‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Near Field Communication (NFC) devices
3+
#
4+
5+
menuconfig NFC_DEVICES
6+
bool "NFC devices"
7+
default n
8+
---help---
9+
You'll have to say Y if your computer contains an NFC device that
10+
you want to use under Linux.
11+
12+
You can say N here if you don't have any Near Field Communication
13+
devices connected to your computer.
14+
15+
if NFC_DEVICES
16+
17+
config PN544_NFC
18+
tristate "PN544 NFC driver"
19+
depends on I2C
20+
select CRC_CCITT
21+
default n
22+
---help---
23+
Say yes if you want PN544 Near Field Communication driver.
24+
This is for i2c connected version. If unsure, say N here.
25+
26+
To compile this driver as a module, choose m here. The module will
27+
be called pn544.
28+
29+
30+
endif # NFC_DEVICES

‎drivers/nfc/Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# Makefile for nfc devices
3+
#
4+
5+
obj-$(CONFIG_PN544_NFC) += pn544.o

0 commit comments

Comments
 (0)