X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Flpc288x.c;h=d681fbf9ea69ce3e0cf54f385e08506f197fc9f2;hp=513e2fcf353b039e9a6dd5018ec2b461f327029d;hb=632fd663a821047df9a9b965ec1c35d6b034ebba;hpb=8b994145b849c40b0a195c3fb332b9770b2f9097 diff --git a/src/flash/lpc288x.c b/src/flash/lpc288x.c index 513e2fcf35..d681fbf9ea 100644 --- a/src/flash/lpc288x.c +++ b/src/flash/lpc288x.c @@ -84,40 +84,11 @@ /* F_CLK_TIME */ #define FCT_CLK_DIV_MASK 0x0FFF -static int lpc288x_register_commands(struct command_context_s *cmd_ctx); -static int lpc288x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int lpc288x_erase(struct flash_bank_s *bank, int first, int last); -static int lpc288x_protect(struct flash_bank_s *bank, int set, int first, int last); -static int lpc288x_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int lpc288x_probe(struct flash_bank_s *bank); -static int lpc288x_erase_check(struct flash_bank_s *bank); -static int lpc288x_protect_check(struct flash_bank_s *bank); -static int lpc288x_info(struct flash_bank_s *bank, char *buf, int buf_size); static uint32_t lpc288x_wait_status_busy(flash_bank_t *bank, int timeout); static void lpc288x_load_timer(int erase, struct target_s *target); static void lpc288x_set_flash_clk(struct flash_bank_s *bank); static uint32_t lpc288x_system_ready(struct flash_bank_s *bank); -flash_driver_t lpc288x_flash = -{ - .name = "lpc288x", - .register_commands = lpc288x_register_commands, - .flash_bank_command = lpc288x_flash_bank_command, - .erase = lpc288x_erase, - .protect = lpc288x_protect, - .write = lpc288x_write, - .probe = lpc288x_probe, - .auto_probe = lpc288x_probe, - .erase_check = lpc288x_erase_check, - .protect_check = lpc288x_protect_check, - .info = lpc288x_info -}; - -static int lpc288x_register_commands(struct command_context_s *cmd_ctx) -{ - return ERROR_OK; -} - static uint32_t lpc288x_wait_status_busy(flash_bank_t *bank, int timeout) { uint32_t status; @@ -166,7 +137,7 @@ static int lpc288x_read_part_info(struct flash_bank_s *bank) /* setup the sector info... */ offset = bank->base; bank->num_sectors = 23; - bank->sectors = malloc(sizeof(flash_sector_t) * 23); + bank->sectors = malloc(sizeof(struct flash_sector) * 23); for (i = 0; i < 15; i++) { @@ -194,7 +165,7 @@ static int lpc288x_protect_check(struct flash_bank_s *bank) } /* flash_bank LPC288x 0 0 0 0 */ -static int lpc288x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank) +FLASH_BANK_COMMAND_HANDLER(lpc288x_flash_bank_command) { lpc288x_flash_bank_t *lpc288x_info; @@ -209,7 +180,7 @@ static int lpc288x_flash_bank_command(struct command_context_s *cmd_ctx, char *c /* part wasn't probed for info yet */ lpc288x_info->cidr = 0; - lpc288x_info->cclk = strtoul(args[6], NULL, 0); + COMMAND_PARSE_NUMBER(u32, args[6], lpc288x_info->cclk); return ERROR_OK; } @@ -499,3 +470,16 @@ static int lpc288x_protect(struct flash_bank_s *bank, int set, int first, int la return ERROR_OK; } + +struct flash_driver lpc288x_flash = { + .name = "lpc288x", + .flash_bank_command = &lpc288x_flash_bank_command, + .erase = &lpc288x_erase, + .protect = &lpc288x_protect, + .write = &lpc288x_write, + .probe = &lpc288x_probe, + .auto_probe = &lpc288x_probe, + .erase_check = &lpc288x_erase_check, + .protect_check = &lpc288x_protect_check, + .info = &lpc288x_info, + };