1 From 35cb51b2162a1a7c5cd977f92595e60ab14d3b22 Mon Sep 17 00:00:00 2001
2 From: Chi-Hsien Lin <Chi-Hsien.Lin@cypress.com>
3 Date: Wed, 21 Nov 2018 07:53:47 +0000
4 Subject: [PATCH] brcmfmac: add support for CYW43012 SDIO chipset
6 CYW43012 is a 1x1 802.11a/b/g/n Dual-Band HT20, 256-QAM/Turbo QAM. It
7 is an Ultra Low Power WLAN+BT combo chip.
9 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
10 Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
11 Signed-off-by: Praveen Babu C <praveen.chandran@cypress.com>
12 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 .../broadcom/brcm80211/brcmfmac/bcmsdh.c | 1 +
15 .../broadcom/brcm80211/brcmfmac/chip.c | 14 +++-
16 .../broadcom/brcm80211/brcmfmac/sdio.c | 74 ++++++++++++++++---
17 .../broadcom/brcm80211/include/brcm_hw_ids.h | 1 +
18 include/linux/mmc/sdio_ids.h | 1 +
19 5 files changed, 78 insertions(+), 13 deletions(-)
21 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
22 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
23 @@ -970,6 +970,7 @@ static const struct sdio_device_id brcmf
24 BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4354),
25 BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4356),
26 BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_CYPRESS_4373),
27 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_CYPRESS_43012),
28 { /* end: all zeroes */ }
30 MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
31 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
32 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
33 @@ -165,6 +165,7 @@ struct sbconfig {
34 #define SRCI_LSS_MASK 0x00f00000
35 #define SRCI_LSS_SHIFT 20
36 #define SRCI_SRNB_MASK 0xf0
37 +#define SRCI_SRNB_MASK_EXT 0x100
38 #define SRCI_SRNB_SHIFT 4
39 #define SRCI_SRBSZ_MASK 0xf
40 #define SRCI_SRBSZ_SHIFT 0
41 @@ -592,7 +593,13 @@ static void brcmf_chip_socram_ramsize(st
43 *ramsize += (1 << ((lss - 1) + SR_BSZ_BASE));
45 - nb = (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
46 + /* length of SRAM Banks increased for corerev greater than 23 */
47 + if (sr->pub.rev >= 23) {
48 + nb = (coreinfo & (SRCI_SRNB_MASK | SRCI_SRNB_MASK_EXT))
51 + nb = (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
53 for (i = 0; i < nb; i++) {
54 retent = brcmf_chip_socram_banksize(sr, i, &banksize);
56 @@ -1356,6 +1363,11 @@ bool brcmf_chip_sr_capable(struct brcmf_
57 addr = CORE_CC_REG(base, sr_control1);
58 reg = chip->ops->read32(chip->ctx, addr);
60 + case CY_CC_43012_CHIP_ID:
61 + addr = CORE_CC_REG(pmu->base, retention_ctl);
62 + reg = chip->ops->read32(chip->ctx, addr);
63 + return (reg & (PMU_RCTL_MACPHY_DISABLE_MASK |
64 + PMU_RCTL_LOGIC_DISABLE_MASK)) == 0;
66 addr = CORE_CC_REG(pmu->base, pmucapabilities_ext);
67 reg = chip->ops->read32(chip->ctx, addr);
68 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
69 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
70 @@ -624,6 +624,7 @@ BRCMF_FW_DEF(43455, "brcmfmac43455-sdio"
71 BRCMF_FW_DEF(4354, "brcmfmac4354-sdio");
72 BRCMF_FW_DEF(4356, "brcmfmac4356-sdio");
73 BRCMF_FW_DEF(4373, "brcmfmac4373-sdio");
74 +BRCMF_FW_DEF(43012, "brcmfmac43012-sdio");
76 static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
77 BRCMF_FW_ENTRY(BRCM_CC_43143_CHIP_ID, 0xFFFFFFFF, 43143),
78 @@ -643,7 +644,8 @@ static const struct brcmf_firmware_mappi
79 BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFFFFFC0, 43455),
80 BRCMF_FW_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354),
81 BRCMF_FW_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
82 - BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0xFFFFFFFF, 4373)
83 + BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0xFFFFFFFF, 4373),
84 + BRCMF_FW_ENTRY(CY_CC_43012_CHIP_ID, 0xFFFFFFFF, 43012)
87 static void pkt_align(struct sk_buff *p, int len, int align)
88 @@ -683,6 +685,14 @@ brcmf_sdio_kso_control(struct brcmf_sdio
89 /* 1st KSO write goes to AOS wake up core if device is asleep */
90 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err);
92 + /* In case of 43012 chip, the chip could go down immediately after
93 + * KSO bit is cleared. So the further reads of KSO register could
94 + * fail. Thereby just bailing out immediately after clearing KSO
95 + * bit, to avoid polling of KSO bit.
97 + if (!on && bus->ci->chip == CY_CC_43012_CHIP_ID)
101 /* device WAKEUP through KSO:
102 * write bit 0 & read back until
103 @@ -2416,6 +2426,14 @@ static int brcmf_sdio_tx_ctrlframe(struc
107 +static bool brcmf_chip_is_ulp(struct brcmf_chip *ci)
109 + if (ci->chip == CY_CC_43012_CHIP_ID)
115 static void brcmf_sdio_bus_stop(struct device *dev)
117 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
118 @@ -2423,7 +2441,7 @@ static void brcmf_sdio_bus_stop(struct d
119 struct brcmf_sdio *bus = sdiodev->bus;
120 struct brcmf_core *core = bus->sdio_core;
121 u32 local_hostintmask;
126 brcmf_dbg(TRACE, "Enter\n");
127 @@ -2450,9 +2468,14 @@ static void brcmf_sdio_bus_stop(struct d
128 /* Force backplane clocks to assure F2 interrupt propagates */
129 saveclk = brcmf_sdiod_readb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
132 - brcmf_sdiod_writeb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
133 - (saveclk | SBSDIO_FORCE_HT), &err);
136 + bpreq |= brcmf_chip_is_ulp(bus->ci) ?
137 + SBSDIO_HT_AVAIL_REQ : SBSDIO_FORCE_HT;
138 + brcmf_sdiod_writeb(sdiodev,
139 + SBSDIO_FUNC1_CHIPCLKCSR,
143 brcmf_err("Failed to force clock for F2: err %d\n",
145 @@ -3345,20 +3368,45 @@ err:
149 +static bool brcmf_sdio_aos_no_decode(struct brcmf_sdio *bus)
151 + if (bus->ci->chip == CY_CC_43012_CHIP_ID)
157 static void brcmf_sdio_sr_init(struct brcmf_sdio *bus)
165 brcmf_dbg(TRACE, "Enter\n");
167 + if (brcmf_chip_is_ulp(bus->ci)) {
168 + wakeupctrl = SBSDIO_FUNC1_WCTRL_ALPWAIT_SHIFT;
169 + chipclkcsr = SBSDIO_HT_AVAIL_REQ;
171 + wakeupctrl = SBSDIO_FUNC1_WCTRL_HTWAIT_SHIFT;
172 + chipclkcsr = SBSDIO_FORCE_HT;
175 + if (brcmf_sdio_aos_no_decode(bus)) {
176 + cardcap = SDIO_CCCR_BRCM_CARDCAP_CMD_NODEC;
178 + cardcap = (SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT |
179 + SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT);
182 val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_WAKEUPCTRL, &err);
184 brcmf_err("error reading SBSDIO_FUNC1_WAKEUPCTRL\n");
188 - val |= 1 << SBSDIO_FUNC1_WCTRL_HTWAIT_SHIFT;
189 + val |= 1 << wakeupctrl;
190 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_WAKEUPCTRL, val, &err);
192 brcmf_err("error writing SBSDIO_FUNC1_WAKEUPCTRL\n");
193 @@ -3367,8 +3415,7 @@ static void brcmf_sdio_sr_init(struct br
195 /* Add CMD14 Support */
196 brcmf_sdiod_func0_wb(bus->sdiodev, SDIO_CCCR_BRCM_CARDCAP,
197 - (SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT |
198 - SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT),
202 brcmf_err("error writing SDIO_CCCR_BRCM_CARDCAP\n");
203 @@ -3376,7 +3423,7 @@ static void brcmf_sdio_sr_init(struct br
206 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
207 - SBSDIO_FORCE_HT, &err);
210 brcmf_err("error writing SBSDIO_FUNC1_CHIPCLKCSR\n");
212 @@ -4067,7 +4114,7 @@ static void brcmf_sdio_firmware_callback
213 const struct firmware *code;
220 brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
221 @@ -4101,8 +4148,11 @@ static void brcmf_sdio_firmware_callback
222 /* Force clocks on backplane to be sure F2 interrupt propagates */
223 saveclk = brcmf_sdiod_readb(sdiod, SBSDIO_FUNC1_CHIPCLKCSR, &err);
226 + bpreq |= brcmf_chip_is_ulp(bus->ci) ?
227 + SBSDIO_HT_AVAIL_REQ : SBSDIO_FORCE_HT;
228 brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_CHIPCLKCSR,
229 - (saveclk | SBSDIO_FORCE_HT), &err);
233 brcmf_err("Failed to force clock for F2: err %d\n", err);
234 --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
235 +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
237 #define BRCM_CC_43664_CHIP_ID 43664
238 #define BRCM_CC_4371_CHIP_ID 0x4371
239 #define CY_CC_4373_CHIP_ID 0x4373
240 +#define CY_CC_43012_CHIP_ID 43012
243 #define BRCM_USB_43143_DEVICE_ID 0xbd1e
244 --- a/include/linux/mmc/sdio_ids.h
245 +++ b/include/linux/mmc/sdio_ids.h
247 #define SDIO_DEVICE_ID_BROADCOM_4354 0x4354
248 #define SDIO_DEVICE_ID_BROADCOM_4356 0x4356
249 #define SDIO_DEVICE_ID_CYPRESS_4373 0x4373
250 +#define SDIO_DEVICE_ID_CYPRESS_43012 43012
252 #define SDIO_VENDOR_ID_INTEL 0x0089
253 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402