Lines Matching full:mmc

18 #include <linux/mmc/host.h>
19 #include <linux/mmc/mmc.h>
20 #include <linux/mmc/sdio.h>
21 #include <linux/mmc/slot-gpio.h>
31 #define DRIVER_NAME "meson-gx-mmc"
151 struct mmc_host *mmc; member
223 static void meson_mmc_get_transfer_mode(struct mmc_host *mmc, in meson_mmc_get_transfer_mode() argument
226 struct meson_host *host = mmc_priv(mmc); in meson_mmc_get_transfer_mode()
272 static void meson_mmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq) in meson_mmc_pre_req() argument
279 meson_mmc_get_transfer_mode(mmc, mrq); in meson_mmc_pre_req()
285 data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg, data->sg_len, in meson_mmc_pre_req()
288 dev_err(mmc_dev(mmc), "dma_map_sg failed"); in meson_mmc_pre_req()
291 static void meson_mmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, in meson_mmc_post_req() argument
297 dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, in meson_mmc_post_req()
302 * Gating the clock on this controller is tricky. It seems the mmc clock
340 struct mmc_host *mmc = host->mmc; in meson_mmc_clk_set() local
351 mmc->actual_clock = 0; in meson_mmc_clk_set()
380 mmc->actual_clock = clk_get_rate(host->mmc_clk); in meson_mmc_clk_set()
385 mmc->actual_clock >>= 1; in meson_mmc_clk_set()
388 dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock); in meson_mmc_clk_set()
389 if (rate != mmc->actual_clock) in meson_mmc_clk_set()
400 * generating the MMC clock. Use the clock framework to create and
481 host->mmc->f_min = clk_round_rate(host->mmc_clk, 400000); in meson_mmc_clk_init()
482 ret = clk_set_rate(host->mmc_clk, host->mmc->f_min); in meson_mmc_clk_init()
508 static int meson_mmc_resampling_tuning(struct mmc_host *mmc, u32 opcode) in meson_mmc_resampling_tuning() argument
510 struct meson_host *host = mmc_priv(mmc); in meson_mmc_resampling_tuning()
522 if (mmc_doing_retune(mmc)) in meson_mmc_resampling_tuning()
532 ret = mmc_send_tuning(mmc, opcode, NULL); in meson_mmc_resampling_tuning()
534 dev_dbg(mmc_dev(mmc), "resampling delay: %u\n", in meson_mmc_resampling_tuning()
576 static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) in meson_mmc_set_ios() argument
578 struct meson_host *host = mmc_priv(mmc); in meson_mmc_set_ios()
588 if (!IS_ERR(mmc->supply.vmmc)) in meson_mmc_set_ios()
589 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in meson_mmc_set_ios()
591 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { in meson_mmc_set_ios()
592 regulator_disable(mmc->supply.vqmmc); in meson_mmc_set_ios()
599 if (!IS_ERR(mmc->supply.vmmc)) in meson_mmc_set_ios()
600 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); in meson_mmc_set_ios()
605 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { in meson_mmc_set_ios()
606 int ret = regulator_enable(mmc->supply.vqmmc); in meson_mmc_set_ios()
648 static void meson_mmc_request_done(struct mmc_host *mmc, in meson_mmc_request_done() argument
651 struct meson_host *host = mmc_priv(mmc); in meson_mmc_request_done()
654 mmc_request_done(host->mmc, mrq); in meson_mmc_request_done()
657 static void meson_mmc_set_blksz(struct mmc_host *mmc, unsigned int blksz) in meson_mmc_set_blksz() argument
659 struct meson_host *host = mmc_priv(mmc); in meson_mmc_set_blksz()
699 static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg) in meson_mmc_desc_chain_transfer() argument
701 struct meson_host *host = mmc_priv(mmc); in meson_mmc_desc_chain_transfer()
713 meson_mmc_set_blksz(mmc, data->blksz); in meson_mmc_desc_chain_transfer()
737 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) in meson_mmc_start_cmd() argument
739 struct meson_host *host = mmc_priv(mmc); in meson_mmc_start_cmd()
763 meson_mmc_desc_chain_transfer(mmc, cmd_cfg); in meson_mmc_start_cmd()
771 meson_mmc_set_blksz(mmc, data->blksz); in meson_mmc_start_cmd()
800 static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) in meson_mmc_request() argument
802 struct meson_host *host = mmc_priv(mmc); in meson_mmc_request()
807 meson_mmc_get_transfer_mode(mmc, mrq); in meson_mmc_request()
813 meson_mmc_pre_req(mmc, mrq); in meson_mmc_request()
818 meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd); in meson_mmc_request()
821 meson_mmc_post_req(mmc, mrq, 0); in meson_mmc_request()
824 static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) in meson_mmc_read_resp() argument
826 struct meson_host *host = mmc_priv(mmc); in meson_mmc_read_resp()
880 meson_mmc_read_resp(host->mmc, cmd); in meson_mmc_irq()
907 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq()
941 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq_thread()
956 meson_mmc_start_cmd(host->mmc, next_cmd); in meson_mmc_irq_thread()
958 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq_thread()
965 * interrupts. For now, the MMC core will use this for polling.
967 static int meson_mmc_get_cd(struct mmc_host *mmc) in meson_mmc_get_cd() argument
969 int status = mmc_gpio_get_cd(mmc); in meson_mmc_get_cd()
992 static int meson_mmc_card_busy(struct mmc_host *mmc) in meson_mmc_card_busy() argument
994 struct meson_host *host = mmc_priv(mmc); in meson_mmc_card_busy()
1003 static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) in meson_mmc_voltage_switch() argument
1008 if (!IS_ERR(mmc->supply.vqmmc)) { in meson_mmc_voltage_switch()
1016 ret = mmc_regulator_set_vqmmc(mmc, ios); in meson_mmc_voltage_switch()
1042 struct mmc_host *mmc; in meson_mmc_probe() local
1045 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev); in meson_mmc_probe()
1046 if (!mmc) in meson_mmc_probe()
1048 host = mmc_priv(mmc); in meson_mmc_probe()
1049 host->mmc = mmc; in meson_mmc_probe()
1059 ret = mmc_regulator_get_supply(mmc); in meson_mmc_probe()
1063 ret = mmc_of_parse(mmc); in meson_mmc_probe()
1141 mmc->caps |= MMC_CAP_CMD23; in meson_mmc_probe()
1144 mmc->max_segs = 1; in meson_mmc_probe()
1146 mmc->max_blk_count = SD_EMMC_SRAM_DATA_BUF_LEN / in meson_mmc_probe()
1147 mmc->max_blk_size; in meson_mmc_probe()
1149 mmc->max_blk_count = CMD_CFG_LENGTH_MASK; in meson_mmc_probe()
1150 mmc->max_segs = SD_EMMC_DESC_BUF_LEN / in meson_mmc_probe()
1153 mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; in meson_mmc_probe()
1154 mmc->max_seg_size = mmc->max_req_size; in meson_mmc_probe()
1161 mmc->caps2 &= ~MMC_CAP2_HS400; in meson_mmc_probe()
1165 * The MMC Controller embeds 1,5KiB of internal SRAM in meson_mmc_probe()
1175 host->bounce_buf_size = mmc->max_req_size; in meson_mmc_probe()
1194 mmc->ops = &meson_mmc_ops; in meson_mmc_probe()
1195 mmc_add_host(mmc); in meson_mmc_probe()
1210 mmc_free_host(mmc); in meson_mmc_probe()
1218 mmc_remove_host(host->mmc); in meson_mmc_remove()
1234 mmc_free_host(host->mmc); in meson_mmc_remove()
1253 { .compatible = "amlogic,meson-gx-mmc", .data = &meson_gx_data },
1254 { .compatible = "amlogic,meson-gxbb-mmc", .data = &meson_gx_data },
1255 { .compatible = "amlogic,meson-gxl-mmc", .data = &meson_gx_data },
1256 { .compatible = "amlogic,meson-gxm-mmc", .data = &meson_gx_data },
1257 { .compatible = "amlogic,meson-axg-mmc", .data = &meson_axg_data },