static int sdhci_bcm2708_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct sdhci_bcm2708_priv *host_priv = SDHCI_HOST_PRIV(host); int dead; u32 scratch; dead = 0; scratch = sdhci_bcm2708_readl(host, SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; device_remove_file(&pdev->dev, &dev_attr_status); device_remove_file(&pdev->dev, &dev_attr_dma_wait); device_remove_file(&pdev->dev, &dev_attr_use_dma); #ifdef CONFIG_MMC_SDHCI_BCM2708_DMA free_irq(host_priv->dma_irq, host); dma_free_writecombine(&pdev->dev, SZ_4K, host_priv->cb_base, host_priv->cb_handle); #endif sdhci_remove_host(host, dead); iounmap(host->ioaddr); release_mem_region(iomem->start, resource_size(iomem)); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_pltfm_remove(struct platform_device *pdev) { const struct platform_device_id *platid = platform_get_device_id(pdev); const struct of_device_id *dtid = sdhci_get_of_device_id(pdev); struct sdhci_pltfm_data *pdata; struct sdhci_host *host = platform_get_drvdata(pdev); struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); int dead; u32 scratch; if (platid && platid->driver_data) pdata = (void *)platid->driver_data; else if (dtid && dtid->data) pdata = dtid->data; else pdata = pdev->dev.platform_data; dead = 0; scratch = readl(host->ioaddr + SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; sdhci_remove_host(host, dead); if (pdata && pdata->exit) pdata->exit(host); iounmap(host->ioaddr); release_mem_region(iomem->start, resource_size(iomem)); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_s3c_remove(struct platform_device *pdev) { struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data; struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_s3c *sc = sdhci_priv(host); int ptr; if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup) pdata->ext_cd_cleanup(&sdhci_s3c_notify_change); if (sc->ext_cd_irq) free_irq(sc->ext_cd_irq, sc); if (gpio_is_valid(sc->ext_cd_gpio)) gpio_free(sc->ext_cd_gpio); sdhci_remove_host(host, 1); pm_runtime_disable(&pdev->dev); for (ptr = 0; ptr < 3; ptr++) { if (sc->clk_bus[ptr]) { clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } } clk_disable(sc->clk_io); clk_put(sc->clk_io); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int tegra_sdhci_remove(struct platform_device *pdev) { struct tegra_sdhci_host *host = platform_get_drvdata(pdev); if (host) { struct tegra_sdhci_platform_data *plat; plat = pdev->dev.platform_data; if (plat && plat->board_probe) plat->board_probe(pdev->id, host->sdhci->mmc); if (host->cd_gpio != -1) gpio_free(host->cd_gpio); if (host->irq_cd != -1) free_irq(host->irq_cd, host->sdhci); if (host->wp_gpio != -1) gpio_free(host->wp_gpio); if (host->power_gpio != -1) gpio_free(host->power_gpio); sdhci_remove_host(host->sdhci, 0); sdhci_free_host(host->sdhci); } return 0; }
static int __devexit sdhci_s3c_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_s3c *sc = sdhci_priv(host); int ptr; sdhci_remove_host(host, 1); for (ptr = 0; ptr < 3; ptr++) { if (sc->clk_bus[ptr]) { clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } } clk_disable(sc->clk_io); clk_put(sc->clk_io); iounmap(host->ioaddr); release_resource(sc->ioarea); kfree(sc->ioarea); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); destroy_workqueue(sc->regulator_workq); return 0; }
static int __devexit sdhci_s3c_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_s3c *sc = sdhci_priv(host); int ptr, dead = 0; u32 scratch; scratch = readl(host->ioaddr + SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; if(sc->pdata && sc->pdata->cfg_ext_cd) free_irq(sc->pdata->ext_cd, sc); sdhci_remove_host(host, dead); for (ptr = 0; ptr < 3; ptr++) { clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } clk_disable(sc->clk_io); clk_put(sc->clk_io); iounmap(host->ioaddr); release_resource(sc->ioarea); kfree(sc->ioarea); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int sdhci_s3c_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_s3c *sc = sdhci_priv(host); struct s3c_sdhci_platdata *pdata = sc->pdata; if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup) pdata->ext_cd_cleanup(&sdhci_s3c_notify_change); if (sc->ext_cd_irq) free_irq(sc->ext_cd_irq, sc); #ifdef CONFIG_PM_RUNTIME if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) clk_prepare_enable(sc->clk_io); #endif sdhci_remove_host(host, 1); pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_disable(&pdev->dev); #ifndef CONFIG_PM_RUNTIME clk_disable_unprepare(sc->clk_bus[sc->cur_clk]); #endif clk_disable_unprepare(sc->clk_io); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev); int dead; u32 scratch; if (sdhci->data) { if (sdhci->data->card_int_gpio >= 0) { free_irq(gpio_to_irq(sdhci->data->card_int_gpio), pdev); gpio_free(sdhci->data->card_int_gpio); } if (sdhci->data->card_power_gpio >= 0) gpio_free(sdhci->data->card_power_gpio); } platform_set_drvdata(pdev, NULL); dead = 0; scratch = readl(host->ioaddr + SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; sdhci_remove_host(host, dead); iounmap(host->ioaddr); sdhci_free_host(host); clk_disable(sdhci->clk); clk_put(sdhci->clk); kfree(sdhci); if (iomem) release_mem_region(iomem->start, resource_size(iomem)); return 0; }
static int __devinit sdhci_of_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->node; struct sdhci_of_data *sdhci_of_data = match->data; struct sdhci_host *host; struct sdhci_of_host *of_host; const u32 *clk; int size; int ret; if (!of_device_is_available(np)) return -ENODEV; host = sdhci_alloc_host(&ofdev->dev, sizeof(*of_host)); if (!host) return -ENOMEM; of_host = sdhci_priv(host); dev_set_drvdata(&ofdev->dev, host); host->ioaddr = of_iomap(np, 0); if (!host->ioaddr) { ret = -ENOMEM; goto err_addr_map; } host->irq = irq_of_parse_and_map(np, 0); if (!host->irq) { ret = -EINVAL; goto err_no_irq; } host->hw_name = dev_name(&ofdev->dev); if (sdhci_of_data) { host->quirks = sdhci_of_data->quirks; host->ops = &sdhci_of_data->ops; } clk = of_get_property(np, "clock-frequency", &size); if (clk && size == sizeof(*clk) && *clk) of_host->clock = *clk; ret = sdhci_add_host(host); if (ret) goto err_add_host; return 0; err_add_host: irq_dispose_mapping(host->irq); err_no_irq: iounmap(host->ioaddr); err_addr_map: sdhci_free_host(host); return ret; }
void sdhci_pltfm_free(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); iounmap(host->ioaddr); release_mem_region(iomem->start, resource_size(iomem)); sdhci_free_host(host); }
static int __devexit sdhci_of_remove(struct of_device *ofdev) { struct sdhci_host *host = dev_get_drvdata(&ofdev->dev); sdhci_remove_host(host, 0); sdhci_free_host(host); irq_dispose_mapping(host->irq); iounmap(host->ioaddr); return 0; }
static int tegra_sdhci_remove(struct platform_device *pdev) { struct tegra_sdhci_host *host = platform_get_drvdata(pdev); if (host) { struct tegra_sdhci_platform_data *plat; plat = pdev->dev.platform_data; if (plat && plat->board_probe) plat->board_probe(pdev->id, host->sdhci->mmc); sdhci_remove_host(host->sdhci, 0); sdhci_free_host(host->sdhci); } return 0; }
static int __devinit sdhci_brcm_probe(struct platform_device *pdev) { struct sdhci_host *host; struct resource *mres, *ires; int mres_size; int err; mres = platform_get_resource(pdev, IORESOURCE_MEM, 0); ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!mres || !ires) { dev_err(&pdev->dev, "can't get resources\n"); return -EIO; } mres_size = mres->end - mres->start + 1; if (!request_mem_region(mres->start, mres_size, DRV_NAME)) { dev_err(&pdev->dev, "can't request memory\n"); return -EBUSY; } host = sdhci_alloc_host(&pdev->dev, 0); if (!host) { dev_err(&pdev->dev, "out of memory\n"); return -ENOMEM; } dev_set_drvdata(&pdev->dev, host); host->hw_name = DRV_NAME; host->ops = &sdhci_brcm_ops; host->flags = 0; #if defined(CONFIG_BCM7635) host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; #else host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; #endif host->irq = ires->start; host->ioaddr = ioremap(mres->start, mres_size); HIF_ACK_IRQ(SDIO); HIF_ENABLE_IRQ(SDIO); err = sdhci_add_host(host); if (err < 0) { dev_err(&pdev->dev, "can't register controller (error %d)\n", err); sdhci_free_host(host); return err; } return 0; }
static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); int dead; u32 scratch; dead = 0; scratch = readl(host->ioaddr + SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; sdhci_remove_host(host, dead); sdhci_free_host(host); return 0; }
static int sdhci_f_sdh30_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct f_sdhost_priv *priv = sdhci_priv(host); sdhci_remove_host(host, readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); clk_disable_unprepare(priv->clk_iface); clk_disable_unprepare(priv->clk); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_s3c_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_s3c *sc = sdhci_priv(host); struct s3c_sdhci_platdata *pdata = sc->pdata; int ptr; if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup) pdata->ext_cd_cleanup(&sdhci_s3c_notify_change); if (sc->ext_cd_irq) free_irq(sc->ext_cd_irq, sc); if (gpio_is_valid(sc->ext_cd_gpio)) gpio_free(sc->ext_cd_gpio); #ifdef CONFIG_PM_RUNTIME if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) clk_prepare_enable(sc->clk_io); #endif sdhci_remove_host(host, 1); pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_disable(&pdev->dev); #ifndef CONFIG_PM_RUNTIME clk_disable_unprepare(sc->clk_bus[sc->cur_clk]); #endif for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { if (sc->clk_bus[ptr]) { clk_put(sc->clk_bus[ptr]); } } clk_disable_unprepare(sc->clk_io); clk_put(sc->clk_io); if (pdev->dev.of_node) { for (ptr = 0; ptr < NUM_GPIOS(sc->pdata->max_width); ptr++) gpio_free(sc->gpios[ptr]); } sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_pltfm_remove(struct platform_device *pdev) { struct sdio_dev *dev = platform_get_drvdata(pdev); struct sdhci_host *host = dev->host; struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); /* Flag used to signal shutdown of eMMC card */ dev->remove_card = 1; sdhci_pltfm_shutdown(pdev); platform_set_drvdata(pdev, NULL); kfree(dev); iounmap(host->ioaddr); release_mem_region(iomem->start, resource_size(iomem)); sdhci_free_host(host); return 0; }
static int sdhci_acpi_remove(struct platform_device *pdev) { struct sdhci_acpi_host *c = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; int dead; if (c->use_runtime_pm) { pm_runtime_get_sync(dev); pm_runtime_disable(dev); pm_runtime_put_noidle(dev); } dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0); sdhci_remove_host(c->host, dead); sdhci_free_host(c->host); return 0; }
static int __devexit sdhci_brcm_remove(struct platform_device *pdev) { struct sdhci_host *host = dev_get_drvdata(&pdev->dev); struct resource *mres; int mres_size; if (host) { sdhci_remove_host(host, 0); HIF_DISABLE_IRQ(SDIO); mres = platform_get_resource(pdev, IORESOURCE_MEM, 0); mres_size = mres->end - mres->start + 1; iounmap(host->ioaddr); release_mem_region(mres->start, mres_size); sdhci_free_host(host); } return 0; }
static int sdhci_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev); int dead = 0; u32 scratch; platform_set_drvdata(pdev, NULL); scratch = readl(host->ioaddr + SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; sdhci_remove_host(host, dead); sdhci_free_host(host); clk_disable_unprepare(sdhci->clk); clk_put(sdhci->clk); return 0; }
static int __devexit sdhci_pltfm_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); int dead; u32 scratch; dead = 0; scratch = readl(host->ioaddr + SDHCI_INT_STATUS); if (scratch == (u32)-1) dead = 1; sdhci_remove_host(host, dead); iounmap(host->ioaddr); release_mem_region(iomem->start, resource_size(iomem)); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_s3c_remove(struct platform_device *pdev) { struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data; struct sdhci_host *host = platform_get_drvdata(pdev); struct sdhci_s3c *sc = sdhci_priv(host); int ptr; if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup) pdata->ext_cd_cleanup(&sdhci_s3c_notify_change); #ifdef CONFIG_MACH_U1_NA_SPR if (pdata->cd_type == S3C_SDHCI_CD_GPIO && pdata->ext_cd_cleanup) pdata->ext_cd_cleanup(&sdhci_s3c_notify_change); #endif if (sc->ext_cd_irq) free_irq(sc->ext_cd_irq, sc); if (gpio_is_valid(sc->ext_cd_gpio)) gpio_free(sc->ext_cd_gpio); sdhci_remove_host(host, 1); for (ptr = 0; ptr < 3; ptr++) { if (sc->clk_bus[ptr]) { clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } } clk_disable(sc->clk_io); clk_put(sc->clk_io); iounmap(host->ioaddr); release_resource(sc->ioarea); kfree(sc->ioarea); sdhci_free_host(host); platform_set_drvdata(pdev, NULL); return 0; }
static int __devexit sdhci_sprd_remove(struct platform_device *pdev) { struct sdhci_host *host = platform_get_drvdata(pdev); struct sprd_host_data *host_data = sdhci_priv(host); #ifdef CONFIG_PM_RUNTIME if (pm_runtime_suspended(&(pdev)->dev)) pm_runtime_resume(&(pdev)->dev); #endif sdhci_remove_host(host, 1); sdhci_free_host(host); if (host_data->clk_enable) { clk_disable(host->clk); host_data->clk_enable = 0; } #ifdef CONFIG_PM_RUNTIME pm_runtime_disable(&(pdev)->dev); pm_runtime_set_suspended(&(pdev)->dev); #endif return 0; }
static int __devinit sdhci_s3c_probe(struct platform_device *pdev) { struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data; struct device *dev = &pdev->dev; struct sdhci_host *host; struct sdhci_s3c *sc; struct resource *res; int ret, irq, ptr, clks; if (!pdata) { dev_err(dev, "no device data specified\n"); return -ENOENT; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(dev, "no irq specified\n"); return irq; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "no memory specified\n"); return -ENOENT; } host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); if (IS_ERR(host)) { dev_err(dev, "sdhci_alloc_host() failed\n"); return PTR_ERR(host); } sc = sdhci_priv(host); sc->host = host; sc->pdev = pdev; sc->pdata = pdata; sc->ext_cd_gpio = -1; platform_set_drvdata(pdev, host); sc->clk_io = clk_get(dev, "hsmmc"); if (IS_ERR(sc->clk_io)) { dev_err(dev, "failed to get io clock\n"); ret = PTR_ERR(sc->clk_io); goto err_io_clk; } /* enable the local io clock and keep it running for the moment. */ clk_enable(sc->clk_io); for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) { struct clk *clk; char *name = pdata->clocks[ptr]; if (name == NULL) continue; clk = clk_get(dev, name); if (IS_ERR(clk)) { dev_err(dev, "failed to get clock %s\n", name); continue; } clks++; sc->clk_bus[ptr] = clk; clk_enable(clk); sc->cur_clk = ptr; dev_info(dev, "clock source %d: %s (%ld Hz)\n", ptr, name, clk_get_rate(clk)); } if (clks == 0) { dev_err(dev, "failed to find any bus clocks\n"); ret = -ENOENT; goto err_no_busclks; } sc->ioarea = request_mem_region(res->start, resource_size(res), mmc_hostname(host->mmc)); if (!sc->ioarea) { dev_err(dev, "failed to reserve register area\n"); ret = -ENXIO; goto err_req_regs; } host->ioaddr = ioremap_nocache(res->start, resource_size(res)); if (!host->ioaddr) { dev_err(dev, "failed to map registers\n"); ret = -ENXIO; goto err_req_regs; } /* Ensure we have minimal gpio selected CMD/CLK/Detect */ if (pdata->cfg_gpio) pdata->cfg_gpio(pdev, pdata->max_width); host->hw_name = "samsung-hsmmc"; host->ops = &sdhci_s3c_ops; host->quirks = 0; host->irq = irq; /* Setup quirks for the controller */ host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; #ifndef CONFIG_MMC_SDHCI_S3C_DMA /* we currently see overruns on errors, so disable the SDMA * support as well. */ host->quirks |= SDHCI_QUIRK_BROKEN_DMA; #endif /* CONFIG_MMC_SDHCI_S3C_DMA */ /* It seems we do not get an DATA transfer complete on non-busy * transfers, not sure if this is a problem with this specific * SDHCI block, or a missing configuration that needs to be set. */ host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ; if (pdata->cd_type == S3C_SDHCI_CD_NONE) host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_32BIT_DMA_SIZE); /* HSMMC on Samsung SoCs uses SDCLK as timeout clock */ host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK; /* IF SD controller's WP pin donsn't connected with SD card and there is an * allocated GPIO for getting WP data form SD card, use this quirk and send * the GPIO number in pdata->wp_gpio. */ if (pdata->has_wp_gpio && gpio_is_valid(pdata->wp_gpio)) { sdhci_s3c_ops.get_ro = sdhci_s3c_get_ro; host->quirks |= SDHCI_QUIRK_NO_WP_BIT; sdhci_s3c_cfg_wp(pdata->wp_gpio); } host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; #ifdef CONFIG_ARCH_S5PV310 host->quirks |= SDHCI_QUIRK_NONSTANDARD_CLOCK; host->quirks |= SDHCI_QUIRK_BROKEN_CLOCK_DIVIDER; #endif if(pdata->host_caps) host->mmc->caps |= pdata->host_caps; /* Fill External GPIO Value */ if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) { pr_info("%s : S3C_SDHCI_CD_PERMANENT\n", __func__); if(gpio_is_valid(pdata->ext_cd_gpio)) { pr_info("%s : MMC GPIO Level is %d\n", __func__ , gpio_get_value(pdata->ext_cd_gpio)); gpio_request(pdata->ext_cd_gpio, "SDHCI EXT CD"); sc->ext_cd_gpio = gpio_get_value(pdata->ext_cd_gpio); } } if (pdata->cd_type == S3C_SDHCI_CD_GPIO && gpio_is_valid(pdata->ext_cd_gpio)) { pr_info("%s : S3C_SDHCI_CD_GPIO\n", __func__); gpio_request(pdata->ext_cd_gpio, "SDHCI EXT CD"); sc->ext_cd_gpio = pdata->ext_cd_gpio; sc->regulator_workq = create_singlethread_workqueue("ktflash_requlatord"); if (!sc->regulator_workq) { pr_info("%s : ERROR: workqueue for Tflash's regulator.\n" "Regulator for Tflash will be always ON\n", __func__); } INIT_DELAYED_WORK(&sc->regul_work, sdhci_s3c_requlator_work); sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio); if (sc->ext_cd_irq && request_irq(sc->ext_cd_irq, sdhci_s3c_gpio_card_detect_isr, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, dev_name(&pdev->dev), sc)) { dev_err(&pdev->dev, "cannot request irq for card detect\n"); sc->ext_cd_irq = 0; } if (tflash_detection_cmd_dev == NULL && sc->ext_cd_gpio) { tflash_detection_cmd_dev = device_create(sec_class, NULL, 0, NULL, "tctest"); if (IS_ERR(tflash_detection_cmd_dev)) pr_err("%s : Failed to create device(ts)!\n", __func__); if (device_create_file(tflash_detection_cmd_dev, &dev_attr_tftest) < 0) pr_err("%s : Failed to create device file(%s)!\n", __func__, dev_attr_tftest.attr.name); dev_set_drvdata(tflash_detection_cmd_dev, sc); } /* T-Flash EINT for CD SHOULD be wakeup source */ set_irq_wake(sc->ext_cd_irq, 1); } /* Call sdhci_host */ ret = sdhci_add_host(host); if (ret) { dev_err(dev, "sdhci_add_host() failed\n"); goto err_add_host; } if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) { host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; host->mmc->caps |= MMC_CAP_NONREMOVABLE; } /* pdata->ext_cd_init might call sdhci_s3c_notify_change immediately, so it can be called only after sdhci_add_host() */ if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init) { pr_info("%s : S3C_SDHCI_CD_EXTERNAL and external init\n", __func__); pdata->ext_cd_init(&sdhci_s3c_notify_change); } if (pdata->cd_type == S3C_SDHCI_CD_GPIO && gpio_is_valid(pdata->ext_cd_gpio)) { host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; } return 0; err_add_host: release_resource(sc->ioarea); kfree(sc->ioarea); err_req_regs: for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } err_no_busclks: clk_disable(sc->clk_io); clk_put(sc->clk_io); err_io_clk: sdhci_free_host(host); return ret; }
static int __devinit sdhci_probe(struct platform_device *pdev) { struct sdhci_host *host; struct resource *iomem; struct spear_sdhci *sdhci; int ret; BUG_ON(pdev == NULL); iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!iomem) { ret = -ENOMEM; dev_dbg(&pdev->dev, "memory resource not defined\n"); goto err; } if (!request_mem_region(iomem->start, resource_size(iomem), "spear-sdhci")) { ret = -EBUSY; dev_dbg(&pdev->dev, "cannot request region\n"); goto err; } sdhci = kzalloc(sizeof(*sdhci), GFP_KERNEL); if (!sdhci) { ret = -ENOMEM; dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n"); goto err_kzalloc; } /* clk enable */ sdhci->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(sdhci->clk)) { ret = PTR_ERR(sdhci->clk); dev_dbg(&pdev->dev, "Error getting clock\n"); goto err_clk_get; } ret = clk_enable(sdhci->clk); if (ret) { dev_dbg(&pdev->dev, "Error enabling clock\n"); goto err_clk_enb; } /* overwrite platform_data */ sdhci->data = dev_get_platdata(&pdev->dev); pdev->dev.platform_data = sdhci; if (pdev->dev.parent) host = sdhci_alloc_host(pdev->dev.parent, 0); else host = sdhci_alloc_host(&pdev->dev, 0); if (IS_ERR(host)) { ret = PTR_ERR(host); dev_dbg(&pdev->dev, "error allocating host\n"); goto err_alloc_host; } host->hw_name = "sdhci"; host->ops = &sdhci_pltfm_ops; host->irq = platform_get_irq(pdev, 0); host->quirks = SDHCI_QUIRK_BROKEN_ADMA; host->ioaddr = ioremap(iomem->start, resource_size(iomem)); if (!host->ioaddr) { ret = -ENOMEM; dev_dbg(&pdev->dev, "failed to remap registers\n"); goto err_ioremap; } ret = sdhci_add_host(host); if (ret) { dev_dbg(&pdev->dev, "error adding host\n"); goto err_add_host; } platform_set_drvdata(pdev, host); /* * It is optional to use GPIOs for sdhci Power control & sdhci card * interrupt detection. If sdhci->data is NULL, then use original sdhci * lines otherwise GPIO lines. * If GPIO is selected for power control, then power should be disabled * after card removal and should be enabled when card insertion * interrupt occurs */ if (!sdhci->data) return 0; if (sdhci->data->card_power_gpio >= 0) { int val = 0; ret = gpio_request(sdhci->data->card_power_gpio, "sdhci"); if (ret < 0) { dev_dbg(&pdev->dev, "gpio request fail: %d\n", sdhci->data->card_power_gpio); goto err_pgpio_request; } if (sdhci->data->power_always_enb) val = sdhci->data->power_active_high; else val = !sdhci->data->power_active_high; ret = gpio_direction_output(sdhci->data->card_power_gpio, val); if (ret) { dev_dbg(&pdev->dev, "gpio set direction fail: %d\n", sdhci->data->card_power_gpio); goto err_pgpio_direction; } gpio_set_value(sdhci->data->card_power_gpio, 1); } if (sdhci->data->card_int_gpio >= 0) { ret = gpio_request(sdhci->data->card_int_gpio, "sdhci"); if (ret < 0) { dev_dbg(&pdev->dev, "gpio request fail: %d\n", sdhci->data->card_int_gpio); goto err_igpio_request; } ret = gpio_direction_input(sdhci->data->card_int_gpio); if (ret) { dev_dbg(&pdev->dev, "gpio set direction fail: %d\n", sdhci->data->card_int_gpio); goto err_igpio_direction; } ret = request_irq(gpio_to_irq(sdhci->data->card_int_gpio), sdhci_gpio_irq, IRQF_TRIGGER_LOW, mmc_hostname(host->mmc), pdev); if (ret) { dev_dbg(&pdev->dev, "gpio request irq fail: %d\n", sdhci->data->card_int_gpio); goto err_igpio_request_irq; } } return 0; err_igpio_request_irq: err_igpio_direction: if (sdhci->data->card_int_gpio >= 0) gpio_free(sdhci->data->card_int_gpio); err_igpio_request: err_pgpio_direction: if (sdhci->data->card_power_gpio >= 0) gpio_free(sdhci->data->card_power_gpio); err_pgpio_request: platform_set_drvdata(pdev, NULL); sdhci_remove_host(host, 1); err_add_host: iounmap(host->ioaddr); err_ioremap: sdhci_free_host(host); err_alloc_host: clk_disable(sdhci->clk); err_clk_enb: clk_put(sdhci->clk); err_clk_get: kfree(sdhci); err_kzalloc: release_mem_region(iomem->start, resource_size(iomem)); err: dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret); return ret; }
static int sdhci_s3c_probe(struct platform_device *pdev) { struct s3c_sdhci_platdata *pdata; struct sdhci_s3c_drv_data *drv_data; struct device *dev = &pdev->dev; struct sdhci_host *host; struct sdhci_s3c *sc; struct resource *res; int ret, irq, ptr, clks; if (!pdev->dev.platform_data && !pdev->dev.of_node) { dev_err(dev, "no device data specified\n"); return -ENOENT; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(dev, "no irq specified\n"); return irq; } host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); if (IS_ERR(host)) { dev_err(dev, "sdhci_alloc_host() failed\n"); return PTR_ERR(host); } sc = sdhci_priv(host); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { ret = -ENOMEM; goto err_pdata_io_clk; } if (pdev->dev.of_node) { ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata); if (ret) goto err_pdata_io_clk; } else { memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata)); sc->ext_cd_gpio = -1; /* invalid gpio number */ } drv_data = sdhci_s3c_get_driver_data(pdev); sc->host = host; sc->pdev = pdev; sc->pdata = pdata; platform_set_drvdata(pdev, host); sc->clk_io = devm_clk_get(dev, "hsmmc"); if (IS_ERR(sc->clk_io)) { dev_err(dev, "failed to get io clock\n"); ret = PTR_ERR(sc->clk_io); goto err_pdata_io_clk; } /* enable the local io clock and keep it running for the moment. */ clk_prepare_enable(sc->clk_io); for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) { struct clk *clk; char name[14]; snprintf(name, 14, "mmc_busclk.%d", ptr); clk = devm_clk_get(dev, name); if (IS_ERR(clk)) continue; clks++; sc->clk_bus[ptr] = clk; /* * save current clock index to know which clock bus * is used later in overriding functions. */ sc->cur_clk = ptr; dev_info(dev, "clock source %d: %s (%ld Hz)\n", ptr, name, clk_get_rate(clk)); } if (clks == 0) { dev_err(dev, "failed to find any bus clocks\n"); ret = -ENOENT; goto err_no_busclks; } #ifndef CONFIG_PM_RUNTIME clk_prepare_enable(sc->clk_bus[sc->cur_clk]); #endif res = platform_get_resource(pdev, IORESOURCE_MEM, 0); host->ioaddr = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(host->ioaddr)) { ret = PTR_ERR(host->ioaddr); goto err_req_regs; } /* Ensure we have minimal gpio selected CMD/CLK/Detect */ if (pdata->cfg_gpio) pdata->cfg_gpio(pdev, pdata->max_width); host->hw_name = "samsung-hsmmc"; host->ops = &sdhci_s3c_ops; host->quirks = 0; host->irq = irq; /* Setup quirks for the controller */ host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; if (drv_data) host->quirks |= drv_data->sdhci_quirks; #ifndef CONFIG_MMC_SDHCI_S3C_DMA /* we currently see overruns on errors, so disable the SDMA * support as well. */ host->quirks |= SDHCI_QUIRK_BROKEN_DMA; #endif /* CONFIG_MMC_SDHCI_S3C_DMA */ /* It seems we do not get an DATA transfer complete on non-busy * transfers, not sure if this is a problem with this specific * SDHCI block, or a missing configuration that needs to be set. */ host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ; /* This host supports the Auto CMD12 */ host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; /* Samsung SoCs need BROKEN_ADMA_ZEROLEN_DESC */ host->quirks |= SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC; if (pdata->cd_type == S3C_SDHCI_CD_NONE || pdata->cd_type == S3C_SDHCI_CD_PERMANENT) host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) host->mmc->caps = MMC_CAP_NONREMOVABLE; switch (pdata->max_width) { case 8: host->mmc->caps |= MMC_CAP_8_BIT_DATA; case 4: host->mmc->caps |= MMC_CAP_4_BIT_DATA; break; } if (pdata->pm_caps) host->mmc->pm_caps |= pdata->pm_caps; host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_32BIT_DMA_SIZE); /* HSMMC on Samsung SoCs uses SDCLK as timeout clock */ host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK; /* * If controller does not have internal clock divider, * we can use overriding functions instead of default. */ if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) { pax_open_kernel(); *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock; *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock; *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock; pax_close_kernel(); } /* It supports additional host capabilities if needed */ if (pdata->host_caps) host->mmc->caps |= pdata->host_caps; if (pdata->host_caps2) host->mmc->caps2 |= pdata->host_caps2; pm_runtime_enable(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 50); pm_runtime_use_autosuspend(&pdev->dev); pm_suspend_ignore_children(&pdev->dev, 1); ret = sdhci_add_host(host); if (ret) { dev_err(dev, "sdhci_add_host() failed\n"); pm_runtime_forbid(&pdev->dev); pm_runtime_get_noresume(&pdev->dev); goto err_req_regs; } /* The following two methods of card detection might call sdhci_s3c_notify_change() immediately, so they can be called only after sdhci_add_host(). Setup errors are ignored. */ if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init) pdata->ext_cd_init(&sdhci_s3c_notify_change); if (pdata->cd_type == S3C_SDHCI_CD_GPIO && gpio_is_valid(pdata->ext_cd_gpio)) sdhci_s3c_setup_card_detect_gpio(sc); #ifdef CONFIG_PM_RUNTIME if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) clk_disable_unprepare(sc->clk_io); #endif return 0; err_req_regs: #ifndef CONFIG_PM_RUNTIME clk_disable_unprepare(sc->clk_bus[sc->cur_clk]); #endif err_no_busclks: clk_disable_unprepare(sc->clk_io); err_pdata_io_clk: sdhci_free_host(host); return ret; }
static int __devinit tegra_sdhci_probe(struct platform_device *pdev) { int rc; struct tegra_sdhci_platform_data *plat; struct sdhci_host *sdhci; struct tegra_sdhci_host *host; struct resource *res; int irq; void __iomem *ioaddr; plat = pdev->dev.platform_data; if (plat == NULL) return -ENXIO; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res == NULL) return -ENODEV; irq = res->start; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) return -ENODEV; ioaddr = ioremap(res->start, res->end - res->start); sdhci = sdhci_alloc_host(&pdev->dev, sizeof(struct tegra_sdhci_host)); if (IS_ERR(sdhci)) { rc = PTR_ERR(sdhci); goto err_unmap; } host = sdhci_priv(sdhci); host->sdhci = sdhci; host->card_always_on = (plat->power_gpio == -1) ? 1 : 0; host->wp_gpio = plat->wp_gpio; host->clk = clk_get(&pdev->dev, plat->clk_id); if (IS_ERR(host->clk)) { rc = PTR_ERR(host->clk); goto err_free_host; } rc = clk_enable(host->clk); if (rc != 0) goto err_clkput; host->clk_enabled = 1; sdhci->hw_name = "tegra"; sdhci->ops = &tegra_sdhci_ops; sdhci->irq = irq; sdhci->ioaddr = ioaddr; sdhci->version = SDHCI_SPEC_200; sdhci->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | SDHCI_QUIRK_SINGLE_POWER_WRITE | SDHCI_QUIRK_ENABLE_INTERRUPT_AT_BLOCK_GAP | SDHCI_QUIRK_BROKEN_WRITE_PROTECT | SDHCI_QUIRK_BROKEN_CTRL_HISPD | SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_8_BIT_DATA | SDHCI_QUIRK_NO_VERSION_REG | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | SDHCI_QUIRK_RUNTIME_DISABLE; if (plat->force_hs != 0) sdhci->quirks |= SDHCI_QUIRK_FORCE_HIGH_SPEED_MODE; #ifdef CONFIG_MMC_EMBEDDED_SDIO mmc_set_embedded_sdio_data(sdhci->mmc, &plat->cis, &plat->cccr, plat->funcs, plat->num_funcs); #endif if (host->card_always_on) sdhci->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; rc = sdhci_add_host(sdhci); if (rc) goto err_clk_disable; platform_set_drvdata(pdev, host); if (plat->cd_gpio != -1) { rc = request_irq(gpio_to_irq(plat->cd_gpio), carddetect_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, mmc_hostname(sdhci->mmc), sdhci); if (rc) goto err_remove_host; } else if (plat->register_status_notify) { plat->register_status_notify( tegra_sdhci_status_notify_cb, sdhci); } if (plat->board_probe) plat->board_probe(pdev->id, sdhci->mmc); printk(KERN_INFO "sdhci%d: initialized irq %d ioaddr %p\n", pdev->id, sdhci->irq, sdhci->ioaddr); return 0; err_remove_host: sdhci_remove_host(sdhci, 1); err_clk_disable: clk_disable(host->clk); err_clkput: clk_put(host->clk); err_free_host: if (sdhci) sdhci_free_host(sdhci); err_unmap: iounmap(sdhci->ioaddr); return rc; }
static int sdhci_acpi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; acpi_handle handle = ACPI_HANDLE(dev); struct acpi_device *device; struct sdhci_acpi_host *c; struct sdhci_host *host; struct resource *iomem; resource_size_t len; const char *hid; int err; if (acpi_bus_get_device(handle, &device)) return -ENODEV; if (acpi_bus_get_status(device) || !device->status.present) return -ENODEV; hid = acpi_device_hid(device); iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!iomem) return -ENOMEM; len = resource_size(iomem); if (len < 0x100) dev_err(dev, "Invalid iomem size!\n"); if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev))) return -ENOMEM; host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host)); if (IS_ERR(host)) return PTR_ERR(host); c = sdhci_priv(host); c->host = host; c->slot = sdhci_acpi_get_slot(handle, hid); c->pdev = pdev; c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM); platform_set_drvdata(pdev, c); host->hw_name = "ACPI"; host->ops = &sdhci_acpi_ops_dflt; host->irq = platform_get_irq(pdev, 0); host->ioaddr = devm_ioremap_nocache(dev, iomem->start, resource_size(iomem)); if (host->ioaddr == NULL) { err = -ENOMEM; goto err_free; } if (!dev->dma_mask) { u64 dma_mask; if (sdhci_readl(host, SDHCI_CAPABILITIES) & SDHCI_CAN_64BIT) { /* 64-bit DMA is not supported at present */ dma_mask = DMA_BIT_MASK(32); } else { dma_mask = DMA_BIT_MASK(32); } err = dma_coerce_mask_and_coherent(dev, dma_mask); if (err) goto err_free; } if (c->slot) { if (c->slot->chip) { host->ops = c->slot->chip->ops; host->quirks |= c->slot->chip->quirks; host->quirks2 |= c->slot->chip->quirks2; host->mmc->caps |= c->slot->chip->caps; host->mmc->caps2 |= c->slot->chip->caps2; host->mmc->pm_caps |= c->slot->chip->pm_caps; } host->quirks |= c->slot->quirks; host->quirks2 |= c->slot->quirks2; host->mmc->caps |= c->slot->caps; host->mmc->caps2 |= c->slot->caps2; host->mmc->pm_caps |= c->slot->pm_caps; } host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; err = sdhci_add_host(host); if (err) goto err_free; if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) { if (sdhci_acpi_add_own_cd(dev, host->mmc)) c->use_runtime_pm = false; } if (c->use_runtime_pm) { pm_runtime_set_active(dev); pm_suspend_ignore_children(dev, 1); pm_runtime_set_autosuspend_delay(dev, 50); pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); } return 0; err_free: sdhci_free_host(c->host); return err; }
static int __devinit sdhci_pltfm_probe(struct platform_device *pdev) { struct sdhci_pltfm_data *pdata = pdev->dev.platform_data; const struct platform_device_id *platid = platform_get_device_id(pdev); struct sdhci_host *host; struct resource *iomem; int ret; if (!pdata && platid && platid->driver_data) pdata = (void *)platid->driver_data; iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!iomem) { ret = -ENOMEM; goto err; } if (resource_size(iomem) < 0x100) dev_err(&pdev->dev, "Invalid iomem size. You may " "experience problems.\n"); if (pdev->dev.parent) host = sdhci_alloc_host(pdev->dev.parent, 0); else host = sdhci_alloc_host(&pdev->dev, 0); if (IS_ERR(host)) { ret = PTR_ERR(host); goto err; } host->hw_name = "platform"; if (pdata && pdata->ops) host->ops = pdata->ops; else host->ops = &sdhci_pltfm_ops; if (pdata) host->quirks = pdata->quirks; host->irq = platform_get_irq(pdev, 0); if (!request_mem_region(iomem->start, resource_size(iomem), mmc_hostname(host->mmc))) { dev_err(&pdev->dev, "cannot request region\n"); ret = -EBUSY; goto err_request; } host->ioaddr = ioremap(iomem->start, resource_size(iomem)); if (!host->ioaddr) { dev_err(&pdev->dev, "failed to remap registers\n"); ret = -ENOMEM; goto err_remap; } if (pdata && pdata->init) { ret = pdata->init(host); if (ret) goto err_plat_init; } ret = sdhci_add_host(host); if (ret) goto err_add_host; platform_set_drvdata(pdev, host); return 0; err_add_host: if (pdata && pdata->exit) pdata->exit(host); err_plat_init: iounmap(host->ioaddr); err_remap: release_mem_region(iomem->start, resource_size(iomem)); err_request: sdhci_free_host(host); err: printk(KERN_ERR"Probing of sdhci-pltfm failed: %d\n", ret); return ret; }
static int __devinit sdhci_sprd_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct sdhci_host *host; struct resource *res; int ret, irq; #ifdef CONFIG_MMC_CARD_HOTPLUG int sd_detect_gpio; int detect_irq; #endif struct sprd_host_data *host_data; irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(dev, "no irq specified\n"); return irq; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "no memory specified\n"); return -ENOENT; } if(pdev->id == 0) { sd_buffer_pre_alloc(); } host = sdhci_alloc_host(dev, sizeof(struct sprd_host_data)); if (IS_ERR(host)) { dev_err(dev, "sdhci_alloc_host() failed\n"); return PTR_ERR(host); } host_data = sdhci_priv(host); host_data->platdata = dev_get_platdata(dev); host_data->clk_enable = 0; BUG_ON(NULL == host_data->platdata); printk("sdio probe %s, vdd %s (%d), clk %s parent %s\n", host_data->platdata->hw_name, host_data->platdata->vdd_name, host_data->platdata->volt_level, host_data->platdata->clk_name, host_data->platdata->clk_parent); platform_set_drvdata(pdev, host); host->vmmc = NULL; host->vmmc_ext = NULL; host->ioaddr = (void __iomem *)res->start; printk("sdio: host->ioaddr:0x%x\n", (u32)host->ioaddr); host->hw_name = (host_data->platdata->hw_name)? host_data->platdata->hw_name:pdev->name; host->ops = &sdhci_sprd_ops; host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |\ SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |\ SDHCI_QUIRK_BROKEN_CARD_DETECTION|\ SDHCI_QUIRK_INVERTED_WRITE_PROTECT; host->irq = irq; #ifdef CONFIG_MMC_CARD_HOTPLUG sd_detect_gpio = host_data->platdata->detect_gpio; if(sd_detect_gpio > 0){ pr_info("%s, sd_detect_gpio:%d\n", __func__, sd_detect_gpio); if (0 == pdev->id){ ret = gpio_request(sd_detect_gpio, "sdio0_detect"); }else{ ret = gpio_request(sd_detect_gpio, "sdio1_detect"); } if (ret) { dev_err(dev, "cannot request gpio\n"); return -1; } ret = gpio_direction_input(sd_detect_gpio); if (ret) { dev_err(dev, "gpio can not change to input\n"); return -1; } detect_irq = gpio_to_irq(sd_detect_gpio); if (detect_irq < 0){ dev_err(dev, "cannot alloc detect irq\n"); return -1; } host_data->detect_irq = detect_irq; }else if (host_data->platdata->register_status_notify) { host_data->platdata->register_status_notify(sdhci_status_notify_cb, host); } else if (!host_data->platdata->status) { printk("%s: No card detect facilities available\n", mmc_hostname(host->mmc)); }else{ printk("%s, sd_detect_gpio == 0 \n", __func__ ); } #endif if(host_data->platdata->vdd_name) { host->vmmc = regulator_get(NULL, host_data->platdata->vdd_name); BUG_ON(IS_ERR(host->vmmc)); if(!is_sd_slot(host)) regulator_enable(host->vmmc); } if(host_data->platdata->vdd_ext_name) { host->vmmc_ext = regulator_get(NULL, host_data->platdata->vdd_ext_name); BUG_ON(IS_ERR(host->vmmc_ext)); regulator_enable(host->vmmc_ext); } host->clk = NULL; sdhci_module_init(host); switch(pdev->id) { case 0: host->mmc->pm_flags |= MMC_PM_ONLY_USED_SDIO0_SHARK; host->caps = sdhci_readl(host, SDHCI_CAPABILITIES) & (~(SDHCI_CAN_VDD_330 | SDHCI_CAN_VDD_180)); host->quirks |= SDHCI_QUIRK_MISSING_CAPS; host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; break; case 1: host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY|MMC_PM_KEEP_POWER |MMC_PM_DISABLE_TIMEOUT_IRQ; host->mmc->pm_caps |= MMC_PM_KEEP_POWER |MMC_PM_DISABLE_TIMEOUT_IRQ; #ifdef CONFIG_SDIO_CARD host->mmc->caps |= MMC_CAP_4_BIT_DATA |MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD; #else host->mmc->caps |= MMC_CAP_4_BIT_DATA |MMC_CAP_NONREMOVABLE; #endif break; case 2: host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY | MMC_PM_KEEP_POWER; host->mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD; break; case 3: host->caps = sdhci_readl(host, SDHCI_CAPABILITIES) & (~(SDHCI_CAN_VDD_330 | SDHCI_CAN_VDD_300)); host->quirks |= SDHCI_QUIRK_MISSING_CAPS; host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY | MMC_PM_KEEP_POWER; host->mmc->caps |= MMC_CAP_NONREMOVABLE | MMC_CAP_8_BIT_DATA | MMC_CAP_HW_RESET; break; default: BUG(); break; } #ifdef CONFIG_PM_RUNTIME switch(pdev->id) { case 1: case 2: #ifdef CONFIG_SDIO_CARD pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 100); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_no_callbacks(mmc_classdev(host->mmc)); pm_suspend_ignore_children(mmc_classdev(host->mmc), true); pm_runtime_set_active(mmc_classdev(host->mmc)); pm_runtime_enable(mmc_classdev(host->mmc)); #endif break; case 3: case 0: pm_suspend_ignore_children(&pdev->dev, true); pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 100); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); default: break; } #endif ret = sdhci_add_host(host); if (ret) { dev_err(dev, "sdhci_add_host() failed\n"); goto err_add_host; } #ifdef CONFIG_MMC_BUS_SCAN if (pdev->id == 1) sdhci_host_g = host; #endif return 0; err_add_host: #ifdef CONFIG_PM_RUNTIME pm_runtime_disable(&(pdev)->dev); pm_runtime_set_suspended(&(pdev)->dev); #endif if (host_data->clk_enable) { clk_disable(host->clk); host_data->clk_enable = 0; } sdhci_free_host(host); return ret; }