target.h 12 KB

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