Lines Matching refs:cmd
52 static bool sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd);
149 static inline bool sdhci_data_line_cmd(struct mmc_command *cmd) in sdhci_data_line_cmd() argument
151 return cmd->data || cmd->flags & MMC_RSP_BUSY; in sdhci_data_line_cmd()
507 if (sdhci_data_line_cmd(mrq->cmd)) in sdhci_mod_timer()
515 if (sdhci_data_line_cmd(mrq->cmd)) in sdhci_del_timer()
523 return host->cmd || host->data_cmd; in sdhci_has_requests()
715 dma_addr_t addr, int len, unsigned int cmd) in sdhci_adma_write_desc() argument
720 dma_desc->cmd = cpu_to_le16(cmd); in sdhci_adma_write_desc()
733 int len, unsigned int cmd) in __sdhci_adma_write_desc() argument
736 host->ops->adma_write_desc(host, desc, addr, len, cmd); in __sdhci_adma_write_desc()
738 sdhci_adma_write_desc(host, desc, addr, len, cmd); in __sdhci_adma_write_desc()
746 dma_desc->cmd |= cpu_to_le16(ADMA2_END); in sdhci_adma_mark_end()
904 struct mmc_command *cmd, in sdhci_target_timeout() argument
911 target_timeout = cmd->busy_timeout * 1000; in sdhci_target_timeout()
933 struct mmc_command *cmd) in sdhci_calc_sw_timeout() argument
935 struct mmc_data *data = cmd->data; in sdhci_calc_sw_timeout()
944 target_timeout = sdhci_target_timeout(host, cmd, data); in sdhci_calc_sw_timeout()
965 static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd, in sdhci_calc_timeout() argument
984 if (cmd == NULL) in sdhci_calc_timeout()
987 data = cmd->data; in sdhci_calc_timeout()
989 if (!data && !cmd->busy_timeout) in sdhci_calc_timeout()
993 target_timeout = sdhci_target_timeout(host, cmd, data); in sdhci_calc_timeout()
1013 count, cmd->opcode); in sdhci_calc_timeout()
1053 void __sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) in __sdhci_set_timeout() argument
1056 u8 count = sdhci_calc_timeout(host, cmd, &too_big); in __sdhci_set_timeout()
1060 sdhci_calc_sw_timeout(host, cmd); in __sdhci_set_timeout()
1070 static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) in sdhci_set_timeout() argument
1073 host->ops->set_timeout(host, cmd); in sdhci_set_timeout()
1075 __sdhci_set_timeout(host, cmd); in sdhci_set_timeout()
1114 static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) in sdhci_prepare_data() argument
1116 struct mmc_data *data = cmd->data; in sdhci_prepare_data()
1247 struct mmc_command *cmd) in sdhci_external_dma_setup() argument
1252 struct mmc_data *data = cmd->data; in sdhci_external_dma_setup()
1317 struct mmc_command *cmd) in __sdhci_external_dma_prepare_data() argument
1319 struct mmc_data *data = cmd->data; in __sdhci_external_dma_prepare_data()
1330 struct mmc_command *cmd) in sdhci_external_dma_prepare_data() argument
1332 if (!sdhci_external_dma_setup(host, cmd)) { in sdhci_external_dma_prepare_data()
1333 __sdhci_external_dma_prepare_data(host, cmd); in sdhci_external_dma_prepare_data()
1338 sdhci_prepare_data(host, cmd); in sdhci_external_dma_prepare_data()
1343 struct mmc_command *cmd) in sdhci_external_dma_pre_transfer() argument
1347 if (!cmd->data) in sdhci_external_dma_pre_transfer()
1350 chan = sdhci_external_dma_channel(host, cmd->data); in sdhci_external_dma_pre_transfer()
1367 struct mmc_command *cmd) in sdhci_external_dma_prepare_data() argument
1374 struct mmc_command *cmd) in sdhci_external_dma_pre_transfer() argument
1412 struct mmc_command *cmd, in sdhci_auto_cmd_select() argument
1415 bool use_cmd12 = sdhci_auto_cmd12(host, cmd->mrq) && in sdhci_auto_cmd_select()
1416 (cmd->opcode != SD_IO_RW_EXTENDED); in sdhci_auto_cmd_select()
1417 bool use_cmd23 = sdhci_auto_cmd23(host, cmd->mrq); in sdhci_auto_cmd_select()
1451 struct mmc_command *cmd) in sdhci_set_transfer_mode() argument
1454 struct mmc_data *data = cmd->data; in sdhci_set_transfer_mode()
1460 if (!mmc_op_tuning(cmd->opcode)) in sdhci_set_transfer_mode()
1476 if (mmc_op_multi(cmd->opcode) || data->blocks > 1) { in sdhci_set_transfer_mode()
1478 sdhci_auto_cmd_select(host, cmd, &mode); in sdhci_set_transfer_mode()
1479 if (sdhci_auto_cmd23(host, cmd->mrq)) in sdhci_set_transfer_mode()
1480 sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); in sdhci_set_transfer_mode()
1494 ((mrq->cmd && mrq->cmd->error) || in sdhci_needs_reset()
1523 if (host->cmd && host->cmd->mrq == mrq) in __sdhci_finish_mrq()
1524 host->cmd = NULL; in __sdhci_finish_mrq()
1566 if (!host->cmd || host->cmd == data_cmd) in __sdhci_finish_data()
1605 host->cmd = NULL; in __sdhci_finish_data()
1630 static bool sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) in sdhci_send_command() argument
1636 WARN_ON(host->cmd); in sdhci_send_command()
1639 cmd->error = 0; in sdhci_send_command()
1642 cmd->opcode == MMC_STOP_TRANSMISSION) in sdhci_send_command()
1643 cmd->flags |= MMC_RSP_BUSY; in sdhci_send_command()
1646 if (sdhci_data_line_cmd(cmd)) in sdhci_send_command()
1651 if (cmd->mrq->data && (cmd == cmd->mrq->data->stop)) in sdhci_send_command()
1657 host->cmd = cmd; in sdhci_send_command()
1659 if (sdhci_data_line_cmd(cmd)) { in sdhci_send_command()
1661 host->data_cmd = cmd; in sdhci_send_command()
1662 sdhci_set_timeout(host, cmd); in sdhci_send_command()
1665 if (cmd->data) { in sdhci_send_command()
1667 sdhci_external_dma_prepare_data(host, cmd); in sdhci_send_command()
1669 sdhci_prepare_data(host, cmd); in sdhci_send_command()
1672 sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT); in sdhci_send_command()
1674 sdhci_set_transfer_mode(host, cmd); in sdhci_send_command()
1676 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) { in sdhci_send_command()
1683 cmd->flags &= ~MMC_RSP_BUSY; in sdhci_send_command()
1686 if (!(cmd->flags & MMC_RSP_PRESENT)) in sdhci_send_command()
1688 else if (cmd->flags & MMC_RSP_136) in sdhci_send_command()
1690 else if (cmd->flags & MMC_RSP_BUSY) in sdhci_send_command()
1695 if (cmd->flags & MMC_RSP_CRC) in sdhci_send_command()
1697 if (cmd->flags & MMC_RSP_OPCODE) in sdhci_send_command()
1701 if (cmd->data || mmc_op_tuning(cmd->opcode)) in sdhci_send_command()
1707 else if (!cmd->data && cmd->busy_timeout > 9000) in sdhci_send_command()
1708 timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ; in sdhci_send_command()
1711 sdhci_mod_timer(host, cmd->mrq, timeout); in sdhci_send_command()
1714 sdhci_external_dma_pre_transfer(host, cmd); in sdhci_send_command()
1716 sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND); in sdhci_send_command()
1722 struct mmc_command *cmd, bool present) in sdhci_present_error() argument
1725 cmd->error = -ENOMEDIUM; in sdhci_present_error()
1733 struct mmc_command *cmd, in sdhci_send_command_retry() argument
1742 while (!sdhci_send_command(host, cmd)) { in sdhci_send_command_retry()
1748 cmd->error = -EIO; in sdhci_send_command_retry()
1761 if (cmd == deferred_cmd && cmd != host->deferred_cmd) in sdhci_send_command_retry()
1764 if (sdhci_present_error(host, cmd, present)) in sdhci_send_command_retry()
1768 if (cmd == host->deferred_cmd) in sdhci_send_command_retry()
1774 static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd) in sdhci_read_rsp_136() argument
1780 cmd->resp[i] = sdhci_readl(host, reg); in sdhci_read_rsp_136()
1788 cmd->resp[i] <<= 8; in sdhci_read_rsp_136()
1790 cmd->resp[i] |= cmd->resp[i + 1] >> 24; in sdhci_read_rsp_136()
1796 struct mmc_command *cmd = host->cmd; in sdhci_finish_command() local
1798 host->cmd = NULL; in sdhci_finish_command()
1800 if (cmd->flags & MMC_RSP_PRESENT) { in sdhci_finish_command()
1801 if (cmd->flags & MMC_RSP_136) { in sdhci_finish_command()
1802 sdhci_read_rsp_136(host, cmd); in sdhci_finish_command()
1804 cmd->resp[0] = sdhci_readl(host, SDHCI_RESPONSE); in sdhci_finish_command()
1808 if (cmd->mrq->cap_cmd_during_tfr && cmd == cmd->mrq->cmd) in sdhci_finish_command()
1809 mmc_command_done(host->mmc, cmd->mrq); in sdhci_finish_command()
1821 if (cmd->flags & MMC_RSP_BUSY) { in sdhci_finish_command()
1822 if (cmd->data) { in sdhci_finish_command()
1825 cmd == host->data_cmd) { in sdhci_finish_command()
1832 if (cmd == cmd->mrq->sbc) { in sdhci_finish_command()
1833 if (!sdhci_send_command(host, cmd->mrq->cmd)) { in sdhci_finish_command()
1835 host->deferred_cmd = cmd->mrq->cmd; in sdhci_finish_command()
1843 if (!cmd->data) in sdhci_finish_command()
1844 __sdhci_finish_mrq(host, cmd->mrq); in sdhci_finish_command()
2179 struct mmc_command *cmd; in sdhci_request() local
2190 if (sdhci_present_error(host, mrq->cmd, present)) in sdhci_request()
2193 cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd; in sdhci_request()
2195 if (!sdhci_send_command_retry(host, cmd, flags)) in sdhci_request()
2211 struct mmc_command *cmd; in sdhci_request_atomic() local
2217 if (sdhci_present_error(host, mrq->cmd, true)) { in sdhci_request_atomic()
2222 cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd; in sdhci_request_atomic()
2231 if (!sdhci_send_command(host, cmd)) in sdhci_request_atomic()
2795 struct mmc_command cmd = {}; in sdhci_send_tuning() local
2802 cmd.opcode = opcode; in sdhci_send_tuning()
2803 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; in sdhci_send_tuning()
2804 cmd.mrq = &mrq; in sdhci_send_tuning()
2806 mrq.cmd = &cmd; in sdhci_send_tuning()
2812 if (cmd.opcode == MMC_SEND_TUNING_BLOCK_HS200 && in sdhci_send_tuning()
2826 if (!sdhci_send_command_retry(host, &cmd, flags)) { in sdhci_send_tuning()
2832 host->cmd = NULL; in sdhci_send_tuning()
3018 if (host->cmd) { in sdhci_error_out_mrqs()
3019 host->cmd->error = err; in sdhci_error_out_mrqs()
3020 sdhci_finish_mrq(host, host->cmd->mrq); in sdhci_error_out_mrqs()
3106 if (host->cmd || host->data_cmd) { in sdhci_request_done()
3130 (mrq->cmd->error || data->error)) { in sdhci_request_done()
3214 if (host->cmd && !sdhci_data_line_cmd(host->cmd)) { in sdhci_timeout_timer()
3220 host->cmd->error = -ETIMEDOUT; in sdhci_timeout_timer()
3221 sdhci_finish_mrq(host, host->cmd->mrq); in sdhci_timeout_timer()
3237 (host->cmd && sdhci_data_line_cmd(host->cmd))) { in sdhci_timeout_data_timer()
3251 host->cmd->error = -ETIMEDOUT; in sdhci_timeout_data_timer()
3252 sdhci_finish_mrq(host, host->cmd->mrq); in sdhci_timeout_data_timer()
3282 if (!host->cmd) { in sdhci_cmd_irq()
3300 host->cmd->error = -ETIMEDOUT; in sdhci_cmd_irq()
3303 host->cmd->error = -EILSEQ; in sdhci_cmd_irq()
3304 if (!mmc_op_tuning(host->cmd->opcode)) in sdhci_cmd_irq()
3308 if (host->cmd->data && in sdhci_cmd_irq()
3311 host->cmd = NULL; in sdhci_cmd_irq()
3316 __sdhci_finish_mrq(host, host->cmd->mrq); in sdhci_cmd_irq()
3322 struct mmc_request *mrq = host->cmd->mrq; in sdhci_cmd_irq()
3357 le16_to_cpu(dma_desc->cmd)); in sdhci_adma_show_error()
3363 le16_to_cpu(dma_desc->cmd)); in sdhci_adma_show_error()
3368 if (dma_desc->cmd & cpu_to_le16(ADMA2_END)) in sdhci_adma_show_error()
3413 if (host->cmd == data_cmd) in sdhci_data_irq()
3499 if (host->cmd == host->data_cmd) { in sdhci_data_irq()
3668 struct mmc_command *cmd; in sdhci_thread_irq() local
3680 cmd = host->deferred_cmd; in sdhci_thread_irq()
3681 if (cmd && !sdhci_send_command_retry(host, cmd, flags)) in sdhci_thread_irq()
3682 sdhci_finish_mrq(host, cmd->mrq); in sdhci_thread_irq()