forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmsdh_sdmmc_linux.c
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
43 *
5
- * Copyright (C) 1999-2019, Broadcom Corporation
6
- *
4
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
5
+ *
6
+ * Copyright (C) 1999-2017, Broadcom Corporation
7
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,7 +26,7 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Proprietary,Open:>>
2728 *
28
- * $Id: bcmsdh_sdmmc_linux.c 708487 2018-10-31 05:33:14Z $
29
+ * $Id: bcmsdh_sdmmc_linux.c 689795 2017-03-13 14:57:21Z $
2930 */
3031
3132 #include <typedefs.h>
....@@ -44,42 +45,13 @@
4445 #include <dhd_linux.h>
4546 #include <bcmsdh_sdmmc.h>
4647 #include <dhd_dbg.h>
47
-
48
-#ifdef LOAD_DHD_WITH_FW_ALIVE
49
-#include <dhd_chip_info.h>
50
-#endif
51
-
48
+#include <bcmdevs.h>
5249
5350 #if !defined(SDIO_VENDOR_ID_BROADCOM)
5451 #define SDIO_VENDOR_ID_BROADCOM 0x02d0
5552 #endif /* !defined(SDIO_VENDOR_ID_BROADCOM) */
5653
5754 #define SDIO_DEVICE_ID_BROADCOM_DEFAULT 0x0000
58
-
59
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB)
60
-#define SDIO_DEVICE_ID_BROADCOM_4325_SDGWB 0x0492 /* BCM94325SDGWB */
61
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) */
62
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4325)
63
-#define SDIO_DEVICE_ID_BROADCOM_4325 0x0493
64
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */
65
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4329)
66
-#define SDIO_DEVICE_ID_BROADCOM_4329 0x4329
67
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */
68
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4319)
69
-#define SDIO_DEVICE_ID_BROADCOM_4319 0x4319
70
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4319) */
71
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4330)
72
-#define SDIO_DEVICE_ID_BROADCOM_4330 0x4330
73
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4330) */
74
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4334)
75
-#define SDIO_DEVICE_ID_BROADCOM_4334 0x4334
76
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4334) */
77
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4324)
78
-#define SDIO_DEVICE_ID_BROADCOM_4324 0x4324
79
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4324) */
80
-#if !defined(SDIO_DEVICE_ID_BROADCOM_43239)
81
-#define SDIO_DEVICE_ID_BROADCOM_43239 43239
82
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_43239) */
8355
8456 extern void wl_cfg80211_set_parent_dev(void *dev);
8557 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
....@@ -113,10 +85,6 @@
11385 osl_t *osh = NULL;
11486 sdioh_info_t *sdioh = NULL;
11587
116
-#ifdef LOAD_DHD_WITH_FW_ALIVE
117
- int ready = 0;
118
-#endif
119
-
12088 sd_err(("bus num (host idx)=%d, slot num (rca)=%d\n", host_idx, rca));
12189 adapter = dhd_wifi_platform_get_adapter(SDIO_BUS, host_idx, rca);
12290 if (adapter != NULL)
....@@ -126,7 +94,7 @@
12694
12795 #ifdef WL_CFG80211
12896 wl_cfg80211_set_parent_dev(&func->dev);
129
-#endif
97
+#endif // endif
13098
13199 /* allocate SDIO Host Controller state info */
132100 osh = osl_attach(&func->dev, SDIO_BUS, TRUE);
....@@ -140,17 +108,6 @@
140108 sd_err(("%s: sdioh_attach failed\n", __FUNCTION__));
141109 goto fail;
142110 }
143
-#ifdef LOAD_DHD_WITH_FW_ALIVE
144
- sdioh_cfg_read(sdioh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, (uint8 *)&ready);
145
-
146
- sd_err(("%s, %d, ready = %08x\n", __func__, __LINE__, ready));
147
- if(ready == (SDIO_FUNC_READY_1|SDIO_FUNC_READY_2)) {
148
- alive = FW_ALIVE_MAGIC; //func->card->nr_parts;
149
- card_dev = func->card->cis.device;
150
- }
151
-
152
- sd_info(("alive = %08x, card_dev = %08x\n", alive, card_dev));
153
-#endif /* LOAD_DHD_WITH_FW_ALIVE */
154111 sdioh->bcmsdh = bcmsdh_probe(osh, &func->dev, sdioh, adapter, SDIO_BUS, host_idx, rca);
155112 if (sdioh->bcmsdh == NULL) {
156113 sd_err(("%s: bcmsdh_probe failed\n", __FUNCTION__));
....@@ -188,6 +145,7 @@
188145 extern int cis_chipvendor;
189146 extern unsigned short cis_device;
190147
148
+
191149 static int bcmsdh_sdmmc_probe(struct sdio_func *func,
192150 const struct sdio_device_id *id)
193151 {
....@@ -201,6 +159,7 @@
201159 sd_info(("sdio_vendor: 0x%04x\n", func->vendor));
202160 sd_info(("sdio_device: 0x%04x\n", func->device));
203161 sd_info(("Function#: 0x%04x\n", func->num));
162
+
204163
205164 if (func->num == 2) {
206165 struct sdio_func_tuple *tuple = func->card->tuples;
....@@ -245,16 +204,16 @@
245204 /* devices we support, null terminated */
246205 static const struct sdio_device_id bcmsdh_sdmmc_ids[] = {
247206 { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_DEFAULT) },
248
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) },
249
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325) },
250
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329) },
251
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4319) },
252
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4330) },
253
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4334) },
254
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4324) },
255
- { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_43239) },
256
- { SDIO_DEVICE_CLASS(SDIO_CLASS_NONE) },
257
- { /* end: all zeroes */ },
207
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM4362_CHIP_ID) },
208
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM43751_CHIP_ID) },
209
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM43012_CHIP_ID) },
210
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM43014_CHIP_ID) },
211
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM43014_D11N_ID) },
212
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM43014_D11N2G_ID) },
213
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM43014_D11N5G_ID) },
214
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, BCM4373_CHIP_ID) },
215
+ { SDIO_DEVICE_CLASS(SDIO_CLASS_NONE) },
216
+ { /* end: all zeroes */ },
258217 };
259218
260219 MODULE_DEVICE_TABLE(sdio, bcmsdh_sdmmc_ids);
....@@ -293,9 +252,6 @@
293252 dhd_mmc_suspend = FALSE;
294253 return err;
295254 }
296
-#if defined(OOB_INTR_ONLY)
297
- bcmsdh_oob_intr_set(sdioh->bcmsdh, FALSE);
298
-#endif
299255 smp_mb();
300256
301257 return 0;
....@@ -312,7 +268,6 @@
312268
313269 sdioh = sdio_get_drvdata(func);
314270 dhd_mmc_suspend = FALSE;
315
-
316271 bcmsdh_resume(sdioh->bcmsdh);
317272
318273 smp_mb();
....@@ -331,6 +286,18 @@
331286 static int dummy_probe(struct sdio_func *func,
332287 const struct sdio_device_id *id)
333288 {
289
+ sd_err(("%s: enter\n", __FUNCTION__));
290
+#if (0)
291
+ if (func)
292
+ sd_err(("%s: func->num=0x%x; \n", __FUNCTION__, func->num));
293
+ if (id) {
294
+ sd_err(("%s: class=0x%x; vendor=0x%x; device=0x%x\n", __FUNCTION__,
295
+ id->class, id->vendor, id->device));
296
+ if (id->vendor != SDIO_VENDOR_ID_BROADCOM)
297
+ return -ENODEV;
298
+ }
299
+#endif
300
+
334301 if (func && (func->num != 2)) {
335302 return 0;
336303 }