iwmc3200top.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * iwmc3200top - Intel Wireless MultiCom 3200 Top Driver
  3. * drivers/misc/iwmc3200top/iwmc3200top.h
  4. *
  5. * Copyright (C) 2009 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. *
  21. *
  22. * Author Name: Maxim Grabarnik <maxim.grabarnink@intel.com>
  23. * -
  24. *
  25. */
  26. #ifndef __IWMC3200TOP_H__
  27. #define __IWMC3200TOP_H__
  28. #include <linux/workqueue.h>
  29. #define DRV_NAME "iwmc3200top"
  30. #define FW_API_VER 1
  31. #define _FW_NAME(api) DRV_NAME "." #api ".fw"
  32. #define FW_NAME(api) _FW_NAME(api)
  33. #define IWMC_SDIO_BLK_SIZE 256
  34. #define IWMC_DEFAULT_TR_BLK 64
  35. #define IWMC_SDIO_DATA_ADDR 0x0
  36. #define IWMC_SDIO_INTR_ENABLE_ADDR 0x14
  37. #define IWMC_SDIO_INTR_STATUS_ADDR 0x13
  38. #define IWMC_SDIO_INTR_CLEAR_ADDR 0x13
  39. #define IWMC_SDIO_INTR_GET_SIZE_ADDR 0x2C
  40. #define COMM_HUB_HEADER_LENGTH 16
  41. #define LOGGER_HEADER_LENGTH 10
  42. #define BARKER_DNLOAD_BT_POS 0
  43. #define BARKER_DNLOAD_BT_MSK BIT(BARKER_DNLOAD_BT_POS)
  44. #define BARKER_DNLOAD_GPS_POS 1
  45. #define BARKER_DNLOAD_GPS_MSK BIT(BARKER_DNLOAD_GPS_POS)
  46. #define BARKER_DNLOAD_TOP_POS 2
  47. #define BARKER_DNLOAD_TOP_MSK BIT(BARKER_DNLOAD_TOP_POS)
  48. #define BARKER_DNLOAD_RESERVED1_POS 3
  49. #define BARKER_DNLOAD_RESERVED1_MSK BIT(BARKER_DNLOAD_RESERVED1_POS)
  50. #define BARKER_DNLOAD_JUMP_POS 4
  51. #define BARKER_DNLOAD_JUMP_MSK BIT(BARKER_DNLOAD_JUMP_POS)
  52. #define BARKER_DNLOAD_SYNC_POS 5
  53. #define BARKER_DNLOAD_SYNC_MSK BIT(BARKER_DNLOAD_SYNC_POS)
  54. #define BARKER_DNLOAD_RESERVED2_POS 6
  55. #define BARKER_DNLOAD_RESERVED2_MSK (0x3 << BARKER_DNLOAD_RESERVED2_POS)
  56. #define BARKER_DNLOAD_BARKER_POS 8
  57. #define BARKER_DNLOAD_BARKER_MSK (0xffffff << BARKER_DNLOAD_BARKER_POS)
  58. #define IWMC_BARKER_REBOOT (0xdeadbe << BARKER_DNLOAD_BARKER_POS)
  59. /* whole field barker */
  60. #define IWMC_BARKER_ACK 0xfeedbabe
  61. #define IWMC_CMD_SIGNATURE 0xcbbc
  62. #define CMD_HDR_OPCODE_POS 0
  63. #define CMD_HDR_OPCODE_MSK_MSK (0xf << CMD_HDR_OPCODE_MSK_POS)
  64. #define CMD_HDR_RESPONSE_CODE_POS 4
  65. #define CMD_HDR_RESPONSE_CODE_MSK (0xf << CMD_HDR_RESPONSE_CODE_POS)
  66. #define CMD_HDR_USE_CHECKSUM_POS 8
  67. #define CMD_HDR_USE_CHECKSUM_MSK BIT(CMD_HDR_USE_CHECKSUM_POS)
  68. #define CMD_HDR_RESPONSE_REQUIRED_POS 9
  69. #define CMD_HDR_RESPONSE_REQUIRED_MSK BIT(CMD_HDR_RESPONSE_REQUIRED_POS)
  70. #define CMD_HDR_DIRECT_ACCESS_POS 10
  71. #define CMD_HDR_DIRECT_ACCESS_MSK BIT(CMD_HDR_DIRECT_ACCESS_POS)
  72. #define CMD_HDR_RESERVED_POS 11
  73. #define CMD_HDR_RESERVED_MSK BIT(0x1f << CMD_HDR_RESERVED_POS)
  74. #define CMD_HDR_SIGNATURE_POS 16
  75. #define CMD_HDR_SIGNATURE_MSK BIT(0xffff << CMD_HDR_SIGNATURE_POS)
  76. enum {
  77. IWMC_OPCODE_PING = 0,
  78. IWMC_OPCODE_READ = 1,
  79. IWMC_OPCODE_WRITE = 2,
  80. IWMC_OPCODE_JUMP = 3,
  81. IWMC_OPCODE_REBOOT = 4,
  82. IWMC_OPCODE_PERSISTENT_WRITE = 5,
  83. IWMC_OPCODE_PERSISTENT_READ = 6,
  84. IWMC_OPCODE_READ_MODIFY_WRITE = 7,
  85. IWMC_OPCODE_LAST_COMMAND = 15
  86. };
  87. struct iwmct_fw_load_hdr {
  88. __le32 cmd;
  89. __le32 target_addr;
  90. __le32 data_size;
  91. __le32 block_chksm;
  92. u8 data[0];
  93. };
  94. /**
  95. * struct iwmct_fw_hdr
  96. * holds all sw components versions
  97. */
  98. struct iwmct_fw_hdr {
  99. u8 top_major;
  100. u8 top_minor;
  101. u8 top_revision;
  102. u8 gps_major;
  103. u8 gps_minor;
  104. u8 gps_revision;
  105. u8 bt_major;
  106. u8 bt_minor;
  107. u8 bt_revision;
  108. u8 tic_name[31];
  109. };
  110. /**
  111. * struct iwmct_fw_sec_hdr
  112. * @type: function type
  113. * @data_size: section's data size
  114. * @target_addr: download address
  115. */
  116. struct iwmct_fw_sec_hdr {
  117. u8 type[4];
  118. __le32 data_size;
  119. __le32 target_addr;
  120. };
  121. /**
  122. * struct iwmct_parser
  123. * @file: fw image
  124. * @file_size: fw size
  125. * @cur_pos: position in file
  126. * @buf: temp buf for download
  127. * @buf_size: size of buf
  128. * @entry_point: address to jump in fw kick-off
  129. */
  130. struct iwmct_parser {
  131. const u8 *file;
  132. size_t file_size;
  133. size_t cur_pos;
  134. u8 *buf;
  135. size_t buf_size;
  136. u32 entry_point;
  137. struct iwmct_fw_hdr versions;
  138. };
  139. struct iwmct_work_struct {
  140. struct list_head list;
  141. ssize_t iosize;
  142. };
  143. struct iwmct_dbg {
  144. int blocks;
  145. bool dump;
  146. bool jump;
  147. bool direct;
  148. bool checksum;
  149. bool fw_download;
  150. int block_size;
  151. int download_trans_blks;
  152. char label_fw[256];
  153. };
  154. struct iwmct_debugfs;
  155. struct iwmct_priv {
  156. struct sdio_func *func;
  157. struct iwmct_debugfs *dbgfs;
  158. struct iwmct_parser parser;
  159. atomic_t reset;
  160. atomic_t dev_sync;
  161. u32 trans_len;
  162. u32 barker;
  163. struct iwmct_dbg dbg;
  164. /* drivers work items */
  165. struct work_struct bus_rescan_worker;
  166. struct work_struct isr_worker;
  167. /* drivers wait queue */
  168. wait_queue_head_t wait_q;
  169. /* rx request list */
  170. struct list_head read_req_list;
  171. };
  172. extern int iwmct_tx(struct iwmct_priv *priv, void *src, int count);
  173. extern int iwmct_fw_load(struct iwmct_priv *priv);
  174. extern void iwmct_dbg_init_params(struct iwmct_priv *drv);
  175. extern void iwmct_dbg_init_drv_attrs(struct device_driver *drv);
  176. extern void iwmct_dbg_remove_drv_attrs(struct device_driver *drv);
  177. extern int iwmct_send_hcmd(struct iwmct_priv *priv, u8 *cmd, u16 len);
  178. #endif /* __IWMC3200TOP_H__ */