HalPwrSeqCmd.c (1627B)
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright(c) 2007 - 2011 Realtek Corporation. */ 3 4#include "../include/HalPwrSeqCmd.h" 5 6u8 HalPwrSeqCmdParsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcmd[]) 7{ 8 struct wl_pwr_cfg pwrcfgcmd = {0}; 9 u8 poll_bit = false; 10 u32 aryidx = 0; 11 u8 value = 0; 12 u32 offset = 0; 13 u32 poll_count = 0; /* polling autoload done. */ 14 u32 max_poll_count = 5000; 15 16 do { 17 pwrcfgcmd = pwrseqcmd[aryidx]; 18 19 switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { 20 case PWR_CMD_WRITE: 21 offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); 22 23 /* Read the value from system register */ 24 value = rtw_read8(padapter, offset); 25 26 value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); 27 value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); 28 29 /* Write the value back to system register */ 30 rtw_write8(padapter, offset, value); 31 break; 32 case PWR_CMD_POLLING: 33 poll_bit = false; 34 offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); 35 do { 36 value = rtw_read8(padapter, offset); 37 38 value &= GET_PWR_CFG_MASK(pwrcfgcmd); 39 if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) 40 poll_bit = true; 41 else 42 udelay(10); 43 44 if (poll_count++ > max_poll_count) 45 return false; 46 } while (!poll_bit); 47 break; 48 case PWR_CMD_DELAY: 49 if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) 50 udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); 51 else 52 udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); 53 break; 54 case PWR_CMD_END: 55 /* When this command is parsed, end the process */ 56 return true; 57 break; 58 default: 59 break; 60 } 61 62 aryidx++;/* Add Array Index */ 63 } while (1); 64 return true; 65}