Merge pull request #1338 from p-woj/litesdcard-init
software/liblitesdcard: Fix condition in sdcard_init
This commit is contained in:
commit
e4c81e8fdf
|
@ -382,6 +382,7 @@ void sdcard_decode_csd(void) {
|
||||||
|
|
||||||
int sdcard_init(void) {
|
int sdcard_init(void) {
|
||||||
uint16_t rca, timeout;
|
uint16_t rca, timeout;
|
||||||
|
uint32_t r[SD_CMD_RESPONSE_SIZE/4];
|
||||||
|
|
||||||
/* Set SD clk freq to Initialization frequency */
|
/* Set SD clk freq to Initialization frequency */
|
||||||
sdcard_set_clk_freq(SDCARD_CLK_FREQ_INIT, 0);
|
sdcard_set_clk_freq(SDCARD_CLK_FREQ_INIT, 0);
|
||||||
|
@ -411,8 +412,13 @@ int sdcard_init(void) {
|
||||||
/* Set SDCard in Operational state */
|
/* Set SDCard in Operational state */
|
||||||
for (timeout=1000; timeout>0; timeout--) {
|
for (timeout=1000; timeout>0; timeout--) {
|
||||||
sdcard_app_cmd(0);
|
sdcard_app_cmd(0);
|
||||||
if (sdcard_app_send_op_cond(1) != SD_OK)
|
if (sdcard_app_send_op_cond(1) == SD_OK) {
|
||||||
break;
|
csr_rd_buf_uint32(CSR_SDCORE_CMD_RESPONSE_ADDR,
|
||||||
|
r, SD_CMD_RESPONSE_SIZE/4);
|
||||||
|
|
||||||
|
if (r[3] & 0x80000000) /* Busy bit, set when init is complete */
|
||||||
|
break;
|
||||||
|
}
|
||||||
busy_wait(1);
|
busy_wait(1);
|
||||||
}
|
}
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
|
|
Loading…
Reference in New Issue