Lines Matching full:mmc
24 #include <linux/mmc/mmc.h>
25 #include <linux/mmc/host.h>
26 #include <linux/mmc/card.h>
58 (cq_host->mmc->max_segs * tag * in get_trans_desc_dma()
65 (cq_host->trans_desc_len * cq_host->mmc->max_segs * tag); in get_trans_desc()
80 if (tag == DCMD_SLOT && (cq_host->mmc->caps2 & MMC_CAP2_CQE_DCMD)) { in setup_trans_desc()
107 pr_err("%s: " DRV_NAME ": " f, mmc_hostname(mmc), ## x)
111 struct mmc_host *mmc = cq_host->mmc; in cqhci_dumpregs() local
150 cq_host->ops->dumpregs(mmc); in cqhci_dumpregs()
204 cq_host->data_size = cq_host->trans_desc_len * cq_host->mmc->max_segs * in cqhci_host_alloc_tdl()
205 cq_host->mmc->cqe_qdepth; in cqhci_host_alloc_tdl()
208 mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size, in cqhci_host_alloc_tdl()
217 cq_host->desc_base = dmam_alloc_coherent(mmc_dev(cq_host->mmc), in cqhci_host_alloc_tdl()
224 cq_host->trans_desc_base = dmam_alloc_coherent(mmc_dev(cq_host->mmc), in cqhci_host_alloc_tdl()
229 dmam_free_coherent(mmc_dev(cq_host->mmc), cq_host->desc_size, in cqhci_host_alloc_tdl()
238 mmc_hostname(cq_host->mmc), cq_host->desc_base, cq_host->trans_desc_base, in cqhci_host_alloc_tdl()
250 struct mmc_host *mmc = cq_host->mmc; in __cqhci_enable() local
263 if (mmc->caps2 & MMC_CAP2_CQE_DCMD) in __cqhci_enable()
284 mmc->cqe_on = true; in __cqhci_enable()
287 cq_host->ops->enable(mmc); in __cqhci_enable()
305 cq_host->mmc->cqe_on = false; in __cqhci_disable()
310 int cqhci_suspend(struct mmc_host *mmc) in cqhci_suspend() argument
312 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_suspend()
321 int cqhci_resume(struct mmc_host *mmc) in cqhci_resume() argument
328 static int cqhci_enable(struct mmc_host *mmc, struct mmc_card *card) in cqhci_enable() argument
330 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_enable()
360 static void cqhci_off(struct mmc_host *mmc) in cqhci_off() argument
362 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_off()
366 if (!cq_host->enabled || !mmc->cqe_on || cq_host->recovery_halt) in cqhci_off()
370 cq_host->ops->disable(mmc, false); in cqhci_off()
377 pr_err("%s: cqhci: CQE stuck on\n", mmc_hostname(mmc)); in cqhci_off()
379 pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc)); in cqhci_off()
381 mmc->cqe_on = false; in cqhci_off()
384 static void cqhci_disable(struct mmc_host *mmc) in cqhci_disable() argument
386 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_disable()
391 cqhci_off(mmc); in cqhci_disable()
395 dmam_free_coherent(mmc_dev(mmc), cq_host->data_size, in cqhci_disable()
399 dmam_free_coherent(mmc_dev(mmc), cq_host->desc_size, in cqhci_disable()
506 static void cqhci_prep_dcmd_desc(struct mmc_host *mmc, in cqhci_prep_dcmd_desc() argument
514 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_prep_dcmd_desc()
542 mmc_hostname(mmc), mrq->cmd->opcode, timing, resp_type); in cqhci_prep_dcmd_desc()
564 static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq) in cqhci_request() argument
570 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_request()
574 pr_err("%s: cqhci: not enabled\n", mmc_hostname(mmc)); in cqhci_request()
582 if (!mmc->cqe_on) { in cqhci_request()
584 mmc->cqe_on = true; in cqhci_request()
585 pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc)); in cqhci_request()
588 mmc_hostname(mmc)); in cqhci_request()
591 cq_host->ops->enable(mmc); in cqhci_request()
601 mmc_hostname(mmc), err); in cqhci_request()
605 cqhci_prep_dcmd_desc(mmc, mrq); in cqhci_request()
624 mmc_hostname(mmc), tag); in cqhci_request()
629 cqhci_post_req(mmc, mrq); in cqhci_request()
634 static void cqhci_recovery_needed(struct mmc_host *mmc, struct mmc_request *mrq, in cqhci_recovery_needed() argument
637 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_recovery_needed()
641 pr_debug("%s: cqhci: recovery needed\n", mmc_hostname(mmc)); in cqhci_recovery_needed()
662 static void cqhci_error_irq(struct mmc_host *mmc, u32 status, int cmd_error, in cqhci_error_irq() argument
665 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_error_irq()
675 mmc_hostname(mmc), status, cmd_error, data_error, terri); in cqhci_error_irq()
683 mmc_hostname(mmc), status, cmd_error, data_error, in cqhci_error_irq()
693 cqhci_recovery_needed(mmc, slot->mrq, true); in cqhci_error_irq()
702 cqhci_recovery_needed(mmc, slot->mrq, true); in cqhci_error_irq()
716 cqhci_recovery_needed(mmc, slot->mrq, true); in cqhci_error_irq()
725 static void cqhci_finish_mrq(struct mmc_host *mmc, unsigned int tag) in cqhci_finish_mrq() argument
727 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_finish_mrq()
734 mmc_hostname(mmc), tag); in cqhci_finish_mrq()
756 mmc_cqe_request_done(mmc, mrq); in cqhci_finish_mrq()
759 irqreturn_t cqhci_irq(struct mmc_host *mmc, u32 intmask, int cmd_error, in cqhci_irq() argument
764 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_irq()
769 pr_debug("%s: cqhci: IRQ status: 0x%08x\n", mmc_hostname(mmc), status); in cqhci_irq()
772 cqhci_error_irq(mmc, status, cmd_error, data_error); in cqhci_irq()
779 mmc_hostname(mmc), comp_status); in cqhci_irq()
786 mmc_hostname(mmc), tag); in cqhci_irq()
787 cqhci_finish_mrq(mmc, tag); in cqhci_irq()
822 static int cqhci_wait_for_idle(struct mmc_host *mmc) in cqhci_wait_for_idle() argument
824 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_wait_for_idle()
832 static bool cqhci_timeout(struct mmc_host *mmc, struct mmc_request *mrq, in cqhci_timeout() argument
835 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_timeout()
845 cqhci_recovery_needed(mmc, mrq, false); in cqhci_timeout()
852 mmc_hostname(mmc), tag); in cqhci_timeout()
864 static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout) in cqhci_clear_all_tasks() argument
866 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_clear_all_tasks()
885 mmc_hostname(mmc)); in cqhci_clear_all_tasks()
895 static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) in cqhci_halt() argument
897 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_halt()
918 pr_debug("%s: cqhci: Failed to halt\n", mmc_hostname(mmc)); in cqhci_halt()
931 static void cqhci_recovery_start(struct mmc_host *mmc) in cqhci_recovery_start() argument
933 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_recovery_start()
935 pr_debug("%s: cqhci: %s\n", mmc_hostname(mmc), __func__); in cqhci_recovery_start()
939 cqhci_halt(mmc, CQHCI_START_HALT_TIMEOUT); in cqhci_recovery_start()
942 cq_host->ops->disable(mmc, true); in cqhci_recovery_start()
944 mmc->cqe_on = false; in cqhci_recovery_start()
983 mmc_cqe_request_done(cq_host->mmc, mrq); in cqhci_recover_mrq()
1004 static void cqhci_recovery_finish(struct mmc_host *mmc) in cqhci_recovery_finish() argument
1006 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_recovery_finish()
1011 pr_debug("%s: cqhci: %s\n", mmc_hostname(mmc), __func__); in cqhci_recovery_finish()
1015 ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); in cqhci_recovery_finish()
1017 if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) in cqhci_recovery_finish()
1027 pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc)); in cqhci_recovery_finish()
1034 ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); in cqhci_recovery_finish()
1035 if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) in cqhci_recovery_finish()
1047 mmc->cqe_on = false; in cqhci_recovery_finish()
1057 pr_debug("%s: cqhci: recovery done\n", mmc_hostname(mmc)); in cqhci_recovery_finish()
1113 int cqhci_init(struct cqhci_host *cq_host, struct mmc_host *mmc, in cqhci_init() argument
1119 cq_host->mmc = mmc; in cqhci_init()
1120 cq_host->mmc->cqe_private = cq_host; in cqhci_init()
1125 mmc->cqe_ops = &cqhci_cqe_ops; in cqhci_init()
1127 mmc->cqe_qdepth = NUM_SLOTS; in cqhci_init()
1128 if (mmc->caps2 & MMC_CAP2_CQE_DCMD) in cqhci_init()
1129 mmc->cqe_qdepth -= 1; in cqhci_init()
1131 cq_host->slot = devm_kcalloc(mmc_dev(mmc), cq_host->num_slots, in cqhci_init()
1144 mmc_hostname(mmc), cqhci_ver_major(cq_host), in cqhci_init()
1151 mmc_hostname(mmc), cqhci_ver_major(cq_host), in cqhci_init()