summaryrefslogtreecommitdiff
path: root/board/dave/common/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/dave/common/flash.c')
-rw-r--r--board/dave/common/flash.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/board/dave/common/flash.c b/board/dave/common/flash.c
index feea093..b0e4116 100644
--- a/board/dave/common/flash.c
+++ b/board/dave/common/flash.c
@@ -22,7 +22,6 @@
*/
#include <common.h>
-#include <ppc4xx.h>
#include <asm/processor.h>
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
@@ -578,15 +577,27 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
if ((l = addr - wp) != 0) {
data = 0;
for (i=0, cp=wp; i<l; ++i, ++cp) {
+#ifdef CONFIG_B2
+ data = data | ((*(uchar *)cp)<<(8*i));
+#else
data = (data << 8) | (*(uchar *)cp);
+#endif
}
for (; i<4 && cnt>0; ++i) {
+#ifdef CONFIG_B2
+ data = data | ((*src++)<<(8*i));
+#else
data = (data << 8) | *src++;
+#endif
--cnt;
++cp;
}
for (; cnt==0 && i<4; ++i, ++cp) {
+#ifdef CONFIG_B2
+ data = data | ((*(uchar *)cp)<<(8*i));
+#else
data = (data << 8) | (*(uchar *)cp);
+#endif
}
if ((rc = write_word(info, wp, data)) != 0) {
@@ -600,9 +611,14 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
while (cnt >= 4) {
data = 0;
+#ifdef CONFIG_B2
+ data = (*(ulong*)src);
+ src += 4;
+#else
for (i=0; i<4; ++i) {
data = (data << 8) | *src++;
}
+#endif
if ((rc = write_word(info, wp, data)) != 0) {
return (rc);
}
@@ -619,11 +635,19 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
data = 0;
for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+#ifdef CONFIG_B2
+ data = data | ((*src++)<<(8*i));
+#else
data = (data << 8) | *src++;
+#endif
--cnt;
}
for (; i<4; ++i, ++cp) {
+#ifdef CONFIG_B2
+ data = data | ((*(uchar *)cp)<<(8*i));
+#else
data = (data << 8) | (*(uchar *)cp);
+#endif
}
return (write_word(info, wp, data));