rsi_mgmt.h 20 KB

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