0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <drv_types.h>
0024 #include <rtw_debug.h>
0025 #include <HalPwrSeqCmd.h>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 u8 HalPwrSeqCmdParsing(
0038 struct adapter *padapter,
0039 u8 CutVersion,
0040 u8 FabVersion,
0041 u8 InterfaceType,
0042 struct wlan_pwr_cfg PwrSeqCmd[]
0043 )
0044 {
0045 struct wlan_pwr_cfg PwrCfgCmd;
0046 u8 bPollingBit = false;
0047 u32 AryIdx = 0;
0048 u8 value = 0;
0049 u32 offset = 0;
0050 u32 pollingCount = 0;
0051 u32 maxPollingCnt = 5000;
0052
0053 do {
0054 PwrCfgCmd = PwrSeqCmd[AryIdx];
0055
0056
0057 if (
0058 (GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) &&
0059 (GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) &&
0060 (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)
0061 ) {
0062 switch (GET_PWR_CFG_CMD(PwrCfgCmd)) {
0063 case PWR_CMD_READ:
0064 break;
0065
0066 case PWR_CMD_WRITE:
0067 offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
0068
0069
0070
0071
0072
0073 if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) {
0074
0075 value = SdioLocalCmd52Read1Byte(padapter, offset);
0076
0077 value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd));
0078 value |= (
0079 GET_PWR_CFG_VALUE(PwrCfgCmd) &
0080 GET_PWR_CFG_MASK(PwrCfgCmd)
0081 );
0082
0083
0084 SdioLocalCmd52Write1Byte(padapter, offset, value);
0085 } else {
0086
0087 value = rtw_read8(padapter, offset);
0088
0089 value &= (~(GET_PWR_CFG_MASK(PwrCfgCmd)));
0090 value |= (
0091 GET_PWR_CFG_VALUE(PwrCfgCmd)
0092 &GET_PWR_CFG_MASK(PwrCfgCmd)
0093 );
0094
0095
0096 rtw_write8(padapter, offset, value);
0097 }
0098 break;
0099
0100 case PWR_CMD_POLLING:
0101
0102 bPollingBit = false;
0103 offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
0104 do {
0105 if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
0106 value = SdioLocalCmd52Read1Byte(padapter, offset);
0107 else
0108 value = rtw_read8(padapter, offset);
0109
0110 value = value&GET_PWR_CFG_MASK(PwrCfgCmd);
0111 if (
0112 value == (GET_PWR_CFG_VALUE(PwrCfgCmd) &
0113 GET_PWR_CFG_MASK(PwrCfgCmd))
0114 )
0115 bPollingBit = true;
0116 else
0117 udelay(10);
0118
0119 if (pollingCount++ > maxPollingCnt)
0120 return false;
0121
0122 } while (!bPollingBit);
0123
0124 break;
0125
0126 case PWR_CMD_DELAY:
0127 if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US)
0128 udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd));
0129 else
0130 udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd)*1000);
0131 break;
0132
0133 case PWR_CMD_END:
0134
0135 return true;
0136
0137 default:
0138 break;
0139 }
0140 }
0141
0142 AryIdx++;
0143 } while (1);
0144
0145 return true;
0146 }