diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2013-02-21 10:16:55 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2013-02-22 04:07:30 -0500 |
commit | edb15d83a875a1f4b1576188844db5c330c3267d (patch) | |
tree | 74d54eab401b6ccf2a6ad4821227108a8d160f03 /Documentation/nfc | |
parent | 8bfc245f9ad7bd4e461179e4e7852ef99b8b6144 (diff) | |
parent | a0b1c42951dd06ec83cc1bc2c9788131d9fefcd8 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into mips-for-linux-next
Conflicts:
include/linux/ssb/ssb_driver_gige.h
Also resolves a logical merge conflict in drivers/net/ethernet/broadcom/-
bgmac.c due to change of an API.
Diffstat (limited to 'Documentation/nfc')
-rw-r--r-- | Documentation/nfc/nfc-hci.txt | 129 | ||||
-rw-r--r-- | Documentation/nfc/nfc-pn544.txt | 84 |
2 files changed, 104 insertions, 109 deletions
diff --git a/Documentation/nfc/nfc-hci.txt b/Documentation/nfc/nfc-hci.txt index 89a339c9b079..0686c9e211c2 100644 --- a/Documentation/nfc/nfc-hci.txt +++ b/Documentation/nfc/nfc-hci.txt | |||
@@ -17,10 +17,12 @@ HCI | |||
17 | HCI registers as an nfc device with NFC Core. Requests coming from userspace are | 17 | HCI registers as an nfc device with NFC Core. Requests coming from userspace are |
18 | routed through netlink sockets to NFC Core and then to HCI. From this point, | 18 | routed through netlink sockets to NFC Core and then to HCI. From this point, |
19 | they are translated in a sequence of HCI commands sent to the HCI layer in the | 19 | they are translated in a sequence of HCI commands sent to the HCI layer in the |
20 | host controller (the chip). The sending context blocks while waiting for the | 20 | host controller (the chip). Commands can be executed synchronously (the sending |
21 | response to arrive. | 21 | context blocks waiting for response) or asynchronously (the response is returned |
22 | from HCI Rx context). | ||
22 | HCI events can also be received from the host controller. They will be handled | 23 | HCI events can also be received from the host controller. They will be handled |
23 | and a translation will be forwarded to NFC Core as needed. | 24 | and a translation will be forwarded to NFC Core as needed. There are hooks to |
25 | let the HCI driver handle proprietary events or override standard behavior. | ||
24 | HCI uses 2 execution contexts: | 26 | HCI uses 2 execution contexts: |
25 | - one for executing commands : nfc_hci_msg_tx_work(). Only one command | 27 | - one for executing commands : nfc_hci_msg_tx_work(). Only one command |
26 | can be executing at any given moment. | 28 | can be executing at any given moment. |
@@ -33,6 +35,8 @@ The Session initialization is an HCI standard which must unfortunately | |||
33 | support proprietary gates. This is the reason why the driver will pass a list | 35 | support proprietary gates. This is the reason why the driver will pass a list |
34 | of proprietary gates that must be part of the session. HCI will ensure all | 36 | of proprietary gates that must be part of the session. HCI will ensure all |
35 | those gates have pipes connected when the hci device is set up. | 37 | those gates have pipes connected when the hci device is set up. |
38 | In case the chip supports pre-opened gates and pseudo-static pipes, the driver | ||
39 | can pass that information to HCI core. | ||
36 | 40 | ||
37 | HCI Gates and Pipes | 41 | HCI Gates and Pipes |
38 | ------------------- | 42 | ------------------- |
@@ -46,6 +50,13 @@ without knowing the pipe connected to it. | |||
46 | Driver interface | 50 | Driver interface |
47 | ---------------- | 51 | ---------------- |
48 | 52 | ||
53 | A driver is generally written in two parts : the physical link management and | ||
54 | the HCI management. This makes it easier to maintain a driver for a chip that | ||
55 | can be connected using various phy (i2c, spi, ...) | ||
56 | |||
57 | HCI Management | ||
58 | -------------- | ||
59 | |||
49 | A driver would normally register itself with HCI and provide the following | 60 | A driver would normally register itself with HCI and provide the following |
50 | entry points: | 61 | entry points: |
51 | 62 | ||
@@ -53,58 +64,113 @@ struct nfc_hci_ops { | |||
53 | int (*open)(struct nfc_hci_dev *hdev); | 64 | int (*open)(struct nfc_hci_dev *hdev); |
54 | void (*close)(struct nfc_hci_dev *hdev); | 65 | void (*close)(struct nfc_hci_dev *hdev); |
55 | int (*hci_ready) (struct nfc_hci_dev *hdev); | 66 | int (*hci_ready) (struct nfc_hci_dev *hdev); |
56 | int (*xmit)(struct nfc_hci_dev *hdev, struct sk_buff *skb); | 67 | int (*xmit) (struct nfc_hci_dev *hdev, struct sk_buff *skb); |
57 | int (*start_poll)(struct nfc_hci_dev *hdev, u32 protocols); | 68 | int (*start_poll) (struct nfc_hci_dev *hdev, |
58 | int (*target_from_gate)(struct nfc_hci_dev *hdev, u8 gate, | 69 | u32 im_protocols, u32 tm_protocols); |
59 | struct nfc_target *target); | 70 | int (*dep_link_up)(struct nfc_hci_dev *hdev, struct nfc_target *target, |
71 | u8 comm_mode, u8 *gb, size_t gb_len); | ||
72 | int (*dep_link_down)(struct nfc_hci_dev *hdev); | ||
73 | int (*target_from_gate) (struct nfc_hci_dev *hdev, u8 gate, | ||
74 | struct nfc_target *target); | ||
60 | int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate, | 75 | int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate, |
61 | struct nfc_target *target); | 76 | struct nfc_target *target); |
62 | int (*data_exchange) (struct nfc_hci_dev *hdev, | 77 | int (*im_transceive) (struct nfc_hci_dev *hdev, |
63 | struct nfc_target *target, | 78 | struct nfc_target *target, struct sk_buff *skb, |
64 | struct sk_buff *skb, struct sk_buff **res_skb); | 79 | data_exchange_cb_t cb, void *cb_context); |
80 | int (*tm_send)(struct nfc_hci_dev *hdev, struct sk_buff *skb); | ||
65 | int (*check_presence)(struct nfc_hci_dev *hdev, | 81 | int (*check_presence)(struct nfc_hci_dev *hdev, |
66 | struct nfc_target *target); | 82 | struct nfc_target *target); |
83 | int (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, | ||
84 | struct sk_buff *skb); | ||
67 | }; | 85 | }; |
68 | 86 | ||
69 | - open() and close() shall turn the hardware on and off. | 87 | - open() and close() shall turn the hardware on and off. |
70 | - hci_ready() is an optional entry point that is called right after the hci | 88 | - hci_ready() is an optional entry point that is called right after the hci |
71 | session has been set up. The driver can use it to do additional initialization | 89 | session has been set up. The driver can use it to do additional initialization |
72 | that must be performed using HCI commands. | 90 | that must be performed using HCI commands. |
73 | - xmit() shall simply write a frame to the chip. | 91 | - xmit() shall simply write a frame to the physical link. |
74 | - start_poll() is an optional entrypoint that shall set the hardware in polling | 92 | - start_poll() is an optional entrypoint that shall set the hardware in polling |
75 | mode. This must be implemented only if the hardware uses proprietary gates or a | 93 | mode. This must be implemented only if the hardware uses proprietary gates or a |
76 | mechanism slightly different from the HCI standard. | 94 | mechanism slightly different from the HCI standard. |
95 | - dep_link_up() is called after a p2p target has been detected, to finish | ||
96 | the p2p connection setup with hardware parameters that need to be passed back | ||
97 | to nfc core. | ||
98 | - dep_link_down() is called to bring the p2p link down. | ||
77 | - target_from_gate() is an optional entrypoint to return the nfc protocols | 99 | - target_from_gate() is an optional entrypoint to return the nfc protocols |
78 | corresponding to a proprietary gate. | 100 | corresponding to a proprietary gate. |
79 | - complete_target_discovered() is an optional entry point to let the driver | 101 | - complete_target_discovered() is an optional entry point to let the driver |
80 | perform additional proprietary processing necessary to auto activate the | 102 | perform additional proprietary processing necessary to auto activate the |
81 | discovered target. | 103 | discovered target. |
82 | - data_exchange() must be implemented by the driver if proprietary HCI commands | 104 | - im_transceive() must be implemented by the driver if proprietary HCI commands |
83 | are required to send data to the tag. Some tag types will require custom | 105 | are required to send data to the tag. Some tag types will require custom |
84 | commands, others can be written to using the standard HCI commands. The driver | 106 | commands, others can be written to using the standard HCI commands. The driver |
85 | can check the tag type and either do proprietary processing, or return 1 to ask | 107 | can check the tag type and either do proprietary processing, or return 1 to ask |
86 | for standard processing. | 108 | for standard processing. The data exchange command itself must be sent |
109 | asynchronously. | ||
110 | - tm_send() is called to send data in the case of a p2p connection | ||
87 | - check_presence() is an optional entry point that will be called regularly | 111 | - check_presence() is an optional entry point that will be called regularly |
88 | by the core to check that an activated tag is still in the field. If this is | 112 | by the core to check that an activated tag is still in the field. If this is |
89 | not implemented, the core will not be able to push tag_lost events to the user | 113 | not implemented, the core will not be able to push tag_lost events to the user |
90 | space | 114 | space |
115 | - event_received() is called to handle an event coming from the chip. Driver | ||
116 | can handle the event or return 1 to let HCI attempt standard processing. | ||
91 | 117 | ||
92 | On the rx path, the driver is responsible to push incoming HCP frames to HCI | 118 | On the rx path, the driver is responsible to push incoming HCP frames to HCI |
93 | using nfc_hci_recv_frame(). HCI will take care of re-aggregation and handling | 119 | using nfc_hci_recv_frame(). HCI will take care of re-aggregation and handling |
94 | This must be done from a context that can sleep. | 120 | This must be done from a context that can sleep. |
95 | 121 | ||
96 | SHDLC | 122 | PHY Management |
97 | ----- | 123 | -------------- |
124 | |||
125 | The physical link (i2c, ...) management is defined by the following struture: | ||
126 | |||
127 | struct nfc_phy_ops { | ||
128 | int (*write)(void *dev_id, struct sk_buff *skb); | ||
129 | int (*enable)(void *dev_id); | ||
130 | void (*disable)(void *dev_id); | ||
131 | }; | ||
132 | |||
133 | enable(): turn the phy on (power on), make it ready to transfer data | ||
134 | disable(): turn the phy off | ||
135 | write(): Send a data frame to the chip. Note that to enable higher | ||
136 | layers such as an llc to store the frame for re-emission, this function must | ||
137 | not alter the skb. It must also not return a positive result (return 0 for | ||
138 | success, negative for failure). | ||
139 | |||
140 | Data coming from the chip shall be sent directly to nfc_hci_recv_frame(). | ||
141 | |||
142 | LLC | ||
143 | --- | ||
144 | |||
145 | Communication between the CPU and the chip often requires some link layer | ||
146 | protocol. Those are isolated as modules managed by the HCI layer. There are | ||
147 | currently two modules : nop (raw transfert) and shdlc. | ||
148 | A new llc must implement the following functions: | ||
149 | |||
150 | struct nfc_llc_ops { | ||
151 | void *(*init) (struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv, | ||
152 | rcv_to_hci_t rcv_to_hci, int tx_headroom, | ||
153 | int tx_tailroom, int *rx_headroom, int *rx_tailroom, | ||
154 | llc_failure_t llc_failure); | ||
155 | void (*deinit) (struct nfc_llc *llc); | ||
156 | int (*start) (struct nfc_llc *llc); | ||
157 | int (*stop) (struct nfc_llc *llc); | ||
158 | void (*rcv_from_drv) (struct nfc_llc *llc, struct sk_buff *skb); | ||
159 | int (*xmit_from_hci) (struct nfc_llc *llc, struct sk_buff *skb); | ||
160 | }; | ||
161 | |||
162 | - init() : allocate and init your private storage | ||
163 | - deinit() : cleanup | ||
164 | - start() : establish the logical connection | ||
165 | - stop () : terminate the logical connection | ||
166 | - rcv_from_drv() : handle data coming from the chip, going to HCI | ||
167 | - xmit_from_hci() : handle data sent by HCI, going to the chip | ||
98 | 168 | ||
99 | Most chips use shdlc to ensure integrity and delivery ordering of the HCP | 169 | The llc must be registered with nfc before it can be used. Do that by |
100 | frames between the host controller (the chip) and hosts (entities connected | 170 | calling nfc_llc_register(const char *name, struct nfc_llc_ops *ops); |
101 | to the chip, like the cpu). In order to simplify writing the driver, an shdlc | 171 | |
102 | layer is available for use by the driver. | 172 | Again, note that the llc does not handle the physical link. It is thus very |
103 | When used, the driver actually registers with shdlc, and shdlc will register | 173 | easy to mix any physical link with any llc for a given chip driver. |
104 | with HCI. HCI sees shdlc as the driver and thus send its HCP frames | ||
105 | through shdlc->xmit. | ||
106 | SHDLC adds a new execution context (nfc_shdlc_sm_work()) to run its state | ||
107 | machine and handle both its rx and tx path. | ||
108 | 174 | ||
109 | Included Drivers | 175 | Included Drivers |
110 | ---------------- | 176 | ---------------- |
@@ -117,10 +183,12 @@ Execution Contexts | |||
117 | 183 | ||
118 | The execution contexts are the following: | 184 | The execution contexts are the following: |
119 | - IRQ handler (IRQH): | 185 | - IRQ handler (IRQH): |
120 | fast, cannot sleep. stores incoming frames into an shdlc rx queue | 186 | fast, cannot sleep. sends incoming frames to HCI where they are passed to |
187 | the current llc. In case of shdlc, the frame is queued in shdlc rx queue. | ||
121 | 188 | ||
122 | - SHDLC State Machine worker (SMW) | 189 | - SHDLC State Machine worker (SMW) |
123 | handles shdlc rx & tx queues. Dispatches HCI cmd responses. | 190 | Only when llc_shdlc is used: handles shdlc rx & tx queues. |
191 | Dispatches HCI cmd responses. | ||
124 | 192 | ||
125 | - HCI Tx Cmd worker (MSGTXWQ) | 193 | - HCI Tx Cmd worker (MSGTXWQ) |
126 | Serializes execution of HCI commands. Completes execution in case of response | 194 | Serializes execution of HCI commands. Completes execution in case of response |
@@ -166,6 +234,15 @@ waiting command execution. Response processing involves invoking the completion | |||
166 | callback that was provided by nfc_hci_msg_tx_work() when it sent the command. | 234 | callback that was provided by nfc_hci_msg_tx_work() when it sent the command. |
167 | The completion callback will then wake the syscall context. | 235 | The completion callback will then wake the syscall context. |
168 | 236 | ||
237 | It is also possible to execute the command asynchronously using this API: | ||
238 | |||
239 | static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | ||
240 | const u8 *param, size_t param_len, | ||
241 | data_exchange_cb_t cb, void *cb_context) | ||
242 | |||
243 | The workflow is the same, except that the API call returns immediately, and | ||
244 | the callback will be called with the result from the SMW context. | ||
245 | |||
169 | Workflow receiving an HCI event or command | 246 | Workflow receiving an HCI event or command |
170 | ------------------------------------------ | 247 | ------------------------------------------ |
171 | 248 | ||
diff --git a/Documentation/nfc/nfc-pn544.txt b/Documentation/nfc/nfc-pn544.txt index 2fcac9f5996e..b36ca14ca2d6 100644 --- a/Documentation/nfc/nfc-pn544.txt +++ b/Documentation/nfc/nfc-pn544.txt | |||
@@ -1,32 +1,15 @@ | |||
1 | Kernel driver for the NXP Semiconductors PN544 Near Field | 1 | Kernel driver for the NXP Semiconductors PN544 Near Field |
2 | Communication chip | 2 | Communication chip |
3 | 3 | ||
4 | Author: Jari Vanhala | ||
5 | Contact: Matti Aaltonen (matti.j.aaltonen at nokia.com) | ||
6 | |||
7 | General | 4 | General |
8 | ------- | 5 | ------- |
9 | 6 | ||
10 | The PN544 is an integrated transmission module for contactless | 7 | The PN544 is an integrated transmission module for contactless |
11 | communication. The driver goes under drives/nfc/ and is compiled as a | 8 | 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 | 9 | module named "pn544". |
13 | file named "/dev/pn544". | ||
14 | 10 | ||
15 | Host Interfaces: I2C, SPI and HSU, this driver supports currently only I2C. | 11 | Host Interfaces: I2C, SPI and HSU, this driver supports currently only I2C. |
16 | 12 | ||
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 | 13 | Protocols |
31 | --------- | 14 | --------- |
32 | 15 | ||
@@ -47,68 +30,3 @@ and third (LSB) bytes of the message. The maximum FW message length is | |||
47 | 30 | ||
48 | For the ETSI HCI specification see | 31 | For the ETSI HCI specification see |
49 | http://www.etsi.org/WebSite/Technologies/ProtocolSpecification.aspx | 32 | 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 | }; | ||