- code reformat (Thanks Pavel Chromy)
git-svn-id: svn://svn.berlios.de/openocd/trunk@354 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
a4cb112599
commit
3a4f43ab56
|
@ -27,52 +27,18 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
tms470_register_commands( struct command_context_s *cmd_ctx );
|
||||
int tms470_register_commands(struct command_context_s *cmd_ctx);
|
||||
int tms470_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
|
||||
int tms470_erase(struct flash_bank_s *bank, int first, int last);
|
||||
int tms470_protect(struct flash_bank_s *bank, int set, int first, int last);
|
||||
int tms470_write(struct flash_bank_s *bank, u8 * buffer, u32 offset, u32 count);
|
||||
int tms470_probe(struct flash_bank_s *bank);
|
||||
int tms470_auto_probe(struct flash_bank_s *bank);
|
||||
int tms470_erase_check(struct flash_bank_s *bank);
|
||||
int tms470_protect_check(struct flash_bank_s *bank);
|
||||
int tms470_info(struct flash_bank_s *bank, char *buf, int buf_size);
|
||||
|
||||
int
|
||||
tms470_flash_bank_command( struct command_context_s *cmd_ctx,
|
||||
char *cmd,
|
||||
char **args,
|
||||
int argc,
|
||||
struct flash_bank_s *bank );
|
||||
|
||||
int
|
||||
tms470_erase( struct flash_bank_s *bank,
|
||||
int first,
|
||||
int last );
|
||||
|
||||
int
|
||||
tms470_protect( struct flash_bank_s *bank,
|
||||
int set,
|
||||
int first,
|
||||
int last );
|
||||
|
||||
int
|
||||
tms470_write( struct flash_bank_s *bank,
|
||||
u8 *buffer,
|
||||
u32 offset,
|
||||
u32 count );
|
||||
|
||||
int
|
||||
tms470_probe( struct flash_bank_s *bank );
|
||||
|
||||
int
|
||||
tms470_auto_probe( struct flash_bank_s *bank );
|
||||
|
||||
int
|
||||
tms470_erase_check( struct flash_bank_s *bank );
|
||||
|
||||
int
|
||||
tms470_protect_check( struct flash_bank_s *bank );
|
||||
|
||||
int
|
||||
tms470_info( struct flash_bank_s *bank,
|
||||
char *buf,
|
||||
int buf_size );
|
||||
|
||||
flash_driver_t tms470_flash =
|
||||
{
|
||||
flash_driver_t tms470_flash = {
|
||||
.name = "tms470",
|
||||
.register_commands = tms470_register_commands,
|
||||
.flash_bank_command = tms470_flash_bank_command,
|
||||
|
@ -90,8 +56,7 @@ flash_driver_t tms470_flash =
|
|||
Internal Support, Helpers
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
const flash_sector_t TMS470R1A256_SECTORS[] =
|
||||
{
|
||||
const flash_sector_t TMS470R1A256_SECTORS[] = {
|
||||
{0x00000000, 0x00002000, -1, -1},
|
||||
{0x00002000, 0x00002000, -1, -1},
|
||||
{0x00004000, 0x00002000, -1, -1},
|
||||
|
@ -111,8 +76,7 @@ const flash_sector_t TMS470R1A256_SECTORS[] =
|
|||
#define TMS470R1A256_NUM_SECTORS \
|
||||
(sizeof(TMS470R1A256_SECTORS)/sizeof(TMS470R1A256_SECTORS[0]))
|
||||
|
||||
const flash_sector_t TMS470R1A288_BANK0_SECTORS[] =
|
||||
{
|
||||
const flash_sector_t TMS470R1A288_BANK0_SECTORS[] = {
|
||||
{0x00000000, 0x00002000, -1, -1},
|
||||
{0x00002000, 0x00002000, -1, -1},
|
||||
{0x00004000, 0x00002000, -1, -1},
|
||||
|
@ -122,8 +86,7 @@ const flash_sector_t TMS470R1A288_BANK0_SECTORS[] =
|
|||
#define TMS470R1A288_BANK0_NUM_SECTORS \
|
||||
(sizeof(TMS470R1A288_BANK0_SECTORS)/sizeof(TMS470R1A288_BANK0_SECTORS[0]))
|
||||
|
||||
const flash_sector_t TMS470R1A288_BANK1_SECTORS[] =
|
||||
{
|
||||
const flash_sector_t TMS470R1A288_BANK1_SECTORS[] = {
|
||||
{0x00040000, 0x00010000, -1, -1},
|
||||
{0x00050000, 0x00010000, -1, -1},
|
||||
{0x00060000, 0x00010000, -1, -1},
|
||||
|
@ -135,8 +98,7 @@ const flash_sector_t TMS470R1A288_BANK1_SECTORS[] =
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_read_part_info( struct flash_bank_s *bank )
|
||||
int tms470_read_part_info(struct flash_bank_s *bank)
|
||||
{
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
target_t *target = bank->target;
|
||||
|
@ -182,8 +144,7 @@ tms470_read_part_info( struct flash_bank_s *bank )
|
|||
|
||||
if (bank->base >= 0x00040000)
|
||||
{
|
||||
ERROR( "No %s flash bank contains base address 0x%08x.",
|
||||
part_name, bank->base );
|
||||
ERROR("No %s flash bank contains base address 0x%08x.", part_name, bank->base);
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
tms470_info->ordinal = 0;
|
||||
|
@ -195,9 +156,7 @@ tms470_read_part_info( struct flash_bank_s *bank )
|
|||
{
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
(void) memcpy( bank->sectors,
|
||||
TMS470R1A256_SECTORS,
|
||||
sizeof( TMS470R1A256_SECTORS ) );
|
||||
(void)memcpy(bank->sectors, TMS470R1A256_SECTORS, sizeof(TMS470R1A256_SECTORS));
|
||||
break;
|
||||
|
||||
case 0x2b:
|
||||
|
@ -214,9 +173,7 @@ tms470_read_part_info( struct flash_bank_s *bank )
|
|||
{
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
(void) memcpy( bank->sectors,
|
||||
TMS470R1A288_BANK0_SECTORS,
|
||||
sizeof( TMS470R1A288_BANK0_SECTORS ) );
|
||||
(void)memcpy(bank->sectors, TMS470R1A288_BANK0_SECTORS, sizeof(TMS470R1A288_BANK0_SECTORS));
|
||||
}
|
||||
else if ((bank->base >= 0x00040000) && (bank->base < 0x00080000))
|
||||
{
|
||||
|
@ -229,21 +186,17 @@ tms470_read_part_info( struct flash_bank_s *bank )
|
|||
{
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
(void) memcpy( bank->sectors,
|
||||
TMS470R1A288_BANK1_SECTORS,
|
||||
sizeof( TMS470R1A288_BANK1_SECTORS ) );
|
||||
(void)memcpy(bank->sectors, TMS470R1A288_BANK1_SECTORS, sizeof(TMS470R1A288_BANK1_SECTORS));
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR( "No %s flash bank contains base address 0x%08x.",
|
||||
part_name, bank->base );
|
||||
ERROR("No %s flash bank contains base address 0x%08x.", part_name, bank->base);
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WARNING( "Could not identify part 0x%02x as a member of the TMS470 family.",
|
||||
part_number );
|
||||
WARNING("Could not identify part 0x%02x as a member of the TMS470 family.", part_number);
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
|
@ -254,11 +207,7 @@ tms470_read_part_info( struct flash_bank_s *bank )
|
|||
bank->chip_width = 32;
|
||||
bank->bus_width = 32;
|
||||
|
||||
INFO( "Identified %s, ver=%d, core=%s, nvmem=%s.",
|
||||
part_name,
|
||||
silicon_version,
|
||||
(technology_family ? "1.8v" : "3.3v"),
|
||||
(rom_flash ? "rom" : "flash") );
|
||||
INFO("Identified %s, ver=%d, core=%s, nvmem=%s.", part_name, silicon_version, (technology_family ? "1.8v" : "3.3v"), (rom_flash ? "rom" : "flash"));
|
||||
|
||||
tms470_info->device_ident_reg = device_ident_reg;
|
||||
tms470_info->silicon_version = silicon_version;
|
||||
|
@ -280,11 +229,7 @@ tms470_read_part_info( struct flash_bank_s *bank )
|
|||
u32 keysSet = 0;
|
||||
u32 flashKeys[4];
|
||||
|
||||
int
|
||||
tms470_handle_flash_keyset_command( struct command_context_s * cmd_ctx,
|
||||
char * cmd,
|
||||
char ** args,
|
||||
int argc )
|
||||
int tms470_handle_flash_keyset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
|
||||
{
|
||||
if (argc > 4)
|
||||
{
|
||||
|
@ -298,6 +243,7 @@ tms470_handle_flash_keyset_command( struct command_context_s * cmd_ctx,
|
|||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
int start = (0 == strncmp(args[i], "0x", 2)) ? 2 : 0;
|
||||
|
||||
if (1 != sscanf(&args[i][start], "%x", &flashKeys[i]))
|
||||
{
|
||||
command_print(cmd_ctx, "could not process flash key %s", args[i]);
|
||||
|
@ -316,8 +262,7 @@ tms470_handle_flash_keyset_command( struct command_context_s * cmd_ctx,
|
|||
|
||||
if (keysSet)
|
||||
{
|
||||
command_print( cmd_ctx, "using flash keys 0x%08x, 0x%08x, 0x%08x, 0x%08x",
|
||||
flashKeys[0], flashKeys[1], flashKeys[2], flashKeys[3] );
|
||||
command_print(cmd_ctx, "using flash keys 0x%08x, 0x%08x, 0x%08x, 0x%08x", flashKeys[0], flashKeys[1], flashKeys[2], flashKeys[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -328,26 +273,26 @@ tms470_handle_flash_keyset_command( struct command_context_s * cmd_ctx,
|
|||
}
|
||||
|
||||
const u32 FLASH_KEYS_ALL_ONES[] = { 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, };
|
||||
0xFFFFFFFF, 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
const u32 FLASH_KEYS_ALL_ZEROS[] = { 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, };
|
||||
0x00000000, 0x00000000,
|
||||
};
|
||||
|
||||
const u32 FLASH_KEYS_MIX1[] = { 0xf0fff0ff, 0xf0fff0ff,
|
||||
0xf0fff0ff, 0xf0fff0ff };
|
||||
0xf0fff0ff, 0xf0fff0ff
|
||||
};
|
||||
|
||||
const u32 FLASH_KEYS_MIX2[] = { 0x0000ffff, 0x0000ffff,
|
||||
0x0000ffff, 0x0000ffff };
|
||||
0x0000ffff, 0x0000ffff
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int oscMHz = 12;
|
||||
|
||||
int
|
||||
tms470_handle_osc_megahertz_command( struct command_context_s * cmd_ctx,
|
||||
char * cmd,
|
||||
char ** args,
|
||||
int argc )
|
||||
int tms470_handle_osc_megahertz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
|
@ -376,11 +321,7 @@ tms470_handle_osc_megahertz_command( struct command_context_s * cmd_ctx,
|
|||
|
||||
int plldis = 0;
|
||||
|
||||
int
|
||||
tms470_handle_plldis_command( struct command_context_s * cmd_ctx,
|
||||
char * cmd,
|
||||
char ** args,
|
||||
int argc )
|
||||
int tms470_handle_plldis_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
|
@ -400,23 +341,18 @@ tms470_handle_plldis_command( struct command_context_s * cmd_ctx,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_check_flash_unlocked( target_t * target )
|
||||
int tms470_check_flash_unlocked(target_t * target)
|
||||
{
|
||||
u32 fmbbusy;
|
||||
|
||||
target_read_u32(target, 0xFFE89C08, &fmbbusy);
|
||||
INFO( "tms470 fmbbusy=0x%08x -> %s",
|
||||
fmbbusy,
|
||||
fmbbusy & 0x8000 ? "unlocked" : "LOCKED" );
|
||||
INFO("tms470 fmbbusy=0x%08x -> %s", fmbbusy, fmbbusy & 0x8000 ? "unlocked" : "LOCKED");
|
||||
return fmbbusy & 0x8000 ? ERROR_OK : ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_try_flash_keys( target_t * target,
|
||||
const u32 * key_set )
|
||||
int tms470_try_flash_keys(target_t * target, const u32 * key_set)
|
||||
{
|
||||
u32 glbctrl, fmmstat;
|
||||
int retval = ERROR_FLASH_OPERATION_FAILED;
|
||||
|
@ -474,6 +410,7 @@ tms470_try_flash_keys( target_t * target,
|
|||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
target_read_u32(target, 0x00001FF0 + 4 * i, &tmp);
|
||||
target_write_u32(target, 0xFFE89C0C, key_set[i]);
|
||||
}
|
||||
|
@ -493,8 +430,7 @@ tms470_try_flash_keys( target_t * target,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_unlock_flash( struct flash_bank_s * bank )
|
||||
int tms470_unlock_flash(struct flash_bank_s *bank)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
const u32 *p_key_sets[5];
|
||||
|
@ -532,8 +468,7 @@ tms470_unlock_flash( struct flash_bank_s * bank )
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_flash_initialize_internal_state_machine( struct flash_bank_s * bank )
|
||||
int tms470_flash_initialize_internal_state_machine(struct flash_bank_s *bank)
|
||||
{
|
||||
u32 fmmac2, fmmac1, fmmaxep, k, delay, glbctrl, sysclk;
|
||||
target_t *target = bank->target;
|
||||
|
@ -667,11 +602,9 @@ tms470_flash_initialize_internal_state_machine( struct flash_bank_s * bank )
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_flash_status( struct flash_bank_s * bank )
|
||||
int tms470_flash_status(struct flash_bank_s *bank)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
int result = ERROR_OK;
|
||||
|
@ -727,9 +660,7 @@ tms470_flash_status( struct flash_bank_s * bank )
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_erase_sector( struct flash_bank_s * bank,
|
||||
int sector )
|
||||
int tms470_erase_sector(struct flash_bank_s *bank, int sector)
|
||||
{
|
||||
u32 glbctrl, orig_fmregopt, fmbsea, fmbseb, fmmstat;
|
||||
target_t *target = bank->target;
|
||||
|
@ -799,15 +730,13 @@ tms470_erase_sector( struct flash_bank_s * bank,
|
|||
{
|
||||
target_write_u32(target, 0xFFE88008, fmbsea);
|
||||
DEBUG("set fmbsea=0x%04x", fmbsea);
|
||||
bank->sectors[sector].is_protected =
|
||||
fmbsea & (1<<sector) ? 0 : 1;
|
||||
bank->sectors[sector].is_protected = fmbsea & (1 << sector) ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
target_write_u32(target, 0xFFE8800C, fmbseb);
|
||||
DEBUG("set fmbseb=0x%04x", fmbseb);
|
||||
bank->sectors[sector].is_protected =
|
||||
fmbseb & (1<<(sector-16)) ? 0 : 1;
|
||||
bank->sectors[sector].is_protected = fmbseb & (1 << (sector - 16)) ? 0 : 1;
|
||||
}
|
||||
target_write_u32(target, 0xFFE89C00, orig_fmregopt);
|
||||
DEBUG("set fmregopt=0x%08x", orig_fmregopt);
|
||||
|
@ -826,46 +755,20 @@ tms470_erase_sector( struct flash_bank_s * bank,
|
|||
Implementation of Flash Driver Interfaces
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_register_commands( struct command_context_s *cmd_ctx )
|
||||
int tms470_register_commands(struct command_context_s *cmd_ctx)
|
||||
{
|
||||
command_t *tms470_cmd = register_command( cmd_ctx,
|
||||
NULL,
|
||||
"tms470",
|
||||
NULL,
|
||||
COMMAND_ANY,
|
||||
"applies to TI tms470 family" );
|
||||
command_t *tms470_cmd = register_command(cmd_ctx, NULL, "tms470", NULL, COMMAND_ANY, "applies to TI tms470 family");
|
||||
|
||||
register_command( cmd_ctx,
|
||||
tms470_cmd,
|
||||
"flash_keyset",
|
||||
tms470_handle_flash_keyset_command,
|
||||
COMMAND_ANY,
|
||||
"tms470 flash_keyset <key0> <key1> <key2> <key3>" );
|
||||
|
||||
register_command( cmd_ctx,
|
||||
tms470_cmd,
|
||||
"osc_megahertz",
|
||||
tms470_handle_osc_megahertz_command,
|
||||
COMMAND_ANY,
|
||||
"tms470 osc_megahertz <MHz>" );
|
||||
|
||||
register_command( cmd_ctx,
|
||||
tms470_cmd,
|
||||
"plldis",
|
||||
tms470_handle_plldis_command,
|
||||
COMMAND_ANY,
|
||||
"tms470 plldis <0/1>" );
|
||||
register_command(cmd_ctx, tms470_cmd, "flash_keyset", tms470_handle_flash_keyset_command, COMMAND_ANY, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
|
||||
register_command(cmd_ctx, tms470_cmd, "osc_megahertz", tms470_handle_osc_megahertz_command, COMMAND_ANY, "tms470 osc_megahertz <MHz>");
|
||||
register_command(cmd_ctx, tms470_cmd, "plldis", tms470_handle_plldis_command, COMMAND_ANY, "tms470 plldis <0/1>");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_erase( struct flash_bank_s * bank,
|
||||
int first,
|
||||
int last )
|
||||
int tms470_erase(struct flash_bank_s *bank, int first, int last)
|
||||
{
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
int sector, result = ERROR_OK;
|
||||
|
@ -875,11 +778,7 @@ tms470_erase( struct flash_bank_s * bank,
|
|||
tms470_read_part_info(bank);
|
||||
}
|
||||
|
||||
if ((first < 0) ||
|
||||
(first >= bank->num_sectors) ||
|
||||
(last < 0) ||
|
||||
(last >= bank->num_sectors) ||
|
||||
(first > last))
|
||||
if ((first < 0) || (first >= bank->num_sectors) || (last < 0) || (last >= bank->num_sectors) || (first > last))
|
||||
{
|
||||
ERROR("Sector range %d to %d invalid.", first, last);
|
||||
return ERROR_FLASH_SECTOR_INVALID;
|
||||
|
@ -893,8 +792,7 @@ tms470_erase( struct flash_bank_s * bank,
|
|||
|
||||
for (sector = first; sector <= last; sector++)
|
||||
{
|
||||
INFO( "Erasing tms470 bank %d sector %d...",
|
||||
tms470_info->ordinal, sector );
|
||||
INFO("Erasing tms470 bank %d sector %d...", tms470_info->ordinal, sector);
|
||||
|
||||
result = tms470_erase_sector(bank, sector);
|
||||
|
||||
|
@ -914,11 +812,7 @@ tms470_erase( struct flash_bank_s * bank,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_protect( struct flash_bank_s * bank,
|
||||
int set,
|
||||
int first,
|
||||
int last )
|
||||
int tms470_protect(struct flash_bank_s *bank, int set, int first, int last)
|
||||
{
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
target_t *target = bank->target;
|
||||
|
@ -930,11 +824,7 @@ tms470_protect( struct flash_bank_s * bank,
|
|||
tms470_read_part_info(bank);
|
||||
}
|
||||
|
||||
if ((first < 0) ||
|
||||
(first >= bank->num_sectors) ||
|
||||
(last < 0) ||
|
||||
(last >= bank->num_sectors) ||
|
||||
(first > last))
|
||||
if ((first < 0) || (first >= bank->num_sectors) || (last < 0) || (last >= bank->num_sectors) || (first > last))
|
||||
{
|
||||
ERROR("Sector range %d to %d invalid.", first, last);
|
||||
return ERROR_FLASH_SECTOR_INVALID;
|
||||
|
@ -942,8 +832,7 @@ tms470_protect( struct flash_bank_s * bank,
|
|||
|
||||
/* enable the appropriate bank */
|
||||
target_read_u32(target, 0xFFE8BC04, &fmmac2);
|
||||
target_write_u32( target, 0xFFE8BC04,
|
||||
(fmmac2 & ~7) | tms470_info->ordinal );
|
||||
target_write_u32(target, 0xFFE8BC04, (fmmac2 & ~7) | tms470_info->ordinal);
|
||||
|
||||
/* get the original sector proection flags for this bank */
|
||||
target_read_u32(target, 0xFFE88008, &fmbsea);
|
||||
|
@ -953,14 +842,12 @@ tms470_protect( struct flash_bank_s * bank,
|
|||
{
|
||||
if (sector < 16)
|
||||
{
|
||||
fmbsea = set ? fmbsea & ~(1<<sector) :
|
||||
fmbsea | (1<<sector);
|
||||
fmbsea = set ? fmbsea & ~(1 << sector) : fmbsea | (1 << sector);
|
||||
bank->sectors[sector].is_protected = set ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmbseb = set ? fmbseb & ~(1<<(sector-16)) :
|
||||
fmbseb | (1<<(sector-16));
|
||||
fmbseb = set ? fmbseb & ~(1 << (sector - 16)) : fmbseb | (1 << (sector - 16));
|
||||
bank->sectors[sector].is_protected = set ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -974,11 +861,7 @@ tms470_protect( struct flash_bank_s * bank,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_write( struct flash_bank_s * bank,
|
||||
u8 * buffer,
|
||||
u32 offset,
|
||||
u32 count )
|
||||
int tms470_write(struct flash_bank_s *bank, u8 * buffer, u32 offset, u32 count)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
|
@ -990,8 +873,7 @@ tms470_write( struct flash_bank_s * bank,
|
|||
tms470_read_part_info(bank);
|
||||
}
|
||||
|
||||
INFO( "Writing %d bytes starting at 0x%08x",
|
||||
count, bank->base + offset );
|
||||
INFO("Writing %d bytes starting at 0x%08x", count, bank->base + offset);
|
||||
|
||||
/* set GLBCTRL.4 */
|
||||
target_read_u32(target, 0xFFFFFFDC, &glbctrl);
|
||||
|
@ -1051,8 +933,7 @@ tms470_write( struct flash_bank_s * bank,
|
|||
if (fmmstat & 0x3ff)
|
||||
{
|
||||
ERROR("fmstat=0x%04x", fmmstat);
|
||||
ERROR( "Could not program word 0x%04x at address 0x%08x.",
|
||||
word, addr );
|
||||
ERROR("Could not program word 0x%04x at address 0x%08x.", word, addr);
|
||||
result = ERROR_FLASH_OPERATION_FAILED;
|
||||
break;
|
||||
}
|
||||
|
@ -1075,8 +956,7 @@ tms470_write( struct flash_bank_s * bank,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_probe( struct flash_bank_s * bank )
|
||||
int tms470_probe(struct flash_bank_s *bank)
|
||||
{
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
|
||||
|
@ -1092,18 +972,18 @@ tms470_probe( struct flash_bank_s * bank )
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int
|
||||
tms470_auto_probe( struct flash_bank_s * bank )
|
||||
int tms470_auto_probe(struct flash_bank_s *bank)
|
||||
{
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
|
||||
if (tms470_info->probed)
|
||||
return ERROR_OK;
|
||||
return tms470_probe(bank);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_erase_check( struct flash_bank_s * bank )
|
||||
int tms470_erase_check(struct flash_bank_s *bank)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
|
@ -1126,8 +1006,7 @@ tms470_erase_check( struct flash_bank_s * bank )
|
|||
|
||||
/* enable the appropriate bank */
|
||||
target_read_u32(target, 0xFFE8BC04, &fmmac2);
|
||||
target_write_u32( target, 0xFFE8BC04,
|
||||
(fmmac2 & ~7) | tms470_info->ordinal );
|
||||
target_write_u32(target, 0xFFE8BC04, (fmmac2 & ~7) | tms470_info->ordinal);
|
||||
|
||||
/* TCR=0 */
|
||||
target_write_u32(target, 0xFFE8BC10, 0x2fc0);
|
||||
|
@ -1150,26 +1029,17 @@ tms470_erase_check( struct flash_bank_s * bank )
|
|||
{
|
||||
u32 i, addr = bank->base + bank->sectors[sector].offset;
|
||||
|
||||
INFO( "checking flash bank %d sector %d",
|
||||
tms470_info->ordinal,
|
||||
sector );
|
||||
INFO("checking flash bank %d sector %d", tms470_info->ordinal, sector);
|
||||
|
||||
target_read_buffer( target,
|
||||
addr,
|
||||
bank->sectors[sector].size,
|
||||
buffer );
|
||||
target_read_buffer(target, addr, bank->sectors[sector].size, buffer);
|
||||
|
||||
bank->sectors[sector].is_erased = 1;
|
||||
for (i = 0; i < bank->sectors[sector].size; i++)
|
||||
{
|
||||
if (buffer[i] != 0xff)
|
||||
{
|
||||
WARNING( "tms470 bank %d, sector %d, not erased.",
|
||||
tms470_info->ordinal,
|
||||
sector );
|
||||
WARNING( "at location 0x%08x: flash data is 0x%02x.",
|
||||
addr+i,
|
||||
buffer[i] );
|
||||
WARNING("tms470 bank %d, sector %d, not erased.", tms470_info->ordinal, sector);
|
||||
WARNING("at location 0x%08x: flash data is 0x%02x.", addr + i, buffer[i]);
|
||||
|
||||
bank->sectors[sector].is_erased = 0;
|
||||
break;
|
||||
|
@ -1198,8 +1068,7 @@ tms470_erase_check( struct flash_bank_s * bank )
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_protect_check( struct flash_bank_s * bank )
|
||||
int tms470_protect_check(struct flash_bank_s *bank)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
|
@ -1213,8 +1082,7 @@ tms470_protect_check( struct flash_bank_s * bank )
|
|||
|
||||
/* enable the appropriate bank */
|
||||
target_read_u32(target, 0xFFE8BC04, &fmmac2);
|
||||
target_write_u32( target, 0xFFE8BC04,
|
||||
(fmmac2 & ~7) | tms470_info->ordinal );
|
||||
target_write_u32(target, 0xFFE8BC04, (fmmac2 & ~7) | tms470_info->ordinal);
|
||||
|
||||
target_read_u32(target, 0xFFE88008, &fmbsea);
|
||||
target_read_u32(target, 0xFFE8800C, &fmbseb);
|
||||
|
@ -1234,10 +1102,7 @@ tms470_protect_check( struct flash_bank_s * bank )
|
|||
bank->sectors[sector].is_protected = protected;
|
||||
}
|
||||
|
||||
DEBUG( "bank %d sector %d is %s",
|
||||
tms470_info->ordinal,
|
||||
sector,
|
||||
protected ? "protected" : "not protected" );
|
||||
DEBUG("bank %d sector %d is %s", tms470_info->ordinal, sector, protected ? "protected" : "not protected");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1245,10 +1110,7 @@ tms470_protect_check( struct flash_bank_s * bank )
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
tms470_info( struct flash_bank_s * bank,
|
||||
char * buf,
|
||||
int buf_size )
|
||||
int tms470_info(struct flash_bank_s *bank, char *buf, int buf_size)
|
||||
{
|
||||
int used = 0;
|
||||
tms470_flash_bank_t *tms470_info = bank->driver_priv;
|
||||
|
@ -1264,15 +1126,11 @@ tms470_info( struct flash_bank_s * bank,
|
|||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
used += snprintf( buf, buf_size,
|
||||
"\ntms470 information: Chip is %s\n",
|
||||
tms470_info->part_name );
|
||||
used += snprintf(buf, buf_size, "\ntms470 information: Chip is %s\n", tms470_info->part_name);
|
||||
buf += used;
|
||||
buf_size -= used;
|
||||
|
||||
used += snprintf( buf, buf_size,
|
||||
"Flash protection level 2 is %s\n",
|
||||
tms470_check_flash_unlocked( bank->target ) == ERROR_OK ? "disabled" : "enabled" );
|
||||
used += snprintf(buf, buf_size, "Flash protection level 2 is %s\n", tms470_check_flash_unlocked(bank->target) == ERROR_OK ? "disabled" : "enabled");
|
||||
buf += used;
|
||||
buf_size -= used;
|
||||
|
||||
|
@ -1286,12 +1144,7 @@ tms470_info( struct flash_bank_s * bank,
|
|||
* [options...]
|
||||
*/
|
||||
|
||||
int
|
||||
tms470_flash_bank_command( struct command_context_s *cmd_ctx,
|
||||
char *cmd,
|
||||
char **args,
|
||||
int argc,
|
||||
struct flash_bank_s *bank )
|
||||
int tms470_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
|
||||
{
|
||||
bank->driver_priv = malloc(sizeof(tms470_flash_bank_t));
|
||||
|
||||
|
|
Loading…
Reference in New Issue