Lines Matching full:mmc
16 #include <linux/mmc/mmc.h>
17 #include <linux/mmc/host.h>
18 #include <linux/mmc/card.h>
50 (cq_host->mmc->max_segs * tag * in get_trans_desc_dma()
57 (cq_host->trans_desc_len * cq_host->mmc->max_segs * tag); in get_trans_desc()
72 if (tag == DCMD_SLOT && (cq_host->mmc->caps2 & MMC_CAP2_CQE_DCMD)) { in setup_trans_desc()
99 pr_err("%s: " DRV_NAME ": " f, mmc_hostname(mmc), ## x)
103 struct mmc_host *mmc = cq_host->mmc; in cqhci_dumpregs() local
142 cq_host->ops->dumpregs(mmc); in cqhci_dumpregs()
196 cq_host->data_size = cq_host->trans_desc_len * cq_host->mmc->max_segs * in cqhci_host_alloc_tdl()
197 cq_host->mmc->cqe_qdepth; in cqhci_host_alloc_tdl()
200 mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size, in cqhci_host_alloc_tdl()
209 cq_host->desc_base = dmam_alloc_coherent(mmc_dev(cq_host->mmc), in cqhci_host_alloc_tdl()
216 cq_host->trans_desc_base = dmam_alloc_coherent(mmc_dev(cq_host->mmc), in cqhci_host_alloc_tdl()
221 dmam_free_coherent(mmc_dev(cq_host->mmc), cq_host->desc_size, in cqhci_host_alloc_tdl()
230 mmc_hostname(cq_host->mmc), cq_host->desc_base, cq_host->trans_desc_base, in cqhci_host_alloc_tdl()
242 struct mmc_host *mmc = cq_host->mmc; in __cqhci_enable() local
255 if (mmc->caps2 & MMC_CAP2_CQE_DCMD) in __cqhci_enable()
276 mmc->cqe_on = true; in __cqhci_enable()
279 cq_host->ops->enable(mmc); in __cqhci_enable()
297 cq_host->mmc->cqe_on = false; in __cqhci_disable()
302 int cqhci_deactivate(struct mmc_host *mmc) in cqhci_deactivate() argument
304 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_deactivate()
313 int cqhci_resume(struct mmc_host *mmc) in cqhci_resume() argument
320 static int cqhci_enable(struct mmc_host *mmc, struct mmc_card *card) in cqhci_enable() argument
322 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_enable()
336 mmc_hostname(mmc), err); in cqhci_enable()
358 static void cqhci_off(struct mmc_host *mmc) in cqhci_off() argument
360 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_off()
364 if (!cq_host->enabled || !mmc->cqe_on || cq_host->recovery_halt) in cqhci_off()
368 cq_host->ops->disable(mmc, false); in cqhci_off()
375 pr_err("%s: cqhci: CQE stuck on\n", mmc_hostname(mmc)); in cqhci_off()
377 pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc)); in cqhci_off()
380 cq_host->ops->post_disable(mmc); in cqhci_off()
382 mmc->cqe_on = false; in cqhci_off()
385 static void cqhci_disable(struct mmc_host *mmc) in cqhci_disable() argument
387 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_disable()
392 cqhci_off(mmc); in cqhci_disable()
396 dmam_free_coherent(mmc_dev(mmc), cq_host->data_size, in cqhci_disable()
400 dmam_free_coherent(mmc_dev(mmc), cq_host->desc_size, in cqhci_disable()
507 static void cqhci_prep_dcmd_desc(struct mmc_host *mmc, in cqhci_prep_dcmd_desc() argument
515 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_prep_dcmd_desc()
541 cq_host->ops->update_dcmd_desc(mmc, mrq, &data); in cqhci_prep_dcmd_desc()
545 mmc_hostname(mmc), mrq->cmd->opcode, timing, resp_type); in cqhci_prep_dcmd_desc()
567 static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq) in cqhci_request() argument
573 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_request()
577 pr_err("%s: cqhci: not enabled\n", mmc_hostname(mmc)); in cqhci_request()
585 if (!mmc->cqe_on) { in cqhci_request()
587 cq_host->ops->pre_enable(mmc); in cqhci_request()
590 mmc->cqe_on = true; in cqhci_request()
591 pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc)); in cqhci_request()
594 mmc_hostname(mmc)); in cqhci_request()
597 cq_host->ops->enable(mmc); in cqhci_request()
607 mmc_hostname(mmc), err); in cqhci_request()
611 cqhci_prep_dcmd_desc(mmc, mrq); in cqhci_request()
630 mmc_hostname(mmc), tag); in cqhci_request()
635 cqhci_post_req(mmc, mrq); in cqhci_request()
640 static void cqhci_recovery_needed(struct mmc_host *mmc, struct mmc_request *mrq, in cqhci_recovery_needed() argument
643 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_recovery_needed()
647 pr_debug("%s: cqhci: recovery needed\n", mmc_hostname(mmc)); in cqhci_recovery_needed()
668 static void cqhci_error_irq(struct mmc_host *mmc, u32 status, int cmd_error, in cqhci_error_irq() argument
671 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_error_irq()
681 mmc_hostname(mmc), status, cmd_error, data_error, terri); in cqhci_error_irq()
689 mmc_hostname(mmc), status, cmd_error, data_error, in cqhci_error_irq()
699 cqhci_recovery_needed(mmc, slot->mrq, true); in cqhci_error_irq()
708 cqhci_recovery_needed(mmc, slot->mrq, true); in cqhci_error_irq()
722 cqhci_recovery_needed(mmc, slot->mrq, true); in cqhci_error_irq()
731 static void cqhci_finish_mrq(struct mmc_host *mmc, unsigned int tag) in cqhci_finish_mrq() argument
733 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_finish_mrq()
740 mmc_hostname(mmc), tag); in cqhci_finish_mrq()
762 mmc_cqe_request_done(mmc, mrq); in cqhci_finish_mrq()
765 irqreturn_t cqhci_irq(struct mmc_host *mmc, u32 intmask, int cmd_error, in cqhci_irq() argument
770 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_irq()
775 pr_debug("%s: cqhci: IRQ status: 0x%08x\n", mmc_hostname(mmc), status); in cqhci_irq()
778 cqhci_error_irq(mmc, status, cmd_error, data_error); in cqhci_irq()
785 mmc_hostname(mmc), comp_status); in cqhci_irq()
792 mmc_hostname(mmc), tag); in cqhci_irq()
793 cqhci_finish_mrq(mmc, tag); in cqhci_irq()
828 static int cqhci_wait_for_idle(struct mmc_host *mmc) in cqhci_wait_for_idle() argument
830 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_wait_for_idle()
838 static bool cqhci_timeout(struct mmc_host *mmc, struct mmc_request *mrq, in cqhci_timeout() argument
841 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_timeout()
851 cqhci_recovery_needed(mmc, mrq, false); in cqhci_timeout()
858 mmc_hostname(mmc), tag); in cqhci_timeout()
870 static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout) in cqhci_clear_all_tasks() argument
872 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_clear_all_tasks()
891 mmc_hostname(mmc)); in cqhci_clear_all_tasks()
901 static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) in cqhci_halt() argument
903 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_halt()
924 pr_debug("%s: cqhci: Failed to halt\n", mmc_hostname(mmc)); in cqhci_halt()
937 static void cqhci_recovery_start(struct mmc_host *mmc) in cqhci_recovery_start() argument
939 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_recovery_start()
941 pr_debug("%s: cqhci: %s\n", mmc_hostname(mmc), __func__); in cqhci_recovery_start()
945 cqhci_halt(mmc, CQHCI_START_HALT_TIMEOUT); in cqhci_recovery_start()
948 cq_host->ops->disable(mmc, true); in cqhci_recovery_start()
950 mmc->cqe_on = false; in cqhci_recovery_start()
989 mmc_cqe_request_done(cq_host->mmc, mrq); in cqhci_recover_mrq()
1010 static void cqhci_recovery_finish(struct mmc_host *mmc) in cqhci_recovery_finish() argument
1012 struct cqhci_host *cq_host = mmc->cqe_private; in cqhci_recovery_finish()
1017 pr_debug("%s: cqhci: %s\n", mmc_hostname(mmc), __func__); in cqhci_recovery_finish()
1021 ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); in cqhci_recovery_finish()
1023 if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) in cqhci_recovery_finish()
1033 pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc)); in cqhci_recovery_finish()
1040 ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); in cqhci_recovery_finish()
1041 if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) in cqhci_recovery_finish()
1053 mmc->cqe_on = false; in cqhci_recovery_finish()
1063 pr_debug("%s: cqhci: recovery done\n", mmc_hostname(mmc)); in cqhci_recovery_finish()
1119 int cqhci_init(struct cqhci_host *cq_host, struct mmc_host *mmc, in cqhci_init() argument
1125 cq_host->mmc = mmc; in cqhci_init()
1126 cq_host->mmc->cqe_private = cq_host; in cqhci_init()
1131 mmc->cqe_ops = &cqhci_cqe_ops; in cqhci_init()
1133 mmc->cqe_qdepth = NUM_SLOTS; in cqhci_init()
1134 if (mmc->caps2 & MMC_CAP2_CQE_DCMD) in cqhci_init()
1135 mmc->cqe_qdepth -= 1; in cqhci_init()
1137 cq_host->slot = devm_kcalloc(mmc_dev(mmc), cq_host->num_slots, in cqhci_init()
1150 mmc_hostname(mmc), cqhci_ver_major(cq_host), in cqhci_init()
1157 mmc_hostname(mmc), cqhci_ver_major(cq_host), in cqhci_init()