forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/mmc/host/via-sdmmc.c
....@@ -1,11 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * drivers/mmc/host/via-sdmmc.c - VIA SD/MMC Card Reader driver
34 * Copyright (c) 2008, VIA Technologies Inc. All Rights Reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or (at
8
- * your option) any later version.
95 */
106
117 #include <linux/pci.h>
....@@ -691,7 +687,6 @@
691687 via_sdc_send_command(host, mrq->cmd);
692688 }
693689
694
- mmiowb();
695690 spin_unlock_irqrestore(&host->lock, flags);
696691 }
697692
....@@ -716,7 +711,6 @@
716711 gatt &= ~VIA_CRDR_PCICLKGATT_PAD_PWRON;
717712 writeb(gatt, host->pcictrl_mmiobase + VIA_CRDR_PCICLKGATT);
718713
719
- mmiowb();
720714 spin_unlock_irqrestore(&host->lock, flags);
721715
722716 via_pwron_sleep(host);
....@@ -775,7 +769,6 @@
775769 if (readb(addrbase + VIA_CRDR_PCISDCCLK) != clock)
776770 writeb(clock, addrbase + VIA_CRDR_PCISDCCLK);
777771
778
- mmiowb();
779772 spin_unlock_irqrestore(&host->lock, flags);
780773
781774 if (ios->power_mode != MMC_POWER_OFF)
....@@ -835,7 +828,6 @@
835828 via_restore_pcictrlreg(host);
836829 via_restore_sdcreg(host);
837830
838
- mmiowb();
839831 spin_unlock_irqrestore(&host->lock, flags);
840832 }
841833
....@@ -933,7 +925,6 @@
933925
934926 result = IRQ_HANDLED;
935927
936
- mmiowb();
937928 out:
938929 spin_unlock(&sdhost->lock);
939930
....@@ -968,7 +959,6 @@
968959 }
969960 }
970961
971
- mmiowb();
972962 spin_unlock_irqrestore(&sdhost->lock, flags);
973963 }
974964
....@@ -1020,7 +1010,6 @@
10201010 tasklet_schedule(&host->finish_tasklet);
10211011 }
10221012
1023
- mmiowb();
10241013 spin_unlock_irqrestore(&host->lock, flags);
10251014
10261015 via_reset_pcictrl(host);
....@@ -1028,7 +1017,6 @@
10281017 spin_lock_irqsave(&host->lock, flags);
10291018 }
10301019
1031
- mmiowb();
10321020 spin_unlock_irqrestore(&host->lock, flags);
10331021
10341022 via_print_pcictrl(host);
....@@ -1126,7 +1114,7 @@
11261114
11271115 len = pci_resource_len(pcidev, 0);
11281116 base = pci_resource_start(pcidev, 0);
1129
- sdhost->mmiobase = ioremap_nocache(base, len);
1117
+ sdhost->mmiobase = ioremap(base, len);
11301118 if (!sdhost->mmiobase) {
11311119 ret = -ENOMEM;
11321120 goto free_mmc_host;
....@@ -1166,7 +1154,9 @@
11661154 pcidev->subsystem_device == 0x3891)
11671155 sdhost->quirks = VIA_CRDR_QUIRK_300MS_PWRDELAY;
11681156
1169
- mmc_add_host(mmc);
1157
+ ret = mmc_add_host(mmc);
1158
+ if (ret)
1159
+ goto unmap;
11701160
11711161 return 0;
11721162
....@@ -1196,7 +1186,6 @@
11961186
11971187 /* Disable generating further interrupts */
11981188 writeb(0x0, sdhost->pcictrl_mmiobase + VIA_CRDR_PCIINTCTRL);
1199
- mmiowb();
12001189
12011190 if (sdhost->mrq) {
12021191 pr_err("%s: Controller removed during "
....@@ -1205,7 +1194,6 @@
12051194 /* make sure all DMA is stopped */
12061195 writel(VIA_CRDR_DMACTRL_SFTRST,
12071196 sdhost->ddma_mmiobase + VIA_CRDR_DMACTRL);
1208
- mmiowb();
12091197 sdhost->mrq->cmd->error = -ENOMEDIUM;
12101198 if (sdhost->mrq->stop)
12111199 sdhost->mrq->stop->error = -ENOMEDIUM;
....@@ -1237,9 +1225,7 @@
12371225 pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device);
12381226 }
12391227
1240
-#ifdef CONFIG_PM
1241
-
1242
-static void via_init_sdc_pm(struct via_crdr_mmc_host *host)
1228
+static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host)
12431229 {
12441230 struct sdhcreg *pm_sdhcreg;
12451231 void __iomem *addrbase;
....@@ -1273,33 +1259,30 @@
12731259 via_print_sdchc(host);
12741260 }
12751261
1276
-static int via_sd_suspend(struct pci_dev *pcidev, pm_message_t state)
1262
+static int __maybe_unused via_sd_suspend(struct device *dev)
12771263 {
12781264 struct via_crdr_mmc_host *host;
12791265 unsigned long flags;
12801266
1281
- host = pci_get_drvdata(pcidev);
1267
+ host = dev_get_drvdata(dev);
12821268
12831269 spin_lock_irqsave(&host->lock, flags);
12841270 via_save_pcictrlreg(host);
12851271 via_save_sdcreg(host);
12861272 spin_unlock_irqrestore(&host->lock, flags);
12871273
1288
- pci_save_state(pcidev);
1289
- pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0);
1290
- pci_disable_device(pcidev);
1291
- pci_set_power_state(pcidev, pci_choose_state(pcidev, state));
1274
+ device_wakeup_enable(dev);
12921275
12931276 return 0;
12941277 }
12951278
1296
-static int via_sd_resume(struct pci_dev *pcidev)
1279
+static int __maybe_unused via_sd_resume(struct device *dev)
12971280 {
12981281 struct via_crdr_mmc_host *sdhost;
12991282 int ret = 0;
13001283 u8 gatt;
13011284
1302
- sdhost = pci_get_drvdata(pcidev);
1285
+ sdhost = dev_get_drvdata(dev);
13031286
13041287 gatt = VIA_CRDR_PCICLKGATT_PAD_PWRON;
13051288 if (sdhost->power == MMC_VDD_165_195)
....@@ -1314,32 +1297,20 @@
13141297
13151298 msleep(100);
13161299
1317
- pci_set_power_state(pcidev, PCI_D0);
1318
- pci_restore_state(pcidev);
1319
- ret = pci_enable_device(pcidev);
1320
- if (ret)
1321
- return ret;
1322
-
13231300 via_restore_pcictrlreg(sdhost);
13241301 via_init_sdc_pm(sdhost);
13251302
13261303 return ret;
13271304 }
13281305
1329
-#else /* CONFIG_PM */
1330
-
1331
-#define via_sd_suspend NULL
1332
-#define via_sd_resume NULL
1333
-
1334
-#endif /* CONFIG_PM */
1306
+static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume);
13351307
13361308 static struct pci_driver via_sd_driver = {
13371309 .name = DRV_NAME,
13381310 .id_table = via_ids,
13391311 .probe = via_sd_probe,
13401312 .remove = via_sd_remove,
1341
- .suspend = via_sd_suspend,
1342
- .resume = via_sd_resume,
1313
+ .driver.pm = &via_sd_pm_ops,
13431314 };
13441315
13451316 module_pci_driver(via_sd_driver);