mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
litelitesdcard/sdcard: remove wait workaround and replace remove SDCARD_MULTIPLE_BLOCK_SUPPORT define (replace it with SDCARD_CMD23_SUPPORT).
This commit is contained in:
parent
94821cb73c
commit
2f6b27da23
1 changed files with 11 additions and 19 deletions
|
@ -17,9 +17,7 @@
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
|
|
||||||
//#define SDCARD_DEBUG
|
//#define SDCARD_DEBUG
|
||||||
#define SDCARD_WAIT_WORKAROUND
|
//#define SDCARD_CMD23_SUPPORT
|
||||||
|
|
||||||
#define SDCARD_MULTIPLE_BLOCK_SUPPORT
|
|
||||||
|
|
||||||
#ifdef CSR_SDCORE_BASE
|
#ifdef CSR_SDCORE_BASE
|
||||||
|
|
||||||
|
@ -43,9 +41,7 @@ int sdcard_wait_cmd_done(void) {
|
||||||
unsigned int cmdevt;
|
unsigned int cmdevt;
|
||||||
while (1) {
|
while (1) {
|
||||||
cmdevt = sdcore_cmdevt_read();
|
cmdevt = sdcore_cmdevt_read();
|
||||||
#ifdef SDCARD_WAIT_WORKAROUND
|
busy_wait_us(1);
|
||||||
busy_wait_us(100); /* FIXME */
|
|
||||||
#endif
|
|
||||||
#ifdef SDCARD_DEBUG
|
#ifdef SDCARD_DEBUG
|
||||||
printf("cmdevt: %08x\n", cmdevt);
|
printf("cmdevt: %08x\n", cmdevt);
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,9 +67,7 @@ int sdcard_wait_data_done(void) {
|
||||||
unsigned int dataevt;
|
unsigned int dataevt;
|
||||||
while (1) {
|
while (1) {
|
||||||
dataevt = sdcore_dataevt_read();
|
dataevt = sdcore_dataevt_read();
|
||||||
#ifdef SDCARD_WAIT_WORKAROUND
|
busy_wait_us(1);
|
||||||
busy_wait_us(100); /* FIXME */
|
|
||||||
#endif
|
|
||||||
#ifdef SDCARD_DEBUG
|
#ifdef SDCARD_DEBUG
|
||||||
printf("dataevt: %08x\n", dataevt);
|
printf("dataevt: %08x\n", dataevt);
|
||||||
#endif
|
#endif
|
||||||
|
@ -490,20 +484,16 @@ void sdcard_read(uint32_t sector, uint32_t count, uint8_t* buf)
|
||||||
sdreader_enable_write(1);
|
sdreader_enable_write(1);
|
||||||
|
|
||||||
/* Read Block(s) from SDCard */
|
/* Read Block(s) from SDCard */
|
||||||
#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT
|
#ifdef SDCARD_CMD23_SUPPORT
|
||||||
sdcard_set_block_count(count);
|
sdcard_set_block_count(count);
|
||||||
sdcard_read_multiple_block(sector, count);
|
|
||||||
#else
|
|
||||||
while (count) {
|
|
||||||
sdcard_read_single_block(sector);
|
|
||||||
sector += 1;
|
|
||||||
count -= 1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
sdcard_read_multiple_block(sector, count);
|
||||||
|
|
||||||
/* Wait for DMA Writer to complete */
|
/* Wait for DMA Writer to complete */
|
||||||
while ((sdreader_done_read() & 0x1) == 0);
|
while ((sdreader_done_read() & 0x1) == 0);
|
||||||
|
|
||||||
|
sdcard_stop_transmission();
|
||||||
|
|
||||||
flush_cpu_dcache(); /* FIXME */
|
flush_cpu_dcache(); /* FIXME */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,11 +511,13 @@ void sdcard_write(uint32_t sector, uint32_t count, uint8_t* buf)
|
||||||
while ((sdwriter_done_read() & 0x1) == 0);
|
while ((sdwriter_done_read() & 0x1) == 0);
|
||||||
|
|
||||||
/* Write Single Block to SDCard */
|
/* Write Single Block to SDCard */
|
||||||
#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT
|
#ifndef SDCARD_CMD23_SUPPORT
|
||||||
sdcard_set_block_count(1);
|
sdcard_set_block_count(1);
|
||||||
#endif
|
#endif
|
||||||
sdcard_write_single_block(sector);
|
sdcard_write_single_block(sector);
|
||||||
|
|
||||||
|
sdcard_stop_transmission();
|
||||||
|
|
||||||
/* Update buf/sector */
|
/* Update buf/sector */
|
||||||
buf += 512;
|
buf += 512;
|
||||||
sector += 1;
|
sector += 1;
|
||||||
|
|
Loading…
Reference in a new issue