This got broken by commits 93c56f212c
 [cfi_flash: support of long cmd in U-boot.]

That command needs to be in little endian format on BE machines
with CFG_WRITE_SWAPPED_DATA. Without this patch, the command 0xf0
gets saved on stack as 0x00 00 00 f0 and 0x00 gets written into
the cmdbuf in case portwidth = chipwidth = 8

Cc: Alexey Korolev <[EMAIL PROTECTED]>
Cc: Vasiliy Leonenko <[EMAIL PROTECTED]>
Signed-off-by: Sebastian Siewior <[EMAIL PROTECTED]>
---
Stefan, this is on top of my previous patch. I don't touch the 
BE + !CFG_WRITE_SWAPPED_DATA because it worked before. What I'm
not 100% sure is whether LE + CFG_WRITE_SWAPPED_DATA still works....

 drivers/mtd/cfi_flash.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 4340b1b..a85e0ff 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -306,16 +306,21 @@ static void flash_make_cmd(flash_info_t *info, u32 cmd, 
void *cmdbuf)
        int i;
        int cword_offset;
        int cp_offset;
+       int cmd_le;
        uchar val;
        uchar *cp = (uchar *) cmdbuf;
 
+       cmd_le = cpu_to_le32(cmd);
        for (i = info->portwidth; i > 0; i--){
                cword_offset = (info->portwidth-i)%info->chipwidth;
 #if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA)
                cp_offset = info->portwidth - i;
-               val = *((uchar*)&cmd + cword_offset);
+               val = *((uchar*)&cmd_le + cword_offset);
 #else
                cp_offset = i - 1;
+               /* we rely here on the fact, that cmd _has_ to be in BE
+                * order because we are not __LITTLE_ENDIAN
+                */
                val = *((uchar*)&cmd + sizeof(u32) - cword_offset - 1);
 #endif
                cp[cp_offset] = (cword_offset >= sizeof(u32)) ? 0x00 : val;
-- 
1.5.5.2


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to