rsi_mgmt.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /**
  2. * Copyright (c) 2014 Redpine Signals 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 __RSI_MGMT_H__
  17. #define __RSI_MGMT_H__
  18. #include <linux/sort.h>
  19. #include "rsi_boot_params.h"
  20. #include "rsi_main.h"
  21. #define MAX_MGMT_PKT_SIZE 512
  22. #define RSI_NEEDED_HEADROOM 80
  23. #define RSI_RCV_BUFFER_LEN 2000
  24. #define RSI_11B_MODE 0
  25. #define RSI_11G_MODE BIT(7)
  26. #define RETRY_COUNT 8
  27. #define RETRY_LONG 4
  28. #define RETRY_SHORT 7
  29. #define WMM_SHORT_SLOT_TIME 9
  30. #define SIFS_DURATION 16
  31. #define KEY_TYPE_CLEAR 0
  32. #define RSI_PAIRWISE_KEY 1
  33. #define RSI_GROUP_KEY 2
  34. /* EPPROM_READ_ADDRESS */
  35. #define WLAN_MAC_EEPROM_ADDR 40
  36. #define WLAN_MAC_MAGIC_WORD_LEN 0x01
  37. #define WLAN_HOST_MODE_LEN 0x04
  38. #define WLAN_FW_VERSION_LEN 0x08
  39. #define MAGIC_WORD 0x5A
  40. #define WLAN_EEPROM_RFTYPE_ADDR 424
  41. /* Receive Frame Types */
  42. #define TA_CONFIRM_TYPE 0x01
  43. #define RX_DOT11_MGMT 0x02
  44. #define TX_STATUS_IND 0x04
  45. #define BEACON_EVENT_IND 0x08
  46. #define PROBEREQ_CONFIRM 2
  47. #define CARD_READY_IND 0x00
  48. #define RSI_DELETE_PEER 0x0
  49. #define RSI_ADD_PEER 0x1
  50. #define START_AMPDU_AGGR 0x1
  51. #define STOP_AMPDU_AGGR 0x0
  52. #define INTERNAL_MGMT_PKT 0x99
  53. #define PUT_BBP_RESET 0
  54. #define BBP_REG_WRITE 0
  55. #define RF_RESET_ENABLE BIT(3)
  56. #define RATE_INFO_ENABLE BIT(0)
  57. #define MORE_DATA_PRESENT BIT(1)
  58. #define RSI_BROADCAST_PKT BIT(9)
  59. #define RSI_DESC_REQUIRE_CFM_TO_HOST BIT(2)
  60. #define RSI_ADD_DELTA_TSF_VAP_ID BIT(3)
  61. #define RSI_FETCH_RETRY_CNT_FRM_HST BIT(4)
  62. #define RSI_QOS_ENABLE BIT(12)
  63. #define RSI_REKEY_PURPOSE BIT(13)
  64. #define RSI_ENCRYPT_PKT BIT(15)
  65. #define RSI_SET_PS_ENABLE BIT(12)
  66. #define RSI_CMDDESC_40MHZ BIT(4)
  67. #define RSI_CMDDESC_UPPER_20_ENABLE BIT(5)
  68. #define RSI_CMDDESC_LOWER_20_ENABLE BIT(6)
  69. #define RSI_CMDDESC_FULL_40_ENABLE (BIT(5) | BIT(6))
  70. #define UPPER_20_ENABLE (0x2 << 12)
  71. #define LOWER_20_ENABLE (0x4 << 12)
  72. #define FULL40M_ENABLE 0x6
  73. #define RSI_LMAC_CLOCK_80MHZ 0x1
  74. #define RSI_ENABLE_40MHZ (0x1 << 3)
  75. #define ENABLE_SHORTGI_RATE BIT(9)
  76. #define RX_BA_INDICATION 1
  77. #define RSI_TBL_SZ 40
  78. #define MAX_RETRIES 8
  79. #define RSI_IFTYPE_STATION 0
  80. #define STD_RATE_MCS7 0x07
  81. #define STD_RATE_MCS6 0x06
  82. #define STD_RATE_MCS5 0x05
  83. #define STD_RATE_MCS4 0x04
  84. #define STD_RATE_MCS3 0x03
  85. #define STD_RATE_MCS2 0x02
  86. #define STD_RATE_MCS1 0x01
  87. #define STD_RATE_MCS0 0x00
  88. #define STD_RATE_54 0x6c
  89. #define STD_RATE_48 0x60
  90. #define STD_RATE_36 0x48
  91. #define STD_RATE_24 0x30
  92. #define STD_RATE_18 0x24
  93. #define STD_RATE_12 0x18
  94. #define STD_RATE_11 0x16
  95. #define STD_RATE_09 0x12
  96. #define STD_RATE_06 0x0C
  97. #define STD_RATE_5_5 0x0B
  98. #define STD_RATE_02 0x04
  99. #define STD_RATE_01 0x02
  100. #define RSI_RF_TYPE 1
  101. #define RSI_RATE_00 0x00
  102. #define RSI_RATE_1 0x0
  103. #define RSI_RATE_2 0x2
  104. #define RSI_RATE_5_5 0x4
  105. #define RSI_RATE_11 0x6
  106. #define RSI_RATE_6 0x8b
  107. #define RSI_RATE_9 0x8f
  108. #define RSI_RATE_12 0x8a
  109. #define RSI_RATE_18 0x8e
  110. #define RSI_RATE_24 0x89
  111. #define RSI_RATE_36 0x8d
  112. #define RSI_RATE_48 0x88
  113. #define RSI_RATE_54 0x8c
  114. #define RSI_RATE_MCS0 0x100
  115. #define RSI_RATE_MCS1 0x101
  116. #define RSI_RATE_MCS2 0x102
  117. #define RSI_RATE_MCS3 0x103
  118. #define RSI_RATE_MCS4 0x104
  119. #define RSI_RATE_MCS5 0x105
  120. #define RSI_RATE_MCS6 0x106
  121. #define RSI_RATE_MCS7 0x107
  122. #define RSI_RATE_MCS7_SG 0x307
  123. #define RSI_RATE_AUTO 0xffff
  124. #define BW_20MHZ 0
  125. #define BW_40MHZ 1
  126. #define EP_2GHZ_20MHZ 0
  127. #define EP_2GHZ_40MHZ 1
  128. #define EP_5GHZ_20MHZ 2
  129. #define EP_5GHZ_40MHZ 3
  130. #define SIFS_TX_11N_VALUE 580
  131. #define SIFS_TX_11B_VALUE 346
  132. #define SHORT_SLOT_VALUE 360
  133. #define LONG_SLOT_VALUE 640
  134. #define OFDM_ACK_TOUT_VALUE 2720
  135. #define CCK_ACK_TOUT_VALUE 9440
  136. #define LONG_PREAMBLE 0x0000
  137. #define SHORT_PREAMBLE 0x0001
  138. #define RSI_SUPP_FILTERS (FIF_ALLMULTI | FIF_PROBE_REQ |\
  139. FIF_BCN_PRBRESP_PROMISC)
  140. #define ANTENNA_SEL_INT 0x02 /* RF_OUT_2 / Integerated */
  141. #define ANTENNA_SEL_UFL 0x03 /* RF_OUT_1 / U.FL */
  142. #define ANTENNA_MASK_VALUE 0x00ff
  143. #define ANTENNA_SEL_TYPE 1
  144. /* Rx filter word definitions */
  145. #define PROMISCOUS_MODE BIT(0)
  146. #define ALLOW_DATA_ASSOC_PEER BIT(1)
  147. #define ALLOW_MGMT_ASSOC_PEER BIT(2)
  148. #define ALLOW_CTRL_ASSOC_PEER BIT(3)
  149. #define DISALLOW_BEACONS BIT(4)
  150. #define ALLOW_CONN_PEER_MGMT_WHILE_BUF_FULL BIT(5)
  151. #define DISALLOW_BROADCAST_DATA BIT(6)
  152. #define RSI_MPDU_DENSITY 0x8
  153. #define RSI_CHAN_RADAR BIT(7)
  154. #define RSI_BEACON_INTERVAL 200
  155. #define RSI_DTIM_COUNT 2
  156. #define RSI_PS_DISABLE_IND BIT(15)
  157. #define RSI_PS_ENABLE 1
  158. #define RSI_PS_DISABLE 0
  159. #define RSI_DEEP_SLEEP 1
  160. #define RSI_CONNECTED_SLEEP 2
  161. #define RSI_SLEEP_REQUEST 1
  162. #define RSI_WAKEUP_REQUEST 2
  163. #define RSI_IEEE80211_UAPSD_QUEUES \
  164. (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO | \
  165. IEEE80211_WMM_IE_STA_QOSINFO_AC_VI | \
  166. IEEE80211_WMM_IE_STA_QOSINFO_AC_BE | \
  167. IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
  168. #define RSI_DATA_DESC_MAC_BBP_INFO BIT(0)
  169. #define RSI_DATA_DESC_NO_ACK_IND BIT(9)
  170. #define RSI_DATA_DESC_QOS_EN BIT(12)
  171. #define RSI_DATA_DESC_NORMAL_FRAME 0x00
  172. #define RSI_DATA_DESC_DTIM_BEACON_GATED_FRAME BIT(10)
  173. #define RSI_DATA_DESC_BEACON_FRAME BIT(11)
  174. #define RSI_DATA_DESC_DTIM_BEACON (BIT(10) | BIT(11))
  175. #define RSI_DATA_DESC_INSERT_TSF BIT(15)
  176. #define RSI_DATA_DESC_INSERT_SEQ_NO BIT(2)
  177. enum opmode {
  178. AP_OPMODE = 0,
  179. STA_OPMODE,
  180. };
  181. enum vap_status {
  182. VAP_ADD = 1,
  183. VAP_DELETE = 2,
  184. VAP_UPDATE = 3
  185. };
  186. enum peer_type {
  187. PEER_TYPE_AP,
  188. PEER_TYPE_STA,
  189. };
  190. extern struct ieee80211_rate rsi_rates[12];
  191. extern const u16 rsi_mcsrates[8];
  192. enum sta_notify_events {
  193. STA_CONNECTED = 0,
  194. STA_DISCONNECTED,
  195. STA_TX_ADDBA_DONE,
  196. STA_TX_DELBA,
  197. STA_RX_ADDBA_DONE,
  198. STA_RX_DELBA
  199. };
  200. /* Send Frames Types */
  201. enum cmd_frame_type {
  202. TX_DOT11_MGMT,
  203. RESET_MAC_REQ,
  204. RADIO_CAPABILITIES,
  205. BB_PROG_VALUES_REQUEST,
  206. RF_PROG_VALUES_REQUEST,
  207. WAKEUP_SLEEP_REQUEST,
  208. SCAN_REQUEST,
  209. TSF_UPDATE,
  210. PEER_NOTIFY,
  211. BLOCK_HW_QUEUE,
  212. SET_KEY_REQ,
  213. AUTO_RATE_IND,
  214. BOOTUP_PARAMS_REQUEST,
  215. VAP_CAPABILITIES,
  216. EEPROM_READ,
  217. EEPROM_WRITE,
  218. GPIO_PIN_CONFIG ,
  219. SET_RX_FILTER,
  220. AMPDU_IND,
  221. STATS_REQUEST_FRAME,
  222. BB_BUF_PROG_VALUES_REQ,
  223. BBP_PROG_IN_TA,
  224. BG_SCAN_PARAMS,
  225. BG_SCAN_PROBE_REQ,
  226. CW_MODE_REQ,
  227. PER_CMD_PKT,
  228. ANT_SEL_FRAME = 0x20,
  229. VAP_DYNAMIC_UPDATE = 0x27,
  230. COMMON_DEV_CONFIG = 0x28,
  231. RADIO_PARAMS_UPDATE = 0x29
  232. };
  233. struct rsi_mac_frame {
  234. __le16 desc_word[8];
  235. } __packed;
  236. #define PWR_SAVE_WAKEUP_IND BIT(0)
  237. #define TCP_CHECK_SUM_OFFLOAD BIT(1)
  238. #define CONFIRM_REQUIRED_TO_HOST BIT(2)
  239. #define ADD_DELTA_TSF BIT(3)
  240. #define FETCH_RETRY_CNT_FROM_HOST_DESC BIT(4)
  241. #define EOSP_INDICATION BIT(5)
  242. #define REQUIRE_TSF_SYNC_CONFIRM BIT(6)
  243. #define ENCAP_MGMT_PKT BIT(7)
  244. #define DESC_IMMEDIATE_WAKEUP BIT(15)
  245. struct rsi_cmd_desc_dword0 {
  246. __le16 len_qno;
  247. u8 frame_type;
  248. u8 misc_flags;
  249. };
  250. struct rsi_cmd_desc_dword1 {
  251. u8 xtend_desc_size;
  252. u8 reserved1;
  253. __le16 reserved2;
  254. };
  255. struct rsi_cmd_desc_dword2 {
  256. __le32 pkt_info; /* Packet specific data */
  257. };
  258. struct rsi_cmd_desc_dword3 {
  259. __le16 token;
  260. u8 qid_tid;
  261. u8 sta_id;
  262. };
  263. struct rsi_cmd_desc {
  264. struct rsi_cmd_desc_dword0 desc_dword0;
  265. struct rsi_cmd_desc_dword1 desc_dword1;
  266. struct rsi_cmd_desc_dword2 desc_dword2;
  267. struct rsi_cmd_desc_dword3 desc_dword3;
  268. };
  269. struct rsi_boot_params {
  270. __le16 desc_word[8];
  271. struct bootup_params bootup_params;
  272. } __packed;
  273. struct rsi_peer_notify {
  274. struct rsi_cmd_desc desc;
  275. u8 mac_addr[6];
  276. __le16 command;
  277. __le16 mpdu_density;
  278. __le16 reserved;
  279. __le32 sta_flags;
  280. } __packed;
  281. /* Aggregation params flags */
  282. #define RSI_AGGR_PARAMS_TID_MASK 0xf
  283. #define RSI_AGGR_PARAMS_START BIT(4)
  284. #define RSI_AGGR_PARAMS_RX_AGGR BIT(5)
  285. struct rsi_aggr_params {
  286. struct rsi_cmd_desc_dword0 desc_dword0;
  287. struct rsi_cmd_desc_dword0 desc_dword1;
  288. __le16 seq_start;
  289. __le16 baw_size;
  290. __le16 token;
  291. u8 aggr_params;
  292. u8 peer_id;
  293. } __packed;
  294. struct rsi_bb_rf_prog {
  295. struct rsi_cmd_desc_dword0 desc_dword0;
  296. __le16 reserved1;
  297. u8 rf_power_mode;
  298. u8 reserved2;
  299. u8 endpoint;
  300. u8 reserved3;
  301. __le16 reserved4;
  302. __le16 reserved5;
  303. __le16 flags;
  304. } __packed;
  305. struct rsi_chan_config {
  306. struct rsi_cmd_desc_dword0 desc_dword0;
  307. struct rsi_cmd_desc_dword1 desc_dword1;
  308. u8 channel_number;
  309. u8 antenna_gain_offset_2g;
  310. u8 antenna_gain_offset_5g;
  311. u8 channel_width;
  312. __le16 tx_power;
  313. u8 region_rftype;
  314. u8 flags;
  315. } __packed;
  316. struct rsi_vap_caps {
  317. struct rsi_cmd_desc_dword0 desc_dword0;
  318. u8 reserved1;
  319. u8 status;
  320. __le16 reserved2;
  321. u8 vif_type;
  322. u8 channel_bw;
  323. __le16 antenna_info;
  324. u8 radioid_macid;
  325. u8 vap_id;
  326. __le16 reserved3;
  327. u8 mac_addr[6];
  328. __le16 keep_alive_period;
  329. u8 bssid[6];
  330. __le16 reserved4;
  331. __le32 flags;
  332. __le16 frag_threshold;
  333. __le16 rts_threshold;
  334. __le32 default_mgmt_rate;
  335. __le16 default_ctrl_rate;
  336. __le16 ctrl_rate_flags;
  337. __le32 default_data_rate;
  338. __le16 beacon_interval;
  339. __le16 dtim_period;
  340. __le16 beacon_miss_threshold;
  341. } __packed;
  342. struct rsi_ant_sel_frame {
  343. struct rsi_cmd_desc_dword0 desc_dword0;
  344. u8 reserved;
  345. u8 sub_frame_type;
  346. __le16 ant_value;
  347. __le32 reserved1;
  348. __le32 reserved2;
  349. } __packed;
  350. struct rsi_dynamic_s {
  351. struct rsi_cmd_desc_dword0 desc_dword0;
  352. struct rsi_cmd_desc_dword1 desc_dword1;
  353. struct rsi_cmd_desc_dword2 desc_dword2;
  354. struct rsi_cmd_desc_dword3 desc_dword3;
  355. struct framebody {
  356. __le16 data_rate;
  357. __le16 mgmt_rate;
  358. __le16 keep_alive_period;
  359. } frame_body;
  360. } __packed;
  361. /* Key descriptor flags */
  362. #define RSI_KEY_TYPE_BROADCAST BIT(1)
  363. #define RSI_WEP_KEY BIT(2)
  364. #define RSI_WEP_KEY_104 BIT(3)
  365. #define RSI_CIPHER_WPA BIT(4)
  366. #define RSI_CIPHER_TKIP BIT(5)
  367. #define RSI_KEY_MODE_AP BIT(7)
  368. #define RSI_PROTECT_DATA_FRAMES BIT(13)
  369. #define RSI_KEY_ID_MASK 0xC0
  370. #define RSI_KEY_ID_OFFSET 14
  371. struct rsi_set_key {
  372. struct rsi_cmd_desc_dword0 desc_dword0;
  373. struct rsi_cmd_desc_dword1 desc_dword1;
  374. __le16 key_desc;
  375. __le32 bpn;
  376. u8 sta_id;
  377. u8 vap_id;
  378. u8 key[4][32];
  379. u8 tx_mic_key[8];
  380. u8 rx_mic_key[8];
  381. } __packed;
  382. struct rsi_auto_rate {
  383. struct rsi_cmd_desc desc;
  384. __le16 failure_limit;
  385. __le16 initial_boundary;
  386. __le16 max_threshold_limt;
  387. __le16 num_supported_rates;
  388. __le16 aarf_rssi;
  389. __le16 moderate_rate_inx;
  390. __le16 collision_tolerance;
  391. __le16 supported_rates[40];
  392. } __packed;
  393. #define QUIET_INFO_VALID BIT(0)
  394. #define QUIET_ENABLE BIT(1)
  395. struct rsi_block_unblock_data {
  396. struct rsi_cmd_desc_dword0 desc_dword0;
  397. u8 xtend_desc_size;
  398. u8 host_quiet_info;
  399. __le16 reserved;
  400. __le16 block_q_bitmap;
  401. __le16 unblock_q_bitmap;
  402. __le16 token;
  403. __le16 flush_q_bitmap;
  404. } __packed;
  405. struct qos_params {
  406. __le16 cont_win_min_q;
  407. __le16 cont_win_max_q;
  408. __le16 aifsn_val_q;
  409. __le16 txop_q;
  410. } __packed;
  411. struct rsi_radio_caps {
  412. struct rsi_cmd_desc_dword0 desc_dword0;
  413. struct rsi_cmd_desc_dword0 desc_dword1;
  414. u8 channel_num;
  415. u8 rf_model;
  416. __le16 ppe_ack_rate;
  417. __le16 mode_11j;
  418. u8 radio_cfg_info;
  419. u8 radio_info;
  420. struct qos_params qos_params[MAX_HW_QUEUES];
  421. u8 num_11n_rates;
  422. u8 num_11ac_rates;
  423. __le16 gcpd_per_rate[20];
  424. __le16 sifs_tx_11n;
  425. __le16 sifs_tx_11b;
  426. __le16 slot_rx_11n;
  427. __le16 ofdm_ack_tout;
  428. __le16 cck_ack_tout;
  429. __le16 preamble_type;
  430. } __packed;
  431. /* ULP GPIO flags */
  432. #define RSI_GPIO_MOTION_SENSOR_ULP_WAKEUP BIT(0)
  433. #define RSI_GPIO_SLEEP_IND_FROM_DEVICE BIT(1)
  434. #define RSI_GPIO_2_ULP BIT(2)
  435. #define RSI_GPIO_PUSH_BUTTON_ULP_WAKEUP BIT(3)
  436. /* SOC GPIO flags */
  437. #define RSI_GPIO_0_PSPI_CSN_0 BIT(0)
  438. #define RSI_GPIO_1_PSPI_CSN_1 BIT(1)
  439. #define RSI_GPIO_2_HOST_WAKEUP_INTR BIT(2)
  440. #define RSI_GPIO_3_PSPI_DATA_0 BIT(3)
  441. #define RSI_GPIO_4_PSPI_DATA_1 BIT(4)
  442. #define RSI_GPIO_5_PSPI_DATA_2 BIT(5)
  443. #define RSI_GPIO_6_PSPI_DATA_3 BIT(6)
  444. #define RSI_GPIO_7_I2C_SCL BIT(7)
  445. #define RSI_GPIO_8_I2C_SDA BIT(8)
  446. #define RSI_GPIO_9_UART1_RX BIT(9)
  447. #define RSI_GPIO_10_UART1_TX BIT(10)
  448. #define RSI_GPIO_11_UART1_RTS_I2S_CLK BIT(11)
  449. #define RSI_GPIO_12_UART1_CTS_I2S_WS BIT(12)
  450. #define RSI_GPIO_13_DBG_UART_RX_I2S_DIN BIT(13)
  451. #define RSI_GPIO_14_DBG_UART_RX_I2S_DOUT BIT(14)
  452. #define RSI_GPIO_15_LP_WAKEUP_BOOT_BYPASS BIT(15)
  453. #define RSI_GPIO_16_LED_0 BIT(16)
  454. #define RSI_GPIO_17_BTCOEX_WLAN_ACT_EXT_ANT_SEL BIT(17)
  455. #define RSI_GPIO_18_BTCOEX_BT_PRIO_EXT_ANT_SEL BIT(18)
  456. #define RSI_GPIO_19_BTCOEX_BT_ACT_EXT_ON_OFF BIT(19)
  457. #define RSI_GPIO_20_RF_RESET BIT(20)
  458. #define RSI_GPIO_21_SLEEP_IND_FROM_DEVICE BIT(21)
  459. #define RSI_UNUSED_SOC_GPIO_BITMAP (RSI_GPIO_9_UART1_RX | \
  460. RSI_GPIO_10_UART1_TX | \
  461. RSI_GPIO_11_UART1_RTS_I2S_CLK | \
  462. RSI_GPIO_12_UART1_CTS_I2S_WS | \
  463. RSI_GPIO_13_DBG_UART_RX_I2S_DIN | \
  464. RSI_GPIO_14_DBG_UART_RX_I2S_DOUT | \
  465. RSI_GPIO_15_LP_WAKEUP_BOOT_BYPASS | \
  466. RSI_GPIO_17_BTCOEX_WLAN_ACT_EXT_ANT_SEL | \
  467. RSI_GPIO_18_BTCOEX_BT_PRIO_EXT_ANT_SEL | \
  468. RSI_GPIO_19_BTCOEX_BT_ACT_EXT_ON_OFF | \
  469. RSI_GPIO_21_SLEEP_IND_FROM_DEVICE)
  470. #define RSI_UNUSED_ULP_GPIO_BITMAP (RSI_GPIO_MOTION_SENSOR_ULP_WAKEUP | \
  471. RSI_GPIO_SLEEP_IND_FROM_DEVICE | \
  472. RSI_GPIO_2_ULP | \
  473. RSI_GPIO_PUSH_BUTTON_ULP_WAKEUP);
  474. struct rsi_config_vals {
  475. __le16 len_qno;
  476. u8 pkt_type;
  477. u8 misc_flags;
  478. __le16 reserved1[6];
  479. u8 lp_ps_handshake;
  480. u8 ulp_ps_handshake;
  481. u8 sleep_config_params; /* 0 for no handshake,
  482. * 1 for GPIO based handshake,
  483. * 2 packet handshake
  484. */
  485. u8 unused_ulp_gpio;
  486. __le32 unused_soc_gpio_bitmap;
  487. u8 ext_pa_or_bt_coex_en;
  488. u8 opermode;
  489. u8 wlan_rf_pwr_mode;
  490. u8 bt_rf_pwr_mode;
  491. u8 zigbee_rf_pwr_mode;
  492. u8 driver_mode;
  493. u8 region_code;
  494. u8 antenna_sel_val;
  495. u8 reserved2[16];
  496. } __packed;
  497. /* Packet info flags */
  498. #define RSI_EEPROM_HDR_SIZE_OFFSET 8
  499. #define RSI_EEPROM_HDR_SIZE_MASK 0x300
  500. #define RSI_EEPROM_LEN_OFFSET 20
  501. #define RSI_EEPROM_LEN_MASK 0xFFF00000
  502. struct rsi_eeprom_read_frame {
  503. __le16 len_qno;
  504. u8 pkt_type;
  505. u8 misc_flags;
  506. __le32 pkt_info;
  507. __le32 eeprom_offset;
  508. __le16 delay_ms;
  509. __le16 reserved3;
  510. } __packed;
  511. struct rsi_request_ps {
  512. struct rsi_cmd_desc desc;
  513. struct ps_sleep_params ps_sleep;
  514. u8 ps_mimic_support;
  515. u8 ps_uapsd_acs;
  516. u8 ps_uapsd_wakeup_period;
  517. u8 reserved;
  518. __le32 ps_listen_interval;
  519. __le32 ps_dtim_interval_duration;
  520. __le16 ps_num_dtim_intervals;
  521. } __packed;
  522. static inline u32 rsi_get_queueno(u8 *addr, u16 offset)
  523. {
  524. return (le16_to_cpu(*(__le16 *)&addr[offset]) & 0x7000) >> 12;
  525. }
  526. static inline u32 rsi_get_length(u8 *addr, u16 offset)
  527. {
  528. return (le16_to_cpu(*(__le16 *)&addr[offset])) & 0x0fff;
  529. }
  530. static inline u8 rsi_get_extended_desc(u8 *addr, u16 offset)
  531. {
  532. return le16_to_cpu(*((__le16 *)&addr[offset + 4])) & 0x00ff;
  533. }
  534. static inline u8 rsi_get_rssi(u8 *addr)
  535. {
  536. return *(u8 *)(addr + FRAME_DESC_SZ);
  537. }
  538. static inline u8 rsi_get_channel(u8 *addr)
  539. {
  540. return *(char *)(addr + 15);
  541. }
  542. static inline void rsi_set_len_qno(__le16 *addr, u16 len, u8 qno)
  543. {
  544. *addr = cpu_to_le16(len | ((qno & 7) << 12));
  545. }
  546. int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg);
  547. int rsi_set_vap_capabilities(struct rsi_common *common, enum opmode mode,
  548. u8 *mac_addr, u8 vap_id, u8 vap_status);
  549. int rsi_send_aggregation_params_frame(struct rsi_common *common, u16 tid,
  550. u16 ssn, u8 buf_size, u8 event,
  551. u8 sta_id);
  552. int rsi_hal_load_key(struct rsi_common *common, u8 *data, u16 key_len,
  553. u8 key_type, u8 key_id, u32 cipher, s16 sta_id);
  554. int rsi_set_channel(struct rsi_common *common,
  555. struct ieee80211_channel *channel);
  556. int rsi_send_vap_dynamic_update(struct rsi_common *common);
  557. int rsi_send_block_unblock_frame(struct rsi_common *common, bool event);
  558. void rsi_inform_bss_status(struct rsi_common *common, enum opmode opmode,
  559. u8 status, const u8 *addr, u8 qos_enable, u16 aid,
  560. struct ieee80211_sta *sta, u16 sta_id);
  561. void rsi_indicate_pkt_to_os(struct rsi_common *common, struct sk_buff *skb);
  562. int rsi_mac80211_attach(struct rsi_common *common);
  563. void rsi_indicate_tx_status(struct rsi_hw *common, struct sk_buff *skb,
  564. int status);
  565. bool rsi_is_cipher_wep(struct rsi_common *common);
  566. void rsi_core_qos_processor(struct rsi_common *common);
  567. void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb);
  568. int rsi_send_mgmt_pkt(struct rsi_common *common, struct sk_buff *skb);
  569. int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb);
  570. int rsi_band_check(struct rsi_common *common);
  571. int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word);
  572. int rsi_send_radio_params_update(struct rsi_common *common);
  573. int rsi_set_antenna(struct rsi_common *common, u8 antenna);
  574. #endif