rsi_mgmt.h 19 KB

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