sdhci-acpi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * Secure Digital Host Controller Interface ACPI driver.
  3. *
  4. * Copyright (c) 2012, Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. */
  20. #include <linux/init.h>
  21. #include <linux/export.h>
  22. #include <linux/module.h>
  23. #include <linux/device.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/ioport.h>
  26. #include <linux/io.h>
  27. #include <linux/dma-mapping.h>
  28. #include <linux/compiler.h>
  29. #include <linux/stddef.h>
  30. #include <linux/bitops.h>
  31. #include <linux/types.h>
  32. #include <linux/err.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/acpi.h>
  35. #include <linux/pm.h>
  36. #include <linux/pm_runtime.h>
  37. #include <linux/delay.h>
  38. #include <linux/mmc/host.h>
  39. #include <linux/mmc/pm.h>
  40. #include <linux/mmc/slot-gpio.h>
  41. #ifdef CONFIG_X86
  42. #include <asm/cpu_device_id.h>
  43. #include <asm/intel-family.h>
  44. #include <asm/iosf_mbi.h>
  45. #include <linux/pci.h>
  46. #endif
  47. #include "sdhci.h"
  48. enum {
  49. SDHCI_ACPI_SD_CD = BIT(0),
  50. SDHCI_ACPI_RUNTIME_PM = BIT(1),
  51. SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL = BIT(2),
  52. };
  53. struct sdhci_acpi_chip {
  54. const struct sdhci_ops *ops;
  55. unsigned int quirks;
  56. unsigned int quirks2;
  57. unsigned long caps;
  58. unsigned int caps2;
  59. mmc_pm_flag_t pm_caps;
  60. };
  61. struct sdhci_acpi_slot {
  62. const struct sdhci_acpi_chip *chip;
  63. unsigned int quirks;
  64. unsigned int quirks2;
  65. unsigned long caps;
  66. unsigned int caps2;
  67. mmc_pm_flag_t pm_caps;
  68. unsigned int flags;
  69. int (*probe_slot)(struct platform_device *, const char *, const char *);
  70. int (*remove_slot)(struct platform_device *);
  71. };
  72. struct sdhci_acpi_host {
  73. struct sdhci_host *host;
  74. const struct sdhci_acpi_slot *slot;
  75. struct platform_device *pdev;
  76. bool use_runtime_pm;
  77. };
  78. static inline bool sdhci_acpi_flag(struct sdhci_acpi_host *c, unsigned int flag)
  79. {
  80. return c->slot && (c->slot->flags & flag);
  81. }
  82. static void sdhci_acpi_int_hw_reset(struct sdhci_host *host)
  83. {
  84. u8 reg;
  85. reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
  86. reg |= 0x10;
  87. sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
  88. /* For eMMC, minimum is 1us but give it 9us for good measure */
  89. udelay(9);
  90. reg &= ~0x10;
  91. sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
  92. /* For eMMC, minimum is 200us but give it 300us for good measure */
  93. usleep_range(300, 1000);
  94. }
  95. static const struct sdhci_ops sdhci_acpi_ops_dflt = {
  96. .set_clock = sdhci_set_clock,
  97. .set_bus_width = sdhci_set_bus_width,
  98. .reset = sdhci_reset,
  99. .set_uhs_signaling = sdhci_set_uhs_signaling,
  100. };
  101. static const struct sdhci_ops sdhci_acpi_ops_int = {
  102. .set_clock = sdhci_set_clock,
  103. .set_bus_width = sdhci_set_bus_width,
  104. .reset = sdhci_reset,
  105. .set_uhs_signaling = sdhci_set_uhs_signaling,
  106. .hw_reset = sdhci_acpi_int_hw_reset,
  107. };
  108. static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
  109. .ops = &sdhci_acpi_ops_int,
  110. };
  111. #ifdef CONFIG_X86
  112. static bool sdhci_acpi_byt(void)
  113. {
  114. static const struct x86_cpu_id byt[] = {
  115. { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
  116. {}
  117. };
  118. return x86_match_cpu(byt);
  119. }
  120. static bool sdhci_acpi_cht(void)
  121. {
  122. static const struct x86_cpu_id cht[] = {
  123. { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
  124. {}
  125. };
  126. return x86_match_cpu(cht);
  127. }
  128. #define BYT_IOSF_SCCEP 0x63
  129. #define BYT_IOSF_OCP_NETCTRL0 0x1078
  130. #define BYT_IOSF_OCP_TIMEOUT_BASE GENMASK(10, 8)
  131. static void sdhci_acpi_byt_setting(struct device *dev)
  132. {
  133. u32 val = 0;
  134. if (!sdhci_acpi_byt())
  135. return;
  136. if (iosf_mbi_read(BYT_IOSF_SCCEP, MBI_CR_READ, BYT_IOSF_OCP_NETCTRL0,
  137. &val)) {
  138. dev_err(dev, "%s read error\n", __func__);
  139. return;
  140. }
  141. if (!(val & BYT_IOSF_OCP_TIMEOUT_BASE))
  142. return;
  143. val &= ~BYT_IOSF_OCP_TIMEOUT_BASE;
  144. if (iosf_mbi_write(BYT_IOSF_SCCEP, MBI_CR_WRITE, BYT_IOSF_OCP_NETCTRL0,
  145. val)) {
  146. dev_err(dev, "%s write error\n", __func__);
  147. return;
  148. }
  149. dev_dbg(dev, "%s completed\n", __func__);
  150. }
  151. static bool sdhci_acpi_byt_defer(struct device *dev)
  152. {
  153. if (!sdhci_acpi_byt())
  154. return false;
  155. if (!iosf_mbi_available())
  156. return true;
  157. sdhci_acpi_byt_setting(dev);
  158. return false;
  159. }
  160. static bool sdhci_acpi_cht_pci_wifi(unsigned int vendor, unsigned int device,
  161. unsigned int slot, unsigned int parent_slot)
  162. {
  163. struct pci_dev *dev, *parent, *from = NULL;
  164. while (1) {
  165. dev = pci_get_device(vendor, device, from);
  166. pci_dev_put(from);
  167. if (!dev)
  168. break;
  169. parent = pci_upstream_bridge(dev);
  170. if (ACPI_COMPANION(&dev->dev) && PCI_SLOT(dev->devfn) == slot &&
  171. parent && PCI_SLOT(parent->devfn) == parent_slot &&
  172. !pci_upstream_bridge(parent)) {
  173. pci_dev_put(dev);
  174. return true;
  175. }
  176. from = dev;
  177. }
  178. return false;
  179. }
  180. /*
  181. * GPDwin uses PCI wifi which conflicts with SDIO's use of
  182. * acpi_device_fix_up_power() on child device nodes. Identifying GPDwin is
  183. * problematic, but since SDIO is only used for wifi, the presence of the PCI
  184. * wifi card in the expected slot with an ACPI companion node, is used to
  185. * indicate that acpi_device_fix_up_power() should be avoided.
  186. */
  187. static inline bool sdhci_acpi_no_fixup_child_power(const char *hid,
  188. const char *uid)
  189. {
  190. return sdhci_acpi_cht() &&
  191. !strcmp(hid, "80860F14") &&
  192. !strcmp(uid, "2") &&
  193. sdhci_acpi_cht_pci_wifi(0x14e4, 0x43ec, 0, 28);
  194. }
  195. #else
  196. static inline void sdhci_acpi_byt_setting(struct device *dev)
  197. {
  198. }
  199. static inline bool sdhci_acpi_byt_defer(struct device *dev)
  200. {
  201. return false;
  202. }
  203. static inline bool sdhci_acpi_no_fixup_child_power(const char *hid,
  204. const char *uid)
  205. {
  206. return false;
  207. }
  208. #endif
  209. static int bxt_get_cd(struct mmc_host *mmc)
  210. {
  211. int gpio_cd = mmc_gpio_get_cd(mmc);
  212. struct sdhci_host *host = mmc_priv(mmc);
  213. unsigned long flags;
  214. int ret = 0;
  215. if (!gpio_cd)
  216. return 0;
  217. spin_lock_irqsave(&host->lock, flags);
  218. if (host->flags & SDHCI_DEVICE_DEAD)
  219. goto out;
  220. ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
  221. out:
  222. spin_unlock_irqrestore(&host->lock, flags);
  223. return ret;
  224. }
  225. static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev,
  226. const char *hid, const char *uid)
  227. {
  228. struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
  229. struct sdhci_host *host;
  230. if (!c || !c->host)
  231. return 0;
  232. host = c->host;
  233. /* Platform specific code during emmc probe slot goes here */
  234. if (hid && uid && !strcmp(hid, "80860F14") && !strcmp(uid, "1") &&
  235. sdhci_readl(host, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
  236. sdhci_readl(host, SDHCI_CAPABILITIES_1) == 0x00000807)
  237. host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
  238. return 0;
  239. }
  240. static int sdhci_acpi_sdio_probe_slot(struct platform_device *pdev,
  241. const char *hid, const char *uid)
  242. {
  243. struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
  244. if (!c || !c->host)
  245. return 0;
  246. /* Platform specific code during sdio probe slot goes here */
  247. return 0;
  248. }
  249. static int sdhci_acpi_sd_probe_slot(struct platform_device *pdev,
  250. const char *hid, const char *uid)
  251. {
  252. struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
  253. struct sdhci_host *host;
  254. if (!c || !c->host || !c->slot)
  255. return 0;
  256. host = c->host;
  257. /* Platform specific code during sd probe slot goes here */
  258. if (hid && !strcmp(hid, "80865ACA"))
  259. host->mmc_host_ops.get_cd = bxt_get_cd;
  260. return 0;
  261. }
  262. static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
  263. .chip = &sdhci_acpi_chip_int,
  264. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
  265. MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
  266. MMC_CAP_CMD_DURING_TFR | MMC_CAP_WAIT_WHILE_BUSY,
  267. .flags = SDHCI_ACPI_RUNTIME_PM,
  268. .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
  269. .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
  270. SDHCI_QUIRK2_STOP_WITH_TC |
  271. SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400,
  272. .probe_slot = sdhci_acpi_emmc_probe_slot,
  273. };
  274. static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
  275. .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
  276. SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
  277. .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON,
  278. .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD |
  279. MMC_CAP_WAIT_WHILE_BUSY,
  280. .flags = SDHCI_ACPI_RUNTIME_PM,
  281. .pm_caps = MMC_PM_KEEP_POWER,
  282. .probe_slot = sdhci_acpi_sdio_probe_slot,
  283. };
  284. static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
  285. .flags = SDHCI_ACPI_SD_CD | SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL |
  286. SDHCI_ACPI_RUNTIME_PM,
  287. .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
  288. .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
  289. SDHCI_QUIRK2_STOP_WITH_TC,
  290. .caps = MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_AGGRESSIVE_PM,
  291. .probe_slot = sdhci_acpi_sd_probe_slot,
  292. };
  293. static const struct sdhci_acpi_slot sdhci_acpi_slot_qcom_sd_3v = {
  294. .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION,
  295. .quirks2 = SDHCI_QUIRK2_NO_1_8_V,
  296. .caps = MMC_CAP_NONREMOVABLE,
  297. };
  298. static const struct sdhci_acpi_slot sdhci_acpi_slot_qcom_sd = {
  299. .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION,
  300. .caps = MMC_CAP_NONREMOVABLE,
  301. };
  302. struct sdhci_acpi_uid_slot {
  303. const char *hid;
  304. const char *uid;
  305. const struct sdhci_acpi_slot *slot;
  306. };
  307. static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = {
  308. { "80865ACA", NULL, &sdhci_acpi_slot_int_sd },
  309. { "80865ACC", NULL, &sdhci_acpi_slot_int_emmc },
  310. { "80865AD0", NULL, &sdhci_acpi_slot_int_sdio },
  311. { "80860F14" , "1" , &sdhci_acpi_slot_int_emmc },
  312. { "80860F14" , "2" , &sdhci_acpi_slot_int_sdio },
  313. { "80860F14" , "3" , &sdhci_acpi_slot_int_sd },
  314. { "80860F16" , NULL, &sdhci_acpi_slot_int_sd },
  315. { "INT33BB" , "2" , &sdhci_acpi_slot_int_sdio },
  316. { "INT33BB" , "3" , &sdhci_acpi_slot_int_sd },
  317. { "INT33C6" , NULL, &sdhci_acpi_slot_int_sdio },
  318. { "INT3436" , NULL, &sdhci_acpi_slot_int_sdio },
  319. { "INT344D" , NULL, &sdhci_acpi_slot_int_sdio },
  320. { "PNP0FFF" , "3" , &sdhci_acpi_slot_int_sd },
  321. { "PNP0D40" },
  322. { "QCOM8051", NULL, &sdhci_acpi_slot_qcom_sd_3v },
  323. { "QCOM8052", NULL, &sdhci_acpi_slot_qcom_sd },
  324. { },
  325. };
  326. static const struct acpi_device_id sdhci_acpi_ids[] = {
  327. { "80865ACA" },
  328. { "80865ACC" },
  329. { "80865AD0" },
  330. { "80860F14" },
  331. { "80860F16" },
  332. { "INT33BB" },
  333. { "INT33C6" },
  334. { "INT3436" },
  335. { "INT344D" },
  336. { "PNP0D40" },
  337. { "QCOM8051" },
  338. { "QCOM8052" },
  339. { },
  340. };
  341. MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
  342. static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid,
  343. const char *uid)
  344. {
  345. const struct sdhci_acpi_uid_slot *u;
  346. for (u = sdhci_acpi_uids; u->hid; u++) {
  347. if (strcmp(u->hid, hid))
  348. continue;
  349. if (!u->uid)
  350. return u->slot;
  351. if (uid && !strcmp(u->uid, uid))
  352. return u->slot;
  353. }
  354. return NULL;
  355. }
  356. static int sdhci_acpi_probe(struct platform_device *pdev)
  357. {
  358. struct device *dev = &pdev->dev;
  359. struct acpi_device *device, *child;
  360. struct sdhci_acpi_host *c;
  361. struct sdhci_host *host;
  362. struct resource *iomem;
  363. resource_size_t len;
  364. const char *hid;
  365. const char *uid;
  366. int err;
  367. device = ACPI_COMPANION(dev);
  368. if (!device)
  369. return -ENODEV;
  370. hid = acpi_device_hid(device);
  371. uid = device->pnp.unique_id;
  372. /* Power on the SDHCI controller and its children */
  373. acpi_device_fix_up_power(device);
  374. if (!sdhci_acpi_no_fixup_child_power(hid, uid)) {
  375. list_for_each_entry(child, &device->children, node)
  376. if (child->status.present && child->status.enabled)
  377. acpi_device_fix_up_power(child);
  378. }
  379. if (sdhci_acpi_byt_defer(dev))
  380. return -EPROBE_DEFER;
  381. iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  382. if (!iomem)
  383. return -ENOMEM;
  384. len = resource_size(iomem);
  385. if (len < 0x100)
  386. dev_err(dev, "Invalid iomem size!\n");
  387. if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev)))
  388. return -ENOMEM;
  389. host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host));
  390. if (IS_ERR(host))
  391. return PTR_ERR(host);
  392. c = sdhci_priv(host);
  393. c->host = host;
  394. c->slot = sdhci_acpi_get_slot(hid, uid);
  395. c->pdev = pdev;
  396. c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM);
  397. platform_set_drvdata(pdev, c);
  398. host->hw_name = "ACPI";
  399. host->ops = &sdhci_acpi_ops_dflt;
  400. host->irq = platform_get_irq(pdev, 0);
  401. host->ioaddr = devm_ioremap_nocache(dev, iomem->start,
  402. resource_size(iomem));
  403. if (host->ioaddr == NULL) {
  404. err = -ENOMEM;
  405. goto err_free;
  406. }
  407. if (c->slot) {
  408. if (c->slot->probe_slot) {
  409. err = c->slot->probe_slot(pdev, hid, uid);
  410. if (err)
  411. goto err_free;
  412. }
  413. if (c->slot->chip) {
  414. host->ops = c->slot->chip->ops;
  415. host->quirks |= c->slot->chip->quirks;
  416. host->quirks2 |= c->slot->chip->quirks2;
  417. host->mmc->caps |= c->slot->chip->caps;
  418. host->mmc->caps2 |= c->slot->chip->caps2;
  419. host->mmc->pm_caps |= c->slot->chip->pm_caps;
  420. }
  421. host->quirks |= c->slot->quirks;
  422. host->quirks2 |= c->slot->quirks2;
  423. host->mmc->caps |= c->slot->caps;
  424. host->mmc->caps2 |= c->slot->caps2;
  425. host->mmc->pm_caps |= c->slot->pm_caps;
  426. }
  427. host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
  428. if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) {
  429. bool v = sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL);
  430. err = mmc_gpiod_request_cd(host->mmc, NULL, 0, v, 0, NULL);
  431. if (err) {
  432. if (err == -EPROBE_DEFER)
  433. goto err_free;
  434. dev_warn(dev, "failed to setup card detect gpio\n");
  435. c->use_runtime_pm = false;
  436. }
  437. }
  438. err = sdhci_add_host(host);
  439. if (err)
  440. goto err_free;
  441. if (c->use_runtime_pm) {
  442. pm_runtime_set_active(dev);
  443. pm_suspend_ignore_children(dev, 1);
  444. pm_runtime_set_autosuspend_delay(dev, 50);
  445. pm_runtime_use_autosuspend(dev);
  446. pm_runtime_enable(dev);
  447. }
  448. device_enable_async_suspend(dev);
  449. return 0;
  450. err_free:
  451. sdhci_free_host(c->host);
  452. return err;
  453. }
  454. static int sdhci_acpi_remove(struct platform_device *pdev)
  455. {
  456. struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
  457. struct device *dev = &pdev->dev;
  458. int dead;
  459. if (c->use_runtime_pm) {
  460. pm_runtime_get_sync(dev);
  461. pm_runtime_disable(dev);
  462. pm_runtime_put_noidle(dev);
  463. }
  464. if (c->slot && c->slot->remove_slot)
  465. c->slot->remove_slot(pdev);
  466. dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0);
  467. sdhci_remove_host(c->host, dead);
  468. sdhci_free_host(c->host);
  469. return 0;
  470. }
  471. #ifdef CONFIG_PM_SLEEP
  472. static int sdhci_acpi_suspend(struct device *dev)
  473. {
  474. struct sdhci_acpi_host *c = dev_get_drvdata(dev);
  475. struct sdhci_host *host = c->host;
  476. if (host->tuning_mode != SDHCI_TUNING_MODE_3)
  477. mmc_retune_needed(host->mmc);
  478. return sdhci_suspend_host(host);
  479. }
  480. static int sdhci_acpi_resume(struct device *dev)
  481. {
  482. struct sdhci_acpi_host *c = dev_get_drvdata(dev);
  483. sdhci_acpi_byt_setting(&c->pdev->dev);
  484. return sdhci_resume_host(c->host);
  485. }
  486. #endif
  487. #ifdef CONFIG_PM
  488. static int sdhci_acpi_runtime_suspend(struct device *dev)
  489. {
  490. struct sdhci_acpi_host *c = dev_get_drvdata(dev);
  491. struct sdhci_host *host = c->host;
  492. if (host->tuning_mode != SDHCI_TUNING_MODE_3)
  493. mmc_retune_needed(host->mmc);
  494. return sdhci_runtime_suspend_host(host);
  495. }
  496. static int sdhci_acpi_runtime_resume(struct device *dev)
  497. {
  498. struct sdhci_acpi_host *c = dev_get_drvdata(dev);
  499. sdhci_acpi_byt_setting(&c->pdev->dev);
  500. return sdhci_runtime_resume_host(c->host);
  501. }
  502. #endif
  503. static const struct dev_pm_ops sdhci_acpi_pm_ops = {
  504. SET_SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
  505. SET_RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend,
  506. sdhci_acpi_runtime_resume, NULL)
  507. };
  508. static struct platform_driver sdhci_acpi_driver = {
  509. .driver = {
  510. .name = "sdhci-acpi",
  511. .acpi_match_table = sdhci_acpi_ids,
  512. .pm = &sdhci_acpi_pm_ops,
  513. },
  514. .probe = sdhci_acpi_probe,
  515. .remove = sdhci_acpi_remove,
  516. };
  517. module_platform_driver(sdhci_acpi_driver);
  518. MODULE_DESCRIPTION("Secure Digital Host Controller Interface ACPI driver");
  519. MODULE_AUTHOR("Adrian Hunter");
  520. MODULE_LICENSE("GPL v2");