Lines Matching full:mmc

2  * drivers/mmc/host/omap_hsmmc.c
4 * Driver for OMAP2430/3430 MMC controller.
34 #include <linux/mmc/host.h>
35 #include <linux/mmc/core.h>
36 #include <linux/mmc/mmc.h>
37 #include <linux/mmc/slot-gpio.h>
156 * MMC Host controller read/write API's
171 struct mmc_host *mmc; member
216 static int omap_hsmmc_enable_supply(struct mmc_host *mmc) in omap_hsmmc_enable_supply() argument
219 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_supply()
220 struct mmc_ios *ios = &mmc->ios; in omap_hsmmc_enable_supply()
222 if (!IS_ERR(mmc->supply.vmmc)) { in omap_hsmmc_enable_supply()
223 ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); in omap_hsmmc_enable_supply()
229 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { in omap_hsmmc_enable_supply()
230 ret = regulator_enable(mmc->supply.vqmmc); in omap_hsmmc_enable_supply()
232 dev_err(mmc_dev(mmc), "vmmc_aux reg enable failed\n"); in omap_hsmmc_enable_supply()
241 if (!IS_ERR(mmc->supply.vmmc)) in omap_hsmmc_enable_supply()
242 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in omap_hsmmc_enable_supply()
247 static int omap_hsmmc_disable_supply(struct mmc_host *mmc) in omap_hsmmc_disable_supply() argument
251 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_disable_supply()
253 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { in omap_hsmmc_disable_supply()
254 ret = regulator_disable(mmc->supply.vqmmc); in omap_hsmmc_disable_supply()
256 dev_err(mmc_dev(mmc), "vmmc_aux reg disable failed\n"); in omap_hsmmc_disable_supply()
262 if (!IS_ERR(mmc->supply.vmmc)) { in omap_hsmmc_disable_supply()
263 ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in omap_hsmmc_disable_supply()
271 if (!IS_ERR(mmc->supply.vqmmc)) { in omap_hsmmc_disable_supply()
272 status = regulator_enable(mmc->supply.vqmmc); in omap_hsmmc_disable_supply()
274 dev_err(mmc_dev(mmc), "vmmc_aux re-enable failed\n"); in omap_hsmmc_disable_supply()
312 struct mmc_host *mmc = host->mmc; in omap_hsmmc_set_power() local
319 if (IS_ERR(mmc->supply.vmmc)) in omap_hsmmc_set_power()
340 ret = omap_hsmmc_enable_supply(mmc); in omap_hsmmc_set_power()
348 ret = omap_hsmmc_disable_supply(mmc); in omap_hsmmc_set_power()
356 omap_hsmmc_disable_supply(mmc); in omap_hsmmc_set_power()
383 struct mmc_host *mmc = host->mmc; in omap_hsmmc_disable_boot_regulators() local
391 ret = omap_hsmmc_disable_boot_regulator(mmc->supply.vmmc); in omap_hsmmc_disable_boot_regulators()
397 ret = omap_hsmmc_disable_boot_regulator(mmc->supply.vqmmc); in omap_hsmmc_disable_boot_regulators()
417 struct mmc_host *mmc = host->mmc; in omap_hsmmc_reg_get() local
420 ret = mmc_regulator_get_supply(mmc); in omap_hsmmc_reg_get()
425 if (IS_ERR(mmc->supply.vqmmc)) { in omap_hsmmc_reg_get()
426 mmc->supply.vqmmc = devm_regulator_get_optional(host->dev, in omap_hsmmc_reg_get()
428 if (IS_ERR(mmc->supply.vqmmc)) { in omap_hsmmc_reg_get()
429 ret = PTR_ERR(mmc->supply.vqmmc); in omap_hsmmc_reg_get()
433 PTR_ERR(mmc->supply.vqmmc)); in omap_hsmmc_reg_get()
477 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stopped\n"); in omap_hsmmc_stop_clock()
497 /* latch pending CIRQ, but don't signal MMC core */ in omap_hsmmc_enable_irq()
535 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_clock()
540 dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); in omap_hsmmc_set_clock()
565 * - MMC/SD clock coming out of controller > 25MHz in omap_hsmmc_set_clock()
585 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_width()
613 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_mode()
626 * Restore the MMC host context, if it was lost as result of a
631 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_context_restore()
655 if (host->mmc->caps & MMC_CAP_SDIO_IRQ) in omap_hsmmc_context_restore()
687 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n", in omap_hsmmc_context_restore()
693 * Save the MMC host context (store the number of power state changes so far).
744 struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev); in omap_hsmmc_show_slot_name() local
745 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_slot_name()
761 dev_vdbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n", in omap_hsmmc_start_command()
762 mmc_hostname(host->mmc), cmd->opcode, cmd->arg); in omap_hsmmc_start_command()
831 mmc_request_done(host->mmc, mrq); in omap_hsmmc_request_done()
835 * Notify the transfer complete to MMC core
945 len = sprintf(buf, "MMC IRQ 0x%x :", status); in omap_hsmmc_dbg_report_irq()
954 dev_vdbg(mmc_dev(host->mmc), "%s\n", res); in omap_hsmmc_dbg_report_irq()
964 * MMC controller internal state machines reset
995 dev_err(mmc_dev(host->mmc), in omap_hsmmc_reset_controller_fsm()
1023 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); in omap_hsmmc_do_irq()
1052 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12); in omap_hsmmc_do_irq()
1064 * MMC controller IRQ handler
1077 mmc_signal_sdio_irq(host->mmc); in omap_hsmmc_irq()
1100 * Switch MMC interface voltage ... only relevant for MMC1.
1130 * If a MMC dual voltage card is detected, the set_ios fn calls in omap_hsmmc_switch_opcond()
1154 dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); in omap_hsmmc_switch_opcond()
1187 mmc_request_done(host->mmc, mrq); in omap_hsmmc_dma_callback()
1230 * Routine to configure and start DMA for the MMC card
1257 /* REVISIT: The MMC buffer increments only when MSB is written. in omap_hsmmc_setup_dma_transfer()
1278 dev_err(mmc_dev(host->mmc), "prep_slave_sg() failed\n"); in omap_hsmmc_setup_dma_transfer()
1348 * Configure block length for MMC/SD cards and initiate the transfer.
1378 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); in omap_hsmmc_prepare_data()
1385 static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, in omap_hsmmc_post_req() argument
1388 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_post_req()
1400 static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq) in omap_hsmmc_pre_req() argument
1402 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_pre_req()
1421 static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req) in omap_hsmmc_request() argument
1423 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_request()
1439 mmc_request_done(mmc, req); in omap_hsmmc_request()
1452 static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) in omap_hsmmc_set_ios() argument
1454 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_set_ios()
1489 dev_dbg(mmc_dev(host->mmc), in omap_hsmmc_set_ios()
1502 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable) in omap_hsmmc_enable_sdio_irq() argument
1504 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_sdio_irq()
1552 dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n"); in omap_hsmmc_configure_wake_irq()
1635 struct mmc_host *mmc = s->private; in mmc_regs_show() local
1636 struct omap_hsmmc_host *host = mmc_priv(mmc); in mmc_regs_show()
1638 seq_printf(s, "mmc%d:\n", mmc->index); in mmc_regs_show()
1640 (mmc->caps & MMC_CAP_SDIO_IRQ) ? "interrupt" : "polling"); in mmc_regs_show()
1642 if (mmc->caps & MMC_CAP_SDIO_IRQ) { in mmc_regs_show()
1674 static void omap_hsmmc_debugfs(struct mmc_host *mmc) in omap_hsmmc_debugfs() argument
1676 if (mmc->debugfs_root) in omap_hsmmc_debugfs()
1677 debugfs_create_file("regs", S_IRUSR, mmc->debugfs_root, in omap_hsmmc_debugfs()
1678 mmc, &mmc_regs_fops); in omap_hsmmc_debugfs()
1683 static void omap_hsmmc_debugfs(struct mmc_host *mmc) in omap_hsmmc_debugfs() argument
1766 struct mmc_host *mmc; in omap_hsmmc_probe() local
1801 mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev); in omap_hsmmc_probe()
1802 if (!mmc) { in omap_hsmmc_probe()
1807 ret = mmc_of_parse(mmc); in omap_hsmmc_probe()
1811 host = mmc_priv(mmc); in omap_hsmmc_probe()
1812 host->mmc = mmc; in omap_hsmmc_probe()
1830 mmc->ops = &omap_hsmmc_ops; in omap_hsmmc_probe()
1832 mmc->f_min = OMAP_MMC_MIN_CLOCK; in omap_hsmmc_probe()
1835 mmc->f_max = pdata->max_freq; in omap_hsmmc_probe()
1836 else if (mmc->f_max == 0) in omap_hsmmc_probe()
1837 mmc->f_max = OMAP_MMC_MAX_CLOCK; in omap_hsmmc_probe()
1849 …dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performanc… in omap_hsmmc_probe()
1863 * MMC can still work without debounce clock. in omap_hsmmc_probe()
1868 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); in omap_hsmmc_probe()
1874 mmc->max_segs = 64; in omap_hsmmc_probe()
1876 mmc->max_blk_size = 512; /* Block Length at max can be 1024 */ in omap_hsmmc_probe()
1877 mmc->max_blk_count = 0xFFFF; /* No. of Blocks is 16 bits */ in omap_hsmmc_probe()
1878 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; in omap_hsmmc_probe()
1880 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | in omap_hsmmc_probe()
1883 mmc->caps |= mmc_pdata(host)->caps; in omap_hsmmc_probe()
1884 if (mmc->caps & MMC_CAP_8_BIT_DATA) in omap_hsmmc_probe()
1885 mmc->caps |= MMC_CAP_4_BIT_DATA; in omap_hsmmc_probe()
1888 mmc->caps |= MMC_CAP_NONREMOVABLE; in omap_hsmmc_probe()
1890 mmc->pm_caps |= mmc_pdata(host)->pm_caps; in omap_hsmmc_probe()
1896 dev_err(mmc_dev(host->mmc), "RX DMA channel request failed\n"); in omap_hsmmc_probe()
1903 dev_err(mmc_dev(host->mmc), "TX DMA channel request failed\n"); in omap_hsmmc_probe()
1915 mmc->max_seg_size = min3(mmc->max_req_size, in omap_hsmmc_probe()
1919 /* Request IRQ for MMC operations */ in omap_hsmmc_probe()
1921 mmc_hostname(mmc), host); in omap_hsmmc_probe()
1923 dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); in omap_hsmmc_probe()
1931 if (!mmc->ocr_avail) in omap_hsmmc_probe()
1932 mmc->ocr_avail = mmc_pdata(host)->ocr_mask; in omap_hsmmc_probe()
1946 mmc->caps |= MMC_CAP_SDIO_IRQ; in omap_hsmmc_probe()
1948 ret = mmc_add_host(mmc); in omap_hsmmc_probe()
1953 ret = device_create_file(&mmc->class_dev, &dev_attr_slot_name); in omap_hsmmc_probe()
1958 omap_hsmmc_debugfs(mmc); in omap_hsmmc_probe()
1965 mmc_remove_host(mmc); in omap_hsmmc_probe()
1977 mmc_free_host(mmc); in omap_hsmmc_probe()
1987 mmc_remove_host(host->mmc); in omap_hsmmc_remove()
1999 mmc_free_host(host->mmc); in omap_hsmmc_remove()
2012 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { in omap_hsmmc_suspend()
2026 /* Routine to resume the MMC device */
2038 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) in omap_hsmmc_resume()
2059 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_suspend()
2100 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_resume()