mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-28 18:05:50 +08:00
sdio: fix missing card status polling after CMD6 in eMMC DDR mode switch
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
doc_doxygen / doxygen_doc generate (push) Has been cancelled
manual_trigger_update_all / update and create pull request (push) Has been cancelled
manual_trigger_scons_build_all / ${{ github.event.inputs.bsp_options }} (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
doc_doxygen / deploy (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
doc_doxygen / doxygen_doc generate (push) Has been cancelled
manual_trigger_update_all / update and create pull request (push) Has been cancelled
manual_trigger_scons_build_all / ${{ github.event.inputs.bsp_options }} (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
doc_doxygen / deploy (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
This commit is contained in:
@@ -142,6 +142,8 @@ struct rt_mmcsd_req
|
|||||||
#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
|
#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
|
||||||
#define R1_APP_CMD (1 << 5) /* sr, c */
|
#define R1_APP_CMD (1 << 5) /* sr, c */
|
||||||
|
|
||||||
|
/*the programing is state*/
|
||||||
|
#define R1_STATE_PRG 0x07
|
||||||
|
|
||||||
#define R1_SPI_IDLE (1 << 0)
|
#define R1_SPI_IDLE (1 << 0)
|
||||||
#define R1_SPI_ERASE_RESET (1 << 1)
|
#define R1_SPI_ERASE_RESET (1 << 1)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2024, RT-Thread Development Team
|
* Copyright (c) 2006-2026, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
@@ -270,6 +270,64 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send Status.
|
||||||
|
*/
|
||||||
|
static int mmc_send_status(struct rt_mmcsd_card *card, rt_uint32_t *status, unsigned retries)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
struct rt_mmcsd_cmd cmd = (struct rt_mmcsd_cmd){ 0 };
|
||||||
|
|
||||||
|
cmd.busy_timeout = 0;
|
||||||
|
cmd.cmd_code = SEND_STATUS;
|
||||||
|
cmd.arg = card->rca << 16;
|
||||||
|
cmd.flags = RESP_R1 | CMD_AC;
|
||||||
|
err = mmcsd_send_cmd(card->host, &cmd, retries);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
*status = cmd.resp[0];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Poll Busy.
|
||||||
|
*/
|
||||||
|
static int mmc_poll_for_busy(struct rt_mmcsd_card *card, rt_uint32_t timeout_ms, unsigned retries)
|
||||||
|
{
|
||||||
|
int timeout = rt_tick_from_millisecond(timeout_ms);
|
||||||
|
int err = 0;
|
||||||
|
rt_uint32_t status;
|
||||||
|
rt_tick_t start;
|
||||||
|
|
||||||
|
start = rt_tick_get();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
rt_bool_t out = (int)(rt_tick_get() - start) >= timeout;
|
||||||
|
|
||||||
|
if (out)
|
||||||
|
{
|
||||||
|
LOG_E("wait card busy timeout");
|
||||||
|
return -RT_ETIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_thread_mdelay(1);
|
||||||
|
|
||||||
|
err = mmc_send_status(card, &status, retries);
|
||||||
|
if (R1_STATUS(err))
|
||||||
|
{
|
||||||
|
LOG_E("error %d requesting status", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!(status & R1_READY_FOR_DATA) ||
|
||||||
|
(R1_CURRENT_STATE(status) == R1_STATE_PRG));
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mmc_switch - modify EXT_CSD register
|
* mmc_switch - modify EXT_CSD register
|
||||||
* @card: the MMC card associated with the data transfer
|
* @card: the MMC card associated with the data transfer
|
||||||
@@ -295,6 +353,13 @@ static int mmc_switch(struct rt_mmcsd_card *card, rt_uint8_t set,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Poll the card status using CMD13 with a timeout of 500ms and a polling interval of 1ms.
|
||||||
|
*/
|
||||||
|
err = mmc_poll_for_busy(card, 500, 3);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +555,7 @@ rt_err_t mmc_send_op_cond(struct rt_mmcsd_host *host,
|
|||||||
|
|
||||||
err = -RT_ETIMEOUT;
|
err = -RT_ETIMEOUT;
|
||||||
|
|
||||||
rt_thread_mdelay(10); //delay 10ms
|
rt_thread_mdelay(10); /* delay 10ms */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rocr && !controller_is_spi(host))
|
if (rocr && !controller_is_spi(host))
|
||||||
@@ -815,3 +880,4 @@ err:
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user