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