Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Marvell NFC driver: Firmware downloader
0004  *
0005  * Copyright (C) 2015, Marvell International Ltd.
0006  */
0007 
0008 #ifndef __NFCMRVL_FW_DNLD_H__
0009 #define __NFCMRVL_FW_DNLD_H__
0010 
0011 #include <linux/workqueue.h>
0012 
0013 #define NFCMRVL_FW_MAGIC        0x88888888
0014 
0015 #define NCI_OP_PROP_BOOT_CMD        0x3A
0016 
0017 #define NCI_CORE_LC_PROP_FW_DL      0xFD
0018 #define NCI_CORE_LC_CONNID_PROP_FW_DL   0x02
0019 
0020 #define HELPER_CMD_ENTRY_POINT      0x04
0021 #define HELPER_CMD_PACKET_FORMAT    0xA5
0022 #define HELPER_ACK_PACKET_FORMAT    0x5A
0023 #define HELPER_RETRY_REQUESTED      (1 << 15)
0024 
0025 struct nfcmrvl_private;
0026 
0027 struct nfcmrvl_fw_uart_config {
0028     uint8_t flow_control;
0029     uint32_t baudrate;
0030 } __packed;
0031 
0032 struct nfcmrvl_fw_i2c_config {
0033     uint32_t clk;
0034 } __packed;
0035 
0036 struct nfcmrvl_fw_spi_config {
0037     uint32_t clk;
0038 } __packed;
0039 
0040 struct nfcmrvl_fw_binary_config {
0041     uint32_t offset;
0042     union {
0043         void *config;
0044         struct nfcmrvl_fw_uart_config uart;
0045         struct nfcmrvl_fw_i2c_config i2c;
0046         struct nfcmrvl_fw_spi_config spi;
0047         uint8_t reserved[64];
0048     };
0049 } __packed;
0050 
0051 struct nfcmrvl_fw {
0052     uint32_t magic;
0053     uint32_t ref_clock;
0054     uint32_t phy;
0055     struct nfcmrvl_fw_binary_config bootrom;
0056     struct nfcmrvl_fw_binary_config helper;
0057     struct nfcmrvl_fw_binary_config firmware;
0058     uint8_t reserved[64];
0059 } __packed;
0060 
0061 struct nfcmrvl_fw_dnld {
0062     char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
0063     const struct firmware *fw;
0064 
0065     const struct nfcmrvl_fw *header;
0066     const struct nfcmrvl_fw_binary_config *binary_config;
0067 
0068     int state;
0069     int substate;
0070     int offset;
0071     int chunk_len;
0072 
0073     struct workqueue_struct *rx_wq;
0074     struct work_struct rx_work;
0075     struct sk_buff_head rx_q;
0076 
0077     struct timer_list timer;
0078 };
0079 
0080 int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv);
0081 void nfcmrvl_fw_dnld_deinit(struct nfcmrvl_private *priv);
0082 void nfcmrvl_fw_dnld_abort(struct nfcmrvl_private *priv);
0083 int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name);
0084 void nfcmrvl_fw_dnld_recv_frame(struct nfcmrvl_private *priv,
0085                 struct sk_buff *skb);
0086 
0087 #endif