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