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 ******************************************************************************/
16 Copyright (c) Realtek Semiconductor Corp. All rights reserved.
22 Implement HW Power sequence configuration CMD handling routine for
27 ---------- --------------- -------------------------------
28 2011-10-26 Lucas Modify to be compatible with SD4-CE driver.
29 2011-07-07 Roger Create.
32 #include <HalPwrSeqCmd.h>
33 #include <usb_ops_linux.h>
37 /* This routine deal with the Power Configuration CMDs parsing
38 for RTL8723/RTL8188E Series IC. */
41 /* We should follow specific format which was released from
44 /* 2011.07.07, added by Roger. */
46 u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
47 u8 FabVersion, u8 InterfaceType,
48 struct wlan_pwr_cfg PwrSeqCmd[])
50 struct wlan_pwr_cfg PwrCfgCmd;
55 u32 pollingCount = 0; /* polling autoload done. */
56 u32 maxPollingCnt = 5000;
59 PwrCfgCmd = PwrSeqCmd[AryIdx];
61 RT_TRACE(_module_hal_init_c_, _drv_info_,
62 "HalPwrSeqCmdParsing23a: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n",
63 GET_PWR_CFG_OFFSET(PwrCfgCmd),
64 GET_PWR_CFG_CUT_MASK(PwrCfgCmd),
65 GET_PWR_CFG_FAB_MASK(PwrCfgCmd),
66 GET_PWR_CFG_INTF_MASK(PwrCfgCmd),
67 GET_PWR_CFG_BASE(PwrCfgCmd),
68 GET_PWR_CFG_CMD(PwrCfgCmd),
69 GET_PWR_CFG_MASK(PwrCfgCmd),
70 GET_PWR_CFG_VALUE(PwrCfgCmd));
72 /* 2 Only Handle the command whose FAB, CUT, and Interface are
74 if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) &&
75 (GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) &&
76 (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) {
77 switch (GET_PWR_CFG_CMD(PwrCfgCmd)) {
79 RT_TRACE(_module_hal_init_c_, _drv_info_,
80 "HalPwrSeqCmdParsing23a: PWR_CMD_READ\n");
84 RT_TRACE(_module_hal_init_c_, _drv_info_,
85 "HalPwrSeqCmdParsing23a: PWR_CMD_WRITE\n");
86 offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
88 /* Read the value from system register */
89 value = rtl8723au_read8(padapter, offset);
91 value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd));
92 value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) &
93 GET_PWR_CFG_MASK(PwrCfgCmd));
95 /* Write the value back to sytem register */
96 rtl8723au_write8(padapter, offset, value);
100 RT_TRACE(_module_hal_init_c_, _drv_info_,
101 "HalPwrSeqCmdParsing23a: PWR_CMD_POLLING\n");
104 offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
106 value = rtl8723au_read8(padapter,
109 value &= GET_PWR_CFG_MASK(PwrCfgCmd);
111 (GET_PWR_CFG_VALUE(PwrCfgCmd) &
112 GET_PWR_CFG_MASK(PwrCfgCmd)))
117 if (pollingCount++ > maxPollingCnt) {
118 DBG_8723A("Fail to polling "
123 } while (!bPollingBit);
128 RT_TRACE(_module_hal_init_c_, _drv_info_,
129 "HalPwrSeqCmdParsing23a: PWR_CMD_DELAY\n");
130 if (GET_PWR_CFG_VALUE(PwrCfgCmd) ==
132 udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd));
134 udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd) *
139 /* When this command is parsed, end
141 RT_TRACE(_module_hal_init_c_, _drv_info_,
142 "HalPwrSeqCmdParsing23a: PWR_CMD_END\n");
146 RT_TRACE(_module_hal_init_c_, _drv_err_,
147 "HalPwrSeqCmdParsing23a: Unknown CMD!!\n");
152 AryIdx++; /* Add Array Index */