mac80211: use wiphy_read_of_freq_limits in brcmfmac
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 653-0047-rtl8xxxu-Implement-rtl8188eu_active_to_emu.patch
1 From b3edeceb7c8c3b0eb70b26e3237afa5086afe8ed Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Fri, 26 Aug 2016 15:16:32 -0400
4 Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_active_to_emu()
5
6 Per the vendor driver's sequence table, this seems to be the correct
7 way to disable RF on the 8188eu, even if the driver doesn't actually
8 call the sequence by itself.
9
10 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
11 ---
12 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 38 ++++++++++++++++++++++
13 1 file changed, 38 insertions(+)
14
15 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
16 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
17 @@ -1155,6 +1155,42 @@ exit:
18 return ret;
19 }
20
21 +static int rtl8188eu_active_to_emu(struct rtl8xxxu_priv *priv)
22 +{
23 + u8 val8;
24 + int count, ret = 0;
25 +
26 + /* Turn off RF */
27 + rtl8xxxu_write8(priv, REG_RF_CTRL, 0);
28 +
29 + /* LDO Sleep mode */
30 + val8 = rtl8xxxu_read8(priv, REG_LPLDO_CTRL);
31 + val8 |= BIT(4);
32 + rtl8xxxu_write8(priv, REG_LPLDO_CTRL, val8);
33 +
34 + /* 0x0005[1] = 1 turn off MAC by HW state machine*/
35 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
36 + val8 |= BIT(1);
37 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8);
38 +
39 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) {
40 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1);
41 + if ((val8 & BIT(1)) == 0)
42 + break;
43 + udelay(10);
44 + }
45 +
46 + if (!count) {
47 + dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n",
48 + __func__);
49 + ret = -EBUSY;
50 + goto exit;
51 + }
52 +
53 +exit:
54 + return ret;
55 +}
56 +
57 static int rtl8188eu_power_on(struct rtl8xxxu_priv *priv)
58 {
59 u16 val16;
60 @@ -1202,6 +1238,8 @@ static void rtl8188e_disable_rf(struct r
61 rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0);
62 if (priv->rf_paths == 2)
63 rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_AC, 0);
64 +
65 + rtl8188eu_active_to_emu(priv);
66 }
67
68 static void rtl8188e_usb_quirks(struct rtl8xxxu_priv *priv)