target.h 12 KB

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