1c4e05037SAdrian Hunter /* 2c4e05037SAdrian Hunter * Secure Digital Host Controller Interface ACPI driver. 3c4e05037SAdrian Hunter * 4c4e05037SAdrian Hunter * Copyright (c) 2012, Intel Corporation. 5c4e05037SAdrian Hunter * 6c4e05037SAdrian Hunter * This program is free software; you can redistribute it and/or modify it 7c4e05037SAdrian Hunter * under the terms and conditions of the GNU General Public License, 8c4e05037SAdrian Hunter * version 2, as published by the Free Software Foundation. 9c4e05037SAdrian Hunter * 10c4e05037SAdrian Hunter * This program is distributed in the hope it will be useful, but WITHOUT 11c4e05037SAdrian Hunter * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12c4e05037SAdrian Hunter * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13c4e05037SAdrian Hunter * more details. 14c4e05037SAdrian Hunter * 15c4e05037SAdrian Hunter * You should have received a copy of the GNU General Public License along with 16c4e05037SAdrian Hunter * this program; if not, write to the Free Software Foundation, Inc., 17c4e05037SAdrian Hunter * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18c4e05037SAdrian Hunter * 19c4e05037SAdrian Hunter */ 20c4e05037SAdrian Hunter 21c4e05037SAdrian Hunter #include <linux/init.h> 22c4e05037SAdrian Hunter #include <linux/export.h> 23c4e05037SAdrian Hunter #include <linux/module.h> 24c4e05037SAdrian Hunter #include <linux/device.h> 25c4e05037SAdrian Hunter #include <linux/platform_device.h> 26c4e05037SAdrian Hunter #include <linux/ioport.h> 27c4e05037SAdrian Hunter #include <linux/io.h> 28c4e05037SAdrian Hunter #include <linux/dma-mapping.h> 29c4e05037SAdrian Hunter #include <linux/compiler.h> 30c4e05037SAdrian Hunter #include <linux/stddef.h> 31c4e05037SAdrian Hunter #include <linux/bitops.h> 32c4e05037SAdrian Hunter #include <linux/types.h> 33c4e05037SAdrian Hunter #include <linux/err.h> 34c4e05037SAdrian Hunter #include <linux/interrupt.h> 35c4e05037SAdrian Hunter #include <linux/acpi.h> 36c4e05037SAdrian Hunter #include <linux/pm.h> 37c4e05037SAdrian Hunter #include <linux/pm_runtime.h> 38b04fa064SAdrian Hunter #include <linux/delay.h> 39c4e05037SAdrian Hunter 40c4e05037SAdrian Hunter #include <linux/mmc/host.h> 41c4e05037SAdrian Hunter #include <linux/mmc/pm.h> 424fd4409cSAdrian Hunter #include <linux/mmc/slot-gpio.h> 43c4e05037SAdrian Hunter #include <linux/mmc/sdhci.h> 44c4e05037SAdrian Hunter 45c4e05037SAdrian Hunter #include "sdhci.h" 46c4e05037SAdrian Hunter 47c4e05037SAdrian Hunter enum { 48c4e05037SAdrian Hunter SDHCI_ACPI_SD_CD = BIT(0), 49c4e05037SAdrian Hunter SDHCI_ACPI_RUNTIME_PM = BIT(1), 504fd4409cSAdrian Hunter SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL = BIT(2), 51c4e05037SAdrian Hunter }; 52c4e05037SAdrian Hunter 53c4e05037SAdrian Hunter struct sdhci_acpi_chip { 54c4e05037SAdrian Hunter const struct sdhci_ops *ops; 55c4e05037SAdrian Hunter unsigned int quirks; 56c4e05037SAdrian Hunter unsigned int quirks2; 57c4e05037SAdrian Hunter unsigned long caps; 58c4e05037SAdrian Hunter unsigned int caps2; 59c4e05037SAdrian Hunter mmc_pm_flag_t pm_caps; 60c4e05037SAdrian Hunter }; 61c4e05037SAdrian Hunter 62c4e05037SAdrian Hunter struct sdhci_acpi_slot { 63c4e05037SAdrian Hunter const struct sdhci_acpi_chip *chip; 64c4e05037SAdrian Hunter unsigned int quirks; 65c4e05037SAdrian Hunter unsigned int quirks2; 66c4e05037SAdrian Hunter unsigned long caps; 67c4e05037SAdrian Hunter unsigned int caps2; 68c4e05037SAdrian Hunter mmc_pm_flag_t pm_caps; 69c4e05037SAdrian Hunter unsigned int flags; 70c4e05037SAdrian Hunter }; 71c4e05037SAdrian Hunter 72c4e05037SAdrian Hunter struct sdhci_acpi_host { 73c4e05037SAdrian Hunter struct sdhci_host *host; 74c4e05037SAdrian Hunter const struct sdhci_acpi_slot *slot; 75c4e05037SAdrian Hunter struct platform_device *pdev; 76c4e05037SAdrian Hunter bool use_runtime_pm; 77c4e05037SAdrian Hunter }; 78c4e05037SAdrian Hunter 79c4e05037SAdrian Hunter static inline bool sdhci_acpi_flag(struct sdhci_acpi_host *c, unsigned int flag) 80c4e05037SAdrian Hunter { 81c4e05037SAdrian Hunter return c->slot && (c->slot->flags & flag); 82c4e05037SAdrian Hunter } 83c4e05037SAdrian Hunter 84c4e05037SAdrian Hunter static int sdhci_acpi_enable_dma(struct sdhci_host *host) 85c4e05037SAdrian Hunter { 86c4e05037SAdrian Hunter return 0; 87c4e05037SAdrian Hunter } 88c4e05037SAdrian Hunter 89b04fa064SAdrian Hunter static void sdhci_acpi_int_hw_reset(struct sdhci_host *host) 90b04fa064SAdrian Hunter { 91b04fa064SAdrian Hunter u8 reg; 92b04fa064SAdrian Hunter 93b04fa064SAdrian Hunter reg = sdhci_readb(host, SDHCI_POWER_CONTROL); 94b04fa064SAdrian Hunter reg |= 0x10; 95b04fa064SAdrian Hunter sdhci_writeb(host, reg, SDHCI_POWER_CONTROL); 96b04fa064SAdrian Hunter /* For eMMC, minimum is 1us but give it 9us for good measure */ 97b04fa064SAdrian Hunter udelay(9); 98b04fa064SAdrian Hunter reg &= ~0x10; 99b04fa064SAdrian Hunter sdhci_writeb(host, reg, SDHCI_POWER_CONTROL); 100b04fa064SAdrian Hunter /* For eMMC, minimum is 200us but give it 300us for good measure */ 101b04fa064SAdrian Hunter usleep_range(300, 1000); 102b04fa064SAdrian Hunter } 103b04fa064SAdrian Hunter 104c4e05037SAdrian Hunter static const struct sdhci_ops sdhci_acpi_ops_dflt = { 105c4e05037SAdrian Hunter .enable_dma = sdhci_acpi_enable_dma, 106c4e05037SAdrian Hunter }; 107c4e05037SAdrian Hunter 108b04fa064SAdrian Hunter static const struct sdhci_ops sdhci_acpi_ops_int = { 109b04fa064SAdrian Hunter .enable_dma = sdhci_acpi_enable_dma, 110b04fa064SAdrian Hunter .hw_reset = sdhci_acpi_int_hw_reset, 111b04fa064SAdrian Hunter }; 112b04fa064SAdrian Hunter 113b04fa064SAdrian Hunter static const struct sdhci_acpi_chip sdhci_acpi_chip_int = { 114b04fa064SAdrian Hunter .ops = &sdhci_acpi_ops_int, 115b04fa064SAdrian Hunter }; 116b04fa064SAdrian Hunter 11707a58883SAdrian Hunter static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = { 118b04fa064SAdrian Hunter .chip = &sdhci_acpi_chip_int, 119b04fa064SAdrian Hunter .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | MMC_CAP_HW_RESET, 12007a58883SAdrian Hunter .caps2 = MMC_CAP2_HC_ERASE_SZ, 12107a58883SAdrian Hunter .flags = SDHCI_ACPI_RUNTIME_PM, 12207a58883SAdrian Hunter }; 12307a58883SAdrian Hunter 124e5571397SAdrian Hunter static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = { 125e5571397SAdrian Hunter .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON, 126e5571397SAdrian Hunter .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD, 127e5571397SAdrian Hunter .flags = SDHCI_ACPI_RUNTIME_PM, 128e5571397SAdrian Hunter .pm_caps = MMC_PM_KEEP_POWER, 129e5571397SAdrian Hunter }; 130e5571397SAdrian Hunter 13107a58883SAdrian Hunter static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = { 1324fd4409cSAdrian Hunter .flags = SDHCI_ACPI_SD_CD | SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL | 1334fd4409cSAdrian Hunter SDHCI_ACPI_RUNTIME_PM, 134a61abe6eSAdrian Hunter .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON, 13507a58883SAdrian Hunter }; 13607a58883SAdrian Hunter 13707a58883SAdrian Hunter struct sdhci_acpi_uid_slot { 13807a58883SAdrian Hunter const char *hid; 13907a58883SAdrian Hunter const char *uid; 14007a58883SAdrian Hunter const struct sdhci_acpi_slot *slot; 14107a58883SAdrian Hunter }; 14207a58883SAdrian Hunter 14307a58883SAdrian Hunter static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = { 14407a58883SAdrian Hunter { "80860F14" , "1" , &sdhci_acpi_slot_int_emmc }, 14507a58883SAdrian Hunter { "80860F14" , "3" , &sdhci_acpi_slot_int_sd }, 14607a58883SAdrian Hunter { "INT33BB" , "2" , &sdhci_acpi_slot_int_sdio }, 14707a58883SAdrian Hunter { "INT33C6" , NULL, &sdhci_acpi_slot_int_sdio }, 14807c001c1SMika Westerberg { "INT3436" , NULL, &sdhci_acpi_slot_int_sdio }, 14907a58883SAdrian Hunter { "PNP0D40" }, 15007a58883SAdrian Hunter { }, 15107a58883SAdrian Hunter }; 15207a58883SAdrian Hunter 153c4e05037SAdrian Hunter static const struct acpi_device_id sdhci_acpi_ids[] = { 15407a58883SAdrian Hunter { "80860F14" }, 15507a58883SAdrian Hunter { "INT33BB" }, 15607a58883SAdrian Hunter { "INT33C6" }, 15707c001c1SMika Westerberg { "INT3436" }, 158c4e05037SAdrian Hunter { "PNP0D40" }, 159c4e05037SAdrian Hunter { }, 160c4e05037SAdrian Hunter }; 161c4e05037SAdrian Hunter MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids); 162c4e05037SAdrian Hunter 16307a58883SAdrian Hunter static const struct sdhci_acpi_slot *sdhci_acpi_get_slot_by_ids(const char *hid, 16407a58883SAdrian Hunter const char *uid) 165c4e05037SAdrian Hunter { 16607a58883SAdrian Hunter const struct sdhci_acpi_uid_slot *u; 167c4e05037SAdrian Hunter 16807a58883SAdrian Hunter for (u = sdhci_acpi_uids; u->hid; u++) { 16907a58883SAdrian Hunter if (strcmp(u->hid, hid)) 17007a58883SAdrian Hunter continue; 17107a58883SAdrian Hunter if (!u->uid) 17207a58883SAdrian Hunter return u->slot; 17307a58883SAdrian Hunter if (uid && !strcmp(u->uid, uid)) 17407a58883SAdrian Hunter return u->slot; 17507a58883SAdrian Hunter } 176c4e05037SAdrian Hunter return NULL; 177c4e05037SAdrian Hunter } 178c4e05037SAdrian Hunter 17907a58883SAdrian Hunter static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(acpi_handle handle, 18007a58883SAdrian Hunter const char *hid) 18107a58883SAdrian Hunter { 18207a58883SAdrian Hunter const struct sdhci_acpi_slot *slot; 18307a58883SAdrian Hunter struct acpi_device_info *info; 18407a58883SAdrian Hunter const char *uid = NULL; 18507a58883SAdrian Hunter acpi_status status; 18607a58883SAdrian Hunter 18707a58883SAdrian Hunter status = acpi_get_object_info(handle, &info); 18807a58883SAdrian Hunter if (!ACPI_FAILURE(status) && (info->valid & ACPI_VALID_UID)) 18907a58883SAdrian Hunter uid = info->unique_id.string; 19007a58883SAdrian Hunter 19107a58883SAdrian Hunter slot = sdhci_acpi_get_slot_by_ids(hid, uid); 19207a58883SAdrian Hunter 19307a58883SAdrian Hunter kfree(info); 19407a58883SAdrian Hunter return slot; 19507a58883SAdrian Hunter } 19607a58883SAdrian Hunter 1974e608e4eSGreg Kroah-Hartman static int sdhci_acpi_probe(struct platform_device *pdev) 198c4e05037SAdrian Hunter { 199c4e05037SAdrian Hunter struct device *dev = &pdev->dev; 200c4e05037SAdrian Hunter acpi_handle handle = ACPI_HANDLE(dev); 201c4e05037SAdrian Hunter struct acpi_device *device; 202c4e05037SAdrian Hunter struct sdhci_acpi_host *c; 203c4e05037SAdrian Hunter struct sdhci_host *host; 204c4e05037SAdrian Hunter struct resource *iomem; 205c4e05037SAdrian Hunter resource_size_t len; 206c4e05037SAdrian Hunter const char *hid; 20787875655SMika Westerberg int err; 208c4e05037SAdrian Hunter 209c4e05037SAdrian Hunter if (acpi_bus_get_device(handle, &device)) 210c4e05037SAdrian Hunter return -ENODEV; 211c4e05037SAdrian Hunter 212c4e05037SAdrian Hunter if (acpi_bus_get_status(device) || !device->status.present) 213c4e05037SAdrian Hunter return -ENODEV; 214c4e05037SAdrian Hunter 215c4e05037SAdrian Hunter hid = acpi_device_hid(device); 216c4e05037SAdrian Hunter 217c4e05037SAdrian Hunter iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 218c4e05037SAdrian Hunter if (!iomem) 219c4e05037SAdrian Hunter return -ENOMEM; 220c4e05037SAdrian Hunter 221c4e05037SAdrian Hunter len = resource_size(iomem); 222c4e05037SAdrian Hunter if (len < 0x100) 223c4e05037SAdrian Hunter dev_err(dev, "Invalid iomem size!\n"); 224c4e05037SAdrian Hunter 225c4e05037SAdrian Hunter if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev))) 226c4e05037SAdrian Hunter return -ENOMEM; 227c4e05037SAdrian Hunter 228c4e05037SAdrian Hunter host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host)); 229c4e05037SAdrian Hunter if (IS_ERR(host)) 230c4e05037SAdrian Hunter return PTR_ERR(host); 231c4e05037SAdrian Hunter 232c4e05037SAdrian Hunter c = sdhci_priv(host); 233c4e05037SAdrian Hunter c->host = host; 23407a58883SAdrian Hunter c->slot = sdhci_acpi_get_slot(handle, hid); 235c4e05037SAdrian Hunter c->pdev = pdev; 236c4e05037SAdrian Hunter c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM); 237c4e05037SAdrian Hunter 238c4e05037SAdrian Hunter platform_set_drvdata(pdev, c); 239c4e05037SAdrian Hunter 240c4e05037SAdrian Hunter host->hw_name = "ACPI"; 241c4e05037SAdrian Hunter host->ops = &sdhci_acpi_ops_dflt; 242c4e05037SAdrian Hunter host->irq = platform_get_irq(pdev, 0); 243c4e05037SAdrian Hunter 244c4e05037SAdrian Hunter host->ioaddr = devm_ioremap_nocache(dev, iomem->start, 245c4e05037SAdrian Hunter resource_size(iomem)); 246c4e05037SAdrian Hunter if (host->ioaddr == NULL) { 247c4e05037SAdrian Hunter err = -ENOMEM; 248c4e05037SAdrian Hunter goto err_free; 249c4e05037SAdrian Hunter } 250c4e05037SAdrian Hunter 251c4e05037SAdrian Hunter if (!dev->dma_mask) { 252c4e05037SAdrian Hunter u64 dma_mask; 253c4e05037SAdrian Hunter 254c4e05037SAdrian Hunter if (sdhci_readl(host, SDHCI_CAPABILITIES) & SDHCI_CAN_64BIT) { 255c4e05037SAdrian Hunter /* 64-bit DMA is not supported at present */ 256c4e05037SAdrian Hunter dma_mask = DMA_BIT_MASK(32); 257c4e05037SAdrian Hunter } else { 258c4e05037SAdrian Hunter dma_mask = DMA_BIT_MASK(32); 259c4e05037SAdrian Hunter } 260c4e05037SAdrian Hunter 26107f4450cSRussell King err = dma_coerce_mask_and_coherent(dev, dma_mask); 26207f4450cSRussell King if (err) 26307f4450cSRussell King goto err_free; 264c4e05037SAdrian Hunter } 265c4e05037SAdrian Hunter 266c4e05037SAdrian Hunter if (c->slot) { 267c4e05037SAdrian Hunter if (c->slot->chip) { 268c4e05037SAdrian Hunter host->ops = c->slot->chip->ops; 269c4e05037SAdrian Hunter host->quirks |= c->slot->chip->quirks; 270c4e05037SAdrian Hunter host->quirks2 |= c->slot->chip->quirks2; 271c4e05037SAdrian Hunter host->mmc->caps |= c->slot->chip->caps; 272c4e05037SAdrian Hunter host->mmc->caps2 |= c->slot->chip->caps2; 273c4e05037SAdrian Hunter host->mmc->pm_caps |= c->slot->chip->pm_caps; 274c4e05037SAdrian Hunter } 275c4e05037SAdrian Hunter host->quirks |= c->slot->quirks; 276c4e05037SAdrian Hunter host->quirks2 |= c->slot->quirks2; 277c4e05037SAdrian Hunter host->mmc->caps |= c->slot->caps; 278c4e05037SAdrian Hunter host->mmc->caps2 |= c->slot->caps2; 279c4e05037SAdrian Hunter host->mmc->pm_caps |= c->slot->pm_caps; 280c4e05037SAdrian Hunter } 281c4e05037SAdrian Hunter 2820d3e3350SAdrian Hunter host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; 2830d3e3350SAdrian Hunter 2844fd4409cSAdrian Hunter if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) { 2854fd4409cSAdrian Hunter bool v = sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL); 2864fd4409cSAdrian Hunter 2874fd4409cSAdrian Hunter if (mmc_gpiod_request_cd(host->mmc, NULL, 0, v, 0)) { 2884fd4409cSAdrian Hunter dev_warn(dev, "failed to setup card detect gpio\n"); 2894fd4409cSAdrian Hunter c->use_runtime_pm = false; 2904fd4409cSAdrian Hunter } 2914fd4409cSAdrian Hunter } 2924fd4409cSAdrian Hunter 293c4e05037SAdrian Hunter err = sdhci_add_host(host); 294c4e05037SAdrian Hunter if (err) 295c4e05037SAdrian Hunter goto err_free; 296c4e05037SAdrian Hunter 297c4e05037SAdrian Hunter if (c->use_runtime_pm) { 2981d1ff458SAdrian Hunter pm_runtime_set_active(dev); 299c4e05037SAdrian Hunter pm_suspend_ignore_children(dev, 1); 300c4e05037SAdrian Hunter pm_runtime_set_autosuspend_delay(dev, 50); 301c4e05037SAdrian Hunter pm_runtime_use_autosuspend(dev); 302c4e05037SAdrian Hunter pm_runtime_enable(dev); 303c4e05037SAdrian Hunter } 304c4e05037SAdrian Hunter 305c4e05037SAdrian Hunter return 0; 306c4e05037SAdrian Hunter 307c4e05037SAdrian Hunter err_free: 308c4e05037SAdrian Hunter sdhci_free_host(c->host); 309c4e05037SAdrian Hunter return err; 310c4e05037SAdrian Hunter } 311c4e05037SAdrian Hunter 3124e608e4eSGreg Kroah-Hartman static int sdhci_acpi_remove(struct platform_device *pdev) 313c4e05037SAdrian Hunter { 314c4e05037SAdrian Hunter struct sdhci_acpi_host *c = platform_get_drvdata(pdev); 315c4e05037SAdrian Hunter struct device *dev = &pdev->dev; 316c4e05037SAdrian Hunter int dead; 317c4e05037SAdrian Hunter 318c4e05037SAdrian Hunter if (c->use_runtime_pm) { 319c4e05037SAdrian Hunter pm_runtime_get_sync(dev); 320c4e05037SAdrian Hunter pm_runtime_disable(dev); 321c4e05037SAdrian Hunter pm_runtime_put_noidle(dev); 322c4e05037SAdrian Hunter } 323c4e05037SAdrian Hunter 324c4e05037SAdrian Hunter dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0); 325c4e05037SAdrian Hunter sdhci_remove_host(c->host, dead); 326c4e05037SAdrian Hunter sdhci_free_host(c->host); 327c4e05037SAdrian Hunter 328c4e05037SAdrian Hunter return 0; 329c4e05037SAdrian Hunter } 330c4e05037SAdrian Hunter 331c4e05037SAdrian Hunter #ifdef CONFIG_PM_SLEEP 332c4e05037SAdrian Hunter 333c4e05037SAdrian Hunter static int sdhci_acpi_suspend(struct device *dev) 334c4e05037SAdrian Hunter { 335c4e05037SAdrian Hunter struct sdhci_acpi_host *c = dev_get_drvdata(dev); 336c4e05037SAdrian Hunter 337c4e05037SAdrian Hunter return sdhci_suspend_host(c->host); 338c4e05037SAdrian Hunter } 339c4e05037SAdrian Hunter 340c4e05037SAdrian Hunter static int sdhci_acpi_resume(struct device *dev) 341c4e05037SAdrian Hunter { 342c4e05037SAdrian Hunter struct sdhci_acpi_host *c = dev_get_drvdata(dev); 343c4e05037SAdrian Hunter 344c4e05037SAdrian Hunter return sdhci_resume_host(c->host); 345c4e05037SAdrian Hunter } 346c4e05037SAdrian Hunter 347c4e05037SAdrian Hunter #else 348c4e05037SAdrian Hunter 349c4e05037SAdrian Hunter #define sdhci_acpi_suspend NULL 350c4e05037SAdrian Hunter #define sdhci_acpi_resume NULL 351c4e05037SAdrian Hunter 352c4e05037SAdrian Hunter #endif 353c4e05037SAdrian Hunter 354c4e05037SAdrian Hunter #ifdef CONFIG_PM_RUNTIME 355c4e05037SAdrian Hunter 356c4e05037SAdrian Hunter static int sdhci_acpi_runtime_suspend(struct device *dev) 357c4e05037SAdrian Hunter { 358c4e05037SAdrian Hunter struct sdhci_acpi_host *c = dev_get_drvdata(dev); 359c4e05037SAdrian Hunter 360c4e05037SAdrian Hunter return sdhci_runtime_suspend_host(c->host); 361c4e05037SAdrian Hunter } 362c4e05037SAdrian Hunter 363c4e05037SAdrian Hunter static int sdhci_acpi_runtime_resume(struct device *dev) 364c4e05037SAdrian Hunter { 365c4e05037SAdrian Hunter struct sdhci_acpi_host *c = dev_get_drvdata(dev); 366c4e05037SAdrian Hunter 367c4e05037SAdrian Hunter return sdhci_runtime_resume_host(c->host); 368c4e05037SAdrian Hunter } 369c4e05037SAdrian Hunter 370c4e05037SAdrian Hunter static int sdhci_acpi_runtime_idle(struct device *dev) 371c4e05037SAdrian Hunter { 372c4e05037SAdrian Hunter return 0; 373c4e05037SAdrian Hunter } 374c4e05037SAdrian Hunter 375c4e05037SAdrian Hunter #else 376c4e05037SAdrian Hunter 377c4e05037SAdrian Hunter #define sdhci_acpi_runtime_suspend NULL 378c4e05037SAdrian Hunter #define sdhci_acpi_runtime_resume NULL 379c4e05037SAdrian Hunter #define sdhci_acpi_runtime_idle NULL 380c4e05037SAdrian Hunter 381c4e05037SAdrian Hunter #endif 382c4e05037SAdrian Hunter 383c4e05037SAdrian Hunter static const struct dev_pm_ops sdhci_acpi_pm_ops = { 384c4e05037SAdrian Hunter .suspend = sdhci_acpi_suspend, 385c4e05037SAdrian Hunter .resume = sdhci_acpi_resume, 386c4e05037SAdrian Hunter .runtime_suspend = sdhci_acpi_runtime_suspend, 387c4e05037SAdrian Hunter .runtime_resume = sdhci_acpi_runtime_resume, 388c4e05037SAdrian Hunter .runtime_idle = sdhci_acpi_runtime_idle, 389c4e05037SAdrian Hunter }; 390c4e05037SAdrian Hunter 391c4e05037SAdrian Hunter static struct platform_driver sdhci_acpi_driver = { 392c4e05037SAdrian Hunter .driver = { 393c4e05037SAdrian Hunter .name = "sdhci-acpi", 394c4e05037SAdrian Hunter .owner = THIS_MODULE, 395c4e05037SAdrian Hunter .acpi_match_table = sdhci_acpi_ids, 396c4e05037SAdrian Hunter .pm = &sdhci_acpi_pm_ops, 397c4e05037SAdrian Hunter }, 398c4e05037SAdrian Hunter .probe = sdhci_acpi_probe, 3994e608e4eSGreg Kroah-Hartman .remove = sdhci_acpi_remove, 400c4e05037SAdrian Hunter }; 401c4e05037SAdrian Hunter 402c4e05037SAdrian Hunter module_platform_driver(sdhci_acpi_driver); 403c4e05037SAdrian Hunter 404c4e05037SAdrian Hunter MODULE_DESCRIPTION("Secure Digital Host Controller Interface ACPI driver"); 405c4e05037SAdrian Hunter MODULE_AUTHOR("Adrian Hunter"); 406c4e05037SAdrian Hunter MODULE_LICENSE("GPL v2"); 407