Lines Matching full:mmc

3  * Driver for sunxi SD/MMC host controllers
21 #include <linux/mmc/card.h>
22 #include <linux/mmc/core.h>
23 #include <linux/mmc/host.h>
24 #include <linux/mmc/mmc.h>
25 #include <linux/mmc/sd.h>
26 #include <linux/mmc/sdio.h>
27 #include <linux/mmc/slot-gpio.h>
259 * a mode switch in the clock controller, or the mmc controller
271 struct mmc_host *mmc; member
317 dev_err(mmc_dev(host->mmc), "fatal err reset timeout\n"); in sunxi_mmc_reset_host()
404 dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, in sunxi_mmc_map_dma()
407 dev_err(mmc_dev(host->mmc), "dma_map_sg failed\n"); in sunxi_mmc_map_dma()
413 dev_err(mmc_dev(host->mmc), in sunxi_mmc_map_dma()
472 dev_err(mmc_dev(host->mmc), "send stop command failed\n"); in sunxi_mmc_send_manual_stop()
488 /* For some cmds timeout is normal with sd/mmc cards */ in sunxi_mmc_dump_errinfo()
494 dev_dbg(mmc_dev(host->mmc), in sunxi_mmc_dump_errinfo()
496 host->mmc->index, cmd->opcode, in sunxi_mmc_dump_errinfo()
555 dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, in sunxi_mmc_finalize_request()
582 dev_dbg(mmc_dev(host->mmc), "irq: rq %p mi %08x idi %08x\n", in sunxi_mmc_irq()
617 mmc_request_done(host->mmc, mrq); in sunxi_mmc_irq()
620 mmc_signal_sdio_irq(host->mmc); in sunxi_mmc_irq()
636 dev_err(mmc_dev(host->mmc), "no request for manual stop\n"); in sunxi_mmc_handle_manual_stop()
640 dev_err(mmc_dev(host->mmc), "data error, sending stop command\n"); in sunxi_mmc_handle_manual_stop()
656 mmc_request_done(host->mmc, mrq); in sunxi_mmc_handle_manual_stop()
666 dev_dbg(mmc_dev(host->mmc), "%sabling the clock\n", in sunxi_mmc_oclk_onoff()
691 dev_err(mmc_dev(host->mmc), "fatal err update clk timeout\n"); in sunxi_mmc_oclk_onoff()
750 dev_dbg(mmc_dev(host->mmc), "Invalid clock... returning\n"); in sunxi_mmc_clk_set_phase()
763 struct mmc_host *mmc = host->mmc; in sunxi_mmc_clk_set_rate() local
773 mmc->actual_clock = 0; in sunxi_mmc_clk_set_rate()
783 * We currently only support the standard MMC DDR52 mode. in sunxi_mmc_clk_set_rate()
797 dev_err(mmc_dev(mmc), in sunxi_mmc_clk_set_rate()
805 dev_err(mmc_dev(mmc), "error rounding clk to %d: %ld\n", in sunxi_mmc_clk_set_rate()
809 dev_dbg(mmc_dev(mmc), "setting clk to %d, rounded %ld\n", in sunxi_mmc_clk_set_rate()
815 dev_err(mmc_dev(mmc), "error setting clk to %ld: %d\n", in sunxi_mmc_clk_set_rate()
864 mmc->actual_clock = rate; in sunxi_mmc_clk_set_rate()
905 struct mmc_host *mmc = host->mmc; in sunxi_mmc_card_power() local
909 dev_dbg(mmc_dev(mmc), "Powering card up\n"); in sunxi_mmc_card_power()
911 if (!IS_ERR(mmc->supply.vmmc)) { in sunxi_mmc_card_power()
912 host->ferror = mmc_regulator_set_ocr(mmc, in sunxi_mmc_card_power()
913 mmc->supply.vmmc, in sunxi_mmc_card_power()
919 if (!IS_ERR(mmc->supply.vqmmc)) { in sunxi_mmc_card_power()
920 host->ferror = regulator_enable(mmc->supply.vqmmc); in sunxi_mmc_card_power()
922 dev_err(mmc_dev(mmc), in sunxi_mmc_card_power()
931 dev_dbg(mmc_dev(mmc), "Powering card off\n"); in sunxi_mmc_card_power()
933 if (!IS_ERR(mmc->supply.vmmc)) in sunxi_mmc_card_power()
934 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in sunxi_mmc_card_power()
936 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) in sunxi_mmc_card_power()
937 regulator_disable(mmc->supply.vqmmc); in sunxi_mmc_card_power()
943 dev_dbg(mmc_dev(mmc), "Ignoring unknown card power state\n"); in sunxi_mmc_card_power()
948 static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) in sunxi_mmc_set_ios() argument
950 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_set_ios()
957 static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) in sunxi_mmc_volt_switch() argument
962 if (!IS_ERR(mmc->supply.vqmmc)) { in sunxi_mmc_volt_switch()
963 ret = mmc_regulator_set_vqmmc(mmc, ios); in sunxi_mmc_volt_switch()
968 if (mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330) in sunxi_mmc_volt_switch()
974 static void sunxi_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) in sunxi_mmc_enable_sdio_irq() argument
976 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_enable_sdio_irq()
997 pm_runtime_put_noidle(host->mmc->parent); in sunxi_mmc_enable_sdio_irq()
1000 static void sunxi_mmc_hw_reset(struct mmc_host *mmc) in sunxi_mmc_hw_reset() argument
1002 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_hw_reset()
1009 static void sunxi_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) in sunxi_mmc_request() argument
1011 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_request()
1023 mmc_request_done(mmc, mrq); in sunxi_mmc_request()
1030 dev_err(mmc_dev(mmc), "map DMA failed\n"); in sunxi_mmc_request()
1033 mmc_request_done(mmc, mrq); in sunxi_mmc_request()
1071 dev_dbg(mmc_dev(mmc), "cmd %d(%08x) arg %x ie 0x%08x len %d\n", in sunxi_mmc_request()
1081 dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, in sunxi_mmc_request()
1084 dev_err(mmc_dev(mmc), "request already pending\n"); in sunxi_mmc_request()
1086 mmc_request_done(mmc, mrq); in sunxi_mmc_request()
1105 static int sunxi_mmc_card_busy(struct mmc_host *mmc) in sunxi_mmc_card_busy() argument
1107 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_card_busy()
1211 { .compatible = "allwinner,sun4i-a10-mmc", .data = &sun4i_a10_cfg },
1212 { .compatible = "allwinner,sun5i-a13-mmc", .data = &sun5i_a13_cfg },
1213 { .compatible = "allwinner,sun7i-a20-mmc", .data = &sun7i_a20_cfg },
1215 { .compatible = "allwinner,sun9i-a80-mmc", .data = &sun9i_a80_cfg },
1216 { .compatible = "allwinner,sun20i-d1-mmc", .data = &sun20i_d1_cfg },
1217 { .compatible = "allwinner,sun50i-a64-mmc", .data = &sun50i_a64_cfg },
1219 { .compatible = "allwinner,sun50i-a100-mmc", .data = &sun20i_d1_cfg },
1221 { .compatible = "allwinner,sun50i-h616-mmc", .data = &sun50i_h616_cfg },
1233 dev_err(host->dev, "Couldn't reset the MMC controller (%d)\n", in sunxi_mmc_enable()
1247 dev_err(host->dev, "Enable mmc clk err %d\n", ret); in sunxi_mmc_enable()
1309 ret = mmc_regulator_get_supply(host->mmc); in sunxi_mmc_resource_request()
1323 host->clk_mmc = devm_clk_get(&pdev->dev, "mmc"); in sunxi_mmc_resource_request()
1325 dev_err(&pdev->dev, "Could not get mmc clock\n"); in sunxi_mmc_resource_request()
1359 sunxi_mmc_handle_manual_stop, 0, "sunxi-mmc", host); in sunxi_mmc_resource_request()
1369 struct mmc_host *mmc; in sunxi_mmc_probe() local
1372 mmc = mmc_alloc_host(sizeof(struct sunxi_mmc_host), &pdev->dev); in sunxi_mmc_probe()
1373 if (!mmc) { in sunxi_mmc_probe()
1374 dev_err(&pdev->dev, "mmc alloc host failed\n"); in sunxi_mmc_probe()
1377 platform_set_drvdata(pdev, mmc); in sunxi_mmc_probe()
1379 host = mmc_priv(mmc); in sunxi_mmc_probe()
1381 host->mmc = mmc; in sunxi_mmc_probe()
1410 dev_warn(&pdev->dev, "MMC clk timing mode unknown\n"); in sunxi_mmc_probe()
1420 mmc->ops = &sunxi_mmc_ops; in sunxi_mmc_probe()
1421 mmc->max_blk_count = 8192; in sunxi_mmc_probe()
1422 mmc->max_blk_size = 4096; in sunxi_mmc_probe()
1423 mmc->max_segs = PAGE_SIZE / sizeof(struct sunxi_idma_des); in sunxi_mmc_probe()
1424 mmc->max_seg_size = (1 << host->cfg->idma_des_size_bits); in sunxi_mmc_probe()
1425 mmc->max_req_size = mmc->max_seg_size * mmc->max_segs; in sunxi_mmc_probe()
1427 mmc->f_min = 400000; in sunxi_mmc_probe()
1428 mmc->f_max = 52000000; in sunxi_mmc_probe()
1429 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | in sunxi_mmc_probe()
1442 mmc->caps |= MMC_CAP_1_8V_DDR | MMC_CAP_3_3V_DDR; in sunxi_mmc_probe()
1444 ret = mmc_of_parse(mmc); in sunxi_mmc_probe()
1455 mmc->caps &= ~(MMC_CAP_3_3V_DDR | MMC_CAP_1_8V_DDR | in sunxi_mmc_probe()
1457 mmc->caps2 &= ~MMC_CAP2_HS200; in sunxi_mmc_probe()
1461 mmc->caps2 &= ~MMC_CAP2_HS400; in sunxi_mmc_probe()
1472 ret = mmc_add_host(mmc); in sunxi_mmc_probe()
1477 mmc->max_req_size >> 10, in sunxi_mmc_probe()
1485 mmc_free_host(mmc); in sunxi_mmc_probe()
1491 struct mmc_host *mmc = platform_get_drvdata(pdev); in sunxi_mmc_remove() local
1492 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_remove()
1494 mmc_remove_host(mmc); in sunxi_mmc_remove()
1501 mmc_free_host(mmc); in sunxi_mmc_remove()
1507 struct mmc_host *mmc = dev_get_drvdata(dev); in sunxi_mmc_runtime_resume() local
1508 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_runtime_resume()
1516 sunxi_mmc_set_bus_width(host, mmc->ios.bus_width); in sunxi_mmc_runtime_resume()
1517 sunxi_mmc_set_clk(host, &mmc->ios); in sunxi_mmc_runtime_resume()
1525 struct mmc_host *mmc = dev_get_drvdata(dev); in sunxi_mmc_runtime_suspend() local
1526 struct sunxi_mmc_host *host = mmc_priv(mmc); in sunxi_mmc_runtime_suspend()
1551 .name = "sunxi-mmc",
1561 MODULE_DESCRIPTION("Allwinner's SD/MMC Card Controller Driver");
1564 MODULE_ALIAS("platform:sunxi-mmc");