diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-02-26 10:32:25 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-02-26 10:32:25 +0100 |
commit | 51c840cd18acd8a9f656b1491bc8ff100acccbd0 (patch) | |
tree | eda7f80c130e7da14b8e447b1248a26a8ee74ebd /include | |
parent | d99f33eb25b8c9c732589ec30a4f38e9f09500b1 (diff) | |
download | barebox-51c840cd18acd8a9f656b1491bc8ff100acccbd0.tar.gz barebox-51c840cd18acd8a9f656b1491bc8ff100acccbd0.tar.xz |
[CFI driver] For some Spansion flashes we have to write the
AMD_CMD_WRITE_TO_BUFFER command to the destination
address of the buffer write and not to the sector
beginning. Linux mtd does this as default, so I
assume this should work for other flashes aswell.
Reorder functions so that this change fits in nicely.
Diffstat (limited to 'include')
-rw-r--r-- | include/cfi_flash_new.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/cfi_flash_new.h b/include/cfi_flash_new.h index 2ccae1dca0..c00f47c546 100644 --- a/include/cfi_flash_new.h +++ b/include/cfi_flash_new.h @@ -25,6 +25,7 @@ */ #include <driver.h> +#include <asm/io.h> typedef unsigned long flash_sect_t; struct cfi_cmd_set; @@ -222,6 +223,27 @@ typedef union { volatile unsigned long long *llp; } cfiptr_t; +static inline void flash_write_word(flash_info_t *info, cfiword_t datum, void *addr) +{ + switch (info->portwidth) { + case FLASH_CFI_8BIT: + debug("fw addr %p val %02x\n", addr, datum.c); + writeb(datum.c, addr); + break; + case FLASH_CFI_16BIT: + debug("fw addr %p val %04x\n", addr, datum.w); + writew(datum.w, addr); + break; + case FLASH_CFI_32BIT: + debug("fw addr %p val %08x\n", addr, datum.l); + writel(datum.l, addr); + break; + case FLASH_CFI_64BIT: + memcpy((void *)addr, &datum.ll, 8); + break; + } +} + extern void flash_print_info (flash_info_t *); extern int flash_sect_erase (ulong addr_first, ulong addr_last); extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last); |