^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Marvell NFC driver: Firmware downloader
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2015, Marvell International Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This software file (the "File") is distributed by Marvell International
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Ltd. under the terms of the GNU General Public License Version 2, June 1991
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * (the "License"). You may use, redistribute and/or modify this File in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * accordance with the terms and conditions of the License, a copy of which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * is available on the worldwide web at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * this warranty disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifndef __NFCMRVL_FW_DNLD_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define __NFCMRVL_FW_DNLD_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define NFCMRVL_FW_MAGIC 0x88888888
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define NCI_OP_PROP_BOOT_CMD 0x3A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define NCI_CORE_LC_PROP_FW_DL 0xFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define NCI_CORE_LC_CONNID_PROP_FW_DL 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define HELPER_CMD_ENTRY_POINT 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define HELPER_CMD_PACKET_FORMAT 0xA5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define HELPER_ACK_PACKET_FORMAT 0x5A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define HELPER_RETRY_REQUESTED (1 << 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct nfcmrvl_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct nfcmrvl_fw_uart_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) uint8_t flow_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) uint32_t baudrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct nfcmrvl_fw_i2c_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) uint32_t clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct nfcmrvl_fw_spi_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) uint32_t clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct nfcmrvl_fw_binary_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) uint32_t offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void *config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct nfcmrvl_fw_uart_config uart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct nfcmrvl_fw_i2c_config i2c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct nfcmrvl_fw_spi_config spi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) uint8_t reserved[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct nfcmrvl_fw {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) uint32_t magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) uint32_t ref_clock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) uint32_t phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct nfcmrvl_fw_binary_config bootrom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct nfcmrvl_fw_binary_config helper;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct nfcmrvl_fw_binary_config firmware;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) uint8_t reserved[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct nfcmrvl_fw_dnld {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) const struct firmware *fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) const struct nfcmrvl_fw *header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) const struct nfcmrvl_fw_binary_config *binary_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) int substate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int chunk_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct workqueue_struct *rx_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct work_struct rx_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct sk_buff_head rx_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) void nfcmrvl_fw_dnld_deinit(struct nfcmrvl_private *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) void nfcmrvl_fw_dnld_abort(struct nfcmrvl_private *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) void nfcmrvl_fw_dnld_recv_frame(struct nfcmrvl_private *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #endif