ath9k: don't run periodic and nf calibration at the same time
[lede.git] / package / kernel / mac80211 / patches / 653-0015-rtl8xxxu-Implement-rtl8188eu_init_phy_bb.patch
1 From b6770f88fd208978bd84e7217fee9fedd9b3fa9f Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Tue, 19 Jul 2016 16:19:30 -0400
4 Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_init_phy_bb()
5
6 This includes adding rtl8188eu_phy_init_table rtl8188e_agc_table, both
7 extracted from the vendor driver.
8
9 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
10 ---
11  .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 202 +++++++++++++++++++++
12  1 file changed, 202 insertions(+)
13
14 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
15 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
16 @@ -67,6 +67,174 @@ static struct rtl8xxxu_reg8val rtl8188e_
17         {0xffff, 0xff},
18  };
19  
20 +static struct rtl8xxxu_reg32val rtl8188eu_phy_init_table[] = {
21 +       {0x800, 0x80040000}, {0x804, 0x00000003},
22 +       {0x808, 0x0000fc00}, {0x80c, 0x0000000a},
23 +       {0x810, 0x10001331}, {0x814, 0x020c3d10},
24 +       {0x818, 0x02200385}, {0x81c, 0x00000000},
25 +       {0x820, 0x01000100}, {0x824, 0x00390204},
26 +       {0x828, 0x00000000}, {0x82c, 0x00000000},
27 +       {0x830, 0x00000000}, {0x834, 0x00000000},
28 +       {0x838, 0x00000000}, {0x83c, 0x00000000},
29 +       {0x840, 0x00010000}, {0x844, 0x00000000},
30 +       {0x848, 0x00000000}, {0x84c, 0x00000000},
31 +       {0x850, 0x00000000}, {0x854, 0x00000000},
32 +       {0x858, 0x569a11a9}, {0x85c, 0x01000014},
33 +       {0x860, 0x66f60110}, {0x864, 0x061f0649},
34 +       {0x868, 0x00000000}, {0x86c, 0x27272700},
35 +       {0x870, 0x07000760}, {0x874, 0x25004000},
36 +       {0x878, 0x00000808}, {0x87c, 0x00000000},
37 +       {0x880, 0xb0000c1c}, {0x884, 0x00000001},
38 +       {0x888, 0x00000000}, {0x88c, 0xccc000c0},
39 +       {0x890, 0x00000800}, {0x894, 0xfffffffe},
40 +       {0x898, 0x40302010}, {0x89c, 0x00706050},
41 +       {0x900, 0x00000000}, {0x904, 0x00000023},
42 +       {0x908, 0x00000000}, {0x90c, 0x81121111},
43 +       {0x910, 0x00000002}, {0x914, 0x00000201},
44 +       {0xa00, 0x00d047c8}, {0xa04, 0x80ff000c},
45 +       {0xa08, 0x8c838300}, {0xa0c, 0x2e7f120f},
46 +       {0xa10, 0x9500bb78}, {0xa14, 0x1114d028},
47 +       {0xa18, 0x00881117}, {0xa1c, 0x89140f00},
48 +       {0xa20, 0x1a1b0000}, {0xa24, 0x090e1317},
49 +       {0xa28, 0x00000204}, {0xa2c, 0x00d30000},
50 +       {0xa70, 0x101fbf00}, {0xa74, 0x00000007},
51 +       {0xa78, 0x00000900}, {0xa7c, 0x225b0606},
52 +       {0xa80, 0x218075b1}, {0xb2c, 0x80000000},
53 +       {0xc00, 0x48071d40}, {0xc04, 0x03a05611},
54 +       {0xc08, 0x000000e4}, {0xc0c, 0x6c6c6c6c},
55 +       {0xc10, 0x08800000}, {0xc14, 0x40000100},
56 +       {0xc18, 0x08800000}, {0xc1c, 0x40000100},
57 +       {0xc20, 0x00000000}, {0xc24, 0x00000000},
58 +       {0xc28, 0x00000000}, {0xc2c, 0x00000000},
59 +       {0xc30, 0x69e9ac47}, {0xc34, 0x469652af},
60 +       {0xc38, 0x49795994}, {0xc3c, 0x0a97971c},
61 +       {0xc40, 0x1f7c403f}, {0xc44, 0x000100b7},
62 +       {0xc48, 0xec020107}, {0xc4c, 0x007f037f},
63 +       {0xc50, 0x69553420}, {0xc54, 0x43bc0094},
64 +       {0xc58, 0x00013169}, {0xc5c, 0x00250492},
65 +       {0xc60, 0x00000000}, {0xc64, 0x7112848b},
66 +       {0xc68, 0x47c00bff}, {0xc6c, 0x00000036},
67 +       {0xc70, 0x2c7f000d}, {0xc74, 0x020610db},
68 +       {0xc78, 0x0000001f}, {0xc7c, 0x00b91612},
69 +       {0xc80, 0x390000e4}, {0xc84, 0x20f60000},
70 +       {0xc88, 0x40000100}, {0xc8c, 0x20200000},
71 +       {0xc90, 0x00091521}, {0xc94, 0x00000000},
72 +       {0xc98, 0x00121820}, {0xc9c, 0x00007f7f},
73 +       {0xca0, 0x00000000}, {0xca4, 0x000300a0},
74 +       {0xca8, 0x00000000}, {0xcac, 0x00000000},
75 +       {0xcb0, 0x00000000}, {0xcb4, 0x00000000},
76 +       {0xcb8, 0x00000000}, {0xcbc, 0x28000000},
77 +       {0xcc0, 0x00000000}, {0xcc4, 0x00000000},
78 +       {0xcc8, 0x00000000}, {0xccc, 0x00000000},
79 +       {0xcd0, 0x00000000}, {0xcd4, 0x00000000},
80 +       {0xcd8, 0x64b22427}, {0xcdc, 0x00766932},
81 +       {0xce0, 0x00222222}, {0xce4, 0x00000000},
82 +       {0xce8, 0x37644302}, {0xcec, 0x2f97d40c},
83 +       {0xd00, 0x00000740}, {0xd04, 0x00020401},
84 +       {0xd08, 0x0000907f}, {0xd0c, 0x20010201},
85 +       {0xd10, 0xa0633333}, {0xd14, 0x3333bc43},
86 +       {0xd18, 0x7a8f5b6f}, {0xd2c, 0xcc979975},
87 +       {0xd30, 0x00000000}, {0xd34, 0x80608000},
88 +       {0xd38, 0x00000000}, {0xd3c, 0x00127353},
89 +       {0xd40, 0x00000000}, {0xd44, 0x00000000},
90 +       {0xd48, 0x00000000}, {0xd4c, 0x00000000},
91 +       {0xd50, 0x6437140a}, {0xd54, 0x00000000},
92 +       {0xd58, 0x00000282}, {0xd5c, 0x30032064},
93 +       {0xd60, 0x4653de68}, {0xd64, 0x04518a3c},
94 +       {0xd68, 0x00002101}, {0xd6c, 0x2a201c16},
95 +       {0xd70, 0x1812362e}, {0xd74, 0x322c2220},
96 +       {0xd78, 0x000e3c24}, {0xe00, 0x2d2d2d2d},
97 +       {0xe04, 0x2d2d2d2d}, {0xe08, 0x0390272d},
98 +       {0xe10, 0x2d2d2d2d}, {0xe14, 0x2d2d2d2d},
99 +       {0xe18, 0x2d2d2d2d}, {0xe1c, 0x2d2d2d2d},
100 +       {0xe28, 0x00000000}, {0xe30, 0x1000dc1f},
101 +       {0xe34, 0x10008c1f}, {0xe38, 0x02140102},
102 +       {0xe3c, 0x681604c2}, {0xe40, 0x01007c00},
103 +       {0xe44, 0x01004800}, {0xe48, 0xfb000000},
104 +       {0xe4c, 0x000028d1}, {0xe50, 0x1000dc1f},
105 +       {0xe54, 0x10008c1f}, {0xe58, 0x02140102},
106 +       {0xe5c, 0x28160d05}, {0xe60, 0x00000008},
107 +       {0xe68, 0x001b25a4}, {0xe6c, 0x00c00014},
108 +       {0xe70, 0x00c00014}, {0xe74, 0x01000014},
109 +       {0xe78, 0x01000014}, {0xe7c, 0x01000014},
110 +       {0xe80, 0x01000014}, {0xe84, 0x00c00014},
111 +       {0xe88, 0x01000014}, {0xe8c, 0x00c00014},
112 +       {0xed0, 0x00c00014}, {0xed4, 0x00c00014},
113 +       {0xed8, 0x00c00014}, {0xedc, 0x00000014},
114 +       {0xee0, 0x00000014}, {0xeec, 0x01c00014},
115 +       {0xf14, 0x00000003}, {0xf4c, 0x00000000},
116 +       {0xf00, 0x00000300},
117 +       {0xffff, 0xffffffff},
118 +};
119 +
120 +static struct rtl8xxxu_reg32val rtl8188e_agc_table[] = {
121 +       {0xc78, 0xfb000001}, {0xc78, 0xfb010001},
122 +       {0xc78, 0xfb020001}, {0xc78, 0xfb030001},
123 +       {0xc78, 0xfb040001}, {0xc78, 0xfb050001},
124 +       {0xc78, 0xfa060001}, {0xc78, 0xf9070001},
125 +       {0xc78, 0xf8080001}, {0xc78, 0xf7090001},
126 +       {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001},
127 +       {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001},
128 +       {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001},
129 +       {0xc78, 0xf0100001}, {0xc78, 0xef110001},
130 +       {0xc78, 0xee120001}, {0xc78, 0xed130001},
131 +       {0xc78, 0xec140001}, {0xc78, 0xeb150001},
132 +       {0xc78, 0xea160001}, {0xc78, 0xe9170001},
133 +       {0xc78, 0xe8180001}, {0xc78, 0xe7190001},
134 +       {0xc78, 0xe61a0001}, {0xc78, 0xe51b0001},
135 +       {0xc78, 0xe41c0001}, {0xc78, 0xe31d0001},
136 +       {0xc78, 0xe21e0001}, {0xc78, 0xe11f0001},
137 +       {0xc78, 0x8a200001}, {0xc78, 0x89210001},
138 +       {0xc78, 0x88220001}, {0xc78, 0x87230001},
139 +       {0xc78, 0x86240001}, {0xc78, 0x85250001},
140 +       {0xc78, 0x84260001}, {0xc78, 0x83270001},
141 +       {0xc78, 0x82280001}, {0xc78, 0x6b290001},
142 +       {0xc78, 0x6a2a0001}, {0xc78, 0x692b0001},
143 +       {0xc78, 0x682c0001}, {0xc78, 0x672d0001},
144 +       {0xc78, 0x662e0001}, {0xc78, 0x652f0001},
145 +       {0xc78, 0x64300001}, {0xc78, 0x63310001},
146 +       {0xc78, 0x62320001}, {0xc78, 0x61330001},
147 +       {0xc78, 0x46340001}, {0xc78, 0x45350001},
148 +       {0xc78, 0x44360001}, {0xc78, 0x43370001},
149 +       {0xc78, 0x42380001}, {0xc78, 0x41390001},
150 +       {0xc78, 0x403a0001}, {0xc78, 0x403b0001},
151 +       {0xc78, 0x403c0001}, {0xc78, 0x403d0001},
152 +       {0xc78, 0x403e0001}, {0xc78, 0x403f0001},
153 +       {0xc78, 0xfb400001}, {0xc78, 0xfb410001},
154 +       {0xc78, 0xfb420001}, {0xc78, 0xfb430001},
155 +       {0xc78, 0xfb440001}, {0xc78, 0xfb450001},
156 +       {0xc78, 0xfb460001}, {0xc78, 0xfb470001},
157 +       {0xc78, 0xfb480001}, {0xc78, 0xfa490001},
158 +       {0xc78, 0xf94a0001}, {0xc78, 0xf84b0001},
159 +       {0xc78, 0xf74c0001}, {0xc78, 0xf64d0001},
160 +       {0xc78, 0xf54e0001}, {0xc78, 0xf44f0001},
161 +       {0xc78, 0xf3500001}, {0xc78, 0xf2510001},
162 +       {0xc78, 0xf1520001}, {0xc78, 0xf0530001},
163 +       {0xc78, 0xef540001}, {0xc78, 0xee550001},
164 +       {0xc78, 0xed560001}, {0xc78, 0xec570001},
165 +       {0xc78, 0xeb580001}, {0xc78, 0xea590001},
166 +       {0xc78, 0xe95a0001}, {0xc78, 0xe85b0001},
167 +       {0xc78, 0xe75c0001}, {0xc78, 0xe65d0001},
168 +       {0xc78, 0xe55e0001}, {0xc78, 0xe45f0001},
169 +       {0xc78, 0xe3600001}, {0xc78, 0xe2610001},
170 +       {0xc78, 0xc3620001}, {0xc78, 0xc2630001},
171 +       {0xc78, 0xc1640001}, {0xc78, 0x8b650001},
172 +       {0xc78, 0x8a660001}, {0xc78, 0x89670001},
173 +       {0xc78, 0x88680001}, {0xc78, 0x87690001},
174 +       {0xc78, 0x866a0001}, {0xc78, 0x856b0001},
175 +       {0xc78, 0x846c0001}, {0xc78, 0x676d0001},
176 +       {0xc78, 0x666e0001}, {0xc78, 0x656f0001},
177 +       {0xc78, 0x64700001}, {0xc78, 0x63710001},
178 +       {0xc78, 0x62720001}, {0xc78, 0x61730001},
179 +       {0xc78, 0x60740001}, {0xc78, 0x46750001},
180 +       {0xc78, 0x45760001}, {0xc78, 0x44770001},
181 +       {0xc78, 0x43780001}, {0xc78, 0x42790001},
182 +       {0xc78, 0x417a0001}, {0xc78, 0x407b0001},
183 +       {0xc78, 0x407c0001}, {0xc78, 0x407d0001},
184 +       {0xc78, 0x407e0001}, {0xc78, 0x407f0001},
185 +       {0xffff, 0xffffffff}
186 +};
187 +
188  static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv)
189  {
190         struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu;
191 @@ -89,6 +257,8 @@ static int rtl8188eu_parse_efuse(struct
192                priv->efuse_wifi.efuse8188eu.ht40_1s_tx_power_index_B,
193                sizeof(priv->ht40_1s_tx_power_index_B));
194  
195 +       priv->xtalk = priv->efuse_wifi.efuse8188eu.xtal_k & 0x3f;
196 +
197         dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name);
198         dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name);
199         dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial);
200 @@ -119,6 +289,37 @@ static int rtl8188eu_load_firmware(struc
201         return ret;
202  }
203  
204 +static void rtl8188eu_init_phy_bb(struct rtl8xxxu_priv *priv)
205 +{
206 +       u8 val8;
207 +       u16 val16;
208 +       u32 val32;
209 +
210 +       val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC);
211 +       val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF;
212 +       rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
213 +
214 +       /*
215 +        * Per vendor driver, run power sequence before init of RF
216 +        */
217 +       val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB;
218 +       rtl8xxxu_write8(priv, REG_RF_CTRL, val8);
219 +
220 +       val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC);
221 +       val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD |
222 +                 SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB);
223 +       rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
224 +
225 +       rtl8xxxu_init_phy_regs(priv, rtl8188eu_phy_init_table);
226 +       rtl8xxxu_init_phy_regs(priv, rtl8188e_agc_table);
227 +
228 +       val32 = rtl8xxxu_read32(priv, REG_AFE_XTAL_CTRL);
229 +       val8 = priv->xtalk;
230 +       val32 &= 0xff8007ff;
231 +       val32 |= ((val8 | (val8 << 6)) << 11);
232 +       rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, val32);
233 +}
234 +
235  static void rtl8188e_disabled_to_emu(struct rtl8xxxu_priv *priv)
236  {
237         u16 val16;
238 @@ -252,6 +453,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops =
239         .power_on = rtl8188eu_power_on,
240         .power_off = rtl8xxxu_power_off,
241         .reset_8051 = rtl8xxxu_reset_8051,
242 +       .init_phy_bb = rtl8188eu_init_phy_bb,
243         .usb_quirks = rtl8188e_usb_quirks,
244         .writeN_block_size = 128,
245         /*