hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/bcmsdh_sdmmc.c
....@@ -83,8 +83,18 @@
8383 #endif /* !defined(OOB_INTR_ONLY) */
8484 static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, uint32 regaddr);
8585 #if defined(ENABLE_INSMOD_NO_FW_LOAD) && !defined(BUS_POWER_RESTORE)
86
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) && defined(MMC_SW_RESET)
86
+#if defined(MMC_SW_RESET) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
87
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
88
+extern int mmc_sw_reset(struct mmc_card *card);
89
+#else
8790 extern int mmc_sw_reset(struct mmc_host *host);
91
+#endif
92
+#elif defined(MMC_HW_RESET) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
93
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
94
+extern int mmc_hw_reset(struct mmc_card *card);
95
+#else
96
+extern int mmc_hw_reset(struct mmc_host *host);
97
+#endif
8898 #else
8999 extern int sdio_reset_comm(struct mmc_card *card);
90100 #endif
....@@ -184,7 +194,7 @@
184194 err_ret = sdio_enable_func(sd->func[1]);
185195 sdio_release_host(sd->func[1]);
186196 if (err_ret) {
187
- sd_err(("bcmsdh_sdmmc: Failed to enable F1 Err: 0x%08x\n", err_ret));
197
+ sd_err(("bcmsdh_sdmmc: Failed to enable F1 Err: %d\n", err_ret));
188198 }
189199
190200 return FALSE;
....@@ -1222,7 +1232,7 @@
12221232 if (err_ret)
12231233 #endif /* MMC_SDIO_ABORT */
12241234 {
1225
- sd_err(("bcmsdh_sdmmc: Failed to %s word F%d:@0x%05x=%02x, Err: 0x%08x\n",
1235
+ sd_err(("bcmsdh_sdmmc: Failed to %s word F%d:@0x%05x=%02x, Err: %d\n",
12261236 rw ? "Write" : "Read", func, addr, *word, err_ret));
12271237 }
12281238 }
....@@ -1772,18 +1782,37 @@
17721782 #if defined(ENABLE_INSMOD_NO_FW_LOAD) && !defined(BUS_POWER_RESTORE)
17731783 static int sdio_sw_reset(sdioh_info_t *sd)
17741784 {
1775
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) && defined(MMC_SW_RESET)
1776
- struct mmc_host *host = sd->func[0]->card->host;
1777
-#endif
1785
+ struct mmc_card *card = sd->func[0]->card;
17781786 int err = 0;
17791787
1780
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) && defined(MMC_SW_RESET)
1781
- printf("%s: Enter\n", __FUNCTION__);
1788
+#if defined(MMC_SW_RESET) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
1789
+ /* MMC_SW_RESET */
1790
+ printf("%s: call mmc_sw_reset\n", __FUNCTION__);
17821791 sdio_claim_host(sd->func[0]);
1783
- err = mmc_sw_reset(host);
1792
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
1793
+ err = mmc_sw_reset(card);
1794
+#else
1795
+ err = mmc_sw_reset(card->host);
1796
+#endif
1797
+ sdio_release_host(sd->func[0]);
1798
+#elif defined(MMC_HW_RESET) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
1799
+ /* MMC_HW_RESET */
1800
+ printf("%s: call mmc_hw_reset\n", __FUNCTION__);
1801
+ sdio_claim_host(sd->func[0]);
1802
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
1803
+ while (atomic_read(&card->sdio_funcs_probed) > 1) {
1804
+ atomic_dec(&card->sdio_funcs_probed);
1805
+ }
1806
+#endif
1807
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
1808
+ err = mmc_hw_reset(card);
1809
+#else
1810
+ err = mmc_hw_reset(card->host);
1811
+#endif
17841812 sdio_release_host(sd->func[0]);
17851813 #else
1786
- err = sdio_reset_comm(sd->func[0]->card);
1814
+ /* sdio_reset_comm */
1815
+ err = sdio_reset_comm(card);
17871816 #endif
17881817
17891818 if (err)