diff options
-rw-r--r-- | firmware/target/arm/rk27xx/sd-rk27xx.c | 9 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/system-target.h | 1 |
2 files changed, 10 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 */ |
46 | unsigned long sd_debug_time_rd = 0; | 47 | unsigned long sd_debug_time_rd = 0; |
@@ -51,7 +52,9 @@ static tCardInfo card_info; | |||
51 | /* for compatibility */ | 52 | /* for compatibility */ |
52 | static long last_disk_activity = -1; | 53 | static long last_disk_activity = -1; |
53 | 54 | ||
55 | #ifdef ALIGN_BUF | ||
54 | static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR; | 56 | static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR; |
57 | #endif | ||
55 | 58 | ||
56 | static struct mutex sd_mtx SHAREDBSS_ATTR; | 59 | static 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 | ||
diff --git a/firmware/target/arm/rk27xx/system-target.h b/firmware/target/arm/rk27xx/system-target.h index a5b27cc6b2..eca675a2af 100644 --- a/firmware/target/arm/rk27xx/system-target.h +++ b/firmware/target/arm/rk27xx/system-target.h | |||
@@ -53,5 +53,6 @@ void commit_discard_idcache(void); | |||
53 | #define CPUFREQ_MAX 200000000 | 53 | #define CPUFREQ_MAX 200000000 |
54 | 54 | ||
55 | #define STORAGE_WANTS_ALIGN | 55 | #define STORAGE_WANTS_ALIGN |
56 | #define STORAGE_NEEDS_BOUNCE_BUFFER | ||
56 | 57 | ||
57 | #endif /* SYSTEM_TARGET_H */ | 58 | #endif /* SYSTEM_TARGET_H */ |