xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8822cs/hal/efuse/rtl8822c/HalEfuseMask8822C_USB.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2 *
3  * Copyright(c) 2015 - 2017 Realtek Corporation.
4 *
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.
8 *
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
12 * more details.
13 *
14  *****************************************************************************/
15 #include <drv_types.h>
16 
17 #include "HalEfuseMask8822C_USB.h"
18 
19 /******************************************************************************
20 *                           MUSB.TXT
21 ******************************************************************************/
22 
23 u8 Array_MP_8822C_MUSB_BT[] = {
24 		0x00,
25 		0x41,
26 		0x00,
27 		0x70,
28 		0x00,
29 		0x00,
30 		0x00,
31 		0x00,
32 		0x00,
33 		0x00,
34 		0x00,
35 		0x00,
36 		0x00,
37 		0x02,
38 		0x00,
39 		0x00,
40 		0x00,
41 		0x00,
42 		0x00,
43 		0x00,
44 		0x00,
45 		0x00,
46 		0x00,
47 		0x00,
48 		0x00,
49 		0x00,
50 		0x00,
51 		0x00,
52 		0x08,
53 		0x00,
54 		0x00,
55 		0x00,
56 		0x00,
57 		0x00,
58 		0x00,
59 		0x00,
60 		0x00,
61 		0x00,
62 		0x00,
63 		0xCF,
64 		0xFF,
65 		0x00,
66 		0x00,
67 		0x00,
68 		0x00,
69 		0x00,
70 		0x00,
71 		0x00,
72 		0x00,
73 		0x00,
74 		0x00,
75 		0x00,
76 		0x00,
77 		0x00,
78 		0x00,
79 		0x00,
80 		0x00,
81 		0x00,
82 		0x00,
83 		0x00,
84 		0x00,
85 		0x00,
86 		0x00,
87 		0x00,
88 };
89 
90 u8 Array_MP_8822C_MUSB[] = {
91 	0xFF,
92 	0xF7,
93 	0xEF,
94 	0xDE,
95 	0xFC,
96 	0xFB,
97 	0x10,
98 	0x00,
99 	0x00,
100 	0x00,
101 	0x00,
102 	0x03,
103 	0xF7,
104 	0xD7,
105 	0x00,
106 	0x00,
107 	0x71,
108 	0xF1,
109 	0x00,
110 	0x00,
111 	0x00,
112 	0xFF,
113 	0xFF,
114 	0xFF,
115 	0xFF,
116 	0xD0,
117 	0x00,
118 	0x00,
119 	0x00,
120 	0x00,
121 	0x00,
122 	0x00,
123 	0x00,
124 	0x00,
125 	0x00,
126 	0x00,
127 	0x00,
128 	0x00,
129 	0x00,
130 	0x00,
131 	0x00,
132 	0x00,
133 	0x00,
134 	0x00,
135 	0x00,
136 	0x00,
137 	0x00,
138 	0x00,
139 };
140 
141 /* BT eFuse Mask */
142 
EFUSE_GetBTArrayLen_MP_8822C_MUSB(void)143 u16 EFUSE_GetBTArrayLen_MP_8822C_MUSB(void)
144 {
145 	return sizeof(Array_MP_8822C_MUSB_BT) / sizeof(u8);
146 }
147 
EFUSE_GetBTMaskArray_MP_8822C_MUSB(u8 * Array)148 void EFUSE_GetBTMaskArray_MP_8822C_MUSB(u8 *Array)
149 {
150 	u16 len = EFUSE_GetBTArrayLen_MP_8822C_MUSB(), i = 0;
151 
152 	for (i = 0; i < len; ++i)
153 		Array[i] = Array_MP_8822C_MUSB_BT[i];
154 }
155 
EFUSE_IsBTAddressMasked_MP_8822C_MUSB(u16 Offset)156 BOOLEAN EFUSE_IsBTAddressMasked_MP_8822C_MUSB(u16 Offset)
157 {
158 	int r = Offset / 16;
159 	int c = (Offset % 16) / 2;
160 	int result = 0;
161 
162 	if (c < 4) /*Upper double word*/
163 		result = (Array_MP_8822C_MUSB_BT[r] & (0x10 << c));
164 	else
165 		result = (Array_MP_8822C_MUSB_BT[r] & (0x01 << (c - 4)));
166 
167 	return (result > 0) ? 0 : 1;
168 }
169 
170 
171 /* WiFi eFuse Mask */
EFUSE_GetArrayLen_MP_8822C_MUSB(void)172 u16 EFUSE_GetArrayLen_MP_8822C_MUSB(void)
173 {
174 	return sizeof(Array_MP_8822C_MUSB) / sizeof(u8);
175 }
176 
EFUSE_GetMaskArray_MP_8822C_MUSB(u8 * Array)177 void EFUSE_GetMaskArray_MP_8822C_MUSB(u8 *Array)
178 {
179 	u16 len = EFUSE_GetArrayLen_MP_8822C_MUSB(), i = 0;
180 
181 	for (i = 0; i < len; ++i)
182 		Array[i] = Array_MP_8822C_MUSB[i];
183 }
184 
EFUSE_IsAddressMasked_MP_8822C_MUSB(u16 Offset)185 BOOLEAN EFUSE_IsAddressMasked_MP_8822C_MUSB(u16 Offset)
186 {
187 	int r = Offset / 16;
188 	int c = (Offset % 16) / 2;
189 	int result = 0;
190 
191 	if (c < 4) /*Upper double word*/
192 		result = (Array_MP_8822C_MUSB[r] & (0x10 << c));
193 	else
194 		result = (Array_MP_8822C_MUSB[r] & (0x01 << (c - 4)));
195 
196 	return (result > 0) ? 0 : 1;
197 }
198