fw_dnld.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef __NFCMRVL_FW_DNLD_H__
  19. #define __NFCMRVL_FW_DNLD_H__
  20. #include <linux/workqueue.h>
  21. #define NFCMRVL_FW_MAGIC 0x88888888
  22. #define NCI_OP_PROP_BOOT_CMD 0x3A
  23. #define NCI_CORE_LC_PROP_FW_DL 0xFD
  24. #define NCI_CORE_LC_CONNID_PROP_FW_DL 0x02
  25. #define HELPER_CMD_ENTRY_POINT 0x04
  26. #define HELPER_CMD_PACKET_FORMAT 0xA5
  27. #define HELPER_ACK_PACKET_FORMAT 0x5A
  28. #define HELPER_RETRY_REQUESTED (1 << 15)
  29. struct nfcmrvl_private;
  30. struct nfcmrvl_fw_uart_config {
  31. uint8_t flow_control;
  32. uint32_t baudrate;
  33. } __packed;
  34. struct nfcmrvl_fw_i2c_config {
  35. uint32_t clk;
  36. } __packed;
  37. struct nfcmrvl_fw_spi_config {
  38. uint32_t clk;
  39. } __packed;
  40. struct nfcmrvl_fw_binary_config {
  41. uint32_t offset;
  42. union {
  43. void *config;
  44. struct nfcmrvl_fw_uart_config uart;
  45. struct nfcmrvl_fw_i2c_config i2c;
  46. struct nfcmrvl_fw_spi_config spi;
  47. uint8_t reserved[64];
  48. };
  49. } __packed;
  50. struct nfcmrvl_fw {
  51. uint32_t magic;
  52. uint32_t ref_clock;
  53. uint32_t phy;
  54. struct nfcmrvl_fw_binary_config bootrom;
  55. struct nfcmrvl_fw_binary_config helper;
  56. struct nfcmrvl_fw_binary_config firmware;
  57. uint8_t reserved[64];
  58. } __packed;
  59. struct nfcmrvl_fw_dnld {
  60. char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
  61. const struct firmware *fw;
  62. const struct nfcmrvl_fw *header;
  63. const struct nfcmrvl_fw_binary_config *binary_config;
  64. int state;
  65. int substate;
  66. int offset;
  67. int chunk_len;
  68. struct workqueue_struct *rx_wq;
  69. struct work_struct rx_work;
  70. struct sk_buff_head rx_q;
  71. struct timer_list timer;
  72. };
  73. int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv);
  74. void nfcmrvl_fw_dnld_deinit(struct nfcmrvl_private *priv);
  75. void nfcmrvl_fw_dnld_abort(struct nfcmrvl_private *priv);
  76. int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name);
  77. void nfcmrvl_fw_dnld_recv_frame(struct nfcmrvl_private *priv,
  78. struct sk_buff *skb);
  79. #endif