fw_dnld.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Marvell NFC driver: Firmware downloader
  4. *
  5. * Copyright (C) 2015, Marvell International Ltd.
  6. */
  7. #ifndef __NFCMRVL_FW_DNLD_H__
  8. #define __NFCMRVL_FW_DNLD_H__
  9. #include <linux/workqueue.h>
  10. #define NFCMRVL_FW_MAGIC 0x88888888
  11. #define NCI_OP_PROP_BOOT_CMD 0x3A
  12. #define NCI_CORE_LC_PROP_FW_DL 0xFD
  13. #define NCI_CORE_LC_CONNID_PROP_FW_DL 0x02
  14. #define HELPER_CMD_ENTRY_POINT 0x04
  15. #define HELPER_CMD_PACKET_FORMAT 0xA5
  16. #define HELPER_ACK_PACKET_FORMAT 0x5A
  17. #define HELPER_RETRY_REQUESTED (1 << 15)
  18. struct nfcmrvl_private;
  19. struct nfcmrvl_fw_uart_config {
  20. uint8_t flow_control;
  21. uint32_t baudrate;
  22. } __packed;
  23. struct nfcmrvl_fw_i2c_config {
  24. uint32_t clk;
  25. } __packed;
  26. struct nfcmrvl_fw_spi_config {
  27. uint32_t clk;
  28. } __packed;
  29. struct nfcmrvl_fw_binary_config {
  30. uint32_t offset;
  31. union {
  32. void *config;
  33. struct nfcmrvl_fw_uart_config uart;
  34. struct nfcmrvl_fw_i2c_config i2c;
  35. struct nfcmrvl_fw_spi_config spi;
  36. uint8_t reserved[64];
  37. };
  38. } __packed;
  39. struct nfcmrvl_fw {
  40. uint32_t magic;
  41. uint32_t ref_clock;
  42. uint32_t phy;
  43. struct nfcmrvl_fw_binary_config bootrom;
  44. struct nfcmrvl_fw_binary_config helper;
  45. struct nfcmrvl_fw_binary_config firmware;
  46. uint8_t reserved[64];
  47. } __packed;
  48. struct nfcmrvl_fw_dnld {
  49. char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
  50. const struct firmware *fw;
  51. const struct nfcmrvl_fw *header;
  52. const struct nfcmrvl_fw_binary_config *binary_config;
  53. int state;
  54. int substate;
  55. int offset;
  56. int chunk_len;
  57. struct workqueue_struct *rx_wq;
  58. struct work_struct rx_work;
  59. struct sk_buff_head rx_q;
  60. struct timer_list timer;
  61. };
  62. int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv);
  63. void nfcmrvl_fw_dnld_deinit(struct nfcmrvl_private *priv);
  64. void nfcmrvl_fw_dnld_abort(struct nfcmrvl_private *priv);
  65. int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name);
  66. void nfcmrvl_fw_dnld_recv_frame(struct nfcmrvl_private *priv,
  67. struct sk_buff *skb);
  68. #endif