mac80211: brcmfmac: backport remaining patches from the Linux 5.0
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / brcm / 329-v5.0-0002-brcmfmac-set-F2-watermark-to-256-for-4373.patch
1 From e1a08730eeb0bad4d82c3bc40e74854872de618d Mon Sep 17 00:00:00 2001
2 From: Wright Feng <wright.feng@cypress.com>
3 Date: Wed, 21 Nov 2018 07:53:44 +0000
4 Subject: [PATCH] brcmfmac: set F2 watermark to 256 for 4373
5
6 We got SDIO_CRC_ERROR with 4373 on SDR104 when doing bi-directional
7 throughput test. Enable watermark to 256 to guarantee the operation
8 stability.
9
10 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
11 Signed-off-by: Wright Feng <wright.feng@cypress.com>
12 Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15 .../broadcom/brcm80211/brcmfmac/sdio.c | 26 +++++++++++++++++--
16 1 file changed, 24 insertions(+), 2 deletions(-)
17
18 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
19 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
20 @@ -49,6 +49,10 @@
21 #define DCMD_RESP_TIMEOUT msecs_to_jiffies(2500)
22 #define CTL_DONE_TIMEOUT msecs_to_jiffies(2500)
23
24 +/* watermark expressed in number of words */
25 +#define DEFAULT_F2_WATERMARK 0x8
26 +#define CY_4373_F2_WATERMARK 0x40
27 +
28 #ifdef DEBUG
29
30 #define BRCMF_TRAP_INFO_SIZE 80
31 @@ -138,6 +142,8 @@ struct rte_console {
32 /* 1: isolate internal sdio signals, put external pads in tri-state; requires
33 * sdio bus power cycle to clear (rev 9) */
34 #define SBSDIO_DEVCTL_PADS_ISO 0x08
35 +/* 1: enable F2 Watermark */
36 +#define SBSDIO_DEVCTL_F2WM_ENAB 0x10
37 /* Force SD->SB reset mapping (rev 11) */
38 #define SBSDIO_DEVCTL_SB_RST_CTL 0x30
39 /* Determined by CoreControl bit */
40 @@ -4046,6 +4052,7 @@ static void brcmf_sdio_firmware_callback
41 void *nvram;
42 u32 nvram_len;
43 u8 saveclk;
44 + u8 devctl;
45
46 brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
47
48 @@ -4101,8 +4108,23 @@ static void brcmf_sdio_firmware_callback
49 brcmf_sdiod_writel(sdiod, core->base + SD_REG(hostintmask),
50 bus->hostintmask, NULL);
51
52 -
53 - brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK, 8, &err);
54 + switch (sdiod->func1->device) {
55 + case SDIO_DEVICE_ID_CYPRESS_4373:
56 + brcmf_dbg(INFO, "set F2 watermark to 0x%x*4 bytes\n",
57 + CY_4373_F2_WATERMARK);
58 + brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
59 + CY_4373_F2_WATERMARK, &err);
60 + devctl = brcmf_sdiod_readb(sdiod, SBSDIO_DEVICE_CTL,
61 + &err);
62 + devctl |= SBSDIO_DEVCTL_F2WM_ENAB;
63 + brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
64 + &err);
65 + break;
66 + default:
67 + brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
68 + DEFAULT_F2_WATERMARK, &err);
69 + break;
70 + }
71 } else {
72 /* Disable F2 again */
73 sdio_disable_func(sdiod->func2);