• Home
  • Raw
  • Download

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
224 static void meson_mmc_get_transfer_mode(struct mmc_host *mmc, in meson_mmc_get_transfer_mode() argument
227 struct meson_host *host = mmc_priv(mmc); in meson_mmc_get_transfer_mode()
273 static void meson_mmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq) in meson_mmc_pre_req() argument
280 meson_mmc_get_transfer_mode(mmc, mrq); in meson_mmc_pre_req()
286 data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg, data->sg_len, in meson_mmc_pre_req()
289 dev_err(mmc_dev(mmc), "dma_map_sg failed"); in meson_mmc_pre_req()
292 static void meson_mmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, in meson_mmc_post_req() argument
298 dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, in meson_mmc_post_req()
303 * Gating the clock on this controller is tricky. It seems the mmc clock
341 struct mmc_host *mmc = host->mmc; in meson_mmc_clk_set() local
352 mmc->actual_clock = 0; in meson_mmc_clk_set()
381 mmc->actual_clock = clk_get_rate(host->mmc_clk); in meson_mmc_clk_set()
386 mmc->actual_clock >>= 1; in meson_mmc_clk_set()
389 dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock); in meson_mmc_clk_set()
390 if (rate != mmc->actual_clock) in meson_mmc_clk_set()
401 * generating the MMC clock. Use the clock framework to create and
482 host->mmc->f_min = clk_round_rate(host->mmc_clk, 400000); in meson_mmc_clk_init()
483 ret = clk_set_rate(host->mmc_clk, host->mmc->f_min); in meson_mmc_clk_init()
509 static int meson_mmc_resampling_tuning(struct mmc_host *mmc, u32 opcode) in meson_mmc_resampling_tuning() argument
511 struct meson_host *host = mmc_priv(mmc); in meson_mmc_resampling_tuning()
523 if (mmc_doing_retune(mmc)) in meson_mmc_resampling_tuning()
533 ret = mmc_send_tuning(mmc, opcode, NULL); in meson_mmc_resampling_tuning()
535 dev_dbg(mmc_dev(mmc), "resampling delay: %u\n", in meson_mmc_resampling_tuning()
577 static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) in meson_mmc_set_ios() argument
579 struct meson_host *host = mmc_priv(mmc); in meson_mmc_set_ios()
589 if (!IS_ERR(mmc->supply.vmmc)) in meson_mmc_set_ios()
590 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in meson_mmc_set_ios()
592 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { in meson_mmc_set_ios()
593 regulator_disable(mmc->supply.vqmmc); in meson_mmc_set_ios()
600 if (!IS_ERR(mmc->supply.vmmc)) in meson_mmc_set_ios()
601 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); in meson_mmc_set_ios()
606 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { in meson_mmc_set_ios()
607 int ret = regulator_enable(mmc->supply.vqmmc); in meson_mmc_set_ios()
649 static void meson_mmc_request_done(struct mmc_host *mmc, in meson_mmc_request_done() argument
652 struct meson_host *host = mmc_priv(mmc); in meson_mmc_request_done()
655 mmc_request_done(host->mmc, mrq); in meson_mmc_request_done()
658 static void meson_mmc_set_blksz(struct mmc_host *mmc, unsigned int blksz) in meson_mmc_set_blksz() argument
660 struct meson_host *host = mmc_priv(mmc); in meson_mmc_set_blksz()
700 static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg) in meson_mmc_desc_chain_transfer() argument
702 struct meson_host *host = mmc_priv(mmc); in meson_mmc_desc_chain_transfer()
714 meson_mmc_set_blksz(mmc, data->blksz); in meson_mmc_desc_chain_transfer()
785 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) in meson_mmc_start_cmd() argument
787 struct meson_host *host = mmc_priv(mmc); in meson_mmc_start_cmd()
811 meson_mmc_desc_chain_transfer(mmc, cmd_cfg); in meson_mmc_start_cmd()
819 meson_mmc_set_blksz(mmc, data->blksz); in meson_mmc_start_cmd()
851 static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data *data) in meson_mmc_validate_dram_access() argument
860 dev_err(mmc_dev(mmc), "unaligned sg offset %u len %u\n", in meson_mmc_validate_dram_access()
869 static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) in meson_mmc_request() argument
871 struct meson_host *host = mmc_priv(mmc); in meson_mmc_request()
881 mrq->cmd->error = meson_mmc_validate_dram_access(mmc, mrq->data); in meson_mmc_request()
883 mmc_request_done(mmc, mrq); in meson_mmc_request()
889 meson_mmc_get_transfer_mode(mmc, mrq); in meson_mmc_request()
895 meson_mmc_pre_req(mmc, mrq); in meson_mmc_request()
900 meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd); in meson_mmc_request()
903 meson_mmc_post_req(mmc, mrq, 0); in meson_mmc_request()
906 static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) in meson_mmc_read_resp() argument
908 struct meson_host *host = mmc_priv(mmc); in meson_mmc_read_resp()
962 meson_mmc_read_resp(host->mmc, cmd); in meson_mmc_irq()
989 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq()
1023 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq_thread()
1041 meson_mmc_start_cmd(host->mmc, next_cmd); in meson_mmc_irq_thread()
1043 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq_thread()
1050 * interrupts. For now, the MMC core will use this for polling.
1052 static int meson_mmc_get_cd(struct mmc_host *mmc) in meson_mmc_get_cd() argument
1054 int status = mmc_gpio_get_cd(mmc); in meson_mmc_get_cd()
1077 static int meson_mmc_card_busy(struct mmc_host *mmc) in meson_mmc_card_busy() argument
1079 struct meson_host *host = mmc_priv(mmc); in meson_mmc_card_busy()
1088 static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) in meson_mmc_voltage_switch() argument
1093 if (!IS_ERR(mmc->supply.vqmmc)) { in meson_mmc_voltage_switch()
1101 ret = mmc_regulator_set_vqmmc(mmc, ios); in meson_mmc_voltage_switch()
1127 struct mmc_host *mmc; in meson_mmc_probe() local
1130 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev); in meson_mmc_probe()
1131 if (!mmc) in meson_mmc_probe()
1133 host = mmc_priv(mmc); in meson_mmc_probe()
1134 host->mmc = mmc; in meson_mmc_probe()
1144 ret = mmc_regulator_get_supply(mmc); in meson_mmc_probe()
1148 ret = mmc_of_parse(mmc); in meson_mmc_probe()
1226 mmc->caps |= MMC_CAP_CMD23; in meson_mmc_probe()
1229 mmc->max_segs = 1; in meson_mmc_probe()
1231 mmc->max_blk_count = SD_EMMC_SRAM_DATA_BUF_LEN / in meson_mmc_probe()
1232 mmc->max_blk_size; in meson_mmc_probe()
1234 mmc->max_blk_count = CMD_CFG_LENGTH_MASK; in meson_mmc_probe()
1235 mmc->max_segs = SD_EMMC_DESC_BUF_LEN / in meson_mmc_probe()
1238 mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; in meson_mmc_probe()
1239 mmc->max_seg_size = mmc->max_req_size; in meson_mmc_probe()
1246 mmc->caps2 &= ~MMC_CAP2_HS400; in meson_mmc_probe()
1250 * The MMC Controller embeds 1,5KiB of internal SRAM in meson_mmc_probe()
1260 host->bounce_buf_size = mmc->max_req_size; in meson_mmc_probe()
1279 mmc->ops = &meson_mmc_ops; in meson_mmc_probe()
1280 mmc_add_host(mmc); in meson_mmc_probe()
1295 mmc_free_host(mmc); in meson_mmc_probe()
1303 mmc_remove_host(host->mmc); in meson_mmc_remove()
1319 mmc_free_host(host->mmc); in meson_mmc_remove()
1338 { .compatible = "amlogic,meson-gx-mmc", .data = &meson_gx_data },
1339 { .compatible = "amlogic,meson-gxbb-mmc", .data = &meson_gx_data },
1340 { .compatible = "amlogic,meson-gxl-mmc", .data = &meson_gx_data },
1341 { .compatible = "amlogic,meson-gxm-mmc", .data = &meson_gx_data },
1342 { .compatible = "amlogic,meson-axg-mmc", .data = &meson_axg_data },