]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
rtl8xxxu: Handle BB init for 8192eu
[karo-tx-linux.git] / drivers / net / wireless / realtek / rtl8xxxu / rtl8xxxu.c
index 484d08fe80cd45c42793d287e09677d0acce95c1..dc67f5b2dbaeda8f8c3e621a6e8f6efd688535b0 100644 (file)
@@ -91,33 +91,33 @@ static struct ieee80211_rate rtl8xxxu_rates[] = {
 };
 
 static struct ieee80211_channel rtl8xxxu_channels_2g[] = {
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2412,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2412,
          .hw_value = 1, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2417,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2417,
          .hw_value = 2, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2422,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2422,
          .hw_value = 3, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2427,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2427,
          .hw_value = 4, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2432,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2432,
          .hw_value = 5, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2437,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2437,
          .hw_value = 6, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2442,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2442,
          .hw_value = 7, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2447,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2447,
          .hw_value = 8, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2452,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2452,
          .hw_value = 9, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2457,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2457,
          .hw_value = 10, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2462,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2462,
          .hw_value = 11, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2467,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2467,
          .hw_value = 12, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2472,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2472,
          .hw_value = 13, .max_power = 30 },
-       { .band = IEEE80211_BAND_2GHZ, .center_freq = 2484,
+       { .band = NL80211_BAND_2GHZ, .center_freq = 2484,
          .hw_value = 14, .max_power = 30 }
 };
 
@@ -184,6 +184,36 @@ static struct rtl8xxxu_reg8val rtl8723b_mac_init_table[] = {
        {0xffff, 0xff},
 };
 
+static struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = {
+       {0x011, 0xeb}, {0x012, 0x07}, {0x014, 0x75}, {0x303, 0xa7},
+       {0x428, 0x0a}, {0x429, 0x10}, {0x430, 0x00}, {0x431, 0x00},
+       {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05},
+       {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05},
+       {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01},
+       {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00},
+       {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f},
+       {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00},
+       {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f},
+       {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66},
+       {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, {0x4cd, 0xff},
+       {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, {0x502, 0x2f},
+       {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, {0x506, 0x5e},
+       {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, {0x50a, 0x5e},
+       {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, {0x50e, 0x00},
+       {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, {0x516, 0x0a},
+       {0x525, 0x4f}, {0x540, 0x12}, {0x541, 0x64}, {0x550, 0x10},
+       {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, {0x55d, 0xff},
+       {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, {0x620, 0xff},
+       {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, {0x624, 0xff},
+       {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, {0x638, 0x50},
+       {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, {0x63f, 0x0e},
+       {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, {0x652, 0xc8},
+       {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, {0x702, 0x65},
+       {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, {0x70a, 0x65},
+       {0x70b, 0x87},
+       {0xffff, 0xff},
+};
+
 static struct rtl8xxxu_reg32val rtl8723a_phy_1t_init_table[] = {
        {0x800, 0x80040000}, {0x804, 0x00000003},
        {0x808, 0x0000fc00}, {0x80c, 0x0000000a},
@@ -580,6 +610,138 @@ static struct rtl8xxxu_reg32val rtl8188ru_phy_1t_highpa_table[] = {
        {0xffff, 0xffffffff},
 };
 
+static struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = {
+       {0x800, 0x80040000}, {0x804, 0x00000003},
+       {0x808, 0x0000fc00}, {0x80c, 0x0000000a},
+       {0x810, 0x10001331}, {0x814, 0x020c3d10},
+       {0x818, 0x02220385}, {0x81c, 0x00000000},
+       {0x820, 0x01000100}, {0x824, 0x00390204},
+       {0x828, 0x01000100}, {0x82c, 0x00390204},
+       {0x830, 0x32323232}, {0x834, 0x30303030},
+       {0x838, 0x30303030}, {0x83c, 0x30303030},
+       {0x840, 0x00010000}, {0x844, 0x00010000},
+       {0x848, 0x28282828}, {0x84c, 0x28282828},
+       {0x850, 0x00000000}, {0x854, 0x00000000},
+       {0x858, 0x009a009a}, {0x85c, 0x01000014},
+       {0x860, 0x66f60000}, {0x864, 0x061f0000},
+       {0x868, 0x30303030}, {0x86c, 0x30303030},
+       {0x870, 0x00000000}, {0x874, 0x55004200},
+       {0x878, 0x08080808}, {0x87c, 0x00000000},
+       {0x880, 0xb0000c1c}, {0x884, 0x00000001},
+       {0x888, 0x00000000}, {0x88c, 0xcc0000c0},
+       {0x890, 0x00000800}, {0x894, 0xfffffffe},
+       {0x898, 0x40302010}, {0x900, 0x00000000},
+       {0x904, 0x00000023}, {0x908, 0x00000000},
+       {0x90c, 0x81121313}, {0x910, 0x806c0001},
+       {0x914, 0x00000001}, {0x918, 0x00000000},
+       {0x91c, 0x00010000}, {0x924, 0x00000001},
+       {0x928, 0x00000000}, {0x92c, 0x00000000},
+       {0x930, 0x00000000}, {0x934, 0x00000000},
+       {0x938, 0x00000000}, {0x93c, 0x00000000},
+       {0x940, 0x00000000}, {0x944, 0x00000000},
+       {0x94c, 0x00000008}, {0xa00, 0x00d0c7c8},
+       {0xa04, 0x81ff000c}, {0xa08, 0x8c838300},
+       {0xa0c, 0x2e68120f}, {0xa10, 0x95009b78},
+       {0xa14, 0x1114d028}, {0xa18, 0x00881117},
+       {0xa1c, 0x89140f00}, {0xa20, 0x1a1b0000},
+       {0xa24, 0x090e1317}, {0xa28, 0x00000204},
+       {0xa2c, 0x00d30000}, {0xa70, 0x101fff00},
+       {0xa74, 0x00000007}, {0xa78, 0x00000900},
+       {0xa7c, 0x225b0606}, {0xa80, 0x218075b1},
+       {0xb38, 0x00000000}, {0xc00, 0x48071d40},
+       {0xc04, 0x03a05633}, {0xc08, 0x000000e4},
+       {0xc0c, 0x6c6c6c6c}, {0xc10, 0x08800000},
+       {0xc14, 0x40000100}, {0xc18, 0x08800000},
+       {0xc1c, 0x40000100}, {0xc20, 0x00000000},
+       {0xc24, 0x00000000}, {0xc28, 0x00000000},
+       {0xc2c, 0x00000000}, {0xc30, 0x69e9ac47},
+       {0xc34, 0x469652af}, {0xc38, 0x49795994},
+       {0xc3c, 0x0a97971c}, {0xc40, 0x1f7c403f},
+       {0xc44, 0x000100b7}, {0xc48, 0xec020107},
+       {0xc4c, 0x007f037f},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0xc50, 0x00340220},
+#else
+       {0xc50, 0x00340020},
+#endif
+       {0xc54, 0x0080801f},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0xc58, 0x00000220},
+#else
+       {0xc58, 0x00000020},
+#endif
+       {0xc5c, 0x00248492}, {0xc60, 0x00000000},
+       {0xc64, 0x7112848b}, {0xc68, 0x47c00bff},
+       {0xc6c, 0x00000036}, {0xc70, 0x00000600},
+       {0xc74, 0x02013169}, {0xc78, 0x0000001f},
+       {0xc7c, 0x00b91612},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0xc80, 0x2d4000b5},
+#else
+       {0xc80, 0x40000100},
+#endif
+       {0xc84, 0x21f60000},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0xc88, 0x2d4000b5},
+#else
+       {0xc88, 0x40000100},
+#endif
+       {0xc8c, 0xa0e40000}, {0xc90, 0x00121820},
+       {0xc94, 0x00000000}, {0xc98, 0x00121820},
+       {0xc9c, 0x00007f7f}, {0xca0, 0x00000000},
+       {0xca4, 0x000300a0}, {0xca8, 0x00000000},
+       {0xcac, 0x00000000}, {0xcb0, 0x00000000},
+       {0xcb4, 0x00000000}, {0xcb8, 0x00000000},
+       {0xcbc, 0x28000000}, {0xcc0, 0x00000000},
+       {0xcc4, 0x00000000}, {0xcc8, 0x00000000},
+       {0xccc, 0x00000000}, {0xcd0, 0x00000000},
+       {0xcd4, 0x00000000}, {0xcd8, 0x64b22427},
+       {0xcdc, 0x00766932}, {0xce0, 0x00222222},
+       {0xce4, 0x00040000}, {0xce8, 0x77644302},
+       {0xcec, 0x2f97d40c}, {0xd00, 0x00080740},
+       {0xd04, 0x00020403}, {0xd08, 0x0000907f},
+       {0xd0c, 0x20010201}, {0xd10, 0xa0633333},
+       {0xd14, 0x3333bc43}, {0xd18, 0x7a8f5b6b},
+       {0xd1c, 0x0000007f}, {0xd2c, 0xcc979975},
+       {0xd30, 0x00000000}, {0xd34, 0x80608000},
+       {0xd38, 0x00000000}, {0xd3c, 0x00127353},
+       {0xd40, 0x00000000}, {0xd44, 0x00000000},
+       {0xd48, 0x00000000}, {0xd4c, 0x00000000},
+       {0xd50, 0x6437140a}, {0xd54, 0x00000000},
+       {0xd58, 0x00000282}, {0xd5c, 0x30032064},
+       {0xd60, 0x4653de68}, {0xd64, 0x04518a3c},
+       {0xd68, 0x00002101}, {0xd6c, 0x2a201c16},
+       {0xd70, 0x1812362e}, {0xd74, 0x322c2220},
+       {0xd78, 0x000e3c24}, {0xd80, 0x01081008},
+       {0xd84, 0x00000800}, {0xd88, 0xf0b50000},
+       {0xe00, 0x30303030}, {0xe04, 0x30303030},
+       {0xe08, 0x03903030}, {0xe10, 0x30303030},
+       {0xe14, 0x30303030}, {0xe18, 0x30303030},
+       {0xe1c, 0x30303030}, {0xe28, 0x00000000},
+       {0xe30, 0x1000dc1f}, {0xe34, 0x10008c1f},
+       {0xe38, 0x02140102}, {0xe3c, 0x681604c2},
+       {0xe40, 0x01007c00}, {0xe44, 0x01004800},
+       {0xe48, 0xfb000000}, {0xe4c, 0x000028d1},
+       {0xe50, 0x1000dc1f}, {0xe54, 0x10008c1f},
+       {0xe58, 0x02140102}, {0xe5c, 0x28160d05},
+       {0xe60, 0x00000008}, {0xe68, 0x0fc05656},
+       {0xe6c, 0x03c09696}, {0xe70, 0x03c09696},
+       {0xe74, 0x0c005656}, {0xe78, 0x0c005656},
+       {0xe7c, 0x0c005656}, {0xe80, 0x0c005656},
+       {0xe84, 0x03c09696}, {0xe88, 0x0c005656},
+       {0xe8c, 0x03c09696}, {0xed0, 0x03c09696},
+       {0xed4, 0x03c09696}, {0xed8, 0x03c09696},
+       {0xedc, 0x0000d6d6}, {0xee0, 0x0000d6d6},
+       {0xeec, 0x0fc01616}, {0xee4, 0xb0000c1c},
+       {0xee8, 0x00000001}, {0xf14, 0x00000003},
+       {0xf4c, 0x00000000}, {0xf00, 0x00000300},
+       {0xffff, 0xffffffff},
+};
+
 static struct rtl8xxxu_reg32val rtl8xxx_agc_standard_table[] = {
        {0xc78, 0x7b000001}, {0xc78, 0x7b010001},
        {0xc78, 0x7b020001}, {0xc78, 0x7b030001},
@@ -819,6 +981,144 @@ static struct rtl8xxxu_reg32val rtl8xxx_agc_8723bu_table[] = {
        {0xffff, 0xffffffff}
 };
 
+static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = {
+       {0xc78, 0xfb000001}, {0xc78, 0xfb010001},
+       {0xc78, 0xfb020001}, {0xc78, 0xfb030001},
+       {0xc78, 0xfb040001}, {0xc78, 0xfb050001},
+       {0xc78, 0xfa060001}, {0xc78, 0xf9070001},
+       {0xc78, 0xf8080001}, {0xc78, 0xf7090001},
+       {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001},
+       {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001},
+       {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001},
+       {0xc78, 0xf0100001}, {0xc78, 0xef110001},
+       {0xc78, 0xee120001}, {0xc78, 0xed130001},
+       {0xc78, 0xec140001}, {0xc78, 0xeb150001},
+       {0xc78, 0xea160001}, {0xc78, 0xe9170001},
+       {0xc78, 0xe8180001}, {0xc78, 0xe7190001},
+       {0xc78, 0xc81a0001}, {0xc78, 0xc71b0001},
+       {0xc78, 0xc61c0001}, {0xc78, 0x071d0001},
+       {0xc78, 0x061e0001}, {0xc78, 0x051f0001},
+       {0xc78, 0x04200001}, {0xc78, 0x03210001},
+       {0xc78, 0xaa220001}, {0xc78, 0xa9230001},
+       {0xc78, 0xa8240001}, {0xc78, 0xa7250001},
+       {0xc78, 0xa6260001}, {0xc78, 0x85270001},
+       {0xc78, 0x84280001}, {0xc78, 0x83290001},
+       {0xc78, 0x252a0001}, {0xc78, 0x242b0001},
+       {0xc78, 0x232c0001}, {0xc78, 0x222d0001},
+       {0xc78, 0x672e0001}, {0xc78, 0x662f0001},
+       {0xc78, 0x65300001}, {0xc78, 0x64310001},
+       {0xc78, 0x63320001}, {0xc78, 0x62330001},
+       {0xc78, 0x61340001}, {0xc78, 0x45350001},
+       {0xc78, 0x44360001}, {0xc78, 0x43370001},
+       {0xc78, 0x42380001}, {0xc78, 0x41390001},
+       {0xc78, 0x403a0001}, {0xc78, 0x403b0001},
+       {0xc78, 0x403c0001}, {0xc78, 0x403d0001},
+       {0xc78, 0x403e0001}, {0xc78, 0x403f0001},
+       {0xc78, 0xfb400001}, {0xc78, 0xfb410001},
+       {0xc78, 0xfb420001}, {0xc78, 0xfb430001},
+       {0xc78, 0xfb440001}, {0xc78, 0xfb450001},
+       {0xc78, 0xfa460001}, {0xc78, 0xf9470001},
+       {0xc78, 0xf8480001}, {0xc78, 0xf7490001},
+       {0xc78, 0xf64a0001}, {0xc78, 0xf54b0001},
+       {0xc78, 0xf44c0001}, {0xc78, 0xf34d0001},
+       {0xc78, 0xf24e0001}, {0xc78, 0xf14f0001},
+       {0xc78, 0xf0500001}, {0xc78, 0xef510001},
+       {0xc78, 0xee520001}, {0xc78, 0xed530001},
+       {0xc78, 0xec540001}, {0xc78, 0xeb550001},
+       {0xc78, 0xea560001}, {0xc78, 0xe9570001},
+       {0xc78, 0xe8580001}, {0xc78, 0xe7590001},
+       {0xc78, 0xe65a0001}, {0xc78, 0xe55b0001},
+       {0xc78, 0xe45c0001}, {0xc78, 0xe35d0001},
+       {0xc78, 0xe25e0001}, {0xc78, 0xe15f0001},
+       {0xc78, 0x8a600001}, {0xc78, 0x89610001},
+       {0xc78, 0x88620001}, {0xc78, 0x87630001},
+       {0xc78, 0x86640001}, {0xc78, 0x85650001},
+       {0xc78, 0x84660001}, {0xc78, 0x83670001},
+       {0xc78, 0x82680001}, {0xc78, 0x6b690001},
+       {0xc78, 0x6a6a0001}, {0xc78, 0x696b0001},
+       {0xc78, 0x686c0001}, {0xc78, 0x676d0001},
+       {0xc78, 0x666e0001}, {0xc78, 0x656f0001},
+       {0xc78, 0x64700001}, {0xc78, 0x63710001},
+       {0xc78, 0x62720001}, {0xc78, 0x61730001},
+       {0xc78, 0x49740001}, {0xc78, 0x48750001},
+       {0xc78, 0x47760001}, {0xc78, 0x46770001},
+       {0xc78, 0x45780001}, {0xc78, 0x44790001},
+       {0xc78, 0x437a0001}, {0xc78, 0x427b0001},
+       {0xc78, 0x417c0001}, {0xc78, 0x407d0001},
+       {0xc78, 0x407e0001}, {0xc78, 0x407f0001},
+       {0xc50, 0x00040022}, {0xc50, 0x00040020},
+       {0xffff, 0xffffffff}
+};
+
+static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = {
+       {0xc78, 0xfa000001}, {0xc78, 0xf9010001},
+       {0xc78, 0xf8020001}, {0xc78, 0xf7030001},
+       {0xc78, 0xf6040001}, {0xc78, 0xf5050001},
+       {0xc78, 0xf4060001}, {0xc78, 0xf3070001},
+       {0xc78, 0xf2080001}, {0xc78, 0xf1090001},
+       {0xc78, 0xf00a0001}, {0xc78, 0xef0b0001},
+       {0xc78, 0xee0c0001}, {0xc78, 0xed0d0001},
+       {0xc78, 0xec0e0001}, {0xc78, 0xeb0f0001},
+       {0xc78, 0xea100001}, {0xc78, 0xe9110001},
+       {0xc78, 0xe8120001}, {0xc78, 0xe7130001},
+       {0xc78, 0xe6140001}, {0xc78, 0xe5150001},
+       {0xc78, 0xe4160001}, {0xc78, 0xe3170001},
+       {0xc78, 0xe2180001}, {0xc78, 0xe1190001},
+       {0xc78, 0x8a1a0001}, {0xc78, 0x891b0001},
+       {0xc78, 0x881c0001}, {0xc78, 0x871d0001},
+       {0xc78, 0x861e0001}, {0xc78, 0x851f0001},
+       {0xc78, 0x84200001}, {0xc78, 0x83210001},
+       {0xc78, 0x82220001}, {0xc78, 0x6a230001},
+       {0xc78, 0x69240001}, {0xc78, 0x68250001},
+       {0xc78, 0x67260001}, {0xc78, 0x66270001},
+       {0xc78, 0x65280001}, {0xc78, 0x64290001},
+       {0xc78, 0x632a0001}, {0xc78, 0x622b0001},
+       {0xc78, 0x612c0001}, {0xc78, 0x602d0001},
+       {0xc78, 0x472e0001}, {0xc78, 0x462f0001},
+       {0xc78, 0x45300001}, {0xc78, 0x44310001},
+       {0xc78, 0x43320001}, {0xc78, 0x42330001},
+       {0xc78, 0x41340001}, {0xc78, 0x40350001},
+       {0xc78, 0x40360001}, {0xc78, 0x40370001},
+       {0xc78, 0x40380001}, {0xc78, 0x40390001},
+       {0xc78, 0x403a0001}, {0xc78, 0x403b0001},
+       {0xc78, 0x403c0001}, {0xc78, 0x403d0001},
+       {0xc78, 0x403e0001}, {0xc78, 0x403f0001},
+       {0xc78, 0xfa400001}, {0xc78, 0xf9410001},
+       {0xc78, 0xf8420001}, {0xc78, 0xf7430001},
+       {0xc78, 0xf6440001}, {0xc78, 0xf5450001},
+       {0xc78, 0xf4460001}, {0xc78, 0xf3470001},
+       {0xc78, 0xf2480001}, {0xc78, 0xf1490001},
+       {0xc78, 0xf04a0001}, {0xc78, 0xef4b0001},
+       {0xc78, 0xee4c0001}, {0xc78, 0xed4d0001},
+       {0xc78, 0xec4e0001}, {0xc78, 0xeb4f0001},
+       {0xc78, 0xea500001}, {0xc78, 0xe9510001},
+       {0xc78, 0xe8520001}, {0xc78, 0xe7530001},
+       {0xc78, 0xe6540001}, {0xc78, 0xe5550001},
+       {0xc78, 0xe4560001}, {0xc78, 0xe3570001},
+       {0xc78, 0xe2580001}, {0xc78, 0xe1590001},
+       {0xc78, 0x8a5a0001}, {0xc78, 0x895b0001},
+       {0xc78, 0x885c0001}, {0xc78, 0x875d0001},
+       {0xc78, 0x865e0001}, {0xc78, 0x855f0001},
+       {0xc78, 0x84600001}, {0xc78, 0x83610001},
+       {0xc78, 0x82620001}, {0xc78, 0x6a630001},
+       {0xc78, 0x69640001}, {0xc78, 0x68650001},
+       {0xc78, 0x67660001}, {0xc78, 0x66670001},
+       {0xc78, 0x65680001}, {0xc78, 0x64690001},
+       {0xc78, 0x636a0001}, {0xc78, 0x626b0001},
+       {0xc78, 0x616c0001}, {0xc78, 0x606d0001},
+       {0xc78, 0x476e0001}, {0xc78, 0x466f0001},
+       {0xc78, 0x45700001}, {0xc78, 0x44710001},
+       {0xc78, 0x43720001}, {0xc78, 0x42730001},
+       {0xc78, 0x41740001}, {0xc78, 0x40750001},
+       {0xc78, 0x40760001}, {0xc78, 0x40770001},
+       {0xc78, 0x40780001}, {0xc78, 0x40790001},
+       {0xc78, 0x407a0001}, {0xc78, 0x407b0001},
+       {0xc78, 0x407c0001}, {0xc78, 0x407d0001},
+       {0xc78, 0x407e0001}, {0xc78, 0x407f0001},
+       {0xc50, 0x00040222}, {0xc50, 0x00040220},
+       {0xffff, 0xffffffff}
+};
+
 static struct rtl8xxxu_rfregval rtl8723au_radioa_1t_init_table[] = {
        {0x00, 0x00030159}, {0x01, 0x00031284},
        {0x02, 0x00098000}, {0x03, 0x00039c63},
@@ -1212,6 +1512,152 @@ static struct rtl8xxxu_rfregval rtl8188ru_radioa_1t_highpa_table[] = {
        {0xff, 0xffffffff}
 };
 
+static struct rtl8xxxu_rfregval rtl8192eu_radioa_init_table[] = {
+       {0x7f, 0x00000082}, {0x81, 0x0003fc00},
+       {0x00, 0x00030000}, {0x08, 0x00008400},
+       {0x18, 0x00000407}, {0x19, 0x00000012},
+       {0x1b, 0x00000064}, {0x1e, 0x00080009},
+       {0x1f, 0x00000880}, {0x2f, 0x0001a060},
+       {0x3f, 0x00000000}, {0x42, 0x000060c0},
+       {0x57, 0x000d0000}, {0x58, 0x000be180},
+       {0x67, 0x00001552}, {0x83, 0x00000000},
+       {0xb0, 0x000ff9f1}, {0xb1, 0x00055418},
+       {0xb2, 0x0008cc00}, {0xb4, 0x00043083},
+       {0xb5, 0x00008166}, {0xb6, 0x0000803e},
+       {0xb7, 0x0001c69f}, {0xb8, 0x0000407f},
+       {0xb9, 0x00080001}, {0xba, 0x00040001},
+       {0xbb, 0x00000400}, {0xbf, 0x000c0000},
+       {0xc2, 0x00002400}, {0xc3, 0x00000009},
+       {0xc4, 0x00040c91}, {0xc5, 0x00099999},
+       {0xc6, 0x000000a3}, {0xc7, 0x00088820},
+       {0xc8, 0x00076c06}, {0xc9, 0x00000000},
+       {0xca, 0x00080000}, {0xdf, 0x00000180},
+       {0xef, 0x000001a0}, {0x51, 0x00069545},
+       {0x52, 0x0007e45e}, {0x53, 0x00000071},
+       {0x56, 0x00051ff3}, {0x35, 0x000000a8},
+       {0x35, 0x000001e2}, {0x35, 0x000002a8},
+       {0x36, 0x00001c24}, {0x36, 0x00009c24},
+       {0x36, 0x00011c24}, {0x36, 0x00019c24},
+       {0x18, 0x00000c07}, {0x5a, 0x00048000},
+       {0x19, 0x000739d0},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0x34, 0x0000a093}, {0x34, 0x0000908f},
+       {0x34, 0x0000808c}, {0x34, 0x0000704d},
+       {0x34, 0x0000604a}, {0x34, 0x00005047},
+       {0x34, 0x0000400a}, {0x34, 0x00003007},
+       {0x34, 0x00002004}, {0x34, 0x00001001},
+       {0x34, 0x00000000},
+#else
+       /* Regular */
+       {0x34, 0x0000add7}, {0x34, 0x00009dd4},
+       {0x34, 0x00008dd1}, {0x34, 0x00007dce},
+       {0x34, 0x00006dcb}, {0x34, 0x00005dc8},
+       {0x34, 0x00004dc5}, {0x34, 0x000034cc},
+       {0x34, 0x0000244f}, {0x34, 0x0000144c},
+       {0x34, 0x00000014},
+#endif
+       {0x00, 0x00030159},
+       {0x84, 0x00068180},
+       {0x86, 0x0000014e},
+       {0x87, 0x00048e00},
+       {0x8e, 0x00065540},
+       {0x8f, 0x00088000},
+       {0xef, 0x000020a0},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0x3b, 0x000f07b0},
+#else
+       {0x3b, 0x000f02b0},
+#endif
+       {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0},
+       {0x3b, 0x000cf060}, {0x3b, 0x000b0090},
+       {0x3b, 0x000a0080}, {0x3b, 0x00090080},
+       {0x3b, 0x0008f780},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0x3b, 0x000787b0},
+#else
+       {0x3b, 0x00078730},
+#endif
+       {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0},
+       {0x3b, 0x00040620}, {0x3b, 0x00037090},
+       {0x3b, 0x00020080}, {0x3b, 0x0001f060},
+       {0x3b, 0x0000ffb0}, {0xef, 0x000000a0},
+       {0xfe, 0x00000000}, {0x18, 0x0000fc07},
+       {0xfe, 0x00000000}, {0xfe, 0x00000000},
+       {0xfe, 0x00000000}, {0xfe, 0x00000000},
+       {0x1e, 0x00000001}, {0x1f, 0x00080000},
+       {0x00, 0x00033e70},
+       {0xff, 0xffffffff}
+};
+
+static struct rtl8xxxu_rfregval rtl8192eu_radiob_init_table[] = {
+       {0x7f, 0x00000082}, {0x81, 0x0003fc00},
+       {0x00, 0x00030000}, {0x08, 0x00008400},
+       {0x18, 0x00000407}, {0x19, 0x00000012},
+       {0x1b, 0x00000064}, {0x1e, 0x00080009},
+       {0x1f, 0x00000880}, {0x2f, 0x0001a060},
+       {0x3f, 0x00000000}, {0x42, 0x000060c0},
+       {0x57, 0x000d0000}, {0x58, 0x000be180},
+       {0x67, 0x00001552}, {0x7f, 0x00000082},
+       {0x81, 0x0003f000}, {0x83, 0x00000000},
+       {0xdf, 0x00000180}, {0xef, 0x000001a0},
+       {0x51, 0x00069545}, {0x52, 0x0007e42e},
+       {0x53, 0x00000071}, {0x56, 0x00051ff3},
+       {0x35, 0x000000a8}, {0x35, 0x000001e0},
+       {0x35, 0x000002a8}, {0x36, 0x00001ca8},
+       {0x36, 0x00009c24}, {0x36, 0x00011c24},
+       {0x36, 0x00019c24}, {0x18, 0x00000c07},
+       {0x5a, 0x00048000}, {0x19, 0x000739d0},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0x34, 0x0000a093}, {0x34, 0x0000908f},
+       {0x34, 0x0000808c}, {0x34, 0x0000704d},
+       {0x34, 0x0000604a}, {0x34, 0x00005047},
+       {0x34, 0x0000400a}, {0x34, 0x00003007},
+       {0x34, 0x00002004}, {0x34, 0x00001001},
+       {0x34, 0x00000000},
+#else
+       {0x34, 0x0000add7}, {0x34, 0x00009dd4},
+       {0x34, 0x00008dd1}, {0x34, 0x00007dce},
+       {0x34, 0x00006dcb}, {0x34, 0x00005dc8},
+       {0x34, 0x00004dc5}, {0x34, 0x000034cc},
+       {0x34, 0x0000244f}, {0x34, 0x0000144c},
+       {0x34, 0x00000014},
+#endif
+       {0x00, 0x00030159}, {0x84, 0x00068180},
+       {0x86, 0x000000ce}, {0x87, 0x00048a00},
+       {0x8e, 0x00065540}, {0x8f, 0x00088000},
+       {0xef, 0x000020a0},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0x3b, 0x000f07b0},
+#else
+       {0x3b, 0x000f02b0},
+#endif
+
+       {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0},
+       {0x3b, 0x000cf060}, {0x3b, 0x000b0090},
+       {0x3b, 0x000a0080}, {0x3b, 0x00090080},
+       {0x3b, 0x0008f780},
+#ifdef EXT_PA_8192EU
+       /* External PA or external LNA */
+       {0x3b, 0x000787b0},
+#else
+       {0x3b, 0x00078730},
+#endif
+       {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0},
+       {0x3b, 0x00040620}, {0x3b, 0x00037090},
+       {0x3b, 0x00020080}, {0x3b, 0x0001f060},
+       {0x3b, 0x0000ffb0}, {0xef, 0x000000a0},
+       {0x00, 0x00010159}, {0xfe, 0x00000000},
+       {0xfe, 0x00000000}, {0xfe, 0x00000000},
+       {0xfe, 0x00000000}, {0x1e, 0x00000001},
+       {0x1f, 0x00080000}, {0x00, 0x00033e70},
+       {0xff, 0xffffffff}
+};
+
 static struct rtl8xxxu_rfregs rtl8xxxu_rfregs[] = {
        {       /* RF_A */
                .hssiparm1 = REG_FPGA0_XA_HSSI_PARM1,
@@ -1574,7 +2020,7 @@ static void rtl8723a_enable_rf(struct rtl8xxxu_priv *priv)
        val32 &= ~OFDM_RF_PATH_TX_MASK;
        if (priv->tx_paths == 2)
                val32 |= OFDM_RF_PATH_TX_A | OFDM_RF_PATH_TX_B;
-       else if (priv->rtlchip == 0x8192c || priv->rtlchip == 0x8191c)
+       else if (priv->rtl_chip == RTL8192C || priv->rtl_chip == RTL8191C)
                val32 |= OFDM_RF_PATH_TX_B;
        else
                val32 |= OFDM_RF_PATH_TX_A;
@@ -1676,6 +2122,9 @@ static int rtl8723a_channel_to_group(int channel)
        return group;
 }
 
+/*
+ * Valid for rtl8723bu and rtl8192eu
+ */
 static int rtl8723b_channel_to_group(int channel)
 {
        int group;
@@ -2199,11 +2648,11 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)
        if (val32 & SYS_CFG_BT_FUNC) {
                if (priv->chip_cut >= 3) {
                        sprintf(priv->chip_name, "8723BU");
-                       priv->rtlchip = 0x8723b;
+                       priv->rtl_chip = RTL8723B;
                } else {
                        sprintf(priv->chip_name, "8723AU");
                        priv->usb_interrupts = 1;
-                       priv->rtlchip = 0x8723a;
+                       priv->rtl_chip = RTL8723A;
                }
 
                priv->rf_paths = 1;
@@ -2221,19 +2670,19 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)
        } else if (val32 & SYS_CFG_TYPE_ID) {
                bonding = rtl8xxxu_read32(priv, REG_HPON_FSM);
                bonding &= HPON_FSM_BONDING_MASK;
-               if (priv->chip_cut >= 3) {
+               if (priv->fops->has_s0s1) {
                        if (bonding == HPON_FSM_BONDING_1T2R) {
                                sprintf(priv->chip_name, "8191EU");
                                priv->rf_paths = 2;
                                priv->rx_paths = 2;
                                priv->tx_paths = 1;
-                               priv->rtlchip = 0x8191e;
+                               priv->rtl_chip = RTL8191E;
                        } else {
                                sprintf(priv->chip_name, "8192EU");
                                priv->rf_paths = 2;
                                priv->rx_paths = 2;
                                priv->tx_paths = 2;
-                               priv->rtlchip = 0x8192e;
+                               priv->rtl_chip = RTL8192E;
                        }
                } else if (bonding == HPON_FSM_BONDING_1T2R) {
                        sprintf(priv->chip_name, "8191CU");
@@ -2241,14 +2690,14 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)
                        priv->rx_paths = 2;
                        priv->tx_paths = 1;
                        priv->usb_interrupts = 1;
-                       priv->rtlchip = 0x8191c;
+                       priv->rtl_chip = RTL8191C;
                } else {
                        sprintf(priv->chip_name, "8192CU");
                        priv->rf_paths = 2;
                        priv->rx_paths = 2;
                        priv->tx_paths = 2;
                        priv->usb_interrupts = 1;
-                       priv->rtlchip = 0x8192c;
+                       priv->rtl_chip = RTL8192C;
                }
                priv->has_wifi = 1;
        } else {
@@ -2256,15 +2705,15 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)
                priv->rf_paths = 1;
                priv->rx_paths = 1;
                priv->tx_paths = 1;
-               priv->rtlchip = 0x8188c;
+               priv->rtl_chip = RTL8188C;
                priv->usb_interrupts = 1;
                priv->has_wifi = 1;
        }
 
-       switch (priv->rtlchip) {
-       case 0x8188e:
-       case 0x8192e:
-       case 0x8723b:
+       switch (priv->rtl_chip) {
+       case RTL8188E:
+       case RTL8192E:
+       case RTL8723B:
                switch (val32 & SYS_CFG_VENDOR_EXT_MASK) {
                case SYS_CFG_VENDOR_ID_TSMC:
                        sprintf(priv->chip_vendor, "TSMC");
@@ -2541,6 +2990,43 @@ static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv)
 
        ether_addr_copy(priv->mac_addr, efuse->mac_addr);
 
+       memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base,
+              sizeof(efuse->tx_power_index_A.cck_base));
+       memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base,
+              sizeof(efuse->tx_power_index_B.cck_base));
+
+       memcpy(priv->ht40_1s_tx_power_index_A,
+              efuse->tx_power_index_A.ht40_base,
+              sizeof(efuse->tx_power_index_A.ht40_base));
+       memcpy(priv->ht40_1s_tx_power_index_B,
+              efuse->tx_power_index_B.ht40_base,
+              sizeof(efuse->tx_power_index_B.ht40_base));
+
+       priv->ht20_tx_power_diff[0].a =
+               efuse->tx_power_index_A.ht20_ofdm_1s_diff.b;
+       priv->ht20_tx_power_diff[0].b =
+               efuse->tx_power_index_B.ht20_ofdm_1s_diff.b;
+
+       priv->ht40_tx_power_diff[0].a = 0;
+       priv->ht40_tx_power_diff[0].b = 0;
+
+       for (i = 1; i < RTL8723B_TX_COUNT; i++) {
+               priv->ofdm_tx_power_diff[i].a =
+                       efuse->tx_power_index_A.pwr_diff[i - 1].ofdm;
+               priv->ofdm_tx_power_diff[i].b =
+                       efuse->tx_power_index_B.pwr_diff[i - 1].ofdm;
+
+               priv->ht20_tx_power_diff[i].a =
+                       efuse->tx_power_index_A.pwr_diff[i - 1].ht20;
+               priv->ht20_tx_power_diff[i].b =
+                       efuse->tx_power_index_B.pwr_diff[i - 1].ht20;
+
+               priv->ht40_tx_power_diff[i].a =
+                       efuse->tx_power_index_A.pwr_diff[i - 1].ht40;
+               priv->ht40_tx_power_diff[i].b =
+                       efuse->tx_power_index_B.pwr_diff[i - 1].ht40;
+       }
+
        priv->has_xtalk = 1;
        priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f;
 
@@ -2814,7 +3300,7 @@ static int rtl8xxxu_start_firmware(struct rtl8xxxu_priv *priv)
        /*
         * Init H2C command
         */
-       if (priv->rtlchip == 0x8723b)
+       if (priv->rtl_chip == RTL8723B)
                rtl8xxxu_write8(priv, REG_HMTFR, 0x0f);
 exit:
        return ret;
@@ -2997,7 +3483,7 @@ static int rtl8192cu_load_firmware(struct rtl8xxxu_priv *priv)
 
        if (!priv->vendor_umc)
                fw_name = "rtlwifi/rtl8192cufw_TMSC.bin";
-       else if (priv->chip_cut || priv->rtlchip == 0x8192c)
+       else if (priv->chip_cut || priv->rtl_chip == RTL8192C)
                fw_name = "rtlwifi/rtl8192cufw_B.bin";
        else
                fw_name = "rtlwifi/rtl8192cufw_A.bin";
@@ -3087,8 +3573,9 @@ static void rtl8723bu_phy_init_antenna_selection(struct rtl8xxxu_priv *priv)
 }
 
 static int
-rtl8xxxu_init_mac(struct rtl8xxxu_priv *priv, struct rtl8xxxu_reg8val *array)
+rtl8xxxu_init_mac(struct rtl8xxxu_priv *priv)
 {
+       struct rtl8xxxu_reg8val *array = priv->fops->mactable;
        int i, ret;
        u16 reg;
        u8 val;
@@ -3103,12 +3590,13 @@ rtl8xxxu_init_mac(struct rtl8xxxu_priv *priv, struct rtl8xxxu_reg8val *array)
                ret = rtl8xxxu_write8(priv, reg, val);
                if (ret != 1) {
                        dev_warn(&priv->udev->dev,
-                                "Failed to initialize MAC\n");
+                                "Failed to initialize MAC "
+                                "(reg: %04x, val %02x)\n", reg, val);
                        return -EAGAIN;
                }
        }
 
-       if (priv->rtlchip != 0x8723b)
+       if (priv->rtl_chip != RTL8723B)
                rtl8xxxu_write8(priv, REG_MAX_AGGR_NUM, 0x0a);
 
        return 0;
@@ -3154,13 +3642,18 @@ static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv)
         *       addresses, which is initialized here. Do we need this?
         */
 
-       if (priv->rtlchip == 0x8723b) {
+       if (priv->rtl_chip == RTL8723B) {
                val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC);
                val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB |
                        SYS_FUNC_DIO_RF;
                rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
 
                rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00);
+       } else if (priv->rtl_chip == RTL8192E) {
+               val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC);
+               val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB |
+                       SYS_FUNC_DIO_RF;
+               rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
        } else {
                val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL);
                udelay(2);
@@ -3176,7 +3669,7 @@ static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv)
                rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
        }
 
-       if (priv->rtlchip != 0x8723b) {
+       if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E) {
                /* AFE_XTAL_RF_GATE (bit 14) if addressing as 32 bit register */
                val32 = rtl8xxxu_read32(priv, REG_AFE_XTAL_CTRL);
                val32 &= ~AFE_XTAL_RF_GATE;
@@ -3189,22 +3682,29 @@ static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv)
        val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB;
        rtl8xxxu_write8(priv, REG_RF_CTRL, val8);
 
-       if (priv->hi_pa)
-               rtl8xxxu_init_phy_regs(priv, rtl8188ru_phy_1t_highpa_table);
-       else if (priv->tx_paths == 2)
-               rtl8xxxu_init_phy_regs(priv, rtl8192cu_phy_2t_init_table);
-       else if (priv->rtlchip == 0x8723b) {
+       if (priv->rtl_chip == RTL8723B) {
                /*
                 * Why?
                 */
                rtl8xxxu_write8(priv, REG_SYS_FUNC, 0xe3);
                rtl8xxxu_write8(priv, REG_AFE_XTAL_CTRL + 1, 0x80);
                rtl8xxxu_init_phy_regs(priv, rtl8723b_phy_1t_init_table);
-       } else
+       } else if (priv->rtl_chip == RTL8192E) {
+               val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC);
+               val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | SYS_FUNC_DIO_RF |
+                         SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB);
+               rtl8xxxu_write16(priv, REG_SYS_FUNC, val16);
+               val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB;
+               rtl8xxxu_write8(priv, REG_RF_CTRL, val8);
+               rtl8xxxu_init_phy_regs(priv, rtl8192eu_phy_init_table);
+       } else  if (priv->hi_pa)
+               rtl8xxxu_init_phy_regs(priv, rtl8188ru_phy_1t_highpa_table);
+       else if (priv->tx_paths == 2)
+               rtl8xxxu_init_phy_regs(priv, rtl8192cu_phy_2t_init_table);
+       else
                rtl8xxxu_init_phy_regs(priv, rtl8723a_phy_1t_init_table);
 
-
-       if (priv->rtlchip == 0x8188c && priv->hi_pa &&
+       if (priv->rtl_chip == RTL8188C && priv->hi_pa &&
            priv->vendor_umc && priv->chip_cut == 1)
                rtl8xxxu_write8(priv, REG_OFDM0_AGC_PARM1 + 2, 0x50);
 
@@ -3266,9 +3766,16 @@ static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv)
                rtl8xxxu_write32(priv, REG_TX_TO_TX, val32);
        }
 
-       if (priv->rtlchip == 0x8723b)
+       if (priv->rtl_chip == RTL8723B)
                rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8723bu_table);
-       else if (priv->hi_pa)
+       else if (priv->rtl_chip == RTL8192E) {
+               if (priv->hi_pa)
+                       rtl8xxxu_init_phy_regs(priv,
+                                              rtl8xxx_agc_8192eu_highpa_table);
+               else
+                       rtl8xxxu_init_phy_regs(priv,
+                                              rtl8xxx_agc_8192eu_std_table);
+       } else if (priv->hi_pa)
                rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_highpa_table);
        else
                rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_standard_table);
@@ -3283,7 +3790,7 @@ static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv)
                rtl8xxxu_write32(priv, REG_MAC_PHY_CTRL, val32);
        }
 
-       if (priv->rtlchip != 0x8723bu) {
+       if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E) {
                ldoa15 = LDOA15_ENABLE | LDOA15_OBUF;
                ldov12d = LDOV12D_ENABLE | BIT(2) | (2 << LDOV12D_VADJ_SHIFT);
                ldohci12 = 0x57;
@@ -5955,7 +6462,7 @@ static int rtl8192cu_power_on(struct rtl8xxxu_priv *priv)
        /*
         * Workaround for 8188RU LNA power leakage problem.
         */
-       if (priv->rtlchip == 0x8188c && priv->hi_pa) {
+       if (priv->rtl_chip == RTL8188C && priv->hi_pa) {
                val32 = rtl8xxxu_read32(priv, REG_FPGA0_XCD_RF_PARM);
                val32 &= ~BIT(1);
                rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_PARM, val32);
@@ -6020,7 +6527,7 @@ static void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv)
        /*
         * Workaround for 8188RU LNA power leakage problem.
         */
-       if (priv->rtlchip == 0x8188c && priv->hi_pa) {
+       if (priv->rtl_chip == RTL8188C && priv->hi_pa) {
                val32 = rtl8xxxu_read32(priv, REG_FPGA0_XCD_RF_PARM);
                val32 |= BIT(1);
                rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_PARM, val32);
@@ -6313,7 +6820,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
                 * Presumably this is for 8188EU as well
                 * Enable TX report and TX report timer
                 */
-               if (priv->rtlchip == 0x8723bu) {
+               if (priv->rtl_chip == RTL8723B) {
                        val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL);
                        val8 |= TX_REPORT_CTRL_TIMER_ENABLE;
                        rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8);
@@ -6340,9 +6847,9 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
 
        /* Solve too many protocol error on USB bus */
        /* Can't do this for 8188/8192 UMC A cut parts */
-       if (priv->rtlchip == 0x8723a ||
-           ((priv->rtlchip == 0x8192c || priv->rtlchip == 0x8191c ||
-             priv->rtlchip == 0x8188c) &&
+       if (priv->rtl_chip == RTL8723A ||
+           ((priv->rtl_chip == RTL8192C || priv->rtl_chip == RTL8191C ||
+             priv->rtl_chip == RTL8188C) &&
             (priv->chip_cut || !priv->vendor_umc))) {
                rtl8xxxu_write8(priv, 0xfe40, 0xe6);
                rtl8xxxu_write8(priv, 0xfe41, 0x94);
@@ -6361,7 +6868,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
                rtl8xxxu_write8(priv, 0xfe42, 0x80);
        }
 
-       if (priv->rtlchip == 0x8192e) {
+       if (priv->rtl_chip == RTL8192E) {
                rtl8xxxu_write32(priv, REG_HIMR0, 0x00);
                rtl8xxxu_write32(priv, REG_HIMR1, 0x00);
        }
@@ -6369,10 +6876,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
        if (priv->fops->phy_init_antenna_selection)
                priv->fops->phy_init_antenna_selection(priv);
 
-       if (priv->rtlchip == 0x8723b)
-               ret = rtl8xxxu_init_mac(priv, rtl8723b_mac_init_table);
-       else
-               ret = rtl8xxxu_init_mac(priv, rtl8723a_mac_init_table);
+       ret = rtl8xxxu_init_mac(priv);
 
        dev_dbg(dev, "%s: init_mac %i\n", __func__, ret);
        if (ret)
@@ -6383,12 +6887,12 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
        if (ret)
                goto exit;
 
-       switch(priv->rtlchip) {
-       case 0x8723a:
+       switch(priv->rtl_chip) {
+       case RTL8723A:
                rftable = rtl8723au_radioa_1t_init_table;
                ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A);
                break;
-       case 0x8723b:
+       case RTL8723B:
                rftable = rtl8723bu_radioa_1t_init_table;
                ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A);
                /*
@@ -6399,18 +6903,18 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
                msleep(200);
                rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdffe0);
                break;
-       case 0x8188c:
+       case RTL8188C:
                if (priv->hi_pa)
                        rftable = rtl8188ru_radioa_1t_highpa_table;
                else
                        rftable = rtl8192cu_radioa_1t_init_table;
                ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A);
                break;
-       case 0x8191c:
+       case RTL8191C:
                rftable = rtl8192cu_radioa_1t_init_table;
                ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A);
                break;
-       case 0x8192c:
+       case RTL8192C:
                rftable = rtl8192cu_radioa_2t_init_table;
                ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A);
                if (ret)
@@ -6418,6 +6922,14 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
                rftable = rtl8192cu_radiob_2t_init_table;
                ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_B);
                break;
+       case RTL8192E:
+               rftable = rtl8192eu_radioa_init_table;
+               ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A);
+               if (ret)
+                       break;
+               rftable = rtl8192eu_radiob_init_table;
+               ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_B);
+               break;
        default:
                ret = -EINVAL;
        }
@@ -6428,7 +6940,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
        /*
         * Chip specific quirks
         */
-       if (priv->rtlchip == 0x8723a) {
+       if (priv->rtl_chip == RTL8723A) {
                /* Fix USB interface interference issue */
                rtl8xxxu_write8(priv, 0xfe40, 0xe0);
                rtl8xxxu_write8(priv, 0xfe41, 0x8d);
@@ -6466,9 +6978,12 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
                /*
                 * Set TX buffer boundary
                 */
-               val8 = TX_TOTAL_PAGE_NUM + 1;
+               if (priv->rtl_chip == RTL8192E)
+                       val8 = TX_TOTAL_PAGE_NUM_8192E + 1;
+               else
+                       val8 = TX_TOTAL_PAGE_NUM + 1;
 
-               if (priv->rtlchip == 0x8723b)
+               if (priv->rtl_chip == RTL8723B)
                        val8 -= 1;
 
                rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8);
@@ -6484,7 +6999,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
                goto exit;
 
        /* RFSW Control - clear bit 14 ?? */
-       if (priv->rtlchip != 0x8723b)
+       if (priv->rtl_chip != RTL8723B)
                rtl8xxxu_write32(priv, REG_FPGA0_TX_INFO, 0x00000003);
        /* 0x07000760 */
        val32 = FPGA0_RF_TRSW | FPGA0_RF_TRSWB | FPGA0_RF_ANTSW |
@@ -6501,14 +7016,16 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
        /*
         * Set RX page boundary
         */
-       if (priv->rtlchip == 0x8723b)
+       if (priv->rtl_chip == RTL8723B)
                rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, 0x3f7f);
+       else if (priv->rtl_chip == RTL8192E)
+               rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, 0x3cff);
        else
                rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, 0x27ff);
        /*
         * Transfer page size is always 128
         */
-       if (priv->rtlchip == 0x8723b)
+       if (priv->rtl_chip == RTL8723B)
                val8 = (PBP_PAGE_SIZE_256 << PBP_PAGE_SIZE_RX_SHIFT) |
                        (PBP_PAGE_SIZE_256 << PBP_PAGE_SIZE_TX_SHIFT);
        else
@@ -6600,7 +7117,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
        /*
         * Initialize burst parameters
         */
-       if (priv->rtlchip == 0x8723b) {
+       if (priv->rtl_chip == RTL8723B) {
                /*
                 * For USB high speed set 512B packets
                 */
@@ -6682,7 +7199,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
        val8 = ((30000 + NAV_UPPER_UNIT - 1) / NAV_UPPER_UNIT);
        rtl8xxxu_write8(priv, REG_NAV_UPPER, val8);
 
-       if (priv->rtlchip == 0x8723a) {
+       if (priv->rtl_chip == RTL8723A) {
                /*
                 * 2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test,
                 * but we need to find root cause.
@@ -8378,7 +8895,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
                dev_info(&udev->dev, "Enabling HT_20_40 on the 2.4GHz band\n");
                sband->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
        }
-       hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband;
+       hw->wiphy->bands[NL80211_BAND_2GHZ] = sband;
 
        hw->wiphy->rts_threshold = 2347;
 
@@ -8452,6 +8969,7 @@ static struct rtl8xxxu_fileops rtl8723au_fops = {
        .adda_1t_path_on = 0x0bdb25a0,
        .adda_2t_path_on_a = 0x04db25a4,
        .adda_2t_path_on_b = 0x0b1b25a4,
+       .mactable = rtl8723a_mac_init_table,
 };
 
 static struct rtl8xxxu_fileops rtl8723bu_fops = {
@@ -8481,6 +8999,7 @@ static struct rtl8xxxu_fileops rtl8723bu_fops = {
        .adda_1t_path_on = 0x01c00014,
        .adda_2t_path_on_a = 0x01c00014,
        .adda_2t_path_on_b = 0x01c00014,
+       .mactable = rtl8723b_mac_init_table,
 };
 
 #ifdef CONFIG_RTL8XXXU_UNTESTED
@@ -8508,6 +9027,7 @@ static struct rtl8xxxu_fileops rtl8192cu_fops = {
        .adda_1t_path_on = 0x0bdb25a0,
        .adda_2t_path_on_a = 0x04db25a4,
        .adda_2t_path_on_b = 0x0b1b25a4,
+       .mactable = rtl8723a_mac_init_table,
 };
 
 #endif
@@ -8525,17 +9045,18 @@ static struct rtl8xxxu_fileops rtl8192eu_fops = {
        .enable_rf = rtl8723b_enable_rf,
        .disable_rf = rtl8723b_disable_rf,
        .set_tx_power = rtl8723b_set_tx_power,
-       .update_rate_mask = rtl8723au_update_rate_mask,
-       .report_connect = rtl8723au_report_connect,
+       .update_rate_mask = rtl8723bu_update_rate_mask,
+       .report_connect = rtl8723bu_report_connect,
        .writeN_block_size = 128,
        .mbox_ext_reg = REG_HMBOX_EXT0_8723B,
        .mbox_ext_width = 4,
-       .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
+       .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
        .has_s0s1 = 1,
        .adda_1t_init = 0x0fc01616,
        .adda_1t_path_on = 0x0fc01616,
        .adda_2t_path_on_a = 0x0fc01616,
        .adda_2t_path_on_b = 0x0fc01616,
+       .mactable = rtl8192e_mac_init_table,
 };
 
 static struct usb_device_id dev_table[] = {