int epcs_write(int addr, int len, u8 *buf) { int sector, page; for(sector=0; sector<len; sector+=4096){ epcs_sector_erase(addr+sector); for(page=0; page<4096; page+=256){ epcs_page_write(addr+sector+page, buf+sector+page); } } return 0; }
/* * * Erase the selected erase block ("sector erase", from the POV * of the EPCS data sheet). */ int alt_epcs_flash_erase_block(alt_flash_dev* flash_info, int block_offset) { int ret_code = 0; alt_flash_epcs_dev *f = (alt_flash_epcs_dev*)flash_info; ret_code = alt_epcs_test_address(flash_info, block_offset); if (ret_code >= 0) { /* Send the Sector Erase command, whose 3 address bytes are anywhere * within the chosen sector. */ epcs_sector_erase(f->register_base, block_offset, f->four_bytes_mode); } return ret_code; }
/* * * Erase the selected erase block ("sector erase", from the POV * of the EPCS data sheet). */ int alt_epcs_flash_erase_block(alt_flash_dev* flash_info, int block_offset) { int ret_code = 0; alt_flash_epcs_dev *f = (alt_flash_epcs_dev*)flash_info; ret_code = alt_epcs_test_address(flash_info, block_offset); if (ret_code >= 0) { /* Execute a WREN instruction */ epcs_write_enable(f->register_base); /* Send the Sector Erase command, whose 3 address bytes are anywhere * within the chosen sector. */ epcs_sector_erase(f->register_base, block_offset); } return ret_code; }