#include "sdcard.h"
//#define SDCARD_DEBUG
-#define SDCARD_WAIT_WORKAROUND
-
-#define SDCARD_MULTIPLE_BLOCK_SUPPORT
+//#define SDCARD_CMD23_SUPPORT
#ifdef CSR_SDCORE_BASE
unsigned int cmdevt;
while (1) {
cmdevt = sdcore_cmdevt_read();
-#ifdef SDCARD_WAIT_WORKAROUND
- busy_wait_us(100); /* FIXME */
-#endif
+ busy_wait_us(1);
#ifdef SDCARD_DEBUG
printf("cmdevt: %08x\n", cmdevt);
#endif
unsigned int dataevt;
while (1) {
dataevt = sdcore_dataevt_read();
-#ifdef SDCARD_WAIT_WORKAROUND
- busy_wait_us(100); /* FIXME */
-#endif
+ busy_wait_us(1);
#ifdef SDCARD_DEBUG
printf("dataevt: %08x\n", dataevt);
#endif
sdreader_enable_write(1);
/* Read Block(s) from SDCard */
-#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT
- sdcard_set_block_count(count);
- sdcard_read_multiple_block(sector, count);
-#else
- while (count) {
- sdcard_read_single_block(sector);
- sector += 1;
- count -= 1;
- }
+#ifdef SDCARD_CMD23_SUPPORT
+sdcard_set_block_count(count);
#endif
+ sdcard_read_multiple_block(sector, count);
/* Wait for DMA Writer to complete */
while ((sdreader_done_read() & 0x1) == 0);
+ sdcard_stop_transmission();
+
flush_cpu_dcache(); /* FIXME */
}
while ((sdwriter_done_read() & 0x1) == 0);
/* Write Single Block to SDCard */
-#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT
+#ifndef SDCARD_CMD23_SUPPORT
sdcard_set_block_count(1);
#endif
sdcard_write_single_block(sector);
+ sdcard_stop_transmission();
+
/* Update buf/sector */
buf += 512;
sector += 1;