refactor(nxp-mmc): set MIXCTRL_DTDSEL
According to the reference manual, the MIX_CTRL.DTDSEL should be set for
commands involving a transfer from the card to the host. Therefore, it
should be disabled for write commands, specifically for single and
multi-block writes.
Change-Id: I97a08291c6ee134e1d5c7e072a06e1b060d5da14
Co-developed-by: Ciprian Costea <ciprianmarian.costea@nxp.com>
Signed-off-by: Ciprian Costea <ciprianmarian.costea@nxp.com>
Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
diff --git a/drivers/imx/usdhc/imx_usdhc.c b/drivers/imx/usdhc/imx_usdhc.c
index 2238943..0c4f8d0 100644
--- a/drivers/imx/usdhc/imx_usdhc.c
+++ b/drivers/imx/usdhc/imx_usdhc.c
@@ -113,6 +113,13 @@
#define FSL_CMD_RETRIES 1000
+static bool is_data_transfer_to_card(const struct mmc_cmd *cmd)
+{
+ unsigned int cmd_idx = cmd->cmd_idx;
+
+ return (cmd_idx == MMC_CMD(24)) || (cmd_idx == MMC_CMD(25));
+}
+
static bool is_data_transfer_cmd(const struct mmc_cmd *cmd)
{
uintptr_t reg_base = imx_usdhc_params.reg_base;
@@ -202,11 +209,6 @@
switch (cmd->cmd_idx) {
case MMC_CMD(18):
multiple = 1;
- /* for read op */
- /* fallthrough */
- case MMC_CMD(17):
- case MMC_CMD(8):
- mixctl |= MIXCTRL_DTDSEL;
break;
case MMC_CMD(25):
multiple = 1;
@@ -226,6 +228,10 @@
mixctl |= MIXCTRL_DMAEN;
}
+ if (!is_data_transfer_to_card(cmd)) {
+ mixctl |= MIXCTRL_DTDSEL;
+ }
+
/* Send the command */
mmio_write_32(reg_base + CMDARG, cmd->cmd_arg);
mmio_clrsetbits32(reg_base + MIXCTRL, MIXCTRL_DATMASK, mixctl);