static int flash_toggle(struct flash_info *info, flash_sect_t sect, unsigned int offset, u8 cmd) { void *addr; cfiword_t cword; int retval; addr = flash_make_addr (info, sect, offset); flash_make_cmd (info, cmd, &cword); if (bankwidth_is_1(info)) { retval = flash_read8(addr) != flash_read8(addr); } else if (bankwidth_is_2(info)) { retval = flash_read16(addr) != flash_read16(addr); } else if (bankwidth_is_4(info)) { retval = flash_read32(addr) != flash_read32(addr); } else if (bankwidth_is_8(info)) { retval = ( (flash_read32( addr ) != flash_read32( addr )) || (flash_read32(addr+4) != flash_read32(addr+4)) ); } else { retval = 0; } return retval; }
static int amd_flash_write_cfibuffer (struct flash_info *info, ulong dest, const uchar * cp, int len) { flash_sect_t sector; int cnt; int retcode; volatile cfiptr_t src; volatile cfiptr_t dst; cfiword_t cword; src.cp = (uchar *)cp; dst.cp = (uchar *) dest; sector = find_sector (info, dest); flash_unlock_seq(info); flash_make_cmd (info, AMD_CMD_WRITE_TO_BUFFER, &cword); flash_write_word(info, cword, (void *)dest); if (bankwidth_is_1(info)) { cnt = len; flash_write_cmd (info, sector, 0, (uchar) cnt - 1); while (cnt-- > 0) *dst.cp++ = *src.cp++; } else if (bankwidth_is_2(info)) { cnt = len >> 1; flash_write_cmd (info, sector, 0, (uchar) cnt - 1); while (cnt-- > 0) *dst.wp++ = *src.wp++; } else if (bankwidth_is_4(info)) {
static int amd_flash_write_cfibuffer(struct flash_info *info, unsigned long dest, const u8 *cp, int len) { flash_sect_t sector; int cnt; void *src = (void *)cp; void *dst = (void *)dest; cfiword_t cword; sector = find_sector (info, dest); flash_unlock_seq(info); flash_make_cmd (info, AMD_CMD_WRITE_TO_BUFFER, &cword); flash_write_word(info, cword, (void *)dest); if (bankwidth_is_1(info)) { cnt = len; flash_write_cmd(info, sector, 0, (u32)cnt - 1); while (cnt-- > 0) { flash_write8(flash_read8(src), dst); src += 1, dst += 1; } } else if (bankwidth_is_2(info)) { cnt = len >> 1; flash_write_cmd(info, sector, 0, (u32)cnt - 1); while (cnt-- > 0) { flash_write16(flash_read16(src), dst); src += 2, dst += 2; } } else if (bankwidth_is_4(info)) {
static int flash_toggle (struct flash_info *info, flash_sect_t sect, uint offset, uchar cmd) { cfiptr_t cptr; cfiword_t cword; int retval; cptr.cp = flash_make_addr (info, sect, offset); flash_make_cmd (info, cmd, &cword); if (bankwidth_is_1(info)) { retval = ((cptr.cp[0] & cword.c) != (cptr.cp[0] & cword.c)); } else if (bankwidth_is_2(info)) { retval = ((cptr.wp[0] & cword.w) != (cptr.wp[0] & cword.w)); } else if (bankwidth_is_4(info)) { retval = ((cptr.lp[0] & cword.l) != (cptr.lp[0] & cword.l)); } else if (bankwidth_is_8(info)) { retval = ((cptr.llp[0] & cword.ll) != (cptr.llp[0] & cword.ll)); } else retval = 0; return retval; }