Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
- {
- struct sdhci_host *host;
- int present;
- unsigned long flags;
- u32 tuning_opcode;
- host = mmc_priv(mmc);
- #ifdef CONFIG_DEBUG_FS
- if (mrq->data && mrq->data->blocks)
- update_stat(host, mrq->data->blksz, mrq->data->blocks,
- true, false, mrq->data->flags);
- #endif
- #ifndef CONFIG_MMC_CQ
- sdhci_runtime_pm_get(host);
- #endif
- present = mmc_gpio_get_cd(host->mmc);
- spin_lock_irqsave(&host->lock, flags);
- WARN_ON(host->mrq_cmd != NULL);
- #ifndef SDHCI_USE_LEDS_CLASS
- sdhci_activate_led(host);
- #endif
- /*
- * Ensure we don't send the STOP for non-SET_BLOCK_COUNTED
- * requests if Auto-CMD12 is enabled.
- */
- if (!MMC_CHECK_CMDQ_MODE(host) && !mrq->sbc && (host->flags & SDHCI_AUTO_CMD12)) {
- if (mrq->stop) {
- mrq->data->stop = NULL;
- mrq->stop = NULL;
- }
- }
- host->mrq_cmd = mrq;
- host->mrq_cmd->data_early = 0;
- /*
- * Firstly check card presence from cd-gpio. The return could
- * be one of the following possibilities:
- * negative: cd-gpio is not available
- * zero: cd-gpio is used, and card is removed
- * one: cd-gpio is used, and card is present
- */
- if (present < 0) {
- /* If polling, assume that the card is always present. */
- if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
- if (host->ops->get_cd)
- present = host->ops->get_cd(host);
- else
- present = 1;
- else
- present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
- SDHCI_CARD_PRESENT;
- }
- if (!present || host->flags & SDHCI_DEVICE_DEAD) {
- host->mrq_cmd->cmd->error = -ENOMEDIUM;
- if (MMC_CHECK_CMDQ_MODE(host))
- tasklet_schedule(&host->finish_cmd_tasklet);
- else
- tasklet_schedule(&host->finish_tasklet);
- } else {
- u32 present_state;
- present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
- /*
- * Check if the re-tuning timer has already expired and there
- * is no on-going data transfer. If so, we need to execute
- * tuning procedure before sending command.
- */
- if ((host->flags & SDHCI_NEEDS_RETUNING) &&
- !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
- if (!mmc->need_tuning || !mmc->ready_tuning) {
- if (!mmc->need_tuning)
- mmc->need_tuning = 1;
- goto end_tuning;
- }
- if (mmc->card) {
- /* eMMC uses cmd21 but sd and sdio use cmd19 */
- tuning_opcode =
- mmc->card->type == MMC_TYPE_MMC ?
- MMC_SEND_TUNING_BLOCK_HS200 :
- MMC_SEND_TUNING_BLOCK;
- host->mrq_cmd = NULL;
- spin_unlock_irqrestore(&host->lock, flags);
- sdhci_execute_tuning(mmc, tuning_opcode);
- mmc->need_tuning = 0;
- mmc->ready_tuning = 0;
- spin_lock_irqsave(&host->lock, flags);
- end_tuning:
- /* Restore original mmc_request structure */
- host->mrq_cmd = mrq;
- }
- }
- /* For a data cmd, check for plat specific preparation */
- spin_unlock_irqrestore(&host->lock, flags);
- if (mrq->data)
- host->ops->platform_get_bus(host);
- spin_lock_irqsave(&host->lock, flags);
- if (!MMC_CHECK_CMDQ_MODE(host) &&
- (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23)))
- sdhci_send_command(host, mrq->sbc);
- else if (MMC_CHECK_CMDQ_MODE(host) && mrq->sbc)
- sdhci_send_command(host, mrq->sbc);
- else {
- sdhci_send_command(host, mrq->cmd);
- }
- }
- mmiowb();
- spin_unlock_irqrestore(&host->lock, flags);
- }
Advertisement
Add Comment
Please, Sign In to add comment