rsi_mgmt.h 19 KB

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