18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* Copyright(c) 2009-2012 Realtek Corporation.*/ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include "../wifi.h" 58c2ecf20Sopenharmony_ci#include "../pci.h" 68c2ecf20Sopenharmony_ci#include "../base.h" 78c2ecf20Sopenharmony_ci#include "../core.h" 88c2ecf20Sopenharmony_ci#include "reg.h" 98c2ecf20Sopenharmony_ci#include "def.h" 108c2ecf20Sopenharmony_ci#include "fw.h" 118c2ecf20Sopenharmony_ci#include "../rtl8723com/fw_common.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistatic bool _rtl8723e_check_fw_read_last_h2c(struct ieee80211_hw *hw, 148c2ecf20Sopenharmony_ci u8 boxnum) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 178c2ecf20Sopenharmony_ci u8 val_hmetfr, val_mcutst_1; 188c2ecf20Sopenharmony_ci bool result = false; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR); 218c2ecf20Sopenharmony_ci val_mcutst_1 = rtl_read_byte(rtlpriv, (REG_MCUTST_1 + boxnum)); 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci if (((val_hmetfr >> boxnum) & BIT(0)) == 0 && val_mcutst_1 == 0) 248c2ecf20Sopenharmony_ci result = true; 258c2ecf20Sopenharmony_ci return result; 268c2ecf20Sopenharmony_ci} 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic void _rtl8723e_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id, 298c2ecf20Sopenharmony_ci u32 cmd_len, u8 *cmdbuffer) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 328c2ecf20Sopenharmony_ci struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 338c2ecf20Sopenharmony_ci u8 boxnum; 348c2ecf20Sopenharmony_ci u16 box_reg = 0, box_extreg = 0; 358c2ecf20Sopenharmony_ci u8 u1b_tmp; 368c2ecf20Sopenharmony_ci bool isfw_read = false; 378c2ecf20Sopenharmony_ci u8 buf_index = 0; 388c2ecf20Sopenharmony_ci bool bwrite_sucess = false; 398c2ecf20Sopenharmony_ci u8 wait_h2c_limmit = 100; 408c2ecf20Sopenharmony_ci u8 wait_writeh2c_limmit = 100; 418c2ecf20Sopenharmony_ci u8 boxcontent[4], boxextcontent[2]; 428c2ecf20Sopenharmony_ci u32 h2c_waitcounter = 0; 438c2ecf20Sopenharmony_ci unsigned long flag; 448c2ecf20Sopenharmony_ci u8 idx; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n"); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci while (true) { 498c2ecf20Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 508c2ecf20Sopenharmony_ci if (rtlhal->h2c_setinprogress) { 518c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 528c2ecf20Sopenharmony_ci "H2C set in progress! Wait to set..element_id(%d).\n", 538c2ecf20Sopenharmony_ci element_id); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci while (rtlhal->h2c_setinprogress) { 568c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, 578c2ecf20Sopenharmony_ci flag); 588c2ecf20Sopenharmony_ci h2c_waitcounter++; 598c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 608c2ecf20Sopenharmony_ci "Wait 100 us (%d times)...\n", 618c2ecf20Sopenharmony_ci h2c_waitcounter); 628c2ecf20Sopenharmony_ci udelay(100); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci if (h2c_waitcounter > 1000) 658c2ecf20Sopenharmony_ci return; 668c2ecf20Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.h2c_lock, 678c2ecf20Sopenharmony_ci flag); 688c2ecf20Sopenharmony_ci } 698c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 708c2ecf20Sopenharmony_ci } else { 718c2ecf20Sopenharmony_ci rtlhal->h2c_setinprogress = true; 728c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 738c2ecf20Sopenharmony_ci break; 748c2ecf20Sopenharmony_ci } 758c2ecf20Sopenharmony_ci } 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci while (!bwrite_sucess) { 788c2ecf20Sopenharmony_ci wait_writeh2c_limmit--; 798c2ecf20Sopenharmony_ci if (wait_writeh2c_limmit == 0) { 808c2ecf20Sopenharmony_ci pr_err("Write H2C fail because no trigger for FW INT!\n"); 818c2ecf20Sopenharmony_ci break; 828c2ecf20Sopenharmony_ci } 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci boxnum = rtlhal->last_hmeboxnum; 858c2ecf20Sopenharmony_ci switch (boxnum) { 868c2ecf20Sopenharmony_ci case 0: 878c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_0; 888c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_0; 898c2ecf20Sopenharmony_ci break; 908c2ecf20Sopenharmony_ci case 1: 918c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_1; 928c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_1; 938c2ecf20Sopenharmony_ci break; 948c2ecf20Sopenharmony_ci case 2: 958c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_2; 968c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_2; 978c2ecf20Sopenharmony_ci break; 988c2ecf20Sopenharmony_ci case 3: 998c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_3; 1008c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_3; 1018c2ecf20Sopenharmony_ci break; 1028c2ecf20Sopenharmony_ci default: 1038c2ecf20Sopenharmony_ci pr_err("switch case %#x not processed\n", 1048c2ecf20Sopenharmony_ci boxnum); 1058c2ecf20Sopenharmony_ci break; 1068c2ecf20Sopenharmony_ci } 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci isfw_read = _rtl8723e_check_fw_read_last_h2c(hw, boxnum); 1098c2ecf20Sopenharmony_ci while (!isfw_read) { 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci wait_h2c_limmit--; 1128c2ecf20Sopenharmony_ci if (wait_h2c_limmit == 0) { 1138c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1148c2ecf20Sopenharmony_ci "Waiting too long for FW read clear HMEBox(%d)!\n", 1158c2ecf20Sopenharmony_ci boxnum); 1168c2ecf20Sopenharmony_ci break; 1178c2ecf20Sopenharmony_ci } 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci udelay(10); 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci isfw_read = _rtl8723e_check_fw_read_last_h2c(hw, 1228c2ecf20Sopenharmony_ci boxnum); 1238c2ecf20Sopenharmony_ci u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); 1248c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1258c2ecf20Sopenharmony_ci "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n", 1268c2ecf20Sopenharmony_ci boxnum, u1b_tmp); 1278c2ecf20Sopenharmony_ci } 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci if (!isfw_read) { 1308c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1318c2ecf20Sopenharmony_ci "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n", 1328c2ecf20Sopenharmony_ci boxnum); 1338c2ecf20Sopenharmony_ci break; 1348c2ecf20Sopenharmony_ci } 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci memset(boxcontent, 0, sizeof(boxcontent)); 1378c2ecf20Sopenharmony_ci memset(boxextcontent, 0, sizeof(boxextcontent)); 1388c2ecf20Sopenharmony_ci boxcontent[0] = element_id; 1398c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1408c2ecf20Sopenharmony_ci "Write element_id box_reg(%4x) = %2x\n", 1418c2ecf20Sopenharmony_ci box_reg, element_id); 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci switch (cmd_len) { 1448c2ecf20Sopenharmony_ci case 1: 1458c2ecf20Sopenharmony_ci boxcontent[0] &= ~(BIT(7)); 1468c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1478c2ecf20Sopenharmony_ci cmdbuffer + buf_index, 1); 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1508c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 1518c2ecf20Sopenharmony_ci boxcontent[idx]); 1528c2ecf20Sopenharmony_ci } 1538c2ecf20Sopenharmony_ci break; 1548c2ecf20Sopenharmony_ci case 2: 1558c2ecf20Sopenharmony_ci boxcontent[0] &= ~(BIT(7)); 1568c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1578c2ecf20Sopenharmony_ci cmdbuffer + buf_index, 2); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1608c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 1618c2ecf20Sopenharmony_ci boxcontent[idx]); 1628c2ecf20Sopenharmony_ci } 1638c2ecf20Sopenharmony_ci break; 1648c2ecf20Sopenharmony_ci case 3: 1658c2ecf20Sopenharmony_ci boxcontent[0] &= ~(BIT(7)); 1668c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1678c2ecf20Sopenharmony_ci cmdbuffer + buf_index, 3); 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1708c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 1718c2ecf20Sopenharmony_ci boxcontent[idx]); 1728c2ecf20Sopenharmony_ci } 1738c2ecf20Sopenharmony_ci break; 1748c2ecf20Sopenharmony_ci case 4: 1758c2ecf20Sopenharmony_ci boxcontent[0] |= (BIT(7)); 1768c2ecf20Sopenharmony_ci memcpy((u8 *)(boxextcontent), 1778c2ecf20Sopenharmony_ci cmdbuffer + buf_index, 2); 1788c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1798c2ecf20Sopenharmony_ci cmdbuffer + buf_index + 2, 2); 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci for (idx = 0; idx < 2; idx++) { 1828c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_extreg + idx, 1838c2ecf20Sopenharmony_ci boxextcontent[idx]); 1848c2ecf20Sopenharmony_ci } 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1878c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 1888c2ecf20Sopenharmony_ci boxcontent[idx]); 1898c2ecf20Sopenharmony_ci } 1908c2ecf20Sopenharmony_ci break; 1918c2ecf20Sopenharmony_ci case 5: 1928c2ecf20Sopenharmony_ci boxcontent[0] |= (BIT(7)); 1938c2ecf20Sopenharmony_ci memcpy((u8 *)(boxextcontent), 1948c2ecf20Sopenharmony_ci cmdbuffer + buf_index, 2); 1958c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1968c2ecf20Sopenharmony_ci cmdbuffer + buf_index + 2, 3); 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci for (idx = 0; idx < 2; idx++) { 1998c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_extreg + idx, 2008c2ecf20Sopenharmony_ci boxextcontent[idx]); 2018c2ecf20Sopenharmony_ci } 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 2048c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 2058c2ecf20Sopenharmony_ci boxcontent[idx]); 2068c2ecf20Sopenharmony_ci } 2078c2ecf20Sopenharmony_ci break; 2088c2ecf20Sopenharmony_ci default: 2098c2ecf20Sopenharmony_ci pr_err("switch case %#x not processed\n", 2108c2ecf20Sopenharmony_ci cmd_len); 2118c2ecf20Sopenharmony_ci break; 2128c2ecf20Sopenharmony_ci } 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci bwrite_sucess = true; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci rtlhal->last_hmeboxnum = boxnum + 1; 2178c2ecf20Sopenharmony_ci if (rtlhal->last_hmeboxnum == 4) 2188c2ecf20Sopenharmony_ci rtlhal->last_hmeboxnum = 0; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 2218c2ecf20Sopenharmony_ci "pHalData->last_hmeboxnum = %d\n", 2228c2ecf20Sopenharmony_ci rtlhal->last_hmeboxnum); 2238c2ecf20Sopenharmony_ci } 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 2268c2ecf20Sopenharmony_ci rtlhal->h2c_setinprogress = false; 2278c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n"); 2308c2ecf20Sopenharmony_ci} 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_civoid rtl8723e_fill_h2c_cmd(struct ieee80211_hw *hw, 2338c2ecf20Sopenharmony_ci u8 element_id, u32 cmd_len, u8 *cmdbuffer) 2348c2ecf20Sopenharmony_ci{ 2358c2ecf20Sopenharmony_ci struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 2368c2ecf20Sopenharmony_ci u32 tmp_cmdbuf[2]; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci if (!rtlhal->fw_ready) { 2398c2ecf20Sopenharmony_ci WARN_ONCE(true, 2408c2ecf20Sopenharmony_ci "rtl8723ae: error H2C cmd because of Fw download fail!!!\n"); 2418c2ecf20Sopenharmony_ci return; 2428c2ecf20Sopenharmony_ci } 2438c2ecf20Sopenharmony_ci memset(tmp_cmdbuf, 0, 8); 2448c2ecf20Sopenharmony_ci memcpy(tmp_cmdbuf, cmdbuffer, cmd_len); 2458c2ecf20Sopenharmony_ci _rtl8723e_fill_h2c_command(hw, element_id, cmd_len, 2468c2ecf20Sopenharmony_ci (u8 *)&tmp_cmdbuf); 2478c2ecf20Sopenharmony_ci} 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_civoid rtl8723e_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 2528c2ecf20Sopenharmony_ci u8 u1_h2c_set_pwrmode[3] = { 0 }; 2538c2ecf20Sopenharmony_ci struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode); 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); 2588c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 2598c2ecf20Sopenharmony_ci (rtlpriv->mac80211.p2p) ? ppsc->smart_ps : 1); 2608c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode, 2618c2ecf20Sopenharmony_ci ppsc->reg_max_lps_awakeintvl); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 2648c2ecf20Sopenharmony_ci "rtl8723e_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", 2658c2ecf20Sopenharmony_ci u1_h2c_set_pwrmode, 3); 2668c2ecf20Sopenharmony_ci rtl8723e_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); 2678c2ecf20Sopenharmony_ci} 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci#define BEACON_PG 0 /* ->1 */ 2708c2ecf20Sopenharmony_ci#define PSPOLL_PG 2 2718c2ecf20Sopenharmony_ci#define NULL_PG 3 2728c2ecf20Sopenharmony_ci#define PROBERSP_PG 4 /* ->5 */ 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci#define TOTAL_RESERVED_PKT_LEN 768 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_cistatic u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = { 2778c2ecf20Sopenharmony_ci /* page 0 beacon */ 2788c2ecf20Sopenharmony_ci 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 2798c2ecf20Sopenharmony_ci 0xFF, 0xFF, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, 2808c2ecf20Sopenharmony_ci 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x50, 0x08, 2818c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2828c2ecf20Sopenharmony_ci 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, 2838c2ecf20Sopenharmony_ci 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, 2848c2ecf20Sopenharmony_ci 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, 2858c2ecf20Sopenharmony_ci 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, 2868c2ecf20Sopenharmony_ci 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, 2878c2ecf20Sopenharmony_ci 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, 2888c2ecf20Sopenharmony_ci 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2898c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2908c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2918c2ecf20Sopenharmony_ci 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, 2928c2ecf20Sopenharmony_ci 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2938c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci /* page 1 beacon */ 2968c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2978c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2988c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2998c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3008c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3018c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3028c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3038c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3048c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3058c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3068c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3078c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3088c2ecf20Sopenharmony_ci 0x10, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x10, 0x00, 3098c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3108c2ecf20Sopenharmony_ci 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3118c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci /* page 2 ps-poll */ 3148c2ecf20Sopenharmony_ci 0xA4, 0x10, 0x01, 0xC0, 0x00, 0x40, 0x10, 0x10, 3158c2ecf20Sopenharmony_ci 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, 3168c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3178c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3188c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3198c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3208c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3218c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3228c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3238c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3248c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3258c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3268c2ecf20Sopenharmony_ci 0x18, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00, 3278c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 3288c2ecf20Sopenharmony_ci 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3298c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci /* page 3 null */ 3328c2ecf20Sopenharmony_ci 0x48, 0x01, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, 3338c2ecf20Sopenharmony_ci 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, 3348c2ecf20Sopenharmony_ci 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 3358c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3368c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3378c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3388c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3398c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3408c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3418c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3428c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3438c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3448c2ecf20Sopenharmony_ci 0x72, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00, 3458c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 3468c2ecf20Sopenharmony_ci 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3478c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci /* page 4 probe_resp */ 3508c2ecf20Sopenharmony_ci 0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, 3518c2ecf20Sopenharmony_ci 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, 3528c2ecf20Sopenharmony_ci 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 3538c2ecf20Sopenharmony_ci 0x9E, 0x46, 0x15, 0x32, 0x27, 0xF2, 0x2D, 0x00, 3548c2ecf20Sopenharmony_ci 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, 3558c2ecf20Sopenharmony_ci 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, 3568c2ecf20Sopenharmony_ci 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, 3578c2ecf20Sopenharmony_ci 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, 3588c2ecf20Sopenharmony_ci 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, 3598c2ecf20Sopenharmony_ci 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, 3608c2ecf20Sopenharmony_ci 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3618c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3628c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3638c2ecf20Sopenharmony_ci 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, 3648c2ecf20Sopenharmony_ci 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3658c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci /* page 5 probe_resp */ 3688c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3698c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3708c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3718c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3728c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3738c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3748c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3758c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3768c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3778c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3788c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3798c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3808c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3818c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3828c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3838c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3848c2ecf20Sopenharmony_ci}; 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_civoid rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) 3878c2ecf20Sopenharmony_ci{ 3888c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 3898c2ecf20Sopenharmony_ci struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 3908c2ecf20Sopenharmony_ci struct sk_buff *skb = NULL; 3918c2ecf20Sopenharmony_ci u32 totalpacketlen; 3928c2ecf20Sopenharmony_ci bool rtstatus; 3938c2ecf20Sopenharmony_ci u8 u1rsvdpageloc[3] = { 0 }; 3948c2ecf20Sopenharmony_ci bool b_dlok = false; 3958c2ecf20Sopenharmony_ci u8 *beacon; 3968c2ecf20Sopenharmony_ci u8 *p_pspoll; 3978c2ecf20Sopenharmony_ci u8 *nullfunc; 3988c2ecf20Sopenharmony_ci u8 *p_probersp; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci /*--------------------------------------------------------- 4018c2ecf20Sopenharmony_ci * (1) beacon 4028c2ecf20Sopenharmony_ci *--------------------------------------------------------- 4038c2ecf20Sopenharmony_ci */ 4048c2ecf20Sopenharmony_ci beacon = &reserved_page_packet[BEACON_PG * 128]; 4058c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr); 4068c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(beacon, mac->bssid); 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci /*------------------------------------------------------- 4098c2ecf20Sopenharmony_ci * (2) ps-poll 4108c2ecf20Sopenharmony_ci *-------------------------------------------------------- 4118c2ecf20Sopenharmony_ci */ 4128c2ecf20Sopenharmony_ci p_pspoll = &reserved_page_packet[PSPOLL_PG * 128]; 4138c2ecf20Sopenharmony_ci SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000)); 4148c2ecf20Sopenharmony_ci SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid); 4158c2ecf20Sopenharmony_ci SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr); 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG); 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci /*-------------------------------------------------------- 4208c2ecf20Sopenharmony_ci * (3) null data 4218c2ecf20Sopenharmony_ci *--------------------------------------------------------- 4228c2ecf20Sopenharmony_ci */ 4238c2ecf20Sopenharmony_ci nullfunc = &reserved_page_packet[NULL_PG * 128]; 4248c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid); 4258c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr); 4268c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid); 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1rsvdpageloc, NULL_PG); 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci /*--------------------------------------------------------- 4318c2ecf20Sopenharmony_ci * (4) probe response 4328c2ecf20Sopenharmony_ci *---------------------------------------------------------- 4338c2ecf20Sopenharmony_ci */ 4348c2ecf20Sopenharmony_ci p_probersp = &reserved_page_packet[PROBERSP_PG * 128]; 4358c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid); 4368c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr); 4378c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid); 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1rsvdpageloc, PROBERSP_PG); 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci totalpacketlen = TOTAL_RESERVED_PKT_LEN; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, 4448c2ecf20Sopenharmony_ci "rtl8723e_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 4458c2ecf20Sopenharmony_ci &reserved_page_packet[0], totalpacketlen); 4468c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 4478c2ecf20Sopenharmony_ci "rtl8723e_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 4488c2ecf20Sopenharmony_ci u1rsvdpageloc, 3); 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci skb = dev_alloc_skb(totalpacketlen); 4518c2ecf20Sopenharmony_ci if (!skb) 4528c2ecf20Sopenharmony_ci return; 4538c2ecf20Sopenharmony_ci skb_put_data(skb, &reserved_page_packet, totalpacketlen); 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci rtstatus = rtl_cmd_send_packet(hw, skb); 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci if (rtstatus) 4588c2ecf20Sopenharmony_ci b_dlok = true; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci if (b_dlok) { 4618c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_POWER, DBG_LOUD, 4628c2ecf20Sopenharmony_ci "Set RSVD page location to Fw.\n"); 4638c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 4648c2ecf20Sopenharmony_ci "H2C_RSVDPAGE:\n", 4658c2ecf20Sopenharmony_ci u1rsvdpageloc, 3); 4668c2ecf20Sopenharmony_ci rtl8723e_fill_h2c_cmd(hw, H2C_RSVDPAGE, 4678c2ecf20Sopenharmony_ci sizeof(u1rsvdpageloc), u1rsvdpageloc); 4688c2ecf20Sopenharmony_ci } else 4698c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_ERR, DBG_WARNING, 4708c2ecf20Sopenharmony_ci "Set RSVD page location to Fw FAIL!!!!!!.\n"); 4718c2ecf20Sopenharmony_ci} 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_civoid rtl8723e_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus) 4748c2ecf20Sopenharmony_ci{ 4758c2ecf20Sopenharmony_ci u8 u1_joinbssrpt_parm[1] = { 0 }; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(u1_joinbssrpt_parm, mstatus); 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci rtl8723e_fill_h2c_cmd(hw, H2C_JOINBSSRPT, 1, u1_joinbssrpt_parm); 4808c2ecf20Sopenharmony_ci} 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_cistatic void rtl8723e_set_p2p_ctw_period_cmd(struct ieee80211_hw *hw, 4838c2ecf20Sopenharmony_ci u8 ctwindow) 4848c2ecf20Sopenharmony_ci{ 4858c2ecf20Sopenharmony_ci u8 u1_ctwindow_period[1] = { ctwindow}; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci rtl8723e_fill_h2c_cmd(hw, H2C_P2P_PS_CTW_CMD, 1, u1_ctwindow_period); 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci} 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_civoid rtl8723e_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state) 4928c2ecf20Sopenharmony_ci{ 4938c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 4948c2ecf20Sopenharmony_ci struct rtl_ps_ctl *rtlps = rtl_psc(rtl_priv(hw)); 4958c2ecf20Sopenharmony_ci struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 4968c2ecf20Sopenharmony_ci struct rtl_p2p_ps_info *p2pinfo = &(rtlps->p2p_ps_info); 4978c2ecf20Sopenharmony_ci struct p2p_ps_offload_t *p2p_ps_offload = &rtlhal->p2p_ps_offload; 4988c2ecf20Sopenharmony_ci u8 i; 4998c2ecf20Sopenharmony_ci u16 ctwindow; 5008c2ecf20Sopenharmony_ci u32 start_time, tsf_low; 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci switch (p2p_ps_state) { 5038c2ecf20Sopenharmony_ci case P2P_PS_DISABLE: 5048c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_DISABLE\n"); 5058c2ecf20Sopenharmony_ci memset(p2p_ps_offload, 0, sizeof(*p2p_ps_offload)); 5068c2ecf20Sopenharmony_ci break; 5078c2ecf20Sopenharmony_ci case P2P_PS_ENABLE: 5088c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_ENABLE\n"); 5098c2ecf20Sopenharmony_ci /* update CTWindow value. */ 5108c2ecf20Sopenharmony_ci if (p2pinfo->ctwindow > 0) { 5118c2ecf20Sopenharmony_ci p2p_ps_offload->ctwindow_en = 1; 5128c2ecf20Sopenharmony_ci ctwindow = p2pinfo->ctwindow; 5138c2ecf20Sopenharmony_ci rtl8723e_set_p2p_ctw_period_cmd(hw, ctwindow); 5148c2ecf20Sopenharmony_ci } 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci /* hw only support 2 set of NoA */ 5178c2ecf20Sopenharmony_ci for (i = 0 ; i < p2pinfo->noa_num ; i++) { 5188c2ecf20Sopenharmony_ci /* To control the register setting for which NOA*/ 5198c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, 0x5cf, (i << 4)); 5208c2ecf20Sopenharmony_ci if (i == 0) 5218c2ecf20Sopenharmony_ci p2p_ps_offload->noa0_en = 1; 5228c2ecf20Sopenharmony_ci else 5238c2ecf20Sopenharmony_ci p2p_ps_offload->noa1_en = 1; 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci /* config P2P NoA Descriptor Register */ 5268c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5E0, 5278c2ecf20Sopenharmony_ci p2pinfo->noa_duration[i]); 5288c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5E4, 5298c2ecf20Sopenharmony_ci p2pinfo->noa_interval[i]); 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci /*Get Current TSF value */ 5328c2ecf20Sopenharmony_ci tsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci start_time = p2pinfo->noa_start_time[i]; 5358c2ecf20Sopenharmony_ci if (p2pinfo->noa_count_type[i] != 1) { 5368c2ecf20Sopenharmony_ci while (start_time <= 5378c2ecf20Sopenharmony_ci (tsf_low+(50*1024))) { 5388c2ecf20Sopenharmony_ci start_time += 5398c2ecf20Sopenharmony_ci p2pinfo->noa_interval[i]; 5408c2ecf20Sopenharmony_ci if (p2pinfo->noa_count_type[i] != 255) 5418c2ecf20Sopenharmony_ci p2pinfo->noa_count_type[i]--; 5428c2ecf20Sopenharmony_ci } 5438c2ecf20Sopenharmony_ci } 5448c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5E8, start_time); 5458c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5EC, 5468c2ecf20Sopenharmony_ci p2pinfo->noa_count_type[i]); 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci } 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci if ((p2pinfo->opp_ps == 1) || (p2pinfo->noa_num > 0)) { 5518c2ecf20Sopenharmony_ci /* rst p2p circuit */ 5528c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, BIT(4)); 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci p2p_ps_offload->offload_en = 1; 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci if (P2P_ROLE_GO == rtlpriv->mac80211.p2p) { 5578c2ecf20Sopenharmony_ci p2p_ps_offload->role = 1; 5588c2ecf20Sopenharmony_ci p2p_ps_offload->allstasleep = 0; 5598c2ecf20Sopenharmony_ci } else { 5608c2ecf20Sopenharmony_ci p2p_ps_offload->role = 0; 5618c2ecf20Sopenharmony_ci } 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci p2p_ps_offload->discovery = 0; 5648c2ecf20Sopenharmony_ci } 5658c2ecf20Sopenharmony_ci break; 5668c2ecf20Sopenharmony_ci case P2P_PS_SCAN: 5678c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN\n"); 5688c2ecf20Sopenharmony_ci p2p_ps_offload->discovery = 1; 5698c2ecf20Sopenharmony_ci break; 5708c2ecf20Sopenharmony_ci case P2P_PS_SCAN_DONE: 5718c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN_DONE\n"); 5728c2ecf20Sopenharmony_ci p2p_ps_offload->discovery = 0; 5738c2ecf20Sopenharmony_ci p2pinfo->p2p_ps_state = P2P_PS_ENABLE; 5748c2ecf20Sopenharmony_ci break; 5758c2ecf20Sopenharmony_ci default: 5768c2ecf20Sopenharmony_ci break; 5778c2ecf20Sopenharmony_ci } 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci rtl8723e_fill_h2c_cmd(hw, H2C_P2P_PS_OFFLOAD, 1, (u8 *)p2p_ps_offload); 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci} 582