diff options
author | Thierry Escande <thierry.escande@linux.intel.com> | 2013-09-19 11:55:26 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-09-24 20:02:07 -0400 |
commit | 59ee2361c9248f07846f7a6e585768dcce18fb16 (patch) | |
tree | 05cb3823442a74481dbec0a7e34e002c12dff53e /include/net/nfc | |
parent | 4b10884eb428c243ae2070a539612e645f3d9b93 (diff) |
NFC Digital: Implement driver commands mechanism
This implements the mechanism used to send commands to the driver in
initiator mode through in_send_cmd().
Commands are serialized and sent to the driver by using a work item
on the system workqueue. Responses are handled asynchronously by
another work item. Once the digital stack receives the response through
the command_complete callback, the next command is sent to the driver.
This also implements the polling mechanism. It's handled by a work item
cycling on all supported protocols. The start poll command for a given
protocol is sent to the driver using the mechanism described above.
The process continues until a peer is discovered or stop_poll is
called. This patch implements the poll function for NFC-A that sends a
SENS_REQ command and waits for the SENS_RES response.
Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/net/nfc')
-rw-r--r-- | include/net/nfc/digital.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/net/nfc/digital.h b/include/net/nfc/digital.h index 8e16b6e0265a..aabd89400d23 100644 --- a/include/net/nfc/digital.h +++ b/include/net/nfc/digital.h | |||
@@ -146,6 +146,15 @@ struct nfc_digital_ops { | |||
146 | void (*abort_cmd)(struct nfc_digital_dev *ddev); | 146 | void (*abort_cmd)(struct nfc_digital_dev *ddev); |
147 | }; | 147 | }; |
148 | 148 | ||
149 | #define NFC_DIGITAL_POLL_MODE_COUNT_MAX 6 /* 106A, 212F, and 424F in & tg */ | ||
150 | |||
151 | typedef int (*digital_poll_t)(struct nfc_digital_dev *ddev, u8 rf_tech); | ||
152 | |||
153 | struct digital_poll_tech { | ||
154 | u8 rf_tech; | ||
155 | digital_poll_t poll_func; | ||
156 | }; | ||
157 | |||
149 | /** | 158 | /** |
150 | * Driver capabilities - bit mask made of the following values | 159 | * Driver capabilities - bit mask made of the following values |
151 | * | 160 | * |
@@ -168,6 +177,22 @@ struct nfc_digital_dev { | |||
168 | 177 | ||
169 | u32 driver_capabilities; | 178 | u32 driver_capabilities; |
170 | void *driver_data; | 179 | void *driver_data; |
180 | |||
181 | struct digital_poll_tech poll_techs[NFC_DIGITAL_POLL_MODE_COUNT_MAX]; | ||
182 | u8 poll_tech_count; | ||
183 | u8 poll_tech_index; | ||
184 | struct mutex poll_lock; | ||
185 | |||
186 | struct work_struct cmd_work; | ||
187 | struct work_struct cmd_complete_work; | ||
188 | struct list_head cmd_queue; | ||
189 | struct mutex cmd_lock; | ||
190 | |||
191 | struct work_struct poll_work; | ||
192 | |||
193 | u8 curr_protocol; | ||
194 | u8 curr_rf_tech; | ||
195 | u8 curr_nfc_dep_pni; | ||
171 | }; | 196 | }; |
172 | 197 | ||
173 | struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops, | 198 | struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops, |