target.h 11 KB

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