1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3 
4 #include "../include/drv_types.h"
5 
odm_ConfigRFReg_8188E(struct odm_dm_struct * pDM_Odm,u32 Addr,u32 Data,u32 RegAddr)6 static void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr,
7 				  u32 Data, u32 RegAddr)
8 {
9 	if (Addr == 0xffe) {
10 		msleep(50);
11 	} else if (Addr == 0xfd) {
12 		mdelay(5);
13 	} else if (Addr == 0xfc) {
14 		mdelay(1);
15 	} else if (Addr == 0xfb) {
16 		udelay(50);
17 	} else if (Addr == 0xfa) {
18 		udelay(5);
19 	} else if (Addr == 0xf9) {
20 		udelay(1);
21 	} else {
22 		rtl8188e_PHY_SetRFReg(pDM_Odm->Adapter, RegAddr, bRFRegOffsetMask, Data);
23 		/*  Add 1us delay between BB/RF register setting. */
24 		udelay(1);
25 	}
26 }
27 
odm_ConfigRF_RadioA_8188E(struct odm_dm_struct * pDM_Odm,u32 Addr,u32 Data)28 void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data)
29 {
30 	u32  content = 0x1000; /*  RF_Content: radioa_txt */
31 	u32 maskforPhySet = (u32)(content & 0xE000);
32 
33 	odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, Addr | maskforPhySet);
34 }
35 
odm_ConfigMAC_8188E(struct odm_dm_struct * pDM_Odm,u32 Addr,u8 Data)36 void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data)
37 {
38 	rtw_write8(pDM_Odm->Adapter, Addr, Data);
39 }
40 
odm_ConfigBB_AGC_8188E(struct odm_dm_struct * pDM_Odm,u32 Addr,u32 Bitmask,u32 Data)41 void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data)
42 {
43 	rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data);
44 	/*  Add 1us delay between BB/RF register setting. */
45 	udelay(1);
46 }
47 
odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct * pDM_Odm,u32 Addr,u32 Bitmask,u32 Data)48 void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr,
49 				   u32 Bitmask, u32 Data)
50 {
51 	if (Addr == 0xfe)
52 		msleep(50);
53 	else if (Addr == 0xfd)
54 		mdelay(5);
55 	else if (Addr == 0xfc)
56 		mdelay(1);
57 	else if (Addr == 0xfb)
58 		udelay(50);
59 	else if (Addr == 0xfa)
60 		udelay(5);
61 	else if (Addr == 0xf9)
62 		udelay(1);
63 	else
64 		storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data);
65 }
66 
odm_ConfigBB_PHY_8188E(struct odm_dm_struct * pDM_Odm,u32 Addr,u32 Bitmask,u32 Data)67 void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data)
68 {
69 	if (Addr == 0xfe) {
70 		msleep(50);
71 	} else if (Addr == 0xfd) {
72 		mdelay(5);
73 	} else if (Addr == 0xfc) {
74 		mdelay(1);
75 	} else if (Addr == 0xfb) {
76 		udelay(50);
77 	} else if (Addr == 0xfa) {
78 		udelay(5);
79 	} else if (Addr == 0xf9) {
80 		udelay(1);
81 	} else {
82 		if (Addr == 0xa24)
83 			pDM_Odm->RFCalibrateInfo.RegA24 = Data;
84 		rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data);
85 
86 		/*  Add 1us delay between BB/RF register setting. */
87 		udelay(1);
88 	}
89 }
90