0a55888fd3ae04cd625692dfcf56ff709d31948f
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 657-0055-rtl8xxxu-Fix-reloading-of-driver-for-8188eu-devices.patch
1 From 8e911ff6eeeb1607dbc05d1782fd9c5cb54db068 Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Wed, 14 Sep 2016 14:10:42 -0400
4 Subject: [PATCH] rtl8xxxu: Fix reloading of driver for 8188eu devices
5
6 For 8188eu, once the MAC is asked to power down by setting
7 APS_FSMCO_MAC_OFF, there seems to be no way to bring it back to life.
8
9 In addition, only disable RF_ENABLE in RF_CTRL rather than all bits.
10
11 This was spotted by Andrea Merello who noticed that if we dropped the
12 call to rtl8188eu_active_to_emu() reloading started working.
13
14 Reported-by: Andrea Merello <andrea.merello@gmail.com>
15 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
16 ---
17 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 29 +++++-----------------
18 1 file changed, 6 insertions(+), 23 deletions(-)
19
20 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
21 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
22 @@ -1160,37 +1160,18 @@ exit:
23 static int rtl8188eu_active_to_emu(struct rtl8xxxu_priv *priv)
24 {
25 u8 val8;
26 - int count, ret = 0;
27
28 /* Turn off RF */
29 - rtl8xxxu_write8(priv, REG_RF_CTRL, 0);
30 + val8 = rtl8xxxu_read8(priv, REG_RF_CTRL);
31 + val8 &= ~RF_ENABLE;
32 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8);
33
34 /* LDO Sleep mode */
35 val8 = rtl8xxxu_read8(priv, REG_LPLDO_CTRL);
36 val8 |= BIT(4);
37 rtl8xxxu_write8(priv, REG_LPLDO_CTRL, val8);
38
39 - /* 0x0005[1] = 1 turn off MAC by HW state machine*/
40 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
41 - val8 |= BIT(1);
42 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8);
43 -
44 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) {
45 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
46 - if ((val8 & BIT(1)) == 0)
47 - break;
48 - udelay(10);
49 - }
50 -
51 - if (!count) {
52 - dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n",
53 - __func__);
54 - ret = -EBUSY;
55 - goto exit;
56 - }
57 -
58 -exit:
59 - return ret;
60 + return 0;
61 }
62
63 static int rtl8188eu_emu_to_disabled(struct rtl8xxxu_priv *priv)
64 @@ -1372,6 +1353,8 @@ void rtl8188eu_power_off(struct rtl8xxxu
65
66 static void rtl8188e_enable_rf(struct rtl8xxxu_priv *priv)
67 {
68 + rtl8xxxu_write8(priv, REG_RF_CTRL, RF_ENABLE | RF_RSTB | RF_SDMRSTB);
69 +
70 rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00);
71 }
72