target.h 12 KB

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