X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Ftms470.c;h=2f02e5d77cf9da23effd2b2797af76923457e82a;hp=7efcbd4b918620217fb9341f30715064aba052d4;hb=2b546fdc45d33a7b407f49b3732d1a57afa60b72;hpb=d9dc604a4d790f557a7ba502babdabffa27eaa17 diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c index 7efcbd4b91..2f02e5d77c 100644 --- a/src/flash/nor/tms470.c +++ b/src/flash/nor/tms470.c @@ -29,7 +29,7 @@ Internal Support, Helpers ---------------------------------------------------------------------- */ -const struct flash_sector TMS470R1A256_SECTORS[] = { +static const struct flash_sector TMS470R1A256_SECTORS[] = { {0x00000000, 0x00002000, -1, -1}, {0x00002000, 0x00002000, -1, -1}, {0x00004000, 0x00002000, -1, -1}, @@ -49,7 +49,7 @@ const struct flash_sector TMS470R1A256_SECTORS[] = { #define TMS470R1A256_NUM_SECTORS \ ARRAY_SIZE(TMS470R1A256_SECTORS) -const struct flash_sector TMS470R1A288_BANK0_SECTORS[] = { +static const struct flash_sector TMS470R1A288_BANK0_SECTORS[] = { {0x00000000, 0x00002000, -1, -1}, {0x00002000, 0x00002000, -1, -1}, {0x00004000, 0x00002000, -1, -1}, @@ -59,7 +59,7 @@ const struct flash_sector TMS470R1A288_BANK0_SECTORS[] = { #define TMS470R1A288_BANK0_NUM_SECTORS \ ARRAY_SIZE(TMS470R1A288_BANK0_SECTORS) -const struct flash_sector TMS470R1A288_BANK1_SECTORS[] = { +static const struct flash_sector TMS470R1A288_BANK1_SECTORS[] = { {0x00040000, 0x00010000, -1, -1}, {0x00050000, 0x00010000, -1, -1}, {0x00060000, 0x00010000, -1, -1}, @@ -69,7 +69,7 @@ const struct flash_sector TMS470R1A288_BANK1_SECTORS[] = { #define TMS470R1A288_BANK1_NUM_SECTORS \ ARRAY_SIZE(TMS470R1A288_BANK1_SECTORS) -const struct flash_sector TMS470R1A384_BANK0_SECTORS[] = { +static const struct flash_sector TMS470R1A384_BANK0_SECTORS[] = { {0x00000000, 0x00002000, -1, -1}, {0x00002000, 0x00002000, -1, -1}, {0x00004000, 0x00004000, -1, -1}, @@ -85,7 +85,7 @@ const struct flash_sector TMS470R1A384_BANK0_SECTORS[] = { #define TMS470R1A384_BANK0_NUM_SECTORS \ ARRAY_SIZE(TMS470R1A384_BANK0_SECTORS) -const struct flash_sector TMS470R1A384_BANK1_SECTORS[] = { +static const struct flash_sector TMS470R1A384_BANK1_SECTORS[] = { {0x00020000, 0x00008000, -1, -1}, {0x00028000, 0x00008000, -1, -1}, {0x00030000, 0x00008000, -1, -1}, @@ -95,7 +95,7 @@ const struct flash_sector TMS470R1A384_BANK1_SECTORS[] = { #define TMS470R1A384_BANK1_NUM_SECTORS \ ARRAY_SIZE(TMS470R1A384_BANK1_SECTORS) -const struct flash_sector TMS470R1A384_BANK2_SECTORS[] = { +static const struct flash_sector TMS470R1A384_BANK2_SECTORS[] = { {0x00040000, 0x00008000, -1, -1}, {0x00048000, 0x00008000, -1, -1}, {0x00050000, 0x00008000, -1, -1}, @@ -139,6 +139,12 @@ static int tms470_read_part_info(struct flash_bank *bank) rom_flash = (device_ident_reg >> 10) & 1; part_number = (device_ident_reg >> 3) & 0x7f; + if (bank->sectors) + { + free(bank->sectors); + bank->sectors = NULL; + } + /* * If the part number is known, determine if the flash bank is valid * based on the base address being within the known flash bank @@ -667,7 +673,7 @@ static int tms470_flash_initialize_internal_state_machine(struct flash_bank *ban /* ---------------------------------------------------------------------- */ -int tms470_flash_status(struct flash_bank *bank) +static int tms470_flash_status(struct flash_bank *bank) { struct target *target = bank->target; int result = ERROR_OK; @@ -821,19 +827,19 @@ static int tms470_erase_sector(struct flash_bank *bank, int sector) static const struct command_registration tms470_any_command_handlers[] = { { .name = "flash_keyset", - .handler = &tms470_handle_flash_keyset_command, + .handler = tms470_handle_flash_keyset_command, .mode = COMMAND_ANY, .help = "tms470 flash_keyset ", }, { .name = "osc_megahertz", - .handler = &tms470_handle_osc_megahertz_command, + .handler = tms470_handle_osc_megahertz_command, .mode = COMMAND_ANY, .help = "tms470 osc_megahertz ", }, { .name = "plldis", - .handler = &tms470_handle_plldis_command, + .handler = tms470_handle_plldis_command, .mode = COMMAND_ANY, .help = "tms470 plldis <0/1>", }, @@ -1209,7 +1215,7 @@ static int tms470_protect_check(struct flash_bank *bank) /* ---------------------------------------------------------------------- */ -static int tms470_info(struct flash_bank *bank, char *buf, int buf_size) +static int get_tms470_info(struct flash_bank *bank, char *buf, int buf_size) { int used = 0; struct tms470_flash_bank *tms470_info = bank->driver_priv; @@ -1258,15 +1264,16 @@ FLASH_BANK_COMMAND_HANDLER(tms470_flash_bank_command) } struct flash_driver tms470_flash = { - .name = "tms470", - .commands = tms470_command_handlers, - .flash_bank_command = &tms470_flash_bank_command, - .erase = &tms470_erase, - .protect = &tms470_protect, - .write = &tms470_write, - .probe = &tms470_probe, - .auto_probe = &tms470_auto_probe, - .erase_check = &tms470_erase_check, - .protect_check = &tms470_protect_check, - .info = &tms470_info, - }; + .name = "tms470", + .commands = tms470_command_handlers, + .flash_bank_command = tms470_flash_bank_command, + .erase = tms470_erase, + .protect = tms470_protect, + .write = tms470_write, + .read = default_flash_read, + .probe = tms470_probe, + .auto_probe = tms470_auto_probe, + .erase_check = tms470_erase_check, + .protect_check = tms470_protect_check, + .info = get_tms470_info, +};