summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-03-27 17:17:19 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-03-27 17:18:21 -0400
commit83fcbedc65f4b9ae7e491ecf6f07c0af4b245f74 (patch)
treed7f7027548890297afba44919ab3f99b4446319a
parent961ffa61dd9126d9f6a01a88a26cac3e7bc87657 (diff)
downloadrockbox-83fcbedc65f4b9ae7e491ecf6f07c0af4b245f74.tar.gz
rockbox-83fcbedc65f4b9ae7e491ecf6f07c0af4b245f74.zip
rk27xx: Take advantage of STORAGE_NEEDS_BOUNCE_BUFFER
(And get rid of its custom realignment code) Change-Id: Iff27d717b870d3db239310421776744ea6863373
-rw-r--r--firmware/target/arm/rk27xx/sd-rk27xx.c9
-rw-r--r--firmware/target/arm/rk27xx/system-target.h1
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 */
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
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 */