1
2
3
4
5
6
7
8
9
10
11#ifndef __LOCAL_NXP_NCI_H_
12#define __LOCAL_NXP_NCI_H_
13
14#include <linux/completion.h>
15#include <linux/firmware.h>
16#include <linux/nfc.h>
17#include <linux/platform_data/nxp-nci.h>
18
19#include <net/nfc/nci_core.h>
20
21#define NXP_NCI_FW_HDR_LEN 2
22#define NXP_NCI_FW_CRC_LEN 2
23
24#define NXP_NCI_FW_FRAME_LEN_MASK 0x03FF
25
26enum nxp_nci_mode {
27 NXP_NCI_MODE_COLD,
28 NXP_NCI_MODE_NCI,
29 NXP_NCI_MODE_FW
30};
31
32struct nxp_nci_phy_ops {
33 int (*set_mode)(void *id, enum nxp_nci_mode mode);
34 int (*write)(void *id, struct sk_buff *skb);
35};
36
37struct nxp_nci_fw_info {
38 char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
39 const struct firmware *fw;
40
41 size_t size;
42 size_t written;
43
44 const u8 *data;
45 size_t frame_size;
46
47 struct work_struct work;
48 struct completion cmd_completion;
49
50 int cmd_result;
51};
52
53struct nxp_nci_info {
54 struct nci_dev *ndev;
55 void *phy_id;
56 struct device *pdev;
57
58 enum nxp_nci_mode mode;
59
60 const struct nxp_nci_phy_ops *phy_ops;
61 unsigned int max_payload;
62
63 struct mutex info_lock;
64
65 struct nxp_nci_fw_info fw_info;
66};
67
68int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name);
69void nxp_nci_fw_work(struct work_struct *work);
70void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
71void nxp_nci_fw_work_complete(struct nxp_nci_info *info, int result);
72
73int nxp_nci_probe(void *phy_id, struct device *pdev,
74 const struct nxp_nci_phy_ops *phy_ops,
75 unsigned int max_payload,
76 struct nci_dev **ndev);
77void nxp_nci_remove(struct nci_dev *ndev);
78
79#endif
80