summaryrefslogtreecommitdiff
path: root/firmware/target/arm/rk27xx/sd-rk27xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/rk27xx/sd-rk27xx.c')
-rw-r--r--firmware/target/arm/rk27xx/sd-rk27xx.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c
index e5467058de..2ddf91a67e 100644
--- a/firmware/target/arm/rk27xx/sd-rk27xx.c
+++ b/firmware/target/arm/rk27xx/sd-rk27xx.c
@@ -41,6 +41,7 @@
41#include "sysfont.h" 41#include "sysfont.h"
42 42
43#define RES_NO (-1) 43#define RES_NO (-1)
44// #define ALIGN_BUF
44 45
45/* debug stuff */ 46/* debug stuff */
46unsigned long sd_debug_time_rd = 0; 47unsigned long sd_debug_time_rd = 0;
@@ -51,7 +52,9 @@ static tCardInfo card_info;
51/* for compatibility */ 52/* for compatibility */
52static long last_disk_activity = -1; 53static long last_disk_activity = -1;
53 54
55#ifdef ALIGN_BUF
54static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR; 56static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR;
57#endif
55 58
56static struct mutex sd_mtx SHAREDBSS_ATTR; 59static struct mutex sd_mtx SHAREDBSS_ATTR;
57#ifndef BOOTLOADER 60#ifndef BOOTLOADER
@@ -397,8 +400,10 @@ static inline void read_sd_data(unsigned char **dst)
397{ 400{
398 void *buf = *dst; 401 void *buf = *dst;
399 402
403#ifdef ALIGN_BUF
400 if (!IS_ALIGNED(((unsigned long)*dst), CACHEALIGN_SIZE)) 404 if (!IS_ALIGNED(((unsigned long)*dst), CACHEALIGN_SIZE))
401 buf = aligned_buf; 405 buf = aligned_buf;
406#endif
402 407
403 commit_discard_dcache_range((const void *)buf, 512); 408 commit_discard_dcache_range((const void *)buf, 512);
404 409
@@ -413,8 +418,10 @@ static inline void read_sd_data(unsigned char **dst)
413 /* wait for DMA engine to finish transfer */ 418 /* wait for DMA engine to finish transfer */
414 while (A2A_DMA_STS & 1); 419 while (A2A_DMA_STS & 1);
415 420
421#ifdef ALIGN_BUF
416 if (buf == aligned_buf) 422 if (buf == aligned_buf)
417 memcpy(*dst, aligned_buf, 512); 423 memcpy(*dst, aligned_buf, 512);
424#endif
418 425
419 *dst += 512; 426 *dst += 512;
420} 427}
@@ -423,11 +430,13 @@ static inline void write_sd_data(unsigned char **src)
423{ 430{
424 void *buf = *src; 431 void *buf = *src;
425 432
433#ifdef ALIGN_BUF
426 if (!IS_ALIGNED(((unsigned long)*src), CACHEALIGN_SIZE)) 434 if (!IS_ALIGNED(((unsigned long)*src), CACHEALIGN_SIZE))
427 { 435 {
428 buf = aligned_buf; 436 buf = aligned_buf;
429 memcpy(aligned_buf, *src, 512); 437 memcpy(aligned_buf, *src, 512);
430 } 438 }
439#endif
431 440
432 commit_discard_dcache_range((const void *)buf, 512); 441 commit_discard_dcache_range((const void *)buf, 512);
433 442