iwl-testmode.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called LICENSE.GPL.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. #ifndef __IWL_TESTMODE_H__
  64. #define __IWL_TESTMODE_H__
  65. #include <linux/types.h>
  66. /*
  67. * Commands from user space to kernel space(IWL_TM_CMD_ID_APP2DEV_XX) and
  68. * from and kernel space to user space(IWL_TM_CMD_ID_DEV2APP_XX).
  69. * The command ID is carried with IWL_TM_ATTR_COMMAND.
  70. *
  71. * @IWL_TM_CMD_APP2DEV_UCODE:
  72. * commands from user application to the uCode,
  73. * the actual uCode host command ID is carried with
  74. * IWL_TM_ATTR_UCODE_CMD_ID
  75. *
  76. * @IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
  77. * @IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
  78. * @IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
  79. * commands from user applicaiton to access register
  80. *
  81. * @IWL_TM_CMD_APP2DEV_GET_DEVICENAME: retrieve device name
  82. * @IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: load initial uCode image
  83. * @IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: perform calibration
  84. * @IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: load runtime uCode image
  85. * @IWL_TM_CMD_APP2DEV_GET_EEPROM: request EEPROM data
  86. * @IWL_TM_CMD_APP2DEV_FIXRATE_REQ: set fix MCS
  87. * commands fom user space for pure driver level operations
  88. *
  89. * @IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
  90. * @IWL_TM_CMD_APP2DEV_END_TRACE:
  91. * @IWL_TM_CMD_APP2DEV_READ_TRACE:
  92. * commands fom user space for uCode trace operations
  93. *
  94. * @IWL_TM_CMD_DEV2APP_SYNC_RSP:
  95. * commands from kernel space to carry the synchronous response
  96. * to user application
  97. * @IWL_TM_CMD_DEV2APP_UCODE_RX_PKT:
  98. * commands from kernel space to multicast the spontaneous messages
  99. * to user application, or reply of host commands
  100. * @IWL_TM_CMD_DEV2APP_EEPROM_RSP:
  101. * commands from kernel space to carry the eeprom response
  102. * to user application
  103. *
  104. * @IWL_TM_CMD_APP2DEV_OWNERSHIP:
  105. * commands from user application to own change the ownership of the uCode
  106. * if application has the ownership, the only host command from
  107. * testmode will deliver to uCode. Default owner is driver
  108. *
  109. * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Wake On Wireless LAN uCode image
  110. * @IWL_TM_CMD_APP2DEV_GET_FW_VERSION: retrieve uCode version
  111. * @IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: retrieve ID information in device
  112. * @IWL_TM_CMD_APP2DEV_GET_FW_INFO:
  113. * retrieve information of existing loaded uCode image
  114. *
  115. * @IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ:
  116. * @IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP:
  117. * @IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE:
  118. * Commands to read/write data from periphery or SRAM memory ranges.
  119. * Fore reading, a READ command is sent from the userspace and the data
  120. * is returned when the user calls a DUMP command.
  121. * For writing, only a WRITE command is used.
  122. */
  123. enum iwl_tm_cmd_t {
  124. IWL_TM_CMD_APP2DEV_UCODE = 1,
  125. IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 = 2,
  126. IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 = 3,
  127. IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8 = 4,
  128. IWL_TM_CMD_APP2DEV_GET_DEVICENAME = 5,
  129. IWL_TM_CMD_APP2DEV_LOAD_INIT_FW = 6,
  130. IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB = 7,
  131. IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW = 8,
  132. IWL_TM_CMD_APP2DEV_GET_EEPROM = 9,
  133. IWL_TM_CMD_APP2DEV_FIXRATE_REQ = 10,
  134. IWL_TM_CMD_APP2DEV_BEGIN_TRACE = 11,
  135. IWL_TM_CMD_APP2DEV_END_TRACE = 12,
  136. IWL_TM_CMD_APP2DEV_READ_TRACE = 13,
  137. IWL_TM_CMD_DEV2APP_SYNC_RSP = 14,
  138. IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15,
  139. IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16,
  140. IWL_TM_CMD_APP2DEV_OWNERSHIP = 17,
  141. RESERVED_18 = 18,
  142. RESERVED_19 = 19,
  143. RESERVED_20 = 20,
  144. RESERVED_21 = 21,
  145. IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22,
  146. IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23,
  147. IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24,
  148. IWL_TM_CMD_APP2DEV_GET_FW_INFO = 25,
  149. IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ = 26,
  150. IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP = 27,
  151. IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE = 28,
  152. IWL_TM_CMD_MAX = 29,
  153. };
  154. /*
  155. * Atrribute filed in testmode command
  156. * See enum iwl_tm_cmd_t.
  157. *
  158. * @IWL_TM_ATTR_NOT_APPLICABLE:
  159. * The attribute is not applicable or invalid
  160. * @IWL_TM_ATTR_COMMAND:
  161. * From user space to kernel space:
  162. * the command either destines to ucode, driver, or register;
  163. * From kernel space to user space:
  164. * the command either carries synchronous response,
  165. * or the spontaneous message multicast from the device;
  166. *
  167. * @IWL_TM_ATTR_UCODE_CMD_ID:
  168. * @IWL_TM_ATTR_UCODE_CMD_DATA:
  169. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE,
  170. * The mandatory fields are :
  171. * IWL_TM_ATTR_UCODE_CMD_ID for recognizable command ID;
  172. * IWL_TM_ATTR_UCODE_CMD_DATA for the actual command payload
  173. * to the ucode
  174. *
  175. * @IWL_TM_ATTR_REG_OFFSET:
  176. * @IWL_TM_ATTR_REG_VALUE8:
  177. * @IWL_TM_ATTR_REG_VALUE32:
  178. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_XXX,
  179. * The mandatory fields are:
  180. * IWL_TM_ATTR_REG_OFFSET for the offset of the target register;
  181. * IWL_TM_ATTR_REG_VALUE8 or IWL_TM_ATTR_REG_VALUE32 for value
  182. *
  183. * @IWL_TM_ATTR_SYNC_RSP:
  184. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_SYNC_RSP,
  185. * The mandatory fields are:
  186. * IWL_TM_ATTR_SYNC_RSP for the data content responding to the user
  187. * application command
  188. *
  189. * @IWL_TM_ATTR_UCODE_RX_PKT:
  190. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_UCODE_RX_PKT,
  191. * The mandatory fields are:
  192. * IWL_TM_ATTR_UCODE_RX_PKT for the data content multicast to the user
  193. * application
  194. *
  195. * @IWL_TM_ATTR_EEPROM:
  196. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_EEPROM,
  197. * The mandatory fields are:
  198. * IWL_TM_ATTR_EEPROM for the data content responging to the user
  199. * application
  200. *
  201. * @IWL_TM_ATTR_TRACE_ADDR:
  202. * @IWL_TM_ATTR_TRACE_SIZE:
  203. * @IWL_TM_ATTR_TRACE_DUMP:
  204. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_XXX_TRACE,
  205. * The mandatory fields are:
  206. * IWL_TM_ATTR_MEM_TRACE_ADDR for the trace address
  207. * IWL_TM_ATTR_MEM_TRACE_SIZE for the trace buffer size
  208. * IWL_TM_ATTR_MEM_TRACE_DUMP for the trace dump
  209. *
  210. * @IWL_TM_ATTR_FIXRATE:
  211. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_FIXRATE_REQ,
  212. * The mandatory fields are:
  213. * IWL_TM_ATTR_FIXRATE for the fixed rate
  214. *
  215. * @IWL_TM_ATTR_UCODE_OWNER:
  216. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_OWNERSHIP,
  217. * The mandatory fields are:
  218. * IWL_TM_ATTR_UCODE_OWNER for the new owner
  219. *
  220. * @IWL_TM_ATTR_MEM_ADDR:
  221. * @IWL_TM_ATTR_BUFFER_SIZE:
  222. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ
  223. * or IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE.
  224. * The mandatory fields are:
  225. * IWL_TM_ATTR_MEM_ADDR for the address in SRAM/periphery to read/write
  226. * IWL_TM_ATTR_BUFFER_SIZE for the buffer size of data to read/write.
  227. *
  228. * @IWL_TM_ATTR_BUFFER_DUMP:
  229. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP,
  230. * IWL_TM_ATTR_BUFFER_DUMP is used for the data that was read.
  231. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE,
  232. * this attribute contains the data to write.
  233. *
  234. * @IWL_TM_ATTR_FW_VERSION:
  235. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_VERSION,
  236. * IWL_TM_ATTR_FW_VERSION for the uCode version
  237. *
  238. * @IWL_TM_ATTR_DEVICE_ID:
  239. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_DEVICE_ID,
  240. * IWL_TM_ATTR_DEVICE_ID for the device ID information
  241. *
  242. * @IWL_TM_ATTR_FW_TYPE:
  243. * @IWL_TM_ATTR_FW_INST_SIZE:
  244. * @IWL_TM_ATTR_FW_DATA_SIZE:
  245. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_INFO,
  246. * The mandatory fields are:
  247. * IWL_TM_ATTR_FW_TYPE for the uCode type (INIT/RUNTIME/...)
  248. * IWL_TM_ATTR_FW_INST_SIZE for the size of instruction section
  249. * IWL_TM_ATTR_FW_DATA_SIZE for the size of data section
  250. *
  251. * @IWL_TM_ATTR_UCODE_CMD_SKB:
  252. * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE this flag
  253. * indicates that the user wants to receive the response of the command
  254. * in a reply SKB. If it's not present, the response is not returned.
  255. */
  256. enum iwl_tm_attr_t {
  257. IWL_TM_ATTR_NOT_APPLICABLE = 0,
  258. IWL_TM_ATTR_COMMAND = 1,
  259. IWL_TM_ATTR_UCODE_CMD_ID = 2,
  260. IWL_TM_ATTR_UCODE_CMD_DATA = 3,
  261. IWL_TM_ATTR_REG_OFFSET = 4,
  262. IWL_TM_ATTR_REG_VALUE8 = 5,
  263. IWL_TM_ATTR_REG_VALUE32 = 6,
  264. IWL_TM_ATTR_SYNC_RSP = 7,
  265. IWL_TM_ATTR_UCODE_RX_PKT = 8,
  266. IWL_TM_ATTR_EEPROM = 9,
  267. IWL_TM_ATTR_TRACE_ADDR = 10,
  268. IWL_TM_ATTR_TRACE_SIZE = 11,
  269. IWL_TM_ATTR_TRACE_DUMP = 12,
  270. IWL_TM_ATTR_FIXRATE = 13,
  271. IWL_TM_ATTR_UCODE_OWNER = 14,
  272. IWL_TM_ATTR_MEM_ADDR = 15,
  273. IWL_TM_ATTR_BUFFER_SIZE = 16,
  274. IWL_TM_ATTR_BUFFER_DUMP = 17,
  275. IWL_TM_ATTR_FW_VERSION = 18,
  276. IWL_TM_ATTR_DEVICE_ID = 19,
  277. IWL_TM_ATTR_FW_TYPE = 20,
  278. IWL_TM_ATTR_FW_INST_SIZE = 21,
  279. IWL_TM_ATTR_FW_DATA_SIZE = 22,
  280. IWL_TM_ATTR_UCODE_CMD_SKB = 23,
  281. IWL_TM_ATTR_MAX = 24,
  282. };
  283. /* uCode trace buffer */
  284. #define TRACE_BUFF_SIZE_MAX 0x200000
  285. #define TRACE_BUFF_SIZE_MIN 0x20000
  286. #define TRACE_BUFF_SIZE_DEF TRACE_BUFF_SIZE_MIN
  287. #define TRACE_BUFF_PADD 0x2000
  288. /* Maximum data size of each dump it packet */
  289. #define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024)
  290. /* Address offset of data segment in SRAM */
  291. #define SRAM_DATA_SEG_OFFSET 0x800000
  292. #endif