target.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /*
  2. * Copyright (c) 2004-2010 Atheros Communications Inc.
  3. * Copyright (c) 2011 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef TARGET_H
  18. #define TARGET_H
  19. #define AR6003_BOARD_DATA_SZ 1024
  20. #define AR6003_BOARD_EXT_DATA_SZ 768
  21. #define AR6003_BOARD_EXT_DATA_SZ_V2 1024
  22. #define AR6004_BOARD_DATA_SZ 6144
  23. #define AR6004_BOARD_EXT_DATA_SZ 0
  24. #define RESET_CONTROL_ADDRESS 0x00004000
  25. #define RESET_CONTROL_COLD_RST 0x00000100
  26. #define RESET_CONTROL_MBOX_RST 0x00000004
  27. #define CPU_CLOCK_STANDARD_S 0
  28. #define CPU_CLOCK_STANDARD 0x00000003
  29. #define CPU_CLOCK_ADDRESS 0x00000020
  30. #define CLOCK_CONTROL_ADDRESS 0x00000028
  31. #define CLOCK_CONTROL_LF_CLK32_S 2
  32. #define CLOCK_CONTROL_LF_CLK32 0x00000004
  33. #define SYSTEM_SLEEP_ADDRESS 0x000000c4
  34. #define SYSTEM_SLEEP_DISABLE_S 0
  35. #define SYSTEM_SLEEP_DISABLE 0x00000001
  36. #define LPO_CAL_ADDRESS 0x000000e0
  37. #define LPO_CAL_ENABLE_S 20
  38. #define LPO_CAL_ENABLE 0x00100000
  39. #define GPIO_PIN9_ADDRESS 0x0000004c
  40. #define GPIO_PIN10_ADDRESS 0x00000050
  41. #define GPIO_PIN11_ADDRESS 0x00000054
  42. #define GPIO_PIN12_ADDRESS 0x00000058
  43. #define GPIO_PIN13_ADDRESS 0x0000005c
  44. #define HOST_INT_STATUS_ADDRESS 0x00000400
  45. #define HOST_INT_STATUS_ERROR_S 7
  46. #define HOST_INT_STATUS_ERROR 0x00000080
  47. #define HOST_INT_STATUS_CPU_S 6
  48. #define HOST_INT_STATUS_CPU 0x00000040
  49. #define HOST_INT_STATUS_COUNTER_S 4
  50. #define HOST_INT_STATUS_COUNTER 0x00000010
  51. #define CPU_INT_STATUS_ADDRESS 0x00000401
  52. #define ERROR_INT_STATUS_ADDRESS 0x00000402
  53. #define ERROR_INT_STATUS_WAKEUP_S 2
  54. #define ERROR_INT_STATUS_WAKEUP 0x00000004
  55. #define ERROR_INT_STATUS_RX_UNDERFLOW_S 1
  56. #define ERROR_INT_STATUS_RX_UNDERFLOW 0x00000002
  57. #define ERROR_INT_STATUS_TX_OVERFLOW_S 0
  58. #define ERROR_INT_STATUS_TX_OVERFLOW 0x00000001
  59. #define COUNTER_INT_STATUS_ADDRESS 0x00000403
  60. #define COUNTER_INT_STATUS_COUNTER_S 0
  61. #define COUNTER_INT_STATUS_COUNTER 0x000000ff
  62. #define RX_LOOKAHEAD_VALID_ADDRESS 0x00000405
  63. #define INT_STATUS_ENABLE_ADDRESS 0x00000418
  64. #define INT_STATUS_ENABLE_ERROR_S 7
  65. #define INT_STATUS_ENABLE_ERROR 0x00000080
  66. #define INT_STATUS_ENABLE_CPU_S 6
  67. #define INT_STATUS_ENABLE_CPU 0x00000040
  68. #define INT_STATUS_ENABLE_INT_S 5
  69. #define INT_STATUS_ENABLE_INT 0x00000020
  70. #define INT_STATUS_ENABLE_COUNTER_S 4
  71. #define INT_STATUS_ENABLE_COUNTER 0x00000010
  72. #define INT_STATUS_ENABLE_MBOX_DATA_S 0
  73. #define INT_STATUS_ENABLE_MBOX_DATA 0x0000000f
  74. #define CPU_INT_STATUS_ENABLE_ADDRESS 0x00000419
  75. #define CPU_INT_STATUS_ENABLE_BIT_S 0
  76. #define CPU_INT_STATUS_ENABLE_BIT 0x000000ff
  77. #define ERROR_STATUS_ENABLE_ADDRESS 0x0000041a
  78. #define ERROR_STATUS_ENABLE_RX_UNDERFLOW_S 1
  79. #define ERROR_STATUS_ENABLE_RX_UNDERFLOW 0x00000002
  80. #define ERROR_STATUS_ENABLE_TX_OVERFLOW_S 0
  81. #define ERROR_STATUS_ENABLE_TX_OVERFLOW 0x00000001
  82. #define COUNTER_INT_STATUS_ENABLE_ADDRESS 0x0000041b
  83. #define COUNTER_INT_STATUS_ENABLE_BIT_S 0
  84. #define COUNTER_INT_STATUS_ENABLE_BIT 0x000000ff
  85. #define COUNT_ADDRESS 0x00000420
  86. #define COUNT_DEC_ADDRESS 0x00000440
  87. #define WINDOW_DATA_ADDRESS 0x00000474
  88. #define WINDOW_WRITE_ADDR_ADDRESS 0x00000478
  89. #define WINDOW_READ_ADDR_ADDRESS 0x0000047c
  90. #define CPU_DBG_SEL_ADDRESS 0x00000483
  91. #define CPU_DBG_ADDRESS 0x00000484
  92. #define LOCAL_SCRATCH_ADDRESS 0x000000c0
  93. #define ATH6KL_OPTION_SLEEP_DISABLE 0x08
  94. #define RTC_BASE_ADDRESS 0x00004000
  95. #define GPIO_BASE_ADDRESS 0x00014000
  96. #define MBOX_BASE_ADDRESS 0x00018000
  97. #define ANALOG_INTF_BASE_ADDRESS 0x0001c000
  98. /* real name of the register is unknown */
  99. #define ATH6KL_ANALOG_PLL_REGISTER (ANALOG_INTF_BASE_ADDRESS + 0x284)
  100. #define SM(f, v) (((v) << f##_S) & f)
  101. #define MS(f, v) (((v) & f) >> f##_S)
  102. /*
  103. * xxx_HOST_INTEREST_ADDRESS is the address in Target RAM of the
  104. * host_interest structure.
  105. *
  106. * Host Interest is shared between Host and Target in order to coordinate
  107. * between the two, and is intended to remain constant (with additions only
  108. * at the end).
  109. */
  110. #define ATH6KL_AR6003_HI_START_ADDR 0x00540600
  111. #define ATH6KL_AR6004_HI_START_ADDR 0x00400800
  112. /*
  113. * These are items that the Host may need to access
  114. * via BMI or via the Diagnostic Window. The position
  115. * of items in this structure must remain constant.
  116. * across firmware revisions!
  117. *
  118. * Types for each item must be fixed size across target and host platforms.
  119. * The structure is used only to calculate offset for each register with
  120. * HI_ITEM() macro, no values are stored to it.
  121. *
  122. * More items may be added at the end.
  123. */
  124. struct host_interest {
  125. /*
  126. * Pointer to application-defined area, if any.
  127. * Set by Target application during startup.
  128. */
  129. u32 hi_app_host_interest; /* 0x00 */
  130. /* Pointer to register dump area, valid after Target crash. */
  131. u32 hi_failure_state; /* 0x04 */
  132. /* Pointer to debug logging header */
  133. u32 hi_dbglog_hdr; /* 0x08 */
  134. u32 hi_unused1; /* 0x0c */
  135. /*
  136. * General-purpose flag bits, similar to ATH6KL_OPTION_* flags.
  137. * Can be used by application rather than by OS.
  138. */
  139. u32 hi_option_flag; /* 0x10 */
  140. /*
  141. * Boolean that determines whether or not to
  142. * display messages on the serial port.
  143. */
  144. u32 hi_serial_enable; /* 0x14 */
  145. /* Start address of DataSet index, if any */
  146. u32 hi_dset_list_head; /* 0x18 */
  147. /* Override Target application start address */
  148. u32 hi_app_start; /* 0x1c */
  149. /* Clock and voltage tuning */
  150. u32 hi_skip_clock_init; /* 0x20 */
  151. u32 hi_core_clock_setting; /* 0x24 */
  152. u32 hi_cpu_clock_setting; /* 0x28 */
  153. u32 hi_system_sleep_setting; /* 0x2c */
  154. u32 hi_xtal_control_setting; /* 0x30 */
  155. u32 hi_pll_ctrl_setting_24ghz; /* 0x34 */
  156. u32 hi_pll_ctrl_setting_5ghz; /* 0x38 */
  157. u32 hi_ref_voltage_trim_setting; /* 0x3c */
  158. u32 hi_clock_info; /* 0x40 */
  159. /*
  160. * Flash configuration overrides, used only
  161. * when firmware is not executing from flash.
  162. * (When using flash, modify the global variables
  163. * with equivalent names.)
  164. */
  165. u32 hi_bank0_addr_value; /* 0x44 */
  166. u32 hi_bank0_read_value; /* 0x48 */
  167. u32 hi_bank0_write_value; /* 0x4c */
  168. u32 hi_bank0_config_value; /* 0x50 */
  169. /* Pointer to Board Data */
  170. u32 hi_board_data; /* 0x54 */
  171. u32 hi_board_data_initialized; /* 0x58 */
  172. u32 hi_dset_ram_index_tbl; /* 0x5c */
  173. u32 hi_desired_baud_rate; /* 0x60 */
  174. u32 hi_dbglog_config; /* 0x64 */
  175. u32 hi_end_ram_reserve_sz; /* 0x68 */
  176. u32 hi_mbox_io_block_sz; /* 0x6c */
  177. u32 hi_num_bpatch_streams; /* 0x70 -- unused */
  178. u32 hi_mbox_isr_yield_limit; /* 0x74 */
  179. u32 hi_refclk_hz; /* 0x78 */
  180. u32 hi_ext_clk_detected; /* 0x7c */
  181. u32 hi_dbg_uart_txpin; /* 0x80 */
  182. u32 hi_dbg_uart_rxpin; /* 0x84 */
  183. u32 hi_hci_uart_baud; /* 0x88 */
  184. u32 hi_hci_uart_pin_assignments; /* 0x8C */
  185. /*
  186. * NOTE: byte [0] = tx pin, [1] = rx pin, [2] = rts pin, [3] = cts
  187. * pin
  188. */
  189. u32 hi_hci_uart_baud_scale_val; /* 0x90 */
  190. u32 hi_hci_uart_baud_step_val; /* 0x94 */
  191. u32 hi_allocram_start; /* 0x98 */
  192. u32 hi_allocram_sz; /* 0x9c */
  193. u32 hi_hci_bridge_flags; /* 0xa0 */
  194. u32 hi_hci_uart_support_pins; /* 0xa4 */
  195. /*
  196. * NOTE: byte [0] = RESET pin (bit 7 is polarity),
  197. * bytes[1]..bytes[3] are for future use
  198. */
  199. u32 hi_hci_uart_pwr_mgmt_params; /* 0xa8 */
  200. /*
  201. * 0xa8 - [1]: 0 = UART FC active low, 1 = UART FC active high
  202. * [31:16]: wakeup timeout in ms
  203. */
  204. /* Pointer to extended board data */
  205. u32 hi_board_ext_data; /* 0xac */
  206. u32 hi_board_ext_data_config; /* 0xb0 */
  207. /*
  208. * Bit [0] : valid
  209. * Bit[31:16: size
  210. */
  211. /*
  212. * hi_reset_flag is used to do some stuff when target reset.
  213. * such as restore app_start after warm reset or
  214. * preserve host Interest area, or preserve ROM data, literals etc.
  215. */
  216. u32 hi_reset_flag; /* 0xb4 */
  217. /* indicate hi_reset_flag is valid */
  218. u32 hi_reset_flag_valid; /* 0xb8 */
  219. u32 hi_hci_uart_pwr_mgmt_params_ext; /* 0xbc */
  220. /*
  221. * 0xbc - [31:0]: idle timeout in ms
  222. */
  223. /* ACS flags */
  224. u32 hi_acs_flags; /* 0xc0 */
  225. u32 hi_console_flags; /* 0xc4 */
  226. u32 hi_nvram_state; /* 0xc8 */
  227. u32 hi_option_flag2; /* 0xcc */
  228. /* If non-zero, override values sent to Host in WMI_READY event. */
  229. u32 hi_sw_version_override; /* 0xd0 */
  230. u32 hi_abi_version_override; /* 0xd4 */
  231. /*
  232. * Percentage of high priority RX traffic to total expected RX traffic -
  233. * applicable only to ar6004
  234. */
  235. u32 hi_hp_rx_traffic_ratio; /* 0xd8 */
  236. /* test applications flags */
  237. u32 hi_test_apps_related; /* 0xdc */
  238. /* location of test script */
  239. u32 hi_ota_testscript; /* 0xe0 */
  240. /* location of CAL data */
  241. u32 hi_cal_data; /* 0xe4 */
  242. /* Number of packet log buffers */
  243. u32 hi_pktlog_num_buffers; /* 0xe8 */
  244. } __packed;
  245. #define HI_ITEM(item) offsetof(struct host_interest, item)
  246. #define HI_OPTION_MAC_ADDR_METHOD_SHIFT 3
  247. #define HI_OPTION_FW_MODE_IBSS 0x0
  248. #define HI_OPTION_FW_MODE_BSS_STA 0x1
  249. #define HI_OPTION_FW_MODE_AP 0x2
  250. #define HI_OPTION_FW_SUBMODE_NONE 0x0
  251. #define HI_OPTION_FW_SUBMODE_P2PDEV 0x1
  252. #define HI_OPTION_FW_SUBMODE_P2PCLIENT 0x2
  253. #define HI_OPTION_FW_SUBMODE_P2PGO 0x3
  254. #define HI_OPTION_NUM_DEV_SHIFT 0x9
  255. #define HI_OPTION_FW_BRIDGE_SHIFT 0x04
  256. /* Fw Mode/SubMode Mask
  257. |------------------------------------------------------------------------------|
  258. | SUB | SUB | SUB | SUB | | | |
  259. | MODE[3] | MODE[2] | MODE[1] | MODE[0] | MODE[3] | MODE[2] | MODE[1] | MODE[0|
  260. | (2) | (2) | (2) | (2) | (2) | (2) | (2) | (2)
  261. |------------------------------------------------------------------------------|
  262. */
  263. #define HI_OPTION_FW_MODE_BITS 0x2
  264. #define HI_OPTION_FW_MODE_SHIFT 0xC
  265. #define HI_OPTION_FW_SUBMODE_BITS 0x2
  266. #define HI_OPTION_FW_SUBMODE_SHIFT 0x14
  267. /* Convert a Target virtual address into a Target physical address */
  268. #define AR6003_VTOP(vaddr) ((vaddr) & 0x001fffff)
  269. #define AR6004_VTOP(vaddr) (vaddr)
  270. #define TARG_VTOP(target_type, vaddr) \
  271. (((target_type) == TARGET_TYPE_AR6003) ? AR6003_VTOP(vaddr) : \
  272. (((target_type) == TARGET_TYPE_AR6004) ? AR6004_VTOP(vaddr) : 0))
  273. #define ATH6KL_FWLOG_PAYLOAD_SIZE 1500
  274. struct ath6kl_dbglog_buf {
  275. __le32 next;
  276. __le32 buffer_addr;
  277. __le32 bufsize;
  278. __le32 length;
  279. __le32 count;
  280. __le32 free;
  281. } __packed;
  282. struct ath6kl_dbglog_hdr {
  283. __le32 dbuf_addr;
  284. __le32 dropped;
  285. } __packed;
  286. #endif