37ba7f360b3eb0328b084a9725d0732037fffccd
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / brcm / 114-v5.6-0002-brcmfmac-set-F2-blocksize-and-watermark-for-4359.patch
1 From 172f6854551d48d1c9530f84513b421db944e714 Mon Sep 17 00:00:00 2001
2 From: Chung-Hsien Hsu <stanley.hsu@cypress.com>
3 Date: Thu, 12 Dec 2019 00:52:46 +0100
4 Subject: [PATCH 2/7] brcmfmac: set F2 blocksize and watermark for 4359
5
6 Set F2 blocksize to 256 bytes and watermark to 0x40 for 4359. Also
7 enable and configure F1 MesBusyCtrl. It fixes DMA error while having
8 UDP bi-directional traffic.
9
10 Signed-off-by: Chung-Hsien Hsu <stanley.hsu@cypress.com>
11 [slightly adapted for rebase on mainline linux]
12 Signed-off-by: Soeren Moch <smoch@web.de>
13 Reviewed-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 6 +++++-
17 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 15 +++++++++++++++
18 2 files changed, 20 insertions(+), 1 deletion(-)
19
20 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
21 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
22 @@ -43,6 +43,7 @@
23
24 #define SDIO_FUNC1_BLOCKSIZE 64
25 #define SDIO_FUNC2_BLOCKSIZE 512
26 +#define SDIO_4359_FUNC2_BLOCKSIZE 256
27 /* Maximum milliseconds to wait for F2 to come up */
28 #define SDIO_WAIT_F2RDY 3000
29
30 @@ -903,6 +904,7 @@ static void brcmf_sdiod_host_fixup(struc
31 static int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev)
32 {
33 int ret = 0;
34 + unsigned int f2_blksz = SDIO_FUNC2_BLOCKSIZE;
35
36 sdio_claim_host(sdiodev->func1);
37
38 @@ -912,7 +914,9 @@ static int brcmf_sdiod_probe(struct brcm
39 sdio_release_host(sdiodev->func1);
40 goto out;
41 }
42 - ret = sdio_set_block_size(sdiodev->func2, SDIO_FUNC2_BLOCKSIZE);
43 + if (sdiodev->func2->device == SDIO_DEVICE_ID_BROADCOM_4359)
44 + f2_blksz = SDIO_4359_FUNC2_BLOCKSIZE;
45 + ret = sdio_set_block_size(sdiodev->func2, f2_blksz);
46 if (ret) {
47 brcmf_err("Failed to set F2 blocksize\n");
48 sdio_release_host(sdiodev->func1);
49 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
50 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
51 @@ -42,6 +42,8 @@
52 #define DEFAULT_F2_WATERMARK 0x8
53 #define CY_4373_F2_WATERMARK 0x40
54 #define CY_43012_F2_WATERMARK 0x60
55 +#define CY_4359_F2_WATERMARK 0x40
56 +#define CY_4359_F1_MESBUSYCTRL (CY_4359_F2_WATERMARK | SBSDIO_MESBUSYCTRL_ENAB)
57
58 #ifdef DEBUG
59
60 @@ -4208,6 +4210,19 @@ static void brcmf_sdio_firmware_callback
61 brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
62 &err);
63 break;
64 + case SDIO_DEVICE_ID_BROADCOM_4359:
65 + brcmf_dbg(INFO, "set F2 watermark to 0x%x*4 bytes\n",
66 + CY_4359_F2_WATERMARK);
67 + brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
68 + CY_4359_F2_WATERMARK, &err);
69 + devctl = brcmf_sdiod_readb(sdiod, SBSDIO_DEVICE_CTL,
70 + &err);
71 + devctl |= SBSDIO_DEVCTL_F2WM_ENAB;
72 + brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
73 + &err);
74 + brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_MESBUSYCTRL,
75 + CY_4359_F1_MESBUSYCTRL, &err);
76 + break;
77 default:
78 brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
79 DEFAULT_F2_WATERMARK, &err);