net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / hal / hal_com_c2h.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __COMMON_C2H_H__
21 #define __COMMON_C2H_H__
22
23 #define C2H_TYPE_REG 0
24 #define C2H_TYPE_PKT 1
25
26 /* 
27 * C2H event format:
28 * Fields    TRIGGER    PAYLOAD    SEQ    PLEN    ID
29 * BITS     [127:120]    [119:16]   [15:8]  [7:4]  [3:0]
30 */
31 #define C2H_ID(_c2h)            LE_BITS_TO_1BYTE(((u8*)(_c2h)), 0, 4)
32 #define C2H_PLEN(_c2h)          LE_BITS_TO_1BYTE(((u8*)(_c2h)), 4, 4)
33 #define C2H_SEQ(_c2h)           LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 1, 0, 8)
34 #define C2H_PAYLOAD(_c2h)       (((u8*)(_c2h)) + 2)
35
36 #define SET_C2H_ID(_c2h, _val)          SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 0, 4, _val)
37 #define SET_C2H_PLEN(_c2h, _val)        SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 4, 4, _val)
38 #define SET_C2H_SEQ(_c2h, _val)         SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1 , 0, 8, _val)
39
40 /* 
41 * C2H event format:
42 * Fields    TRIGGER     PLEN      PAYLOAD    SEQ      ID
43 * BITS    [127:120]  [119:112]  [111:16]   [15:8]   [7:0]
44 */
45 #define C2H_ID_88XX(_c2h)               LE_BITS_TO_1BYTE(((u8*)(_c2h)), 0, 8)
46 #define C2H_SEQ_88XX(_c2h)              LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 1, 0, 8)
47 #define C2H_PAYLOAD_88XX(_c2h)  (((u8*)(_c2h)) + 2)
48 #define C2H_PLEN_88XX(_c2h)             LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 14, 0, 8)
49 #define C2H_TRIGGER_88XX(_c2h)  LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 15, 0, 8)
50
51 #define SET_C2H_ID_88XX(_c2h, _val)             SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 0, 8, _val)
52 #define SET_C2H_SEQ_88XX(_c2h, _val)    SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1, 0, 8, _val)
53 #define SET_C2H_PLEN_88XX(_c2h, _val)   SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 14, 0, 8, _val)
54
55 typedef enum _C2H_EVT {
56         C2H_DBG = 0x00,
57         C2H_LB = 0x01,
58         C2H_TXBF = 0x02,
59         C2H_CCX_TX_RPT = 0x03,
60         C2H_AP_REQ_TXRPT = 0x04,
61         C2H_FW_SCAN_COMPLETE = 0x7,
62         C2H_BT_INFO = 0x09,
63         C2H_BT_MP_INFO = 0x0B,
64         C2H_RA_RPT = 0x0C,
65         C2H_SPC_STAT = 0x0D,
66         C2H_RA_PARA_RPT = 0x0E,
67         C2H_FW_CHNL_SWITCH_COMPLETE = 0x10,
68         C2H_IQK_FINISH = 0x11,
69         C2H_MAILBOX_STATUS = 0x15,
70         C2H_P2P_RPORT = 0x16,
71         C2H_MCC = 0x17,
72         C2H_MAC_HIDDEN_RPT = 0x19,
73         C2H_MAC_HIDDEN_RPT_2 = 0x1A,
74         C2H_BCN_EARLY_RPT = 0x1E,
75         C2H_DEFEATURE_DBG = 0x22,
76         C2H_CUSTOMER_STR_RPT = 0x24,
77         C2H_CUSTOMER_STR_RPT_2 = 0x25,
78         C2H_DEFEATURE_RSVD = 0xFD,
79         C2H_EXTEND = 0xff,
80 } C2H_EVT;
81
82 typedef enum _EXTEND_C2H_EVT {
83         EXTEND_C2H_DBG_PRINT = 0
84 } EXTEND_C2H_EVT;
85
86 #define C2H_REG_LEN 16
87
88 /* C2H_IQK_FINISH, 0x11 */
89 #define IQK_OFFLOAD_LEN 1
90 void c2h_iqk_offload(_adapter *adapter, u8 *data, u8 len);
91 int     c2h_iqk_offload_wait(_adapter *adapter, u32 timeout_ms);
92 #define rtl8812_iqk_wait c2h_iqk_offload_wait /* TODO: remove this after phydm call c2h_iqk_offload_wait instead */
93
94 #ifdef CONFIG_RTW_MAC_HIDDEN_RPT
95 /* C2H_MAC_HIDDEN_RPT, 0x19 */
96 #define MAC_HIDDEN_RPT_LEN 8
97 int c2h_mac_hidden_rpt_hdl(_adapter *adapter, u8 *data, u8 len);
98
99 /* C2H_MAC_HIDDEN_RPT_2, 0x1A */
100 #define MAC_HIDDEN_RPT_2_LEN 5
101 int c2h_mac_hidden_rpt_2_hdl(_adapter *adapter, u8 *data, u8 len);
102 int hal_read_mac_hidden_rpt(_adapter *adapter);
103 #endif /* CONFIG_RTW_MAC_HIDDEN_RPT */
104
105 /* C2H_DEFEATURE_DBG, 0x22 */
106 #define DEFEATURE_DBG_LEN 1
107 int c2h_defeature_dbg_hdl(_adapter *adapter, u8 *data, u8 len);
108
109 #ifdef CONFIG_RTW_CUSTOMER_STR
110 /* C2H_CUSTOMER_STR_RPT, 0x24 */
111 #define CUSTOMER_STR_RPT_LEN 8
112 int c2h_customer_str_rpt_hdl(_adapter *adapter, u8 *data, u8 len);
113
114 /* C2H_CUSTOMER_STR_RPT_2, 0x25 */
115 #define CUSTOMER_STR_RPT_2_LEN 8
116 int c2h_customer_str_rpt_2_hdl(_adapter *adapter, u8 *data, u8 len);
117 #endif /* CONFIG_RTW_CUSTOMER_STR */
118
119 #endif /* __COMMON_C2H_H__ */