• 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
226 static void meson_mmc_get_transfer_mode(struct mmc_host *mmc, in meson_mmc_get_transfer_mode() argument
229 struct meson_host *host = mmc_priv(mmc); in meson_mmc_get_transfer_mode()
275 static void meson_mmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq) in meson_mmc_pre_req() argument
282 meson_mmc_get_transfer_mode(mmc, mrq); in meson_mmc_pre_req()
288 data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg, data->sg_len, in meson_mmc_pre_req()
291 dev_err(mmc_dev(mmc), "dma_map_sg failed"); in meson_mmc_pre_req()
294 static void meson_mmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, in meson_mmc_post_req() argument
300 dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, in meson_mmc_post_req()
305 * Gating the clock on this controller is tricky. It seems the mmc clock
343 struct mmc_host *mmc = host->mmc; in meson_mmc_clk_set() local
354 mmc->actual_clock = 0; in meson_mmc_clk_set()
383 mmc->actual_clock = clk_get_rate(host->mmc_clk); in meson_mmc_clk_set()
388 mmc->actual_clock >>= 1; in meson_mmc_clk_set()
391 dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock); in meson_mmc_clk_set()
392 if (rate != mmc->actual_clock) in meson_mmc_clk_set()
403 * generating the MMC clock. Use the clock framework to create and
484 host->mmc->f_min = clk_round_rate(host->mmc_clk, 400000); in meson_mmc_clk_init()
485 ret = clk_set_rate(host->mmc_clk, host->mmc->f_min); in meson_mmc_clk_init()
511 static int meson_mmc_resampling_tuning(struct mmc_host *mmc, u32 opcode) in meson_mmc_resampling_tuning() argument
513 struct meson_host *host = mmc_priv(mmc); in meson_mmc_resampling_tuning()
525 if (mmc_doing_retune(mmc)) in meson_mmc_resampling_tuning()
535 ret = mmc_send_tuning(mmc, opcode, NULL); in meson_mmc_resampling_tuning()
537 dev_dbg(mmc_dev(mmc), "resampling delay: %u\n", in meson_mmc_resampling_tuning()
579 static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) in meson_mmc_set_ios() argument
581 struct meson_host *host = mmc_priv(mmc); in meson_mmc_set_ios()
591 if (!IS_ERR(mmc->supply.vmmc)) in meson_mmc_set_ios()
592 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in meson_mmc_set_ios()
594 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { in meson_mmc_set_ios()
595 regulator_disable(mmc->supply.vqmmc); in meson_mmc_set_ios()
602 if (!IS_ERR(mmc->supply.vmmc)) in meson_mmc_set_ios()
603 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); in meson_mmc_set_ios()
608 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { in meson_mmc_set_ios()
609 int ret = regulator_enable(mmc->supply.vqmmc); in meson_mmc_set_ios()
651 static void meson_mmc_request_done(struct mmc_host *mmc, in meson_mmc_request_done() argument
654 struct meson_host *host = mmc_priv(mmc); in meson_mmc_request_done()
658 meson_mmc_post_req(mmc, mrq, 0); in meson_mmc_request_done()
659 mmc_request_done(host->mmc, mrq); in meson_mmc_request_done()
662 static void meson_mmc_set_blksz(struct mmc_host *mmc, unsigned int blksz) in meson_mmc_set_blksz() argument
664 struct meson_host *host = mmc_priv(mmc); in meson_mmc_set_blksz()
704 static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg) in meson_mmc_desc_chain_transfer() argument
706 struct meson_host *host = mmc_priv(mmc); in meson_mmc_desc_chain_transfer()
718 meson_mmc_set_blksz(mmc, data->blksz); in meson_mmc_desc_chain_transfer()
789 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) in meson_mmc_start_cmd() argument
791 struct meson_host *host = mmc_priv(mmc); in meson_mmc_start_cmd()
815 meson_mmc_desc_chain_transfer(mmc, cmd_cfg); in meson_mmc_start_cmd()
823 meson_mmc_set_blksz(mmc, data->blksz); in meson_mmc_start_cmd()
855 static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data *data) in meson_mmc_validate_dram_access() argument
864 dev_err(mmc_dev(mmc), "unaligned sg offset %u len %u\n", in meson_mmc_validate_dram_access()
873 static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) in meson_mmc_request() argument
875 struct meson_host *host = mmc_priv(mmc); in meson_mmc_request()
885 mrq->cmd->error = meson_mmc_validate_dram_access(mmc, mrq->data); in meson_mmc_request()
887 mmc_request_done(mmc, mrq); in meson_mmc_request()
893 meson_mmc_get_transfer_mode(mmc, mrq); in meson_mmc_request()
899 meson_mmc_pre_req(mmc, mrq); in meson_mmc_request()
904 meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd); in meson_mmc_request()
907 static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) in meson_mmc_read_resp() argument
909 struct meson_host *host = mmc_priv(mmc); in meson_mmc_read_resp()
963 meson_mmc_read_resp(host->mmc, cmd); in meson_mmc_irq()
990 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq()
1024 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq_thread()
1042 meson_mmc_start_cmd(host->mmc, next_cmd); in meson_mmc_irq_thread()
1044 meson_mmc_request_done(host->mmc, cmd->mrq); in meson_mmc_irq_thread()
1051 * interrupts. For now, the MMC core will use this for polling.
1053 static int meson_mmc_get_cd(struct mmc_host *mmc) in meson_mmc_get_cd() argument
1055 int status = mmc_gpio_get_cd(mmc); in meson_mmc_get_cd()
1078 static int meson_mmc_card_busy(struct mmc_host *mmc) in meson_mmc_card_busy() argument
1080 struct meson_host *host = mmc_priv(mmc); in meson_mmc_card_busy()
1089 static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) in meson_mmc_voltage_switch() argument
1094 if (!IS_ERR(mmc->supply.vqmmc)) { in meson_mmc_voltage_switch()
1102 ret = mmc_regulator_set_vqmmc(mmc, ios); in meson_mmc_voltage_switch()
1128 struct mmc_host *mmc; in meson_mmc_probe() local
1131 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev); in meson_mmc_probe()
1132 if (!mmc) in meson_mmc_probe()
1134 host = mmc_priv(mmc); in meson_mmc_probe()
1135 host->mmc = mmc; in meson_mmc_probe()
1145 ret = mmc_regulator_get_supply(mmc); in meson_mmc_probe()
1149 ret = mmc_of_parse(mmc); in meson_mmc_probe()
1229 mmc->caps |= MMC_CAP_CMD23; in meson_mmc_probe()
1232 mmc->max_segs = 1; in meson_mmc_probe()
1234 mmc->max_blk_count = SD_EMMC_SRAM_DATA_BUF_LEN / in meson_mmc_probe()
1235 mmc->max_blk_size; in meson_mmc_probe()
1237 mmc->max_blk_count = CMD_CFG_LENGTH_MASK; in meson_mmc_probe()
1238 mmc->max_segs = SD_EMMC_DESC_BUF_LEN / in meson_mmc_probe()
1241 mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; in meson_mmc_probe()
1242 mmc->max_seg_size = mmc->max_req_size; in meson_mmc_probe()
1249 mmc->caps2 &= ~MMC_CAP2_HS400; in meson_mmc_probe()
1253 * The MMC Controller embeds 1,5KiB of internal SRAM in meson_mmc_probe()
1263 host->bounce_buf_size = mmc->max_req_size; in meson_mmc_probe()
1282 mmc->ops = &meson_mmc_ops; in meson_mmc_probe()
1283 ret = mmc_add_host(mmc); in meson_mmc_probe()
1300 mmc_free_host(mmc); in meson_mmc_probe()
1308 mmc_remove_host(host->mmc); in meson_mmc_remove()
1324 mmc_free_host(host->mmc); in meson_mmc_remove()
1343 { .compatible = "amlogic,meson-gx-mmc", .data = &meson_gx_data },
1344 { .compatible = "amlogic,meson-gxbb-mmc", .data = &meson_gx_data },
1345 { .compatible = "amlogic,meson-gxl-mmc", .data = &meson_gx_data },
1346 { .compatible = "amlogic,meson-gxm-mmc", .data = &meson_gx_data },
1347 { .compatible = "amlogic,meson-axg-mmc", .data = &meson_axg_data },