Merge tag 'arc-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
[deliverable/linux.git] / drivers / nfc / nxp-nci / nxp-nci.h
1 /*
2 * Copyright (C) 2014 NXP Semiconductors All rights reserved.
3 *
4 * Authors: Clément Perrochaud <clement.perrochaud@nxp.com>
5 *
6 * Derived from PN544 device driver:
7 * Copyright (C) 2012 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
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
37 enum nxp_nci_mode {
38 NXP_NCI_MODE_COLD,
39 NXP_NCI_MODE_NCI,
40 NXP_NCI_MODE_FW
41 };
42
43 struct 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
48 struct 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
64 struct 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
79 int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name);
80 void nxp_nci_fw_work(struct work_struct *work);
81 void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
82 void nxp_nci_fw_work_complete(struct nxp_nci_info *info, int result);
83
84 int 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);
88 void nxp_nci_remove(struct nci_dev *ndev);
89
90 #endif /* __LOCAL_NXP_NCI_H_ */
This page took 0.031599 seconds and 5 git commands to generate.