30 #include <linux/module.h>
31 #include <linux/types.h>
38 #define NFCWILINK_CHNL 12
39 #define NFCWILINK_OPCODE 7
40 #define NFCWILINK_MAX_FRAME_SIZE 300
41 #define NFCWILINK_HDR_LEN 4
42 #define NFCWILINK_OFFSET_LEN_IN_HDR 1
43 #define NFCWILINK_LEN_SIZE 2
44 #define NFCWILINK_REGISTER_TIMEOUT 8000
45 #define NFCWILINK_CMD_TIMEOUT 5000
47 #define BTS_FILE_NAME_MAX_SIZE 40
48 #define BTS_FILE_HDR_MAGIC 0x42535442
49 #define BTS_FILE_CMD_MAX_LEN 0xff
50 #define BTS_FILE_ACTION_TYPE_SEND_CMD 1
52 #define NCI_VS_NFCC_INFO_CMD_GID 0x2f
53 #define NCI_VS_NFCC_INFO_CMD_OID 0x12
54 #define NCI_VS_NFCC_INFO_RSP_GID 0x4f
55 #define NCI_VS_NFCC_INFO_RSP_OID 0x12
112 static int nfcwilink_send(
struct sk_buff *
skb);
114 static inline struct sk_buff *nfcwilink_skb_alloc(
unsigned int len,
gfp_t how)
125 static void nfcwilink_fw_download_receive(
struct nfcwilink *drv,
146 unsigned long comp_ret;
155 "no memory for nci_vs_nfcc_info_cmd");
169 rc = nfcwilink_send(skb);
175 nfc_dev_dbg(&drv->
pdev->dev,
"wait_for_completion_timeout returned %ld",
179 "timeout on wait_for_completion_timeout");
183 nfc_dev_dbg(&drv->
pdev->dev,
"nci_vs_nfcc_info_rsp: plen %d, status %d",
189 "invalid nci_vs_nfcc_info_rsp");
194 "TINfcInit_%d.%d.%d.%d.bts",
209 unsigned long comp_ret;
220 "ignoring invalid bts cmd, len %d, chnl %d, opcode %d",
239 rc = nfcwilink_send(skb);
245 nfc_dev_dbg(&drv->
pdev->dev,
"wait_for_completion_timeout returned %ld",
249 "timeout on wait_for_completion_timeout");
256 static int nfcwilink_download_fw(
struct nfcwilink *drv)
260 __u16 action_type, action_len;
268 rc = nfcwilink_get_bts_file_name(drv, file_name);
286 if ((len == 0) || (ptr ==
NULL)) {
288 "request_firmware returned size %d", len);
310 action_type, action_len);
312 switch (action_type) {
314 rc = nfcwilink_send_bts_cmd(drv,
336 static void nfcwilink_register_complete(
void *priv_data,
char data)
350 static long nfcwilink_receive(
void *priv_data,
struct sk_buff *skb)
370 nfcwilink_fw_download_receive(drv, skb);
394 .
recv = nfcwilink_receive,
401 struct nfcwilink *drv = nci_get_drvdata(ndev);
402 unsigned long comp_ret;
425 "wait_for_completion_timeout returned %ld",
435 "st_register_cb failed %d", rc);
440 "st_register failed %d", rc);
449 if (nfcwilink_download_fw(drv)) {
464 static int nfcwilink_close(
struct nci_dev *ndev)
466 struct nfcwilink *drv = nci_get_drvdata(ndev);
483 static int nfcwilink_send(
struct sk_buff *skb)
486 struct nfcwilink *drv = nci_get_drvdata(ndev);
515 static struct nci_ops nfcwilink_ops = {
516 .open = nfcwilink_open,
517 .close = nfcwilink_close,
518 .send = nfcwilink_send,
553 nci_set_parent_dev(drv->
ndev, &pdev->
dev);
554 nci_set_drvdata(drv->
ndev, drv);
599 .probe = nfcwilink_probe,
600 .remove = nfcwilink_remove,