18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * RTL8XXXU mac80211 USB driver - 8192e specific subdriver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2014 - 2017 Jes Sorensen <Jes.Sorensen@gmail.com> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Portions, notably calibration code: 88c2ecf20Sopenharmony_ci * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * This driver was written as a replacement for the vendor provided 118c2ecf20Sopenharmony_ci * rtl8723au driver. As the Realtek 8xxx chips are very similar in 128c2ecf20Sopenharmony_ci * their programming interface, I have started adding support for 138c2ecf20Sopenharmony_ci * additional 8xxx chips like the 8192cu, 8188cus, etc. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/init.h> 178c2ecf20Sopenharmony_ci#include <linux/kernel.h> 188c2ecf20Sopenharmony_ci#include <linux/sched.h> 198c2ecf20Sopenharmony_ci#include <linux/errno.h> 208c2ecf20Sopenharmony_ci#include <linux/slab.h> 218c2ecf20Sopenharmony_ci#include <linux/module.h> 228c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 238c2ecf20Sopenharmony_ci#include <linux/list.h> 248c2ecf20Sopenharmony_ci#include <linux/usb.h> 258c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 268c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 278c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 288c2ecf20Sopenharmony_ci#include <linux/wireless.h> 298c2ecf20Sopenharmony_ci#include <linux/firmware.h> 308c2ecf20Sopenharmony_ci#include <linux/moduleparam.h> 318c2ecf20Sopenharmony_ci#include <net/mac80211.h> 328c2ecf20Sopenharmony_ci#include "rtl8xxxu.h" 338c2ecf20Sopenharmony_ci#include "rtl8xxxu_regs.h" 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = { 368c2ecf20Sopenharmony_ci {0x011, 0xeb}, {0x012, 0x07}, {0x014, 0x75}, {0x303, 0xa7}, 378c2ecf20Sopenharmony_ci {0x428, 0x0a}, {0x429, 0x10}, {0x430, 0x00}, {0x431, 0x00}, 388c2ecf20Sopenharmony_ci {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 398c2ecf20Sopenharmony_ci {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05}, 408c2ecf20Sopenharmony_ci {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01}, 418c2ecf20Sopenharmony_ci {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00}, 428c2ecf20Sopenharmony_ci {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f}, 438c2ecf20Sopenharmony_ci {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00}, 448c2ecf20Sopenharmony_ci {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f}, 458c2ecf20Sopenharmony_ci {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66}, 468c2ecf20Sopenharmony_ci {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, {0x4cd, 0xff}, 478c2ecf20Sopenharmony_ci {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, {0x502, 0x2f}, 488c2ecf20Sopenharmony_ci {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, {0x506, 0x5e}, 498c2ecf20Sopenharmony_ci {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, {0x50a, 0x5e}, 508c2ecf20Sopenharmony_ci {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, {0x50e, 0x00}, 518c2ecf20Sopenharmony_ci {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, {0x516, 0x0a}, 528c2ecf20Sopenharmony_ci {0x525, 0x4f}, {0x540, 0x12}, {0x541, 0x64}, {0x550, 0x10}, 538c2ecf20Sopenharmony_ci {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, {0x55d, 0xff}, 548c2ecf20Sopenharmony_ci {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, {0x620, 0xff}, 558c2ecf20Sopenharmony_ci {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, {0x624, 0xff}, 568c2ecf20Sopenharmony_ci {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, {0x638, 0x50}, 578c2ecf20Sopenharmony_ci {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, {0x63f, 0x0e}, 588c2ecf20Sopenharmony_ci {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, {0x652, 0xc8}, 598c2ecf20Sopenharmony_ci {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, {0x702, 0x65}, 608c2ecf20Sopenharmony_ci {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, {0x70a, 0x65}, 618c2ecf20Sopenharmony_ci {0x70b, 0x87}, 628c2ecf20Sopenharmony_ci {0xffff, 0xff}, 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = { 668c2ecf20Sopenharmony_ci {0x800, 0x80040000}, {0x804, 0x00000003}, 678c2ecf20Sopenharmony_ci {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, 688c2ecf20Sopenharmony_ci {0x810, 0x10001331}, {0x814, 0x020c3d10}, 698c2ecf20Sopenharmony_ci {0x818, 0x02220385}, {0x81c, 0x00000000}, 708c2ecf20Sopenharmony_ci {0x820, 0x01000100}, {0x824, 0x00390204}, 718c2ecf20Sopenharmony_ci {0x828, 0x01000100}, {0x82c, 0x00390204}, 728c2ecf20Sopenharmony_ci {0x830, 0x32323232}, {0x834, 0x30303030}, 738c2ecf20Sopenharmony_ci {0x838, 0x30303030}, {0x83c, 0x30303030}, 748c2ecf20Sopenharmony_ci {0x840, 0x00010000}, {0x844, 0x00010000}, 758c2ecf20Sopenharmony_ci {0x848, 0x28282828}, {0x84c, 0x28282828}, 768c2ecf20Sopenharmony_ci {0x850, 0x00000000}, {0x854, 0x00000000}, 778c2ecf20Sopenharmony_ci {0x858, 0x009a009a}, {0x85c, 0x01000014}, 788c2ecf20Sopenharmony_ci {0x860, 0x66f60000}, {0x864, 0x061f0000}, 798c2ecf20Sopenharmony_ci {0x868, 0x30303030}, {0x86c, 0x30303030}, 808c2ecf20Sopenharmony_ci {0x870, 0x00000000}, {0x874, 0x55004200}, 818c2ecf20Sopenharmony_ci {0x878, 0x08080808}, {0x87c, 0x00000000}, 828c2ecf20Sopenharmony_ci {0x880, 0xb0000c1c}, {0x884, 0x00000001}, 838c2ecf20Sopenharmony_ci {0x888, 0x00000000}, {0x88c, 0xcc0000c0}, 848c2ecf20Sopenharmony_ci {0x890, 0x00000800}, {0x894, 0xfffffffe}, 858c2ecf20Sopenharmony_ci {0x898, 0x40302010}, {0x900, 0x00000000}, 868c2ecf20Sopenharmony_ci {0x904, 0x00000023}, {0x908, 0x00000000}, 878c2ecf20Sopenharmony_ci {0x90c, 0x81121313}, {0x910, 0x806c0001}, 888c2ecf20Sopenharmony_ci {0x914, 0x00000001}, {0x918, 0x00000000}, 898c2ecf20Sopenharmony_ci {0x91c, 0x00010000}, {0x924, 0x00000001}, 908c2ecf20Sopenharmony_ci {0x928, 0x00000000}, {0x92c, 0x00000000}, 918c2ecf20Sopenharmony_ci {0x930, 0x00000000}, {0x934, 0x00000000}, 928c2ecf20Sopenharmony_ci {0x938, 0x00000000}, {0x93c, 0x00000000}, 938c2ecf20Sopenharmony_ci {0x940, 0x00000000}, {0x944, 0x00000000}, 948c2ecf20Sopenharmony_ci {0x94c, 0x00000008}, {0xa00, 0x00d0c7c8}, 958c2ecf20Sopenharmony_ci {0xa04, 0x81ff000c}, {0xa08, 0x8c838300}, 968c2ecf20Sopenharmony_ci {0xa0c, 0x2e68120f}, {0xa10, 0x95009b78}, 978c2ecf20Sopenharmony_ci {0xa14, 0x1114d028}, {0xa18, 0x00881117}, 988c2ecf20Sopenharmony_ci {0xa1c, 0x89140f00}, {0xa20, 0x1a1b0000}, 998c2ecf20Sopenharmony_ci {0xa24, 0x090e1317}, {0xa28, 0x00000204}, 1008c2ecf20Sopenharmony_ci {0xa2c, 0x00d30000}, {0xa70, 0x101fff00}, 1018c2ecf20Sopenharmony_ci {0xa74, 0x00000007}, {0xa78, 0x00000900}, 1028c2ecf20Sopenharmony_ci {0xa7c, 0x225b0606}, {0xa80, 0x218075b1}, 1038c2ecf20Sopenharmony_ci {0xb38, 0x00000000}, {0xc00, 0x48071d40}, 1048c2ecf20Sopenharmony_ci {0xc04, 0x03a05633}, {0xc08, 0x000000e4}, 1058c2ecf20Sopenharmony_ci {0xc0c, 0x6c6c6c6c}, {0xc10, 0x08800000}, 1068c2ecf20Sopenharmony_ci {0xc14, 0x40000100}, {0xc18, 0x08800000}, 1078c2ecf20Sopenharmony_ci {0xc1c, 0x40000100}, {0xc20, 0x00000000}, 1088c2ecf20Sopenharmony_ci {0xc24, 0x00000000}, {0xc28, 0x00000000}, 1098c2ecf20Sopenharmony_ci {0xc2c, 0x00000000}, {0xc30, 0x69e9ac47}, 1108c2ecf20Sopenharmony_ci {0xc34, 0x469652af}, {0xc38, 0x49795994}, 1118c2ecf20Sopenharmony_ci {0xc3c, 0x0a97971c}, {0xc40, 0x1f7c403f}, 1128c2ecf20Sopenharmony_ci {0xc44, 0x000100b7}, {0xc48, 0xec020107}, 1138c2ecf20Sopenharmony_ci {0xc4c, 0x007f037f}, 1148c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 1158c2ecf20Sopenharmony_ci /* External PA or external LNA */ 1168c2ecf20Sopenharmony_ci {0xc50, 0x00340220}, 1178c2ecf20Sopenharmony_ci#else 1188c2ecf20Sopenharmony_ci {0xc50, 0x00340020}, 1198c2ecf20Sopenharmony_ci#endif 1208c2ecf20Sopenharmony_ci {0xc54, 0x0080801f}, 1218c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 1228c2ecf20Sopenharmony_ci /* External PA or external LNA */ 1238c2ecf20Sopenharmony_ci {0xc58, 0x00000220}, 1248c2ecf20Sopenharmony_ci#else 1258c2ecf20Sopenharmony_ci {0xc58, 0x00000020}, 1268c2ecf20Sopenharmony_ci#endif 1278c2ecf20Sopenharmony_ci {0xc5c, 0x00248492}, {0xc60, 0x00000000}, 1288c2ecf20Sopenharmony_ci {0xc64, 0x7112848b}, {0xc68, 0x47c00bff}, 1298c2ecf20Sopenharmony_ci {0xc6c, 0x00000036}, {0xc70, 0x00000600}, 1308c2ecf20Sopenharmony_ci {0xc74, 0x02013169}, {0xc78, 0x0000001f}, 1318c2ecf20Sopenharmony_ci {0xc7c, 0x00b91612}, 1328c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 1338c2ecf20Sopenharmony_ci /* External PA or external LNA */ 1348c2ecf20Sopenharmony_ci {0xc80, 0x2d4000b5}, 1358c2ecf20Sopenharmony_ci#else 1368c2ecf20Sopenharmony_ci {0xc80, 0x40000100}, 1378c2ecf20Sopenharmony_ci#endif 1388c2ecf20Sopenharmony_ci {0xc84, 0x21f60000}, 1398c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 1408c2ecf20Sopenharmony_ci /* External PA or external LNA */ 1418c2ecf20Sopenharmony_ci {0xc88, 0x2d4000b5}, 1428c2ecf20Sopenharmony_ci#else 1438c2ecf20Sopenharmony_ci {0xc88, 0x40000100}, 1448c2ecf20Sopenharmony_ci#endif 1458c2ecf20Sopenharmony_ci {0xc8c, 0xa0e40000}, {0xc90, 0x00121820}, 1468c2ecf20Sopenharmony_ci {0xc94, 0x00000000}, {0xc98, 0x00121820}, 1478c2ecf20Sopenharmony_ci {0xc9c, 0x00007f7f}, {0xca0, 0x00000000}, 1488c2ecf20Sopenharmony_ci {0xca4, 0x000300a0}, {0xca8, 0x00000000}, 1498c2ecf20Sopenharmony_ci {0xcac, 0x00000000}, {0xcb0, 0x00000000}, 1508c2ecf20Sopenharmony_ci {0xcb4, 0x00000000}, {0xcb8, 0x00000000}, 1518c2ecf20Sopenharmony_ci {0xcbc, 0x28000000}, {0xcc0, 0x00000000}, 1528c2ecf20Sopenharmony_ci {0xcc4, 0x00000000}, {0xcc8, 0x00000000}, 1538c2ecf20Sopenharmony_ci {0xccc, 0x00000000}, {0xcd0, 0x00000000}, 1548c2ecf20Sopenharmony_ci {0xcd4, 0x00000000}, {0xcd8, 0x64b22427}, 1558c2ecf20Sopenharmony_ci {0xcdc, 0x00766932}, {0xce0, 0x00222222}, 1568c2ecf20Sopenharmony_ci {0xce4, 0x00040000}, {0xce8, 0x77644302}, 1578c2ecf20Sopenharmony_ci {0xcec, 0x2f97d40c}, {0xd00, 0x00080740}, 1588c2ecf20Sopenharmony_ci {0xd04, 0x00020403}, {0xd08, 0x0000907f}, 1598c2ecf20Sopenharmony_ci {0xd0c, 0x20010201}, {0xd10, 0xa0633333}, 1608c2ecf20Sopenharmony_ci {0xd14, 0x3333bc43}, {0xd18, 0x7a8f5b6b}, 1618c2ecf20Sopenharmony_ci {0xd1c, 0x0000007f}, {0xd2c, 0xcc979975}, 1628c2ecf20Sopenharmony_ci {0xd30, 0x00000000}, {0xd34, 0x80608000}, 1638c2ecf20Sopenharmony_ci {0xd38, 0x00000000}, {0xd3c, 0x00127353}, 1648c2ecf20Sopenharmony_ci {0xd40, 0x00000000}, {0xd44, 0x00000000}, 1658c2ecf20Sopenharmony_ci {0xd48, 0x00000000}, {0xd4c, 0x00000000}, 1668c2ecf20Sopenharmony_ci {0xd50, 0x6437140a}, {0xd54, 0x00000000}, 1678c2ecf20Sopenharmony_ci {0xd58, 0x00000282}, {0xd5c, 0x30032064}, 1688c2ecf20Sopenharmony_ci {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, 1698c2ecf20Sopenharmony_ci {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, 1708c2ecf20Sopenharmony_ci {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, 1718c2ecf20Sopenharmony_ci {0xd78, 0x000e3c24}, {0xd80, 0x01081008}, 1728c2ecf20Sopenharmony_ci {0xd84, 0x00000800}, {0xd88, 0xf0b50000}, 1738c2ecf20Sopenharmony_ci {0xe00, 0x30303030}, {0xe04, 0x30303030}, 1748c2ecf20Sopenharmony_ci {0xe08, 0x03903030}, {0xe10, 0x30303030}, 1758c2ecf20Sopenharmony_ci {0xe14, 0x30303030}, {0xe18, 0x30303030}, 1768c2ecf20Sopenharmony_ci {0xe1c, 0x30303030}, {0xe28, 0x00000000}, 1778c2ecf20Sopenharmony_ci {0xe30, 0x1000dc1f}, {0xe34, 0x10008c1f}, 1788c2ecf20Sopenharmony_ci {0xe38, 0x02140102}, {0xe3c, 0x681604c2}, 1798c2ecf20Sopenharmony_ci {0xe40, 0x01007c00}, {0xe44, 0x01004800}, 1808c2ecf20Sopenharmony_ci {0xe48, 0xfb000000}, {0xe4c, 0x000028d1}, 1818c2ecf20Sopenharmony_ci {0xe50, 0x1000dc1f}, {0xe54, 0x10008c1f}, 1828c2ecf20Sopenharmony_ci {0xe58, 0x02140102}, {0xe5c, 0x28160d05}, 1838c2ecf20Sopenharmony_ci {0xe60, 0x00000008}, {0xe68, 0x0fc05656}, 1848c2ecf20Sopenharmony_ci {0xe6c, 0x03c09696}, {0xe70, 0x03c09696}, 1858c2ecf20Sopenharmony_ci {0xe74, 0x0c005656}, {0xe78, 0x0c005656}, 1868c2ecf20Sopenharmony_ci {0xe7c, 0x0c005656}, {0xe80, 0x0c005656}, 1878c2ecf20Sopenharmony_ci {0xe84, 0x03c09696}, {0xe88, 0x0c005656}, 1888c2ecf20Sopenharmony_ci {0xe8c, 0x03c09696}, {0xed0, 0x03c09696}, 1898c2ecf20Sopenharmony_ci {0xed4, 0x03c09696}, {0xed8, 0x03c09696}, 1908c2ecf20Sopenharmony_ci {0xedc, 0x0000d6d6}, {0xee0, 0x0000d6d6}, 1918c2ecf20Sopenharmony_ci {0xeec, 0x0fc01616}, {0xee4, 0xb0000c1c}, 1928c2ecf20Sopenharmony_ci {0xee8, 0x00000001}, {0xf14, 0x00000003}, 1938c2ecf20Sopenharmony_ci {0xf4c, 0x00000000}, {0xf00, 0x00000300}, 1948c2ecf20Sopenharmony_ci {0xffff, 0xffffffff}, 1958c2ecf20Sopenharmony_ci}; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_cistatic struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = { 1988c2ecf20Sopenharmony_ci {0xc78, 0xfb000001}, {0xc78, 0xfb010001}, 1998c2ecf20Sopenharmony_ci {0xc78, 0xfb020001}, {0xc78, 0xfb030001}, 2008c2ecf20Sopenharmony_ci {0xc78, 0xfb040001}, {0xc78, 0xfb050001}, 2018c2ecf20Sopenharmony_ci {0xc78, 0xfa060001}, {0xc78, 0xf9070001}, 2028c2ecf20Sopenharmony_ci {0xc78, 0xf8080001}, {0xc78, 0xf7090001}, 2038c2ecf20Sopenharmony_ci {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001}, 2048c2ecf20Sopenharmony_ci {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001}, 2058c2ecf20Sopenharmony_ci {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001}, 2068c2ecf20Sopenharmony_ci {0xc78, 0xf0100001}, {0xc78, 0xef110001}, 2078c2ecf20Sopenharmony_ci {0xc78, 0xee120001}, {0xc78, 0xed130001}, 2088c2ecf20Sopenharmony_ci {0xc78, 0xec140001}, {0xc78, 0xeb150001}, 2098c2ecf20Sopenharmony_ci {0xc78, 0xea160001}, {0xc78, 0xe9170001}, 2108c2ecf20Sopenharmony_ci {0xc78, 0xe8180001}, {0xc78, 0xe7190001}, 2118c2ecf20Sopenharmony_ci {0xc78, 0xc81a0001}, {0xc78, 0xc71b0001}, 2128c2ecf20Sopenharmony_ci {0xc78, 0xc61c0001}, {0xc78, 0x071d0001}, 2138c2ecf20Sopenharmony_ci {0xc78, 0x061e0001}, {0xc78, 0x051f0001}, 2148c2ecf20Sopenharmony_ci {0xc78, 0x04200001}, {0xc78, 0x03210001}, 2158c2ecf20Sopenharmony_ci {0xc78, 0xaa220001}, {0xc78, 0xa9230001}, 2168c2ecf20Sopenharmony_ci {0xc78, 0xa8240001}, {0xc78, 0xa7250001}, 2178c2ecf20Sopenharmony_ci {0xc78, 0xa6260001}, {0xc78, 0x85270001}, 2188c2ecf20Sopenharmony_ci {0xc78, 0x84280001}, {0xc78, 0x83290001}, 2198c2ecf20Sopenharmony_ci {0xc78, 0x252a0001}, {0xc78, 0x242b0001}, 2208c2ecf20Sopenharmony_ci {0xc78, 0x232c0001}, {0xc78, 0x222d0001}, 2218c2ecf20Sopenharmony_ci {0xc78, 0x672e0001}, {0xc78, 0x662f0001}, 2228c2ecf20Sopenharmony_ci {0xc78, 0x65300001}, {0xc78, 0x64310001}, 2238c2ecf20Sopenharmony_ci {0xc78, 0x63320001}, {0xc78, 0x62330001}, 2248c2ecf20Sopenharmony_ci {0xc78, 0x61340001}, {0xc78, 0x45350001}, 2258c2ecf20Sopenharmony_ci {0xc78, 0x44360001}, {0xc78, 0x43370001}, 2268c2ecf20Sopenharmony_ci {0xc78, 0x42380001}, {0xc78, 0x41390001}, 2278c2ecf20Sopenharmony_ci {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 2288c2ecf20Sopenharmony_ci {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 2298c2ecf20Sopenharmony_ci {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 2308c2ecf20Sopenharmony_ci {0xc78, 0xfb400001}, {0xc78, 0xfb410001}, 2318c2ecf20Sopenharmony_ci {0xc78, 0xfb420001}, {0xc78, 0xfb430001}, 2328c2ecf20Sopenharmony_ci {0xc78, 0xfb440001}, {0xc78, 0xfb450001}, 2338c2ecf20Sopenharmony_ci {0xc78, 0xfa460001}, {0xc78, 0xf9470001}, 2348c2ecf20Sopenharmony_ci {0xc78, 0xf8480001}, {0xc78, 0xf7490001}, 2358c2ecf20Sopenharmony_ci {0xc78, 0xf64a0001}, {0xc78, 0xf54b0001}, 2368c2ecf20Sopenharmony_ci {0xc78, 0xf44c0001}, {0xc78, 0xf34d0001}, 2378c2ecf20Sopenharmony_ci {0xc78, 0xf24e0001}, {0xc78, 0xf14f0001}, 2388c2ecf20Sopenharmony_ci {0xc78, 0xf0500001}, {0xc78, 0xef510001}, 2398c2ecf20Sopenharmony_ci {0xc78, 0xee520001}, {0xc78, 0xed530001}, 2408c2ecf20Sopenharmony_ci {0xc78, 0xec540001}, {0xc78, 0xeb550001}, 2418c2ecf20Sopenharmony_ci {0xc78, 0xea560001}, {0xc78, 0xe9570001}, 2428c2ecf20Sopenharmony_ci {0xc78, 0xe8580001}, {0xc78, 0xe7590001}, 2438c2ecf20Sopenharmony_ci {0xc78, 0xe65a0001}, {0xc78, 0xe55b0001}, 2448c2ecf20Sopenharmony_ci {0xc78, 0xe45c0001}, {0xc78, 0xe35d0001}, 2458c2ecf20Sopenharmony_ci {0xc78, 0xe25e0001}, {0xc78, 0xe15f0001}, 2468c2ecf20Sopenharmony_ci {0xc78, 0x8a600001}, {0xc78, 0x89610001}, 2478c2ecf20Sopenharmony_ci {0xc78, 0x88620001}, {0xc78, 0x87630001}, 2488c2ecf20Sopenharmony_ci {0xc78, 0x86640001}, {0xc78, 0x85650001}, 2498c2ecf20Sopenharmony_ci {0xc78, 0x84660001}, {0xc78, 0x83670001}, 2508c2ecf20Sopenharmony_ci {0xc78, 0x82680001}, {0xc78, 0x6b690001}, 2518c2ecf20Sopenharmony_ci {0xc78, 0x6a6a0001}, {0xc78, 0x696b0001}, 2528c2ecf20Sopenharmony_ci {0xc78, 0x686c0001}, {0xc78, 0x676d0001}, 2538c2ecf20Sopenharmony_ci {0xc78, 0x666e0001}, {0xc78, 0x656f0001}, 2548c2ecf20Sopenharmony_ci {0xc78, 0x64700001}, {0xc78, 0x63710001}, 2558c2ecf20Sopenharmony_ci {0xc78, 0x62720001}, {0xc78, 0x61730001}, 2568c2ecf20Sopenharmony_ci {0xc78, 0x49740001}, {0xc78, 0x48750001}, 2578c2ecf20Sopenharmony_ci {0xc78, 0x47760001}, {0xc78, 0x46770001}, 2588c2ecf20Sopenharmony_ci {0xc78, 0x45780001}, {0xc78, 0x44790001}, 2598c2ecf20Sopenharmony_ci {0xc78, 0x437a0001}, {0xc78, 0x427b0001}, 2608c2ecf20Sopenharmony_ci {0xc78, 0x417c0001}, {0xc78, 0x407d0001}, 2618c2ecf20Sopenharmony_ci {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 2628c2ecf20Sopenharmony_ci {0xc50, 0x00040022}, {0xc50, 0x00040020}, 2638c2ecf20Sopenharmony_ci {0xffff, 0xffffffff} 2648c2ecf20Sopenharmony_ci}; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_cistatic struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = { 2678c2ecf20Sopenharmony_ci {0xc78, 0xfa000001}, {0xc78, 0xf9010001}, 2688c2ecf20Sopenharmony_ci {0xc78, 0xf8020001}, {0xc78, 0xf7030001}, 2698c2ecf20Sopenharmony_ci {0xc78, 0xf6040001}, {0xc78, 0xf5050001}, 2708c2ecf20Sopenharmony_ci {0xc78, 0xf4060001}, {0xc78, 0xf3070001}, 2718c2ecf20Sopenharmony_ci {0xc78, 0xf2080001}, {0xc78, 0xf1090001}, 2728c2ecf20Sopenharmony_ci {0xc78, 0xf00a0001}, {0xc78, 0xef0b0001}, 2738c2ecf20Sopenharmony_ci {0xc78, 0xee0c0001}, {0xc78, 0xed0d0001}, 2748c2ecf20Sopenharmony_ci {0xc78, 0xec0e0001}, {0xc78, 0xeb0f0001}, 2758c2ecf20Sopenharmony_ci {0xc78, 0xea100001}, {0xc78, 0xe9110001}, 2768c2ecf20Sopenharmony_ci {0xc78, 0xe8120001}, {0xc78, 0xe7130001}, 2778c2ecf20Sopenharmony_ci {0xc78, 0xe6140001}, {0xc78, 0xe5150001}, 2788c2ecf20Sopenharmony_ci {0xc78, 0xe4160001}, {0xc78, 0xe3170001}, 2798c2ecf20Sopenharmony_ci {0xc78, 0xe2180001}, {0xc78, 0xe1190001}, 2808c2ecf20Sopenharmony_ci {0xc78, 0x8a1a0001}, {0xc78, 0x891b0001}, 2818c2ecf20Sopenharmony_ci {0xc78, 0x881c0001}, {0xc78, 0x871d0001}, 2828c2ecf20Sopenharmony_ci {0xc78, 0x861e0001}, {0xc78, 0x851f0001}, 2838c2ecf20Sopenharmony_ci {0xc78, 0x84200001}, {0xc78, 0x83210001}, 2848c2ecf20Sopenharmony_ci {0xc78, 0x82220001}, {0xc78, 0x6a230001}, 2858c2ecf20Sopenharmony_ci {0xc78, 0x69240001}, {0xc78, 0x68250001}, 2868c2ecf20Sopenharmony_ci {0xc78, 0x67260001}, {0xc78, 0x66270001}, 2878c2ecf20Sopenharmony_ci {0xc78, 0x65280001}, {0xc78, 0x64290001}, 2888c2ecf20Sopenharmony_ci {0xc78, 0x632a0001}, {0xc78, 0x622b0001}, 2898c2ecf20Sopenharmony_ci {0xc78, 0x612c0001}, {0xc78, 0x602d0001}, 2908c2ecf20Sopenharmony_ci {0xc78, 0x472e0001}, {0xc78, 0x462f0001}, 2918c2ecf20Sopenharmony_ci {0xc78, 0x45300001}, {0xc78, 0x44310001}, 2928c2ecf20Sopenharmony_ci {0xc78, 0x43320001}, {0xc78, 0x42330001}, 2938c2ecf20Sopenharmony_ci {0xc78, 0x41340001}, {0xc78, 0x40350001}, 2948c2ecf20Sopenharmony_ci {0xc78, 0x40360001}, {0xc78, 0x40370001}, 2958c2ecf20Sopenharmony_ci {0xc78, 0x40380001}, {0xc78, 0x40390001}, 2968c2ecf20Sopenharmony_ci {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 2978c2ecf20Sopenharmony_ci {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 2988c2ecf20Sopenharmony_ci {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 2998c2ecf20Sopenharmony_ci {0xc78, 0xfa400001}, {0xc78, 0xf9410001}, 3008c2ecf20Sopenharmony_ci {0xc78, 0xf8420001}, {0xc78, 0xf7430001}, 3018c2ecf20Sopenharmony_ci {0xc78, 0xf6440001}, {0xc78, 0xf5450001}, 3028c2ecf20Sopenharmony_ci {0xc78, 0xf4460001}, {0xc78, 0xf3470001}, 3038c2ecf20Sopenharmony_ci {0xc78, 0xf2480001}, {0xc78, 0xf1490001}, 3048c2ecf20Sopenharmony_ci {0xc78, 0xf04a0001}, {0xc78, 0xef4b0001}, 3058c2ecf20Sopenharmony_ci {0xc78, 0xee4c0001}, {0xc78, 0xed4d0001}, 3068c2ecf20Sopenharmony_ci {0xc78, 0xec4e0001}, {0xc78, 0xeb4f0001}, 3078c2ecf20Sopenharmony_ci {0xc78, 0xea500001}, {0xc78, 0xe9510001}, 3088c2ecf20Sopenharmony_ci {0xc78, 0xe8520001}, {0xc78, 0xe7530001}, 3098c2ecf20Sopenharmony_ci {0xc78, 0xe6540001}, {0xc78, 0xe5550001}, 3108c2ecf20Sopenharmony_ci {0xc78, 0xe4560001}, {0xc78, 0xe3570001}, 3118c2ecf20Sopenharmony_ci {0xc78, 0xe2580001}, {0xc78, 0xe1590001}, 3128c2ecf20Sopenharmony_ci {0xc78, 0x8a5a0001}, {0xc78, 0x895b0001}, 3138c2ecf20Sopenharmony_ci {0xc78, 0x885c0001}, {0xc78, 0x875d0001}, 3148c2ecf20Sopenharmony_ci {0xc78, 0x865e0001}, {0xc78, 0x855f0001}, 3158c2ecf20Sopenharmony_ci {0xc78, 0x84600001}, {0xc78, 0x83610001}, 3168c2ecf20Sopenharmony_ci {0xc78, 0x82620001}, {0xc78, 0x6a630001}, 3178c2ecf20Sopenharmony_ci {0xc78, 0x69640001}, {0xc78, 0x68650001}, 3188c2ecf20Sopenharmony_ci {0xc78, 0x67660001}, {0xc78, 0x66670001}, 3198c2ecf20Sopenharmony_ci {0xc78, 0x65680001}, {0xc78, 0x64690001}, 3208c2ecf20Sopenharmony_ci {0xc78, 0x636a0001}, {0xc78, 0x626b0001}, 3218c2ecf20Sopenharmony_ci {0xc78, 0x616c0001}, {0xc78, 0x606d0001}, 3228c2ecf20Sopenharmony_ci {0xc78, 0x476e0001}, {0xc78, 0x466f0001}, 3238c2ecf20Sopenharmony_ci {0xc78, 0x45700001}, {0xc78, 0x44710001}, 3248c2ecf20Sopenharmony_ci {0xc78, 0x43720001}, {0xc78, 0x42730001}, 3258c2ecf20Sopenharmony_ci {0xc78, 0x41740001}, {0xc78, 0x40750001}, 3268c2ecf20Sopenharmony_ci {0xc78, 0x40760001}, {0xc78, 0x40770001}, 3278c2ecf20Sopenharmony_ci {0xc78, 0x40780001}, {0xc78, 0x40790001}, 3288c2ecf20Sopenharmony_ci {0xc78, 0x407a0001}, {0xc78, 0x407b0001}, 3298c2ecf20Sopenharmony_ci {0xc78, 0x407c0001}, {0xc78, 0x407d0001}, 3308c2ecf20Sopenharmony_ci {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 3318c2ecf20Sopenharmony_ci {0xc50, 0x00040222}, {0xc50, 0x00040220}, 3328c2ecf20Sopenharmony_ci {0xffff, 0xffffffff} 3338c2ecf20Sopenharmony_ci}; 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_cistatic struct rtl8xxxu_rfregval rtl8192eu_radioa_init_table[] = { 3368c2ecf20Sopenharmony_ci {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 3378c2ecf20Sopenharmony_ci {0x00, 0x00030000}, {0x08, 0x00008400}, 3388c2ecf20Sopenharmony_ci {0x18, 0x00000407}, {0x19, 0x00000012}, 3398c2ecf20Sopenharmony_ci {0x1b, 0x00000064}, {0x1e, 0x00080009}, 3408c2ecf20Sopenharmony_ci {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 3418c2ecf20Sopenharmony_ci {0x3f, 0x00000000}, {0x42, 0x000060c0}, 3428c2ecf20Sopenharmony_ci {0x57, 0x000d0000}, {0x58, 0x000be180}, 3438c2ecf20Sopenharmony_ci {0x67, 0x00001552}, {0x83, 0x00000000}, 3448c2ecf20Sopenharmony_ci {0xb0, 0x000ff9f1}, {0xb1, 0x00055418}, 3458c2ecf20Sopenharmony_ci {0xb2, 0x0008cc00}, {0xb4, 0x00043083}, 3468c2ecf20Sopenharmony_ci {0xb5, 0x00008166}, {0xb6, 0x0000803e}, 3478c2ecf20Sopenharmony_ci {0xb7, 0x0001c69f}, {0xb8, 0x0000407f}, 3488c2ecf20Sopenharmony_ci {0xb9, 0x00080001}, {0xba, 0x00040001}, 3498c2ecf20Sopenharmony_ci {0xbb, 0x00000400}, {0xbf, 0x000c0000}, 3508c2ecf20Sopenharmony_ci {0xc2, 0x00002400}, {0xc3, 0x00000009}, 3518c2ecf20Sopenharmony_ci {0xc4, 0x00040c91}, {0xc5, 0x00099999}, 3528c2ecf20Sopenharmony_ci {0xc6, 0x000000a3}, {0xc7, 0x00088820}, 3538c2ecf20Sopenharmony_ci {0xc8, 0x00076c06}, {0xc9, 0x00000000}, 3548c2ecf20Sopenharmony_ci {0xca, 0x00080000}, {0xdf, 0x00000180}, 3558c2ecf20Sopenharmony_ci {0xef, 0x000001a0}, {0x51, 0x00069545}, 3568c2ecf20Sopenharmony_ci {0x52, 0x0007e45e}, {0x53, 0x00000071}, 3578c2ecf20Sopenharmony_ci {0x56, 0x00051ff3}, {0x35, 0x000000a8}, 3588c2ecf20Sopenharmony_ci {0x35, 0x000001e2}, {0x35, 0x000002a8}, 3598c2ecf20Sopenharmony_ci {0x36, 0x00001c24}, {0x36, 0x00009c24}, 3608c2ecf20Sopenharmony_ci {0x36, 0x00011c24}, {0x36, 0x00019c24}, 3618c2ecf20Sopenharmony_ci {0x18, 0x00000c07}, {0x5a, 0x00048000}, 3628c2ecf20Sopenharmony_ci {0x19, 0x000739d0}, 3638c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 3648c2ecf20Sopenharmony_ci /* External PA or external LNA */ 3658c2ecf20Sopenharmony_ci {0x34, 0x0000a093}, {0x34, 0x0000908f}, 3668c2ecf20Sopenharmony_ci {0x34, 0x0000808c}, {0x34, 0x0000704d}, 3678c2ecf20Sopenharmony_ci {0x34, 0x0000604a}, {0x34, 0x00005047}, 3688c2ecf20Sopenharmony_ci {0x34, 0x0000400a}, {0x34, 0x00003007}, 3698c2ecf20Sopenharmony_ci {0x34, 0x00002004}, {0x34, 0x00001001}, 3708c2ecf20Sopenharmony_ci {0x34, 0x00000000}, 3718c2ecf20Sopenharmony_ci#else 3728c2ecf20Sopenharmony_ci /* Regular */ 3738c2ecf20Sopenharmony_ci {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 3748c2ecf20Sopenharmony_ci {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 3758c2ecf20Sopenharmony_ci {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 3768c2ecf20Sopenharmony_ci {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 3778c2ecf20Sopenharmony_ci {0x34, 0x0000244f}, {0x34, 0x0000144c}, 3788c2ecf20Sopenharmony_ci {0x34, 0x00000014}, 3798c2ecf20Sopenharmony_ci#endif 3808c2ecf20Sopenharmony_ci {0x00, 0x00030159}, 3818c2ecf20Sopenharmony_ci {0x84, 0x00068180}, 3828c2ecf20Sopenharmony_ci {0x86, 0x0000014e}, 3838c2ecf20Sopenharmony_ci {0x87, 0x00048e00}, 3848c2ecf20Sopenharmony_ci {0x8e, 0x00065540}, 3858c2ecf20Sopenharmony_ci {0x8f, 0x00088000}, 3868c2ecf20Sopenharmony_ci {0xef, 0x000020a0}, 3878c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 3888c2ecf20Sopenharmony_ci /* External PA or external LNA */ 3898c2ecf20Sopenharmony_ci {0x3b, 0x000f07b0}, 3908c2ecf20Sopenharmony_ci#else 3918c2ecf20Sopenharmony_ci {0x3b, 0x000f02b0}, 3928c2ecf20Sopenharmony_ci#endif 3938c2ecf20Sopenharmony_ci {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 3948c2ecf20Sopenharmony_ci {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 3958c2ecf20Sopenharmony_ci {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 3968c2ecf20Sopenharmony_ci {0x3b, 0x0008f780}, 3978c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 3988c2ecf20Sopenharmony_ci /* External PA or external LNA */ 3998c2ecf20Sopenharmony_ci {0x3b, 0x000787b0}, 4008c2ecf20Sopenharmony_ci#else 4018c2ecf20Sopenharmony_ci {0x3b, 0x00078730}, 4028c2ecf20Sopenharmony_ci#endif 4038c2ecf20Sopenharmony_ci {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 4048c2ecf20Sopenharmony_ci {0x3b, 0x00040620}, {0x3b, 0x00037090}, 4058c2ecf20Sopenharmony_ci {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 4068c2ecf20Sopenharmony_ci {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 4078c2ecf20Sopenharmony_ci {0xfe, 0x00000000}, {0x18, 0x0000fc07}, 4088c2ecf20Sopenharmony_ci {0xfe, 0x00000000}, {0xfe, 0x00000000}, 4098c2ecf20Sopenharmony_ci {0xfe, 0x00000000}, {0xfe, 0x00000000}, 4108c2ecf20Sopenharmony_ci {0x1e, 0x00000001}, {0x1f, 0x00080000}, 4118c2ecf20Sopenharmony_ci {0x00, 0x00033e70}, 4128c2ecf20Sopenharmony_ci {0xff, 0xffffffff} 4138c2ecf20Sopenharmony_ci}; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_cistatic struct rtl8xxxu_rfregval rtl8192eu_radiob_init_table[] = { 4168c2ecf20Sopenharmony_ci {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 4178c2ecf20Sopenharmony_ci {0x00, 0x00030000}, {0x08, 0x00008400}, 4188c2ecf20Sopenharmony_ci {0x18, 0x00000407}, {0x19, 0x00000012}, 4198c2ecf20Sopenharmony_ci {0x1b, 0x00000064}, {0x1e, 0x00080009}, 4208c2ecf20Sopenharmony_ci {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 4218c2ecf20Sopenharmony_ci {0x3f, 0x00000000}, {0x42, 0x000060c0}, 4228c2ecf20Sopenharmony_ci {0x57, 0x000d0000}, {0x58, 0x000be180}, 4238c2ecf20Sopenharmony_ci {0x67, 0x00001552}, {0x7f, 0x00000082}, 4248c2ecf20Sopenharmony_ci {0x81, 0x0003f000}, {0x83, 0x00000000}, 4258c2ecf20Sopenharmony_ci {0xdf, 0x00000180}, {0xef, 0x000001a0}, 4268c2ecf20Sopenharmony_ci {0x51, 0x00069545}, {0x52, 0x0007e42e}, 4278c2ecf20Sopenharmony_ci {0x53, 0x00000071}, {0x56, 0x00051ff3}, 4288c2ecf20Sopenharmony_ci {0x35, 0x000000a8}, {0x35, 0x000001e0}, 4298c2ecf20Sopenharmony_ci {0x35, 0x000002a8}, {0x36, 0x00001ca8}, 4308c2ecf20Sopenharmony_ci {0x36, 0x00009c24}, {0x36, 0x00011c24}, 4318c2ecf20Sopenharmony_ci {0x36, 0x00019c24}, {0x18, 0x00000c07}, 4328c2ecf20Sopenharmony_ci {0x5a, 0x00048000}, {0x19, 0x000739d0}, 4338c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 4348c2ecf20Sopenharmony_ci /* External PA or external LNA */ 4358c2ecf20Sopenharmony_ci {0x34, 0x0000a093}, {0x34, 0x0000908f}, 4368c2ecf20Sopenharmony_ci {0x34, 0x0000808c}, {0x34, 0x0000704d}, 4378c2ecf20Sopenharmony_ci {0x34, 0x0000604a}, {0x34, 0x00005047}, 4388c2ecf20Sopenharmony_ci {0x34, 0x0000400a}, {0x34, 0x00003007}, 4398c2ecf20Sopenharmony_ci {0x34, 0x00002004}, {0x34, 0x00001001}, 4408c2ecf20Sopenharmony_ci {0x34, 0x00000000}, 4418c2ecf20Sopenharmony_ci#else 4428c2ecf20Sopenharmony_ci {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 4438c2ecf20Sopenharmony_ci {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 4448c2ecf20Sopenharmony_ci {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 4458c2ecf20Sopenharmony_ci {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 4468c2ecf20Sopenharmony_ci {0x34, 0x0000244f}, {0x34, 0x0000144c}, 4478c2ecf20Sopenharmony_ci {0x34, 0x00000014}, 4488c2ecf20Sopenharmony_ci#endif 4498c2ecf20Sopenharmony_ci {0x00, 0x00030159}, {0x84, 0x00068180}, 4508c2ecf20Sopenharmony_ci {0x86, 0x000000ce}, {0x87, 0x00048a00}, 4518c2ecf20Sopenharmony_ci {0x8e, 0x00065540}, {0x8f, 0x00088000}, 4528c2ecf20Sopenharmony_ci {0xef, 0x000020a0}, 4538c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 4548c2ecf20Sopenharmony_ci /* External PA or external LNA */ 4558c2ecf20Sopenharmony_ci {0x3b, 0x000f07b0}, 4568c2ecf20Sopenharmony_ci#else 4578c2ecf20Sopenharmony_ci {0x3b, 0x000f02b0}, 4588c2ecf20Sopenharmony_ci#endif 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 4618c2ecf20Sopenharmony_ci {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 4628c2ecf20Sopenharmony_ci {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 4638c2ecf20Sopenharmony_ci {0x3b, 0x0008f780}, 4648c2ecf20Sopenharmony_ci#ifdef EXT_PA_8192EU 4658c2ecf20Sopenharmony_ci /* External PA or external LNA */ 4668c2ecf20Sopenharmony_ci {0x3b, 0x000787b0}, 4678c2ecf20Sopenharmony_ci#else 4688c2ecf20Sopenharmony_ci {0x3b, 0x00078730}, 4698c2ecf20Sopenharmony_ci#endif 4708c2ecf20Sopenharmony_ci {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 4718c2ecf20Sopenharmony_ci {0x3b, 0x00040620}, {0x3b, 0x00037090}, 4728c2ecf20Sopenharmony_ci {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 4738c2ecf20Sopenharmony_ci {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 4748c2ecf20Sopenharmony_ci {0x00, 0x00010159}, {0xfe, 0x00000000}, 4758c2ecf20Sopenharmony_ci {0xfe, 0x00000000}, {0xfe, 0x00000000}, 4768c2ecf20Sopenharmony_ci {0xfe, 0x00000000}, {0x1e, 0x00000001}, 4778c2ecf20Sopenharmony_ci {0x1f, 0x00080000}, {0x00, 0x00033e70}, 4788c2ecf20Sopenharmony_ci {0xff, 0xffffffff} 4798c2ecf20Sopenharmony_ci}; 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_cistatic void 4828c2ecf20Sopenharmony_cirtl8192e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 4838c2ecf20Sopenharmony_ci{ 4848c2ecf20Sopenharmony_ci u32 val32, ofdm, mcs; 4858c2ecf20Sopenharmony_ci u8 cck, ofdmbase, mcsbase; 4868c2ecf20Sopenharmony_ci int group, tx_idx; 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci tx_idx = 0; 4898c2ecf20Sopenharmony_ci group = rtl8xxxu_gen2_channel_to_group(channel); 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci cck = priv->cck_tx_power_index_A[group]; 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); 4948c2ecf20Sopenharmony_ci val32 &= 0xffff00ff; 4958c2ecf20Sopenharmony_ci val32 |= (cck << 8); 4968c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 4998c2ecf20Sopenharmony_ci val32 &= 0xff; 5008c2ecf20Sopenharmony_ci val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 5018c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci ofdmbase = priv->ht40_1s_tx_power_index_A[group]; 5048c2ecf20Sopenharmony_ci ofdmbase += priv->ofdm_tx_power_diff[tx_idx].a; 5058c2ecf20Sopenharmony_ci ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); 5088c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci mcsbase = priv->ht40_1s_tx_power_index_A[group]; 5118c2ecf20Sopenharmony_ci if (ht40) 5128c2ecf20Sopenharmony_ci mcsbase += priv->ht40_tx_power_diff[tx_idx++].a; 5138c2ecf20Sopenharmony_ci else 5148c2ecf20Sopenharmony_ci mcsbase += priv->ht20_tx_power_diff[tx_idx++].a; 5158c2ecf20Sopenharmony_ci mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 5188c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 5198c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs); 5208c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci if (priv->tx_paths > 1) { 5238c2ecf20Sopenharmony_ci cck = priv->cck_tx_power_index_B[group]; 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK1_55_MCS32); 5268c2ecf20Sopenharmony_ci val32 &= 0xff; 5278c2ecf20Sopenharmony_ci val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 5288c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK1_55_MCS32, val32); 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 5318c2ecf20Sopenharmony_ci val32 &= 0xffffff00; 5328c2ecf20Sopenharmony_ci val32 |= cck; 5338c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci ofdmbase = priv->ht40_1s_tx_power_index_B[group]; 5368c2ecf20Sopenharmony_ci ofdmbase += priv->ofdm_tx_power_diff[tx_idx].b; 5378c2ecf20Sopenharmony_ci ofdm = ofdmbase | ofdmbase << 8 | 5388c2ecf20Sopenharmony_ci ofdmbase << 16 | ofdmbase << 24; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE18_06, ofdm); 5418c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE54_24, ofdm); 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci mcsbase = priv->ht40_1s_tx_power_index_B[group]; 5448c2ecf20Sopenharmony_ci if (ht40) 5458c2ecf20Sopenharmony_ci mcsbase += priv->ht40_tx_power_diff[tx_idx++].b; 5468c2ecf20Sopenharmony_ci else 5478c2ecf20Sopenharmony_ci mcsbase += priv->ht20_tx_power_diff[tx_idx++].b; 5488c2ecf20Sopenharmony_ci mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS03_MCS00, mcs); 5518c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS07_MCS04, mcs); 5528c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS11_MCS08, mcs); 5538c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS15_MCS12, mcs); 5548c2ecf20Sopenharmony_ci } 5558c2ecf20Sopenharmony_ci} 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_cistatic void rtl8192eu_log_next_device_info(struct rtl8xxxu_priv *priv, 5588c2ecf20Sopenharmony_ci char *record_name, 5598c2ecf20Sopenharmony_ci char *device_info, 5608c2ecf20Sopenharmony_ci unsigned int *record_offset) 5618c2ecf20Sopenharmony_ci{ 5628c2ecf20Sopenharmony_ci char *record = device_info + *record_offset; 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci /* A record is [ total length | 0x03 | value ] */ 5658c2ecf20Sopenharmony_ci unsigned char l = record[0]; 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci /* 5688c2ecf20Sopenharmony_ci * The whole device info section seems to be 80 characters, make sure 5698c2ecf20Sopenharmony_ci * we don't read further. 5708c2ecf20Sopenharmony_ci */ 5718c2ecf20Sopenharmony_ci if (*record_offset + l > 80) { 5728c2ecf20Sopenharmony_ci dev_warn(&priv->udev->dev, 5738c2ecf20Sopenharmony_ci "invalid record length %d while parsing \"%s\" at offset %u.\n", 5748c2ecf20Sopenharmony_ci l, record_name, *record_offset); 5758c2ecf20Sopenharmony_ci return; 5768c2ecf20Sopenharmony_ci } 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ci if (l >= 2) { 5798c2ecf20Sopenharmony_ci char value[80]; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci memcpy(value, &record[2], l - 2); 5828c2ecf20Sopenharmony_ci value[l - 2] = '\0'; 5838c2ecf20Sopenharmony_ci dev_info(&priv->udev->dev, "%s: %s\n", record_name, value); 5848c2ecf20Sopenharmony_ci *record_offset = *record_offset + l; 5858c2ecf20Sopenharmony_ci } else { 5868c2ecf20Sopenharmony_ci dev_info(&priv->udev->dev, "%s not available.\n", record_name); 5878c2ecf20Sopenharmony_ci } 5888c2ecf20Sopenharmony_ci} 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_cistatic int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv) 5918c2ecf20Sopenharmony_ci{ 5928c2ecf20Sopenharmony_ci struct rtl8192eu_efuse *efuse = &priv->efuse_wifi.efuse8192eu; 5938c2ecf20Sopenharmony_ci unsigned int record_offset; 5948c2ecf20Sopenharmony_ci int i; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci if (efuse->rtl_id != cpu_to_le16(0x8129)) 5978c2ecf20Sopenharmony_ci return -EINVAL; 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci ether_addr_copy(priv->mac_addr, efuse->mac_addr); 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, 6028c2ecf20Sopenharmony_ci sizeof(efuse->tx_power_index_A.cck_base)); 6038c2ecf20Sopenharmony_ci memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base, 6048c2ecf20Sopenharmony_ci sizeof(efuse->tx_power_index_B.cck_base)); 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci memcpy(priv->ht40_1s_tx_power_index_A, 6078c2ecf20Sopenharmony_ci efuse->tx_power_index_A.ht40_base, 6088c2ecf20Sopenharmony_ci sizeof(efuse->tx_power_index_A.ht40_base)); 6098c2ecf20Sopenharmony_ci memcpy(priv->ht40_1s_tx_power_index_B, 6108c2ecf20Sopenharmony_ci efuse->tx_power_index_B.ht40_base, 6118c2ecf20Sopenharmony_ci sizeof(efuse->tx_power_index_B.ht40_base)); 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci priv->ht20_tx_power_diff[0].a = 6148c2ecf20Sopenharmony_ci efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; 6158c2ecf20Sopenharmony_ci priv->ht20_tx_power_diff[0].b = 6168c2ecf20Sopenharmony_ci efuse->tx_power_index_B.ht20_ofdm_1s_diff.b; 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci priv->ht40_tx_power_diff[0].a = 0; 6198c2ecf20Sopenharmony_ci priv->ht40_tx_power_diff[0].b = 0; 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci for (i = 1; i < RTL8723B_TX_COUNT; i++) { 6228c2ecf20Sopenharmony_ci priv->ofdm_tx_power_diff[i].a = 6238c2ecf20Sopenharmony_ci efuse->tx_power_index_A.pwr_diff[i - 1].ofdm; 6248c2ecf20Sopenharmony_ci priv->ofdm_tx_power_diff[i].b = 6258c2ecf20Sopenharmony_ci efuse->tx_power_index_B.pwr_diff[i - 1].ofdm; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci priv->ht20_tx_power_diff[i].a = 6288c2ecf20Sopenharmony_ci efuse->tx_power_index_A.pwr_diff[i - 1].ht20; 6298c2ecf20Sopenharmony_ci priv->ht20_tx_power_diff[i].b = 6308c2ecf20Sopenharmony_ci efuse->tx_power_index_B.pwr_diff[i - 1].ht20; 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci priv->ht40_tx_power_diff[i].a = 6338c2ecf20Sopenharmony_ci efuse->tx_power_index_A.pwr_diff[i - 1].ht40; 6348c2ecf20Sopenharmony_ci priv->ht40_tx_power_diff[i].b = 6358c2ecf20Sopenharmony_ci efuse->tx_power_index_B.pwr_diff[i - 1].ht40; 6368c2ecf20Sopenharmony_ci } 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci priv->has_xtalk = 1; 6398c2ecf20Sopenharmony_ci priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci /* 6428c2ecf20Sopenharmony_ci * device_info section seems to be laid out as records 6438c2ecf20Sopenharmony_ci * [ total length | 0x03 | value ] so: 6448c2ecf20Sopenharmony_ci * - vendor length + 2 6458c2ecf20Sopenharmony_ci * - 0x03 6468c2ecf20Sopenharmony_ci * - vendor string (not null terminated) 6478c2ecf20Sopenharmony_ci * - product length + 2 6488c2ecf20Sopenharmony_ci * - 0x03 6498c2ecf20Sopenharmony_ci * - product string (not null terminated) 6508c2ecf20Sopenharmony_ci * Then there is one or 2 0x00 on all the 4 devices I own or found 6518c2ecf20Sopenharmony_ci * dumped online. 6528c2ecf20Sopenharmony_ci * As previous version of the code handled an optional serial 6538c2ecf20Sopenharmony_ci * string, I now assume there may be a third record if the 6548c2ecf20Sopenharmony_ci * length is not 0. 6558c2ecf20Sopenharmony_ci */ 6568c2ecf20Sopenharmony_ci record_offset = 0; 6578c2ecf20Sopenharmony_ci rtl8192eu_log_next_device_info(priv, "Vendor", efuse->device_info, &record_offset); 6588c2ecf20Sopenharmony_ci rtl8192eu_log_next_device_info(priv, "Product", efuse->device_info, &record_offset); 6598c2ecf20Sopenharmony_ci rtl8192eu_log_next_device_info(priv, "Serial", efuse->device_info, &record_offset); 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 6628c2ecf20Sopenharmony_ci unsigned char *raw = priv->efuse_wifi.raw; 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci dev_info(&priv->udev->dev, 6658c2ecf20Sopenharmony_ci "%s: dumping efuse (0x%02zx bytes):\n", 6668c2ecf20Sopenharmony_ci __func__, sizeof(struct rtl8192eu_efuse)); 6678c2ecf20Sopenharmony_ci for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8) 6688c2ecf20Sopenharmony_ci dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]); 6698c2ecf20Sopenharmony_ci } 6708c2ecf20Sopenharmony_ci return 0; 6718c2ecf20Sopenharmony_ci} 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_cistatic int rtl8192eu_load_firmware(struct rtl8xxxu_priv *priv) 6748c2ecf20Sopenharmony_ci{ 6758c2ecf20Sopenharmony_ci char *fw_name; 6768c2ecf20Sopenharmony_ci int ret; 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci fw_name = "rtlwifi/rtl8192eu_nic.bin"; 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci ret = rtl8xxxu_load_firmware(priv, fw_name); 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci return ret; 6838c2ecf20Sopenharmony_ci} 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_cistatic void rtl8192eu_init_phy_bb(struct rtl8xxxu_priv *priv) 6868c2ecf20Sopenharmony_ci{ 6878c2ecf20Sopenharmony_ci u8 val8; 6888c2ecf20Sopenharmony_ci u16 val16; 6898c2ecf20Sopenharmony_ci 6908c2ecf20Sopenharmony_ci val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 6918c2ecf20Sopenharmony_ci val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 6928c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci /* 6. 0x1f[7:0] = 0x07 */ 6958c2ecf20Sopenharmony_ci val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 6968c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 6998c2ecf20Sopenharmony_ci val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | SYS_FUNC_DIO_RF | 7008c2ecf20Sopenharmony_ci SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB); 7018c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 7028c2ecf20Sopenharmony_ci val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 7038c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 7048c2ecf20Sopenharmony_ci rtl8xxxu_init_phy_regs(priv, rtl8192eu_phy_init_table); 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ci if (priv->hi_pa) 7078c2ecf20Sopenharmony_ci rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_highpa_table); 7088c2ecf20Sopenharmony_ci else 7098c2ecf20Sopenharmony_ci rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_std_table); 7108c2ecf20Sopenharmony_ci} 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_cistatic int rtl8192eu_init_phy_rf(struct rtl8xxxu_priv *priv) 7138c2ecf20Sopenharmony_ci{ 7148c2ecf20Sopenharmony_ci int ret; 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ci ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radioa_init_table, RF_A); 7178c2ecf20Sopenharmony_ci if (ret) 7188c2ecf20Sopenharmony_ci goto exit; 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radiob_init_table, RF_B); 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ciexit: 7238c2ecf20Sopenharmony_ci return ret; 7248c2ecf20Sopenharmony_ci} 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_cistatic int rtl8192eu_iqk_path_a(struct rtl8xxxu_priv *priv) 7278c2ecf20Sopenharmony_ci{ 7288c2ecf20Sopenharmony_ci u32 reg_eac, reg_e94, reg_e9c; 7298c2ecf20Sopenharmony_ci int result = 0; 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci /* 7328c2ecf20Sopenharmony_ci * TX IQK 7338c2ecf20Sopenharmony_ci * PA/PAD controlled by 0x0 7348c2ecf20Sopenharmony_ci */ 7358c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 7368c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00180); 7378c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_ci /* Path A IQK setting */ 7408c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 7418c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 7428c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 7438c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82140303); 7468c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160000); 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci /* LO calibration setting */ 7498c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ci /* One shot, path A LOK & IQK */ 7528c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 7538c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci mdelay(10); 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci /* Check failed */ 7588c2ecf20Sopenharmony_ci reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 7598c2ecf20Sopenharmony_ci reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 7608c2ecf20Sopenharmony_ci reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci if (!(reg_eac & BIT(28)) && 7638c2ecf20Sopenharmony_ci ((reg_e94 & 0x03ff0000) != 0x01420000) && 7648c2ecf20Sopenharmony_ci ((reg_e9c & 0x03ff0000) != 0x00420000)) 7658c2ecf20Sopenharmony_ci result |= 0x01; 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci return result; 7688c2ecf20Sopenharmony_ci} 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_cistatic int rtl8192eu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) 7718c2ecf20Sopenharmony_ci{ 7728c2ecf20Sopenharmony_ci u32 reg_ea4, reg_eac, reg_e94, reg_e9c, val32; 7738c2ecf20Sopenharmony_ci int result = 0; 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_ci /* Leave IQK mode */ 7768c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00); 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci /* Enable path A PA in TX IQK mode */ 7798c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 7808c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 7818c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 7828c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf117b); 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci /* PA/PAD control by 0x56, and set = 0x0 */ 7858c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 7868c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ci /* Enter IQK mode */ 7898c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci /* TX IQK setting */ 7928c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 7938c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci /* path-A IQK setting */ 7968c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 7978c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 7988c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 7998c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 8028c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160c1f); 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci /* LO calibration setting */ 8058c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_ci /* One shot, path A LOK & IQK */ 8088c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 8098c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_ci mdelay(10); 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci /* Check failed */ 8148c2ecf20Sopenharmony_ci reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 8158c2ecf20Sopenharmony_ci reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 8168c2ecf20Sopenharmony_ci reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_ci if (!(reg_eac & BIT(28)) && 8198c2ecf20Sopenharmony_ci ((reg_e94 & 0x03ff0000) != 0x01420000) && 8208c2ecf20Sopenharmony_ci ((reg_e9c & 0x03ff0000) != 0x00420000)) { 8218c2ecf20Sopenharmony_ci result |= 0x01; 8228c2ecf20Sopenharmony_ci } else { 8238c2ecf20Sopenharmony_ci /* PA/PAD controlled by 0x0 */ 8248c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 8258c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 8268c2ecf20Sopenharmony_ci goto out; 8278c2ecf20Sopenharmony_ci } 8288c2ecf20Sopenharmony_ci 8298c2ecf20Sopenharmony_ci val32 = 0x80007c00 | 8308c2ecf20Sopenharmony_ci (reg_e94 & 0x03ff0000) | ((reg_e9c >> 16) & 0x03ff); 8318c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK, val32); 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci /* Modify RX IQK mode table */ 8348c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 8378c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 8388c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 8398c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7ffa); 8408c2ecf20Sopenharmony_ci 8418c2ecf20Sopenharmony_ci /* PA/PAD control by 0x56, and set = 0x0 */ 8428c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 8438c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci /* Enter IQK mode */ 8468c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 8478c2ecf20Sopenharmony_ci 8488c2ecf20Sopenharmony_ci /* IQK setting */ 8498c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_ci /* Path A IQK setting */ 8528c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 8538c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); 8548c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 8558c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 8568c2ecf20Sopenharmony_ci 8578c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 8588c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 8598c2ecf20Sopenharmony_ci 8608c2ecf20Sopenharmony_ci /* LO calibration setting */ 8618c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_ci /* One shot, path A LOK & IQK */ 8648c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 8658c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 8668c2ecf20Sopenharmony_ci 8678c2ecf20Sopenharmony_ci mdelay(10); 8688c2ecf20Sopenharmony_ci 8698c2ecf20Sopenharmony_ci reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 8708c2ecf20Sopenharmony_ci reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 8738c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci if (!(reg_eac & BIT(27)) && 8768c2ecf20Sopenharmony_ci ((reg_ea4 & 0x03ff0000) != 0x01320000) && 8778c2ecf20Sopenharmony_ci ((reg_eac & 0x03ff0000) != 0x00360000)) 8788c2ecf20Sopenharmony_ci result |= 0x02; 8798c2ecf20Sopenharmony_ci else 8808c2ecf20Sopenharmony_ci dev_warn(&priv->udev->dev, "%s: Path A RX IQK failed!\n", 8818c2ecf20Sopenharmony_ci __func__); 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ciout: 8848c2ecf20Sopenharmony_ci return result; 8858c2ecf20Sopenharmony_ci} 8868c2ecf20Sopenharmony_ci 8878c2ecf20Sopenharmony_cistatic int rtl8192eu_iqk_path_b(struct rtl8xxxu_priv *priv) 8888c2ecf20Sopenharmony_ci{ 8898c2ecf20Sopenharmony_ci u32 reg_eac, reg_eb4, reg_ebc; 8908c2ecf20Sopenharmony_ci int result = 0; 8918c2ecf20Sopenharmony_ci 8928c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 8938c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00180); 8948c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 8958c2ecf20Sopenharmony_ci 8968c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 8978c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ci /* Path B IQK setting */ 9008c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 9018c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 9028c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 9038c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x821403e2); 9068c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160000); 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci /* LO calibration setting */ 9098c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00492911); 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_ci /* One shot, path A LOK & IQK */ 9128c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 9138c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_ci mdelay(1); 9168c2ecf20Sopenharmony_ci 9178c2ecf20Sopenharmony_ci /* Check failed */ 9188c2ecf20Sopenharmony_ci reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 9198c2ecf20Sopenharmony_ci reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 9208c2ecf20Sopenharmony_ci reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci if (!(reg_eac & BIT(31)) && 9238c2ecf20Sopenharmony_ci ((reg_eb4 & 0x03ff0000) != 0x01420000) && 9248c2ecf20Sopenharmony_ci ((reg_ebc & 0x03ff0000) != 0x00420000)) 9258c2ecf20Sopenharmony_ci result |= 0x01; 9268c2ecf20Sopenharmony_ci else 9278c2ecf20Sopenharmony_ci dev_warn(&priv->udev->dev, "%s: Path B IQK failed!\n", 9288c2ecf20Sopenharmony_ci __func__); 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_ci return result; 9318c2ecf20Sopenharmony_ci} 9328c2ecf20Sopenharmony_ci 9338c2ecf20Sopenharmony_cistatic int rtl8192eu_rx_iqk_path_b(struct rtl8xxxu_priv *priv) 9348c2ecf20Sopenharmony_ci{ 9358c2ecf20Sopenharmony_ci u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc, val32; 9368c2ecf20Sopenharmony_ci int result = 0; 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci /* Leave IQK mode */ 9398c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ci /* Enable path A PA in TX IQK mode */ 9428c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 9438c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 9448c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 9458c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf117b); 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_ci /* PA/PAD control by 0x56, and set = 0x0 */ 9488c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 9498c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci /* Enter IQK mode */ 9528c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 9538c2ecf20Sopenharmony_ci 9548c2ecf20Sopenharmony_ci /* TX IQK setting */ 9558c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 9568c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 9578c2ecf20Sopenharmony_ci 9588c2ecf20Sopenharmony_ci /* path-A IQK setting */ 9598c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 9608c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 9618c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 9628c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82160c1f); 9658c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160c1f); 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_ci /* LO calibration setting */ 9688c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 9698c2ecf20Sopenharmony_ci 9708c2ecf20Sopenharmony_ci /* One shot, path A LOK & IQK */ 9718c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 9728c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 9738c2ecf20Sopenharmony_ci 9748c2ecf20Sopenharmony_ci mdelay(10); 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci /* Check failed */ 9778c2ecf20Sopenharmony_ci reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 9788c2ecf20Sopenharmony_ci reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 9798c2ecf20Sopenharmony_ci reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 9808c2ecf20Sopenharmony_ci 9818c2ecf20Sopenharmony_ci if (!(reg_eac & BIT(31)) && 9828c2ecf20Sopenharmony_ci ((reg_eb4 & 0x03ff0000) != 0x01420000) && 9838c2ecf20Sopenharmony_ci ((reg_ebc & 0x03ff0000) != 0x00420000)) { 9848c2ecf20Sopenharmony_ci result |= 0x01; 9858c2ecf20Sopenharmony_ci } else { 9868c2ecf20Sopenharmony_ci /* 9878c2ecf20Sopenharmony_ci * PA/PAD controlled by 0x0 9888c2ecf20Sopenharmony_ci * Vendor driver restores RF_A here which I believe is a bug 9898c2ecf20Sopenharmony_ci */ 9908c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 9918c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 9928c2ecf20Sopenharmony_ci goto out; 9938c2ecf20Sopenharmony_ci } 9948c2ecf20Sopenharmony_ci 9958c2ecf20Sopenharmony_ci val32 = 0x80007c00 | 9968c2ecf20Sopenharmony_ci (reg_eb4 & 0x03ff0000) | ((reg_ebc >> 16) & 0x03ff); 9978c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK, val32); 9988c2ecf20Sopenharmony_ci 9998c2ecf20Sopenharmony_ci /* Modify RX IQK mode table */ 10008c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 10018c2ecf20Sopenharmony_ci 10028c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 10038c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 10048c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 10058c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf7ffa); 10068c2ecf20Sopenharmony_ci 10078c2ecf20Sopenharmony_ci /* PA/PAD control by 0x56, and set = 0x0 */ 10088c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 10098c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_ci /* Enter IQK mode */ 10128c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_ci /* IQK setting */ 10158c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 10168c2ecf20Sopenharmony_ci 10178c2ecf20Sopenharmony_ci /* Path A IQK setting */ 10188c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 10198c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 10208c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 10218c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x18008c1c); 10228c2ecf20Sopenharmony_ci 10238c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 10248c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci /* LO calibration setting */ 10278c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 10288c2ecf20Sopenharmony_ci 10298c2ecf20Sopenharmony_ci /* One shot, path A LOK & IQK */ 10308c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 10318c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci mdelay(10); 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ci reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 10368c2ecf20Sopenharmony_ci reg_ec4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); 10378c2ecf20Sopenharmony_ci reg_ecc = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); 10388c2ecf20Sopenharmony_ci 10398c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 10408c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 10418c2ecf20Sopenharmony_ci 10428c2ecf20Sopenharmony_ci if (!(reg_eac & BIT(30)) && 10438c2ecf20Sopenharmony_ci ((reg_ec4 & 0x03ff0000) != 0x01320000) && 10448c2ecf20Sopenharmony_ci ((reg_ecc & 0x03ff0000) != 0x00360000)) 10458c2ecf20Sopenharmony_ci result |= 0x02; 10468c2ecf20Sopenharmony_ci else 10478c2ecf20Sopenharmony_ci dev_warn(&priv->udev->dev, "%s: Path B RX IQK failed!\n", 10488c2ecf20Sopenharmony_ci __func__); 10498c2ecf20Sopenharmony_ci 10508c2ecf20Sopenharmony_ciout: 10518c2ecf20Sopenharmony_ci return result; 10528c2ecf20Sopenharmony_ci} 10538c2ecf20Sopenharmony_ci 10548c2ecf20Sopenharmony_cistatic void rtl8192eu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 10558c2ecf20Sopenharmony_ci int result[][8], int t) 10568c2ecf20Sopenharmony_ci{ 10578c2ecf20Sopenharmony_ci struct device *dev = &priv->udev->dev; 10588c2ecf20Sopenharmony_ci u32 i, val32; 10598c2ecf20Sopenharmony_ci int path_a_ok, path_b_ok; 10608c2ecf20Sopenharmony_ci int retry = 2; 10618c2ecf20Sopenharmony_ci static const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { 10628c2ecf20Sopenharmony_ci REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, 10638c2ecf20Sopenharmony_ci REG_RX_WAIT_CCA, REG_TX_CCK_RFON, 10648c2ecf20Sopenharmony_ci REG_TX_CCK_BBON, REG_TX_OFDM_RFON, 10658c2ecf20Sopenharmony_ci REG_TX_OFDM_BBON, REG_TX_TO_RX, 10668c2ecf20Sopenharmony_ci REG_TX_TO_TX, REG_RX_CCK, 10678c2ecf20Sopenharmony_ci REG_RX_OFDM, REG_RX_WAIT_RIFS, 10688c2ecf20Sopenharmony_ci REG_RX_TO_RX, REG_STANDBY, 10698c2ecf20Sopenharmony_ci REG_SLEEP, REG_PMPD_ANAEN 10708c2ecf20Sopenharmony_ci }; 10718c2ecf20Sopenharmony_ci static const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { 10728c2ecf20Sopenharmony_ci REG_TXPAUSE, REG_BEACON_CTRL, 10738c2ecf20Sopenharmony_ci REG_BEACON_CTRL_1, REG_GPIO_MUXCFG 10748c2ecf20Sopenharmony_ci }; 10758c2ecf20Sopenharmony_ci static const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { 10768c2ecf20Sopenharmony_ci REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, 10778c2ecf20Sopenharmony_ci REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, 10788c2ecf20Sopenharmony_ci REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, 10798c2ecf20Sopenharmony_ci REG_FPGA0_XB_RF_INT_OE, REG_CCK0_AFE_SETTING 10808c2ecf20Sopenharmony_ci }; 10818c2ecf20Sopenharmony_ci u8 xa_agc = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1) & 0xff; 10828c2ecf20Sopenharmony_ci u8 xb_agc = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1) & 0xff; 10838c2ecf20Sopenharmony_ci 10848c2ecf20Sopenharmony_ci /* 10858c2ecf20Sopenharmony_ci * Note: IQ calibration must be performed after loading 10868c2ecf20Sopenharmony_ci * PHY_REG.txt , and radio_a, radio_b.txt 10878c2ecf20Sopenharmony_ci */ 10888c2ecf20Sopenharmony_ci 10898c2ecf20Sopenharmony_ci if (t == 0) { 10908c2ecf20Sopenharmony_ci /* Save ADDA parameters, turn Path A ADDA on */ 10918c2ecf20Sopenharmony_ci rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, 10928c2ecf20Sopenharmony_ci RTL8XXXU_ADDA_REGS); 10938c2ecf20Sopenharmony_ci rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 10948c2ecf20Sopenharmony_ci rtl8xxxu_save_regs(priv, iqk_bb_regs, 10958c2ecf20Sopenharmony_ci priv->bb_backup, RTL8XXXU_BB_REGS); 10968c2ecf20Sopenharmony_ci } 10978c2ecf20Sopenharmony_ci 10988c2ecf20Sopenharmony_ci rtl8xxxu_path_adda_on(priv, adda_regs, true); 10998c2ecf20Sopenharmony_ci 11008c2ecf20Sopenharmony_ci /* MAC settings */ 11018c2ecf20Sopenharmony_ci rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); 11028c2ecf20Sopenharmony_ci 11038c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 11048c2ecf20Sopenharmony_ci val32 |= 0x0f000000; 11058c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 11068c2ecf20Sopenharmony_ci 11078c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); 11088c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 11098c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22208200); 11108c2ecf20Sopenharmony_ci 11118c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); 11128c2ecf20Sopenharmony_ci val32 |= (FPGA0_RF_PAPE | (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 11138c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_RF_INT_OE); 11168c2ecf20Sopenharmony_ci val32 |= BIT(10); 11178c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, val32); 11188c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_RF_INT_OE); 11198c2ecf20Sopenharmony_ci val32 |= BIT(10); 11208c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_XB_RF_INT_OE, val32); 11218c2ecf20Sopenharmony_ci 11228c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 11238c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 11248c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 11258c2ecf20Sopenharmony_ci 11268c2ecf20Sopenharmony_ci for (i = 0; i < retry; i++) { 11278c2ecf20Sopenharmony_ci path_a_ok = rtl8192eu_iqk_path_a(priv); 11288c2ecf20Sopenharmony_ci if (path_a_ok == 0x01) { 11298c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, 11308c2ecf20Sopenharmony_ci REG_TX_POWER_BEFORE_IQK_A); 11318c2ecf20Sopenharmony_ci result[t][0] = (val32 >> 16) & 0x3ff; 11328c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, 11338c2ecf20Sopenharmony_ci REG_TX_POWER_AFTER_IQK_A); 11348c2ecf20Sopenharmony_ci result[t][1] = (val32 >> 16) & 0x3ff; 11358c2ecf20Sopenharmony_ci 11368c2ecf20Sopenharmony_ci break; 11378c2ecf20Sopenharmony_ci } 11388c2ecf20Sopenharmony_ci } 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_ci if (!path_a_ok) 11418c2ecf20Sopenharmony_ci dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); 11428c2ecf20Sopenharmony_ci 11438c2ecf20Sopenharmony_ci for (i = 0; i < retry; i++) { 11448c2ecf20Sopenharmony_ci path_a_ok = rtl8192eu_rx_iqk_path_a(priv); 11458c2ecf20Sopenharmony_ci if (path_a_ok == 0x03) { 11468c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, 11478c2ecf20Sopenharmony_ci REG_RX_POWER_BEFORE_IQK_A_2); 11488c2ecf20Sopenharmony_ci result[t][2] = (val32 >> 16) & 0x3ff; 11498c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, 11508c2ecf20Sopenharmony_ci REG_RX_POWER_AFTER_IQK_A_2); 11518c2ecf20Sopenharmony_ci result[t][3] = (val32 >> 16) & 0x3ff; 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci break; 11548c2ecf20Sopenharmony_ci } 11558c2ecf20Sopenharmony_ci } 11568c2ecf20Sopenharmony_ci 11578c2ecf20Sopenharmony_ci if (!path_a_ok) 11588c2ecf20Sopenharmony_ci dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); 11598c2ecf20Sopenharmony_ci 11608c2ecf20Sopenharmony_ci if (priv->rf_paths > 1) { 11618c2ecf20Sopenharmony_ci /* Path A into standby */ 11628c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 11638c2ecf20Sopenharmony_ci rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x10000); 11648c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 11658c2ecf20Sopenharmony_ci 11668c2ecf20Sopenharmony_ci /* Turn Path B ADDA on */ 11678c2ecf20Sopenharmony_ci rtl8xxxu_path_adda_on(priv, adda_regs, false); 11688c2ecf20Sopenharmony_ci 11698c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 11708c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 11718c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_ci for (i = 0; i < retry; i++) { 11748c2ecf20Sopenharmony_ci path_b_ok = rtl8192eu_iqk_path_b(priv); 11758c2ecf20Sopenharmony_ci if (path_b_ok == 0x01) { 11768c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 11778c2ecf20Sopenharmony_ci result[t][4] = (val32 >> 16) & 0x3ff; 11788c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 11798c2ecf20Sopenharmony_ci result[t][5] = (val32 >> 16) & 0x3ff; 11808c2ecf20Sopenharmony_ci break; 11818c2ecf20Sopenharmony_ci } 11828c2ecf20Sopenharmony_ci } 11838c2ecf20Sopenharmony_ci 11848c2ecf20Sopenharmony_ci if (!path_b_ok) 11858c2ecf20Sopenharmony_ci dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); 11868c2ecf20Sopenharmony_ci 11878c2ecf20Sopenharmony_ci for (i = 0; i < retry; i++) { 11888c2ecf20Sopenharmony_ci path_b_ok = rtl8192eu_rx_iqk_path_b(priv); 11898c2ecf20Sopenharmony_ci if (path_b_ok == 0x03) { 11908c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, 11918c2ecf20Sopenharmony_ci REG_RX_POWER_BEFORE_IQK_B_2); 11928c2ecf20Sopenharmony_ci result[t][6] = (val32 >> 16) & 0x3ff; 11938c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, 11948c2ecf20Sopenharmony_ci REG_RX_POWER_AFTER_IQK_B_2); 11958c2ecf20Sopenharmony_ci result[t][7] = (val32 >> 16) & 0x3ff; 11968c2ecf20Sopenharmony_ci break; 11978c2ecf20Sopenharmony_ci } 11988c2ecf20Sopenharmony_ci } 11998c2ecf20Sopenharmony_ci 12008c2ecf20Sopenharmony_ci if (!path_b_ok) 12018c2ecf20Sopenharmony_ci dev_dbg(dev, "%s: Path B RX IQK failed!\n", __func__); 12028c2ecf20Sopenharmony_ci } 12038c2ecf20Sopenharmony_ci 12048c2ecf20Sopenharmony_ci /* Back to BB mode, load original value */ 12058c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 12068c2ecf20Sopenharmony_ci 12078c2ecf20Sopenharmony_ci if (t) { 12088c2ecf20Sopenharmony_ci /* Reload ADDA power saving parameters */ 12098c2ecf20Sopenharmony_ci rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, 12108c2ecf20Sopenharmony_ci RTL8XXXU_ADDA_REGS); 12118c2ecf20Sopenharmony_ci 12128c2ecf20Sopenharmony_ci /* Reload MAC parameters */ 12138c2ecf20Sopenharmony_ci rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 12148c2ecf20Sopenharmony_ci 12158c2ecf20Sopenharmony_ci /* Reload BB parameters */ 12168c2ecf20Sopenharmony_ci rtl8xxxu_restore_regs(priv, iqk_bb_regs, 12178c2ecf20Sopenharmony_ci priv->bb_backup, RTL8XXXU_BB_REGS); 12188c2ecf20Sopenharmony_ci 12198c2ecf20Sopenharmony_ci /* Restore RX initial gain */ 12208c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1); 12218c2ecf20Sopenharmony_ci val32 &= 0xffffff00; 12228c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | 0x50); 12238c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | xa_agc); 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci if (priv->rf_paths > 1) { 12268c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1); 12278c2ecf20Sopenharmony_ci val32 &= 0xffffff00; 12288c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 12298c2ecf20Sopenharmony_ci val32 | 0x50); 12308c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 12318c2ecf20Sopenharmony_ci val32 | xb_agc); 12328c2ecf20Sopenharmony_ci } 12338c2ecf20Sopenharmony_ci 12348c2ecf20Sopenharmony_ci /* Load 0xe30 IQC default value */ 12358c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); 12368c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); 12378c2ecf20Sopenharmony_ci } 12388c2ecf20Sopenharmony_ci} 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_cistatic void rtl8192eu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 12418c2ecf20Sopenharmony_ci{ 12428c2ecf20Sopenharmony_ci struct device *dev = &priv->udev->dev; 12438c2ecf20Sopenharmony_ci int result[4][8]; /* last is final result */ 12448c2ecf20Sopenharmony_ci int i, candidate; 12458c2ecf20Sopenharmony_ci bool path_a_ok, path_b_ok; 12468c2ecf20Sopenharmony_ci u32 reg_e94, reg_e9c, reg_ea4, reg_eac; 12478c2ecf20Sopenharmony_ci u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 12488c2ecf20Sopenharmony_ci bool simu; 12498c2ecf20Sopenharmony_ci 12508c2ecf20Sopenharmony_ci memset(result, 0, sizeof(result)); 12518c2ecf20Sopenharmony_ci candidate = -1; 12528c2ecf20Sopenharmony_ci 12538c2ecf20Sopenharmony_ci path_a_ok = false; 12548c2ecf20Sopenharmony_ci path_b_ok = false; 12558c2ecf20Sopenharmony_ci 12568c2ecf20Sopenharmony_ci for (i = 0; i < 3; i++) { 12578c2ecf20Sopenharmony_ci rtl8192eu_phy_iqcalibrate(priv, result, i); 12588c2ecf20Sopenharmony_ci 12598c2ecf20Sopenharmony_ci if (i == 1) { 12608c2ecf20Sopenharmony_ci simu = rtl8xxxu_gen2_simularity_compare(priv, 12618c2ecf20Sopenharmony_ci result, 0, 1); 12628c2ecf20Sopenharmony_ci if (simu) { 12638c2ecf20Sopenharmony_ci candidate = 0; 12648c2ecf20Sopenharmony_ci break; 12658c2ecf20Sopenharmony_ci } 12668c2ecf20Sopenharmony_ci } 12678c2ecf20Sopenharmony_ci 12688c2ecf20Sopenharmony_ci if (i == 2) { 12698c2ecf20Sopenharmony_ci simu = rtl8xxxu_gen2_simularity_compare(priv, 12708c2ecf20Sopenharmony_ci result, 0, 2); 12718c2ecf20Sopenharmony_ci if (simu) { 12728c2ecf20Sopenharmony_ci candidate = 0; 12738c2ecf20Sopenharmony_ci break; 12748c2ecf20Sopenharmony_ci } 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_ci simu = rtl8xxxu_gen2_simularity_compare(priv, 12778c2ecf20Sopenharmony_ci result, 1, 2); 12788c2ecf20Sopenharmony_ci if (simu) 12798c2ecf20Sopenharmony_ci candidate = 1; 12808c2ecf20Sopenharmony_ci else 12818c2ecf20Sopenharmony_ci candidate = 3; 12828c2ecf20Sopenharmony_ci } 12838c2ecf20Sopenharmony_ci } 12848c2ecf20Sopenharmony_ci 12858c2ecf20Sopenharmony_ci for (i = 0; i < 4; i++) { 12868c2ecf20Sopenharmony_ci reg_e94 = result[i][0]; 12878c2ecf20Sopenharmony_ci reg_e9c = result[i][1]; 12888c2ecf20Sopenharmony_ci reg_ea4 = result[i][2]; 12898c2ecf20Sopenharmony_ci reg_eb4 = result[i][4]; 12908c2ecf20Sopenharmony_ci reg_ebc = result[i][5]; 12918c2ecf20Sopenharmony_ci reg_ec4 = result[i][6]; 12928c2ecf20Sopenharmony_ci } 12938c2ecf20Sopenharmony_ci 12948c2ecf20Sopenharmony_ci if (candidate >= 0) { 12958c2ecf20Sopenharmony_ci reg_e94 = result[candidate][0]; 12968c2ecf20Sopenharmony_ci priv->rege94 = reg_e94; 12978c2ecf20Sopenharmony_ci reg_e9c = result[candidate][1]; 12988c2ecf20Sopenharmony_ci priv->rege9c = reg_e9c; 12998c2ecf20Sopenharmony_ci reg_ea4 = result[candidate][2]; 13008c2ecf20Sopenharmony_ci reg_eac = result[candidate][3]; 13018c2ecf20Sopenharmony_ci reg_eb4 = result[candidate][4]; 13028c2ecf20Sopenharmony_ci priv->regeb4 = reg_eb4; 13038c2ecf20Sopenharmony_ci reg_ebc = result[candidate][5]; 13048c2ecf20Sopenharmony_ci priv->regebc = reg_ebc; 13058c2ecf20Sopenharmony_ci reg_ec4 = result[candidate][6]; 13068c2ecf20Sopenharmony_ci reg_ecc = result[candidate][7]; 13078c2ecf20Sopenharmony_ci dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); 13088c2ecf20Sopenharmony_ci dev_dbg(dev, 13098c2ecf20Sopenharmony_ci "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x ecc=%x\n", 13108c2ecf20Sopenharmony_ci __func__, reg_e94, reg_e9c, 13118c2ecf20Sopenharmony_ci reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); 13128c2ecf20Sopenharmony_ci path_a_ok = true; 13138c2ecf20Sopenharmony_ci path_b_ok = true; 13148c2ecf20Sopenharmony_ci } else { 13158c2ecf20Sopenharmony_ci reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; 13168c2ecf20Sopenharmony_ci reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; 13178c2ecf20Sopenharmony_ci } 13188c2ecf20Sopenharmony_ci 13198c2ecf20Sopenharmony_ci if (reg_e94 && candidate >= 0) 13208c2ecf20Sopenharmony_ci rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, 13218c2ecf20Sopenharmony_ci candidate, (reg_ea4 == 0)); 13228c2ecf20Sopenharmony_ci 13238c2ecf20Sopenharmony_ci if (priv->rf_paths > 1) 13248c2ecf20Sopenharmony_ci rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 13258c2ecf20Sopenharmony_ci candidate, (reg_ec4 == 0)); 13268c2ecf20Sopenharmony_ci 13278c2ecf20Sopenharmony_ci rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 13288c2ecf20Sopenharmony_ci priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 13298c2ecf20Sopenharmony_ci} 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_ci/* 13328c2ecf20Sopenharmony_ci * This is needed for 8723bu as well, presumable 13338c2ecf20Sopenharmony_ci */ 13348c2ecf20Sopenharmony_cistatic void rtl8192e_crystal_afe_adjust(struct rtl8xxxu_priv *priv) 13358c2ecf20Sopenharmony_ci{ 13368c2ecf20Sopenharmony_ci u8 val8; 13378c2ecf20Sopenharmony_ci u32 val32; 13388c2ecf20Sopenharmony_ci 13398c2ecf20Sopenharmony_ci /* 13408c2ecf20Sopenharmony_ci * 40Mhz crystal source, MAC 0x28[2]=0 13418c2ecf20Sopenharmony_ci */ 13428c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 13438c2ecf20Sopenharmony_ci val8 &= 0xfb; 13448c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 13458c2ecf20Sopenharmony_ci 13468c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 13478c2ecf20Sopenharmony_ci val32 &= 0xfffffc7f; 13488c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_ci /* 13518c2ecf20Sopenharmony_ci * 92e AFE parameter 13528c2ecf20Sopenharmony_ci * AFE PLL KVCO selection, MAC 0x28[6]=1 13538c2ecf20Sopenharmony_ci */ 13548c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 13558c2ecf20Sopenharmony_ci val8 &= 0xbf; 13568c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 13578c2ecf20Sopenharmony_ci 13588c2ecf20Sopenharmony_ci /* 13598c2ecf20Sopenharmony_ci * AFE PLL KVCO selection, MAC 0x78[21]=0 13608c2ecf20Sopenharmony_ci */ 13618c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 13628c2ecf20Sopenharmony_ci val32 &= 0xffdfffff; 13638c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 13648c2ecf20Sopenharmony_ci} 13658c2ecf20Sopenharmony_ci 13668c2ecf20Sopenharmony_cistatic void rtl8192e_disabled_to_emu(struct rtl8xxxu_priv *priv) 13678c2ecf20Sopenharmony_ci{ 13688c2ecf20Sopenharmony_ci u8 val8; 13698c2ecf20Sopenharmony_ci 13708c2ecf20Sopenharmony_ci /* Clear suspend enable and power down enable*/ 13718c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 13728c2ecf20Sopenharmony_ci val8 &= ~(BIT(3) | BIT(4)); 13738c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 13748c2ecf20Sopenharmony_ci} 13758c2ecf20Sopenharmony_ci 13768c2ecf20Sopenharmony_cistatic int rtl8192e_emu_to_active(struct rtl8xxxu_priv *priv) 13778c2ecf20Sopenharmony_ci{ 13788c2ecf20Sopenharmony_ci u8 val8; 13798c2ecf20Sopenharmony_ci u32 val32; 13808c2ecf20Sopenharmony_ci int count, ret = 0; 13818c2ecf20Sopenharmony_ci 13828c2ecf20Sopenharmony_ci /* disable HWPDN 0x04[15]=0*/ 13838c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 13848c2ecf20Sopenharmony_ci val8 &= ~BIT(7); 13858c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 13868c2ecf20Sopenharmony_ci 13878c2ecf20Sopenharmony_ci /* disable SW LPS 0x04[10]= 0 */ 13888c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 13898c2ecf20Sopenharmony_ci val8 &= ~BIT(2); 13908c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 13918c2ecf20Sopenharmony_ci 13928c2ecf20Sopenharmony_ci /* disable WL suspend*/ 13938c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 13948c2ecf20Sopenharmony_ci val8 &= ~(BIT(3) | BIT(4)); 13958c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 13968c2ecf20Sopenharmony_ci 13978c2ecf20Sopenharmony_ci /* wait till 0x04[17] = 1 power ready*/ 13988c2ecf20Sopenharmony_ci for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 13998c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 14008c2ecf20Sopenharmony_ci if (val32 & BIT(17)) 14018c2ecf20Sopenharmony_ci break; 14028c2ecf20Sopenharmony_ci 14038c2ecf20Sopenharmony_ci udelay(10); 14048c2ecf20Sopenharmony_ci } 14058c2ecf20Sopenharmony_ci 14068c2ecf20Sopenharmony_ci if (!count) { 14078c2ecf20Sopenharmony_ci ret = -EBUSY; 14088c2ecf20Sopenharmony_ci goto exit; 14098c2ecf20Sopenharmony_ci } 14108c2ecf20Sopenharmony_ci 14118c2ecf20Sopenharmony_ci /* We should be able to optimize the following three entries into one */ 14128c2ecf20Sopenharmony_ci 14138c2ecf20Sopenharmony_ci /* release WLON reset 0x04[16]= 1*/ 14148c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 14158c2ecf20Sopenharmony_ci val8 |= BIT(0); 14168c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 14178c2ecf20Sopenharmony_ci 14188c2ecf20Sopenharmony_ci /* set, then poll until 0 */ 14198c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 14208c2ecf20Sopenharmony_ci val32 |= APS_FSMCO_MAC_ENABLE; 14218c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 14228c2ecf20Sopenharmony_ci 14238c2ecf20Sopenharmony_ci for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 14248c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 14258c2ecf20Sopenharmony_ci if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 14268c2ecf20Sopenharmony_ci ret = 0; 14278c2ecf20Sopenharmony_ci break; 14288c2ecf20Sopenharmony_ci } 14298c2ecf20Sopenharmony_ci udelay(10); 14308c2ecf20Sopenharmony_ci } 14318c2ecf20Sopenharmony_ci 14328c2ecf20Sopenharmony_ci if (!count) { 14338c2ecf20Sopenharmony_ci ret = -EBUSY; 14348c2ecf20Sopenharmony_ci goto exit; 14358c2ecf20Sopenharmony_ci } 14368c2ecf20Sopenharmony_ci 14378c2ecf20Sopenharmony_ciexit: 14388c2ecf20Sopenharmony_ci return ret; 14398c2ecf20Sopenharmony_ci} 14408c2ecf20Sopenharmony_ci 14418c2ecf20Sopenharmony_cistatic int rtl8192eu_active_to_lps(struct rtl8xxxu_priv *priv) 14428c2ecf20Sopenharmony_ci{ 14438c2ecf20Sopenharmony_ci struct device *dev = &priv->udev->dev; 14448c2ecf20Sopenharmony_ci u8 val8; 14458c2ecf20Sopenharmony_ci u16 val16; 14468c2ecf20Sopenharmony_ci u32 val32; 14478c2ecf20Sopenharmony_ci int retry, retval; 14488c2ecf20Sopenharmony_ci 14498c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff); 14508c2ecf20Sopenharmony_ci 14518c2ecf20Sopenharmony_ci retry = 100; 14528c2ecf20Sopenharmony_ci retval = -EBUSY; 14538c2ecf20Sopenharmony_ci /* 14548c2ecf20Sopenharmony_ci * Poll 32 bit wide 0x05f8 for 0x00000000 to ensure no TX is pending. 14558c2ecf20Sopenharmony_ci */ 14568c2ecf20Sopenharmony_ci do { 14578c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_SCH_TX_CMD); 14588c2ecf20Sopenharmony_ci if (!val32) { 14598c2ecf20Sopenharmony_ci retval = 0; 14608c2ecf20Sopenharmony_ci break; 14618c2ecf20Sopenharmony_ci } 14628c2ecf20Sopenharmony_ci } while (retry--); 14638c2ecf20Sopenharmony_ci 14648c2ecf20Sopenharmony_ci if (!retry) { 14658c2ecf20Sopenharmony_ci dev_warn(dev, "Failed to flush TX queue\n"); 14668c2ecf20Sopenharmony_ci retval = -EBUSY; 14678c2ecf20Sopenharmony_ci goto out; 14688c2ecf20Sopenharmony_ci } 14698c2ecf20Sopenharmony_ci 14708c2ecf20Sopenharmony_ci /* Disable CCK and OFDM, clock gated */ 14718c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC); 14728c2ecf20Sopenharmony_ci val8 &= ~SYS_FUNC_BBRSTB; 14738c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_SYS_FUNC, val8); 14748c2ecf20Sopenharmony_ci 14758c2ecf20Sopenharmony_ci udelay(2); 14768c2ecf20Sopenharmony_ci 14778c2ecf20Sopenharmony_ci /* Reset whole BB */ 14788c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC); 14798c2ecf20Sopenharmony_ci val8 &= ~SYS_FUNC_BB_GLB_RSTN; 14808c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_SYS_FUNC, val8); 14818c2ecf20Sopenharmony_ci 14828c2ecf20Sopenharmony_ci /* Reset MAC TRX */ 14838c2ecf20Sopenharmony_ci val16 = rtl8xxxu_read16(priv, REG_CR); 14848c2ecf20Sopenharmony_ci val16 &= 0xff00; 14858c2ecf20Sopenharmony_ci val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE); 14868c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_CR, val16); 14878c2ecf20Sopenharmony_ci 14888c2ecf20Sopenharmony_ci val16 = rtl8xxxu_read16(priv, REG_CR); 14898c2ecf20Sopenharmony_ci val16 &= ~CR_SECURITY_ENABLE; 14908c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_CR, val16); 14918c2ecf20Sopenharmony_ci 14928c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_DUAL_TSF_RST); 14938c2ecf20Sopenharmony_ci val8 |= DUAL_TSF_TX_OK; 14948c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, val8); 14958c2ecf20Sopenharmony_ci 14968c2ecf20Sopenharmony_ciout: 14978c2ecf20Sopenharmony_ci return retval; 14988c2ecf20Sopenharmony_ci} 14998c2ecf20Sopenharmony_ci 15008c2ecf20Sopenharmony_cistatic int rtl8192eu_active_to_emu(struct rtl8xxxu_priv *priv) 15018c2ecf20Sopenharmony_ci{ 15028c2ecf20Sopenharmony_ci u8 val8; 15038c2ecf20Sopenharmony_ci int count, ret = 0; 15048c2ecf20Sopenharmony_ci 15058c2ecf20Sopenharmony_ci /* Turn off RF */ 15068c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_RF_CTRL); 15078c2ecf20Sopenharmony_ci val8 &= ~RF_ENABLE; 15088c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 15098c2ecf20Sopenharmony_ci 15108c2ecf20Sopenharmony_ci /* Switch DPDT_SEL_P output from register 0x65[2] */ 15118c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); 15128c2ecf20Sopenharmony_ci val8 &= ~LEDCFG2_DPDT_SELECT; 15138c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_LEDCFG2, val8); 15148c2ecf20Sopenharmony_ci 15158c2ecf20Sopenharmony_ci /* 0x0005[1] = 1 turn off MAC by HW state machine*/ 15168c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 15178c2ecf20Sopenharmony_ci val8 |= BIT(1); 15188c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 15198c2ecf20Sopenharmony_ci 15208c2ecf20Sopenharmony_ci for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 15218c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 15228c2ecf20Sopenharmony_ci if ((val8 & BIT(1)) == 0) 15238c2ecf20Sopenharmony_ci break; 15248c2ecf20Sopenharmony_ci udelay(10); 15258c2ecf20Sopenharmony_ci } 15268c2ecf20Sopenharmony_ci 15278c2ecf20Sopenharmony_ci if (!count) { 15288c2ecf20Sopenharmony_ci dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n", 15298c2ecf20Sopenharmony_ci __func__); 15308c2ecf20Sopenharmony_ci ret = -EBUSY; 15318c2ecf20Sopenharmony_ci goto exit; 15328c2ecf20Sopenharmony_ci } 15338c2ecf20Sopenharmony_ci 15348c2ecf20Sopenharmony_ciexit: 15358c2ecf20Sopenharmony_ci return ret; 15368c2ecf20Sopenharmony_ci} 15378c2ecf20Sopenharmony_ci 15388c2ecf20Sopenharmony_cistatic int rtl8192eu_emu_to_disabled(struct rtl8xxxu_priv *priv) 15398c2ecf20Sopenharmony_ci{ 15408c2ecf20Sopenharmony_ci u8 val8; 15418c2ecf20Sopenharmony_ci 15428c2ecf20Sopenharmony_ci /* 0x04[12:11] = 01 enable WL suspend */ 15438c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 15448c2ecf20Sopenharmony_ci val8 &= ~(BIT(3) | BIT(4)); 15458c2ecf20Sopenharmony_ci val8 |= BIT(3); 15468c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 15478c2ecf20Sopenharmony_ci 15488c2ecf20Sopenharmony_ci return 0; 15498c2ecf20Sopenharmony_ci} 15508c2ecf20Sopenharmony_ci 15518c2ecf20Sopenharmony_cistatic int rtl8192eu_power_on(struct rtl8xxxu_priv *priv) 15528c2ecf20Sopenharmony_ci{ 15538c2ecf20Sopenharmony_ci u16 val16; 15548c2ecf20Sopenharmony_ci u32 val32; 15558c2ecf20Sopenharmony_ci int ret; 15568c2ecf20Sopenharmony_ci 15578c2ecf20Sopenharmony_ci ret = 0; 15588c2ecf20Sopenharmony_ci 15598c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_SYS_CFG); 15608c2ecf20Sopenharmony_ci if (val32 & SYS_CFG_SPS_LDO_SEL) { 15618c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0xc3); 15628c2ecf20Sopenharmony_ci } else { 15638c2ecf20Sopenharmony_ci /* 15648c2ecf20Sopenharmony_ci * Raise 1.2V voltage 15658c2ecf20Sopenharmony_ci */ 15668c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_8192E_LDOV12_CTRL); 15678c2ecf20Sopenharmony_ci val32 &= 0xff0fffff; 15688c2ecf20Sopenharmony_ci val32 |= 0x00500000; 15698c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_8192E_LDOV12_CTRL, val32); 15708c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0x83); 15718c2ecf20Sopenharmony_ci } 15728c2ecf20Sopenharmony_ci 15738c2ecf20Sopenharmony_ci /* 15748c2ecf20Sopenharmony_ci * Adjust AFE before enabling PLL 15758c2ecf20Sopenharmony_ci */ 15768c2ecf20Sopenharmony_ci rtl8192e_crystal_afe_adjust(priv); 15778c2ecf20Sopenharmony_ci rtl8192e_disabled_to_emu(priv); 15788c2ecf20Sopenharmony_ci 15798c2ecf20Sopenharmony_ci ret = rtl8192e_emu_to_active(priv); 15808c2ecf20Sopenharmony_ci if (ret) 15818c2ecf20Sopenharmony_ci goto exit; 15828c2ecf20Sopenharmony_ci 15838c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_CR, 0x0000); 15848c2ecf20Sopenharmony_ci 15858c2ecf20Sopenharmony_ci /* 15868c2ecf20Sopenharmony_ci * Enable MAC DMA/WMAC/SCHEDULE/SEC block 15878c2ecf20Sopenharmony_ci * Set CR bit10 to enable 32k calibration. 15888c2ecf20Sopenharmony_ci */ 15898c2ecf20Sopenharmony_ci val16 = rtl8xxxu_read16(priv, REG_CR); 15908c2ecf20Sopenharmony_ci val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 15918c2ecf20Sopenharmony_ci CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 15928c2ecf20Sopenharmony_ci CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 15938c2ecf20Sopenharmony_ci CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 15948c2ecf20Sopenharmony_ci CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 15958c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_CR, val16); 15968c2ecf20Sopenharmony_ci 15978c2ecf20Sopenharmony_ciexit: 15988c2ecf20Sopenharmony_ci return ret; 15998c2ecf20Sopenharmony_ci} 16008c2ecf20Sopenharmony_ci 16018c2ecf20Sopenharmony_cistatic void rtl8192eu_power_off(struct rtl8xxxu_priv *priv) 16028c2ecf20Sopenharmony_ci{ 16038c2ecf20Sopenharmony_ci u8 val8; 16048c2ecf20Sopenharmony_ci u16 val16; 16058c2ecf20Sopenharmony_ci 16068c2ecf20Sopenharmony_ci rtl8xxxu_flush_fifo(priv); 16078c2ecf20Sopenharmony_ci 16088c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); 16098c2ecf20Sopenharmony_ci val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE; 16108c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); 16118c2ecf20Sopenharmony_ci 16128c2ecf20Sopenharmony_ci /* Turn off RF */ 16138c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_RF_CTRL, 0x00); 16148c2ecf20Sopenharmony_ci 16158c2ecf20Sopenharmony_ci rtl8192eu_active_to_lps(priv); 16168c2ecf20Sopenharmony_ci 16178c2ecf20Sopenharmony_ci /* Reset Firmware if running in RAM */ 16188c2ecf20Sopenharmony_ci if (rtl8xxxu_read8(priv, REG_MCU_FW_DL) & MCU_FW_RAM_SEL) 16198c2ecf20Sopenharmony_ci rtl8xxxu_firmware_self_reset(priv); 16208c2ecf20Sopenharmony_ci 16218c2ecf20Sopenharmony_ci /* Reset MCU */ 16228c2ecf20Sopenharmony_ci val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 16238c2ecf20Sopenharmony_ci val16 &= ~SYS_FUNC_CPU_ENABLE; 16248c2ecf20Sopenharmony_ci rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 16258c2ecf20Sopenharmony_ci 16268c2ecf20Sopenharmony_ci /* Reset MCU ready status */ 16278c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00); 16288c2ecf20Sopenharmony_ci 16298c2ecf20Sopenharmony_ci rtl8xxxu_reset_8051(priv); 16308c2ecf20Sopenharmony_ci 16318c2ecf20Sopenharmony_ci rtl8192eu_active_to_emu(priv); 16328c2ecf20Sopenharmony_ci rtl8192eu_emu_to_disabled(priv); 16338c2ecf20Sopenharmony_ci} 16348c2ecf20Sopenharmony_ci 16358c2ecf20Sopenharmony_cistatic void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv) 16368c2ecf20Sopenharmony_ci{ 16378c2ecf20Sopenharmony_ci u32 val32; 16388c2ecf20Sopenharmony_ci u8 val8; 16398c2ecf20Sopenharmony_ci 16408c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_RX_WAIT_CCA); 16418c2ecf20Sopenharmony_ci val32 |= (BIT(22) | BIT(23)); 16428c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RX_WAIT_CCA, val32); 16438c2ecf20Sopenharmony_ci 16448c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 16458c2ecf20Sopenharmony_ci val8 |= BIT(5); 16468c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 16478c2ecf20Sopenharmony_ci 16488c2ecf20Sopenharmony_ci /* 16498c2ecf20Sopenharmony_ci * WLAN action by PTA 16508c2ecf20Sopenharmony_ci */ 16518c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 16528c2ecf20Sopenharmony_ci 16538c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 16548c2ecf20Sopenharmony_ci val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 16558c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 16568c2ecf20Sopenharmony_ci 16578c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 16588c2ecf20Sopenharmony_ci val32 |= (BIT(0) | BIT(1)); 16598c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 16608c2ecf20Sopenharmony_ci 16618c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_RFE_CTRL_ANTA_SRC, 0x77); 16628c2ecf20Sopenharmony_ci 16638c2ecf20Sopenharmony_ci val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 16648c2ecf20Sopenharmony_ci val32 &= ~BIT(24); 16658c2ecf20Sopenharmony_ci val32 |= BIT(23); 16668c2ecf20Sopenharmony_ci rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 16678c2ecf20Sopenharmony_ci 16688c2ecf20Sopenharmony_ci /* 16698c2ecf20Sopenharmony_ci * Fix external switch Main->S1, Aux->S0 16708c2ecf20Sopenharmony_ci */ 16718c2ecf20Sopenharmony_ci val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 16728c2ecf20Sopenharmony_ci val8 &= ~BIT(0); 16738c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 16748c2ecf20Sopenharmony_ci 16758c2ecf20Sopenharmony_ci /* 16768c2ecf20Sopenharmony_ci * Fix transmission failure of rtl8192e. 16778c2ecf20Sopenharmony_ci */ 16788c2ecf20Sopenharmony_ci rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); 16798c2ecf20Sopenharmony_ci} 16808c2ecf20Sopenharmony_ci 16818c2ecf20Sopenharmony_cistruct rtl8xxxu_fileops rtl8192eu_fops = { 16828c2ecf20Sopenharmony_ci .parse_efuse = rtl8192eu_parse_efuse, 16838c2ecf20Sopenharmony_ci .load_firmware = rtl8192eu_load_firmware, 16848c2ecf20Sopenharmony_ci .power_on = rtl8192eu_power_on, 16858c2ecf20Sopenharmony_ci .power_off = rtl8192eu_power_off, 16868c2ecf20Sopenharmony_ci .reset_8051 = rtl8xxxu_reset_8051, 16878c2ecf20Sopenharmony_ci .llt_init = rtl8xxxu_auto_llt_table, 16888c2ecf20Sopenharmony_ci .init_phy_bb = rtl8192eu_init_phy_bb, 16898c2ecf20Sopenharmony_ci .init_phy_rf = rtl8192eu_init_phy_rf, 16908c2ecf20Sopenharmony_ci .phy_iq_calibrate = rtl8192eu_phy_iq_calibrate, 16918c2ecf20Sopenharmony_ci .config_channel = rtl8xxxu_gen2_config_channel, 16928c2ecf20Sopenharmony_ci .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 16938c2ecf20Sopenharmony_ci .enable_rf = rtl8192e_enable_rf, 16948c2ecf20Sopenharmony_ci .disable_rf = rtl8xxxu_gen2_disable_rf, 16958c2ecf20Sopenharmony_ci .usb_quirks = rtl8xxxu_gen2_usb_quirks, 16968c2ecf20Sopenharmony_ci .set_tx_power = rtl8192e_set_tx_power, 16978c2ecf20Sopenharmony_ci .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 16988c2ecf20Sopenharmony_ci .report_connect = rtl8xxxu_gen2_report_connect, 16998c2ecf20Sopenharmony_ci .fill_txdesc = rtl8xxxu_fill_txdesc_v2, 17008c2ecf20Sopenharmony_ci .writeN_block_size = 128, 17018c2ecf20Sopenharmony_ci .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 17028c2ecf20Sopenharmony_ci .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 17038c2ecf20Sopenharmony_ci .has_s0s1 = 0, 17048c2ecf20Sopenharmony_ci .gen2_thermal_meter = 1, 17058c2ecf20Sopenharmony_ci .needs_full_init = 1, 17068c2ecf20Sopenharmony_ci .adda_1t_init = 0x0fc01616, 17078c2ecf20Sopenharmony_ci .adda_1t_path_on = 0x0fc01616, 17088c2ecf20Sopenharmony_ci .adda_2t_path_on_a = 0x0fc01616, 17098c2ecf20Sopenharmony_ci .adda_2t_path_on_b = 0x0fc01616, 17108c2ecf20Sopenharmony_ci .trxff_boundary = 0x3cff, 17118c2ecf20Sopenharmony_ci .mactable = rtl8192e_mac_init_table, 17128c2ecf20Sopenharmony_ci .total_page_num = TX_TOTAL_PAGE_NUM_8192E, 17138c2ecf20Sopenharmony_ci .page_num_hi = TX_PAGE_NUM_HI_PQ_8192E, 17148c2ecf20Sopenharmony_ci .page_num_lo = TX_PAGE_NUM_LO_PQ_8192E, 17158c2ecf20Sopenharmony_ci .page_num_norm = TX_PAGE_NUM_NORM_PQ_8192E, 17168c2ecf20Sopenharmony_ci}; 1717