653-0015-rtl8xxxu-Implement-rtl8188eu_init_phy_bb.patch 9.6 KB

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