liblitesdcard/sdcard: add SDCARD_MULTIPLE_BLOCK_SUPPORT define.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 1 Jul 2020 10:40:23 +0000 (12:40 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 1 Jul 2020 10:40:23 +0000 (12:40 +0200)
litex/soc/software/liblitesdcard/sdcard.c

index 4b9e8aef2646d8cddf15bdf08ef34cced886c8d2..66a4c876584d554dcc55931f427c1e3430226831 100644 (file)
@@ -19,6 +19,8 @@
 //#define SDCARD_DEBUG
 #define SDCARD_WAIT_WORKAROUND
 
+#define SDCARD_MULTIPLE_BLOCK_SUPPORT
+
 #ifdef CSR_SDCORE_BASE
 
 unsigned int sdcard_response[SD_RESPONSE_SIZE/4];
@@ -491,11 +493,16 @@ void sdcard_read(uint32_t sector, uint32_t count, uint8_t* buf)
        sdreader_enable_write(1);
 
        /* Read Block(s) from SDCard */
+#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT
        sdcard_set_block_count(count);
-       if (count > 0)
-               sdcard_read_multiple_block(sector, count);
-       else
+       sdcard_read_multiple_block(sector, count);
+#else
+       while (count) {
                sdcard_read_single_block(sector);
+               sector += 1;
+               count  -= 1;
+       }
+#endif
 
        /* Wait for DMA Writer to complete */
        while ((sdreader_done_read() & 0x1) == 0);
@@ -517,7 +524,9 @@ void sdcard_write(uint32_t sector, uint32_t count, uint8_t* buf)
                while ((sdwriter_done_read() & 0x1) == 0);
 
                /* Write Single Block to SDCard */
+#ifdef SDCARD_MULTIPLE_BLOCK_SUPPORT
                sdcard_set_block_count(1);
+#endif
                sdcard_write_single_block(sector);
 
                /* Update buf/sector */