X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Flpc288x.c;h=8852c859c351cdb9b78b6078a769467c76a21f9b;hp=2ecb5b2d425bcfee736f9dc1fa9214e16c563c12;hb=a7479fa89def9d8b1854d629dfdaa0ba17132617;hpb=9f0cba528a163645c8ecace413731c23310f2c26 diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c index 2ecb5b2d42..8852c859c3 100644 --- a/src/flash/nor/lpc288x.c +++ b/src/flash/nor/lpc288x.c @@ -13,9 +13,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * along with this program. If not, see . * ***************************************************************************/ /*************************************************************************** @@ -169,6 +167,7 @@ static int lpc288x_read_part_info(struct flash_bank *bank) return ERROR_OK; } +/* TODO: Revisit! Is it impossible to read protection status? */ static int lpc288x_protect_check(struct flash_bank *bank) { return ERROR_OK; @@ -233,17 +232,6 @@ static uint32_t lpc288x_system_ready(struct flash_bank *bank) return ERROR_OK; } -static int lpc288x_erase_check(struct flash_bank *bank) -{ - uint32_t status = lpc288x_system_ready(bank); /* probed? halted? */ - if (status != ERROR_OK) { - LOG_INFO("Processor not halted/not probed"); - return status; - } - - return ERROR_OK; -} - static int lpc288x_erase(struct flash_bank *bank, int first, int last) { uint32_t status; @@ -277,7 +265,7 @@ static int lpc288x_erase(struct flash_bank *bank, int first, int last) return ERROR_OK; } -static int lpc288x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) +static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) { uint8_t page_buffer[FLASH_PAGE_SIZE]; uint32_t status, source_offset, dest_offset; @@ -350,22 +338,13 @@ static int lpc288x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs target_write_u32(target, F_CTRL, FC_CS | FC_SET_DATA | FC_WEN | FC_FUNC); target_write_u32(target, F_CTRL, FC_CS | FC_WEN | FC_FUNC); - /*would be better to use the clean target_write_buffer() interface but - * it seems not to be a LOT slower.... - * bulk_write_memory() is no quicker :(*/ -#if 1 - if (target_write_memory(target, offset + dest_offset, 4, 128, - page_buffer) != ERROR_OK) { - LOG_ERROR("Write failed s %" PRIx32 " p %" PRIx32 "", sector, page); - return ERROR_FLASH_OPERATION_FAILED; - } -#else + if (target_write_buffer(target, offset + dest_offset, FLASH_PAGE_SIZE, page_buffer) != ERROR_OK) { LOG_INFO("Write to flash buffer failed"); return ERROR_FLASH_OPERATION_FAILED; } -#endif + dest_offset += FLASH_PAGE_SIZE; source_offset += count; bytes_remaining -= count; @@ -400,12 +379,6 @@ static int lpc288x_probe(struct flash_bank *bank) return ERROR_OK; } -static int lpc288x_info(struct flash_bank *bank, char *buf, int buf_size) -{ - snprintf(buf, buf_size, "lpc288x flash driver"); - return ERROR_OK; -} - static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last) { int lockregion, status; @@ -439,7 +412,7 @@ static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last return ERROR_OK; } -struct flash_driver lpc288x_flash = { +const struct flash_driver lpc288x_flash = { .name = "lpc288x", .flash_bank_command = lpc288x_flash_bank_command, .erase = lpc288x_erase, @@ -448,7 +421,7 @@ struct flash_driver lpc288x_flash = { .read = default_flash_read, .probe = lpc288x_probe, .auto_probe = lpc288x_probe, - .erase_check = lpc288x_erase_check, + .erase_check = default_flash_blank_check, .protect_check = lpc288x_protect_check, - .info = lpc288x_info, + .free_driver_priv = default_flash_free_driver_priv, };