aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc/nfcmrvl/fw_dnld.h
diff options
context:
space:
mode:
authorVincent Cuissard <cuissard@marvell.com>2015-10-26 05:27:39 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2015-10-26 23:18:44 -0400
commit3194c6870158e305dac2af52f83681e9cb67280f (patch)
treeb4fc6cbfbd419132051f3a06d67c5d827a5d6e5a /drivers/nfc/nfcmrvl/fw_dnld.h
parente5629d29470134af1954d2bbe45c4f2b73f68ee9 (diff)
NFC: nfcmrvl: add firmware download support
Implement firmware download protocol for Marvell NFC controllers. This protocol is based on NCI frames that's why parts of its implementation use some NCI generic functions. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/nfcmrvl/fw_dnld.h')
-rw-r--r--drivers/nfc/nfcmrvl/fw_dnld.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/nfc/nfcmrvl/fw_dnld.h b/drivers/nfc/nfcmrvl/fw_dnld.h
new file mode 100644
index 000000000000..ee4a339c05fd
--- /dev/null
+++ b/drivers/nfc/nfcmrvl/fw_dnld.h
@@ -0,0 +1,98 @@
1/**
2 * Marvell NFC driver: Firmware downloader
3 *
4 * Copyright (C) 2015, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available on the worldwide web at
11 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12 *
13 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
14 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
15 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
16 * this warranty disclaimer.
17 **/
18
19#ifndef __NFCMRVL_FW_DNLD_H__
20#define __NFCMRVL_FW_DNLD_H__
21
22#include <linux/workqueue.h>
23
24#define NFCMRVL_FW_MAGIC 0x88888888
25
26#define NCI_OP_PROP_BOOT_CMD 0x3A
27
28#define NCI_CORE_LC_PROP_FW_DL 0xFD
29#define NCI_CORE_LC_CONNID_PROP_FW_DL 0x02
30
31#define HELPER_CMD_ENTRY_POINT 0x04
32#define HELPER_CMD_PACKET_FORMAT 0xA5
33#define HELPER_ACK_PACKET_FORMAT 0x5A
34#define HELPER_RETRY_REQUESTED (1 << 15)
35
36struct nfcmrvl_private;
37
38struct nfcmrvl_fw_uart_config {
39 uint8_t flow_control;
40 uint32_t baudrate;
41} __packed;
42
43struct nfcmrvl_fw_i2c_config {
44 uint32_t clk;
45} __packed;
46
47struct nfcmrvl_fw_spi_config {
48 uint32_t clk;
49} __packed;
50
51struct nfcmrvl_fw_binary_config {
52 uint32_t offset;
53 union {
54 void *config;
55 struct nfcmrvl_fw_uart_config uart;
56 struct nfcmrvl_fw_i2c_config i2c;
57 struct nfcmrvl_fw_spi_config spi;
58 uint8_t reserved[64];
59 };
60} __packed;
61
62struct nfcmrvl_fw {
63 uint32_t magic;
64 uint32_t ref_clock;
65 uint32_t phy;
66 struct nfcmrvl_fw_binary_config bootrom;
67 struct nfcmrvl_fw_binary_config helper;
68 struct nfcmrvl_fw_binary_config firmware;
69 uint8_t reserved[64];
70} __packed;
71
72struct nfcmrvl_fw_dnld {
73 char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
74 const struct firmware *fw;
75
76 const struct nfcmrvl_fw *header;
77 const struct nfcmrvl_fw_binary_config *binary_config;
78
79 int state;
80 int substate;
81 int offset;
82 int chunk_len;
83
84 struct workqueue_struct *rx_wq;
85 struct work_struct rx_work;
86 struct sk_buff_head rx_q;
87
88 struct timer_list timer;
89};
90
91int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv);
92void nfcmrvl_fw_dnld_deinit(struct nfcmrvl_private *priv);
93void nfcmrvl_fw_dnld_abort(struct nfcmrvl_private *priv);
94int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name);
95void nfcmrvl_fw_dnld_recv_frame(struct nfcmrvl_private *priv,
96 struct sk_buff *skb);
97
98#endif