1
/******************************************************************************
3
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms of version 2 of the GNU General Public License as
7
* published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
* You should have received a copy of the GNU General Public License along with
15
* this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19
******************************************************************************/
21
Copyright (c) Realtek Semiconductor Corp. All rights reserved.
27
Implement HW Power sequence configuration CMD handling routine for Realtek devices.
31
---------- --------------- -------------------------------
32
2011-10-26 Lucas Modify to be compatible with SD4-CE driver.
33
2011-07-07 Roger Create.
36
#include <HalPwrSeqCmd.h>
41
* This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC.
44
* We should follow specific format which was released from HW SD.
46
* 2011.07.07, added by Roger.
48
u8 HalPwrSeqCmdParsing(
53
WLAN_PWR_CFG PwrSeqCmd[])
55
WLAN_PWR_CFG PwrCfgCmd = {0};
56
u8 bPollingBit = _FALSE;
60
u32 pollingCount = 0; /* polling autoload done. */
61
u32 maxPollingCnt = 5000;
64
PwrCfgCmd = PwrSeqCmd[AryIdx];
67
/* 2 Only Handle the command whose FAB, CUT, and Interface are matched */
68
if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) &&
69
(GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) &&
70
(GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) {
71
switch (GET_PWR_CFG_CMD(PwrCfgCmd)) {
76
offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
78
#ifdef CONFIG_SDIO_HCI
80
/* <Roger_Notes> We should deal with interface specific address mapping for some interfaces, e.g., SDIO interface */
83
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) {
84
/* Read Back SDIO Local value */
85
value = SdioLocalCmd52Read1Byte(padapter, offset);
87
value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd));
88
value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd));
90
/* Write Back SDIO Local value */
91
SdioLocalCmd52Write1Byte(padapter, offset, value);
95
#ifdef CONFIG_GSPI_HCI
96
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
97
offset = SPI_LOCAL_OFFSET | offset;
99
/* Read the value from system register */
100
value = rtw_read8(padapter, offset);
102
value = value & (~(GET_PWR_CFG_MASK(PwrCfgCmd)));
103
value = value | (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd));
105
/* Write the value back to sytem register */
106
rtw_write8(padapter, offset, value);
110
case PWR_CMD_POLLING:
112
bPollingBit = _FALSE;
113
offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
114
#ifdef CONFIG_GSPI_HCI
115
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
116
offset = SPI_LOCAL_OFFSET | offset;
119
#ifdef CONFIG_SDIO_HCI
120
if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO)
121
value = SdioLocalCmd52Read1Byte(padapter, offset);
124
value = rtw_read8(padapter, offset);
126
value = value & GET_PWR_CFG_MASK(PwrCfgCmd);
127
if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)))
132
if (pollingCount++ > maxPollingCnt) {
133
RTW_ERR("HalPwrSeqCmdParsing: Fail to polling Offset[%#x]=%02x\n", offset, value);
136
} while (!bPollingBit);
141
if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US)
142
rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd));
144
rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd) * 1000);
148
/* When this command is parsed, end the process */
157
AryIdx++;/* Add Array Index */