xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8723ds/include/rtw_iol.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2017 Realtek Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  *****************************************************************************/
16 #ifndef __RTW_IOL_H_
17 #define __RTW_IOL_H_
18 
19 
20 struct xmit_frame	*rtw_IOL_accquire_xmit_frame(ADAPTER *adapter);
21 int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len);
22 int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary);
23 int rtw_IOL_exec_cmds_sync(ADAPTER *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt);
24 bool rtw_IOL_applied(ADAPTER *adapter);
25 int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us);
26 int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms);
27 int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame);
28 
29 
30 #ifdef CONFIG_IOL_NEW_GENERATION
31 #define IOREG_CMD_END_LEN	4
32 
33 struct ioreg_cfg {
34 	u8	length;
35 	u8	cmd_id;
36 	u16	address;
37 	u32	data;
38 	u32  mask;
39 };
40 enum ioreg_cmd {
41 	IOREG_CMD_LLT			= 0x01,
42 	IOREG_CMD_REFUSE		= 0x02,
43 	IOREG_CMD_EFUSE_PATH = 0x03,
44 	IOREG_CMD_WB_REG		= 0x04,
45 	IOREG_CMD_WW_REG	= 0x05,
46 	IOREG_CMD_WD_REG	= 0x06,
47 	IOREG_CMD_W_RF		= 0x07,
48 	IOREG_CMD_DELAY_US	= 0x10,
49 	IOREG_CMD_DELAY_MS	= 0x11,
50 	IOREG_CMD_END		= 0xFF,
51 };
52 void read_efuse_from_txpktbuf(ADAPTER *adapter, int bcnhead, u8 *content, u16 *size);
53 
54 int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask);
55 int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask);
56 int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask);
57 int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask);
58 #define rtw_IOL_append_WB_cmd(xmit_frame, addr, value, mask) _rtw_IOL_append_WB_cmd((xmit_frame), (addr), (value), (mask))
59 #define rtw_IOL_append_WW_cmd(xmit_frame, addr, value, mask) _rtw_IOL_append_WW_cmd((xmit_frame), (addr), (value), (mask))
60 #define rtw_IOL_append_WD_cmd(xmit_frame, addr, value, mask) _rtw_IOL_append_WD_cmd((xmit_frame), (addr), (value), (mask))
61 #define rtw_IOL_append_WRF_cmd(xmit_frame, rf_path, addr, value, mask) _rtw_IOL_append_WRF_cmd((xmit_frame), (rf_path), (addr), (value), (mask))
62 
63 u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame);
64 void  rtw_IOL_cmd_buf_dump(ADAPTER *Adapter, int buf_len, u8 *pbuf);
65 
66 #ifdef CONFIG_IOL_IOREG_CFG_DBG
67 struct cmd_cmp {
68 	u16 addr;
69 	u32 value;
70 };
71 #endif
72 
73 #else /* CONFIG_IOL_NEW_GENERATION */
74 
75 typedef struct _io_offload_cmd {
76 	u8 rsvd0;
77 	u8 cmd;
78 	u16 address;
79 	u32 value;
80 } IO_OFFLOAD_CMD, IOL_CMD;
81 
82 #define IOL_CMD_LLT			0x00
83 /* #define IOL_CMD_R_EFUSE	0x01 */
84 #define IOL_CMD_WB_REG		0x02
85 #define IOL_CMD_WW_REG	0x03
86 #define IOL_CMD_WD_REG		0x04
87 /* #define IOL_CMD_W_RF		0x05 */
88 #define IOL_CMD_DELAY_US	0x80
89 #define IOL_CMD_DELAY_MS	0x81
90 /* #define IOL_CMD_DELAY_S	0x82 */
91 #define IOL_CMD_END			0x83
92 
93 /*****************************************************
94 CMD					Address			Value
95 (B1)					(B2/B3:H/L addr)	(B4:B7 : MSB:LSB)
96 ******************************************************
97 IOL_CMD_LLT			-				B7: PGBNDY
98 IOL_CMD_R_EFUSE	-				-
99 IOL_CMD_WB_REG		0x0~0xFFFF		B7
100 IOL_CMD_WW_REG	0x0~0xFFFF		B6~B7
101 IOL_CMD_WD_REG	0x0~0xFFFF		B4~B7
102 IOL_CMD_W_RF		RF Reg			B5~B7
103 IOL_CMD_DELAY_US	-				B6~B7
104 IOL_CMD_DELAY_MS	-				B6~B7
105 IOL_CMD_DELAY_S	-				B6~B7
106 IOL_CMD_END		-				-
107 ******************************************************/
108 int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value);
109 int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value);
110 int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value);
111 
112 
113 int rtw_IOL_exec_cmd_array_sync(PADAPTER adapter, u8 *IOL_cmds, u32 cmd_num, u32 max_wating_ms);
114 int rtw_IOL_exec_empty_cmds_sync(ADAPTER *adapter, u32 max_wating_ms);
115 
116 #ifdef DBG_IO
117 int dbg_rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, const char *caller, const int line);
118 int dbg_rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, const char *caller, const int line);
119 int dbg_rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, const char *caller, const int line);
120 #define rtw_IOL_append_WB_cmd(xmit_frame, addr, value) dbg_rtw_IOL_append_WB_cmd((xmit_frame), (addr), (value), __FUNCTION__, __LINE__)
121 #define rtw_IOL_append_WW_cmd(xmit_frame, addr, value) dbg_rtw_IOL_append_WW_cmd((xmit_frame), (addr), (value), __FUNCTION__, __LINE__)
122 #define rtw_IOL_append_WD_cmd(xmit_frame, addr, value) dbg_rtw_IOL_append_WD_cmd((xmit_frame), (addr), (value), __FUNCTION__, __LINE__)
123 #else
124 #define rtw_IOL_append_WB_cmd(xmit_frame, addr, value) _rtw_IOL_append_WB_cmd((xmit_frame), (addr), (value))
125 #define rtw_IOL_append_WW_cmd(xmit_frame, addr, value) _rtw_IOL_append_WW_cmd((xmit_frame), (addr), (value))
126 #define rtw_IOL_append_WD_cmd(xmit_frame, addr, value) _rtw_IOL_append_WD_cmd((xmit_frame), (addr), (value))
127 #endif /* DBG_IO */
128 #endif /* CONFIG_IOL_NEW_GENERATION */
129 
130 
131 
132 #endif /* __RTW_IOL_H_ */
133