#define DID0_VER(did0) ((did0 >> 28)&0x07)
-static int stellaris_register_commands(struct command_context_s *cmd_ctx);
-static int stellaris_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
-static int stellaris_erase(struct flash_bank_s *bank, int first, int last);
-static int stellaris_protect(struct flash_bank_s *bank, int set, int first, int last);
-static int stellaris_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count);
-static int stellaris_auto_probe(struct flash_bank_s *bank);
-static int stellaris_probe(struct flash_bank_s *bank);
-static int stellaris_protect_check(struct flash_bank_s *bank);
-static int stellaris_info(struct flash_bank_s *bank, char *buf, int buf_size);
static int stellaris_read_part_info(struct flash_bank_s *bank);
static uint32_t stellaris_get_flash_status(flash_bank_t *bank);
static void stellaris_set_flash_mode(flash_bank_t *bank,int mode);
//static uint32_t stellaris_wait_status_busy(flash_bank_t *bank, uint32_t waitbits, int timeout);
-static int stellaris_handle_mass_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
static int stellaris_mass_erase(struct flash_bank_s *bank);
-flash_driver_t stellaris_flash =
-{
- .name = "stellaris",
- .register_commands = stellaris_register_commands,
- .flash_bank_command = stellaris_flash_bank_command,
- .erase = stellaris_erase,
- .protect = stellaris_protect,
- .write = stellaris_write,
- .probe = stellaris_probe,
- .auto_probe = stellaris_auto_probe,
- .erase_check = default_flash_mem_blank_check,
- .protect_check = stellaris_protect_check,
- .info = stellaris_info
-};
-
static struct {
uint32_t partno;
char *partname;
/* flash_bank stellaris <base> <size> 0 0 <target#>
*/
-static int stellaris_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
+FLASH_BANK_COMMAND_HANDLER(stellaris_flash_bank_command)
{
- stellaris_flash_bank_t *stellaris_info;
+ struct stellaris_flash_bank *stellaris_info;
if (argc < 6)
{
return ERROR_FLASH_BANK_INVALID;
}
- stellaris_info = calloc(sizeof(stellaris_flash_bank_t), 1);
+ stellaris_info = calloc(sizeof(struct stellaris_flash_bank), 1);
bank->base = 0x0;
bank->driver_priv = stellaris_info;
return ERROR_OK;
}
-static int stellaris_register_commands(struct command_context_s *cmd_ctx)
-{
- command_t *stm32x_cmd = register_command(cmd_ctx, NULL, "stellaris", NULL, COMMAND_ANY, "stellaris flash specific commands");
-
- register_command(cmd_ctx, stm32x_cmd, "mass_erase", stellaris_handle_mass_erase_command, COMMAND_EXEC, "mass erase device");
- return ERROR_OK;
-}
-
static int stellaris_info(struct flash_bank_s *bank, char *buf, int buf_size)
{
int printed, device_class;
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
stellaris_read_part_info(bank);
static void stellaris_read_clock_info(flash_bank_t *bank)
{
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
target_t *target = bank->target;
uint32_t rcc, rcc2, pllcfg, sysdiv, usesysdiv, bypass, oscsrc;
unsigned xtal;
/* Setup the timimg registers */
static void stellaris_set_flash_mode(flash_bank_t *bank,int mode)
{
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
target_t *target = bank->target;
uint32_t usecrl = (stellaris_info->mck_freq/1000000ul-1);
/* Read device id register, main clock frequency register and fill in driver info structure */
static int stellaris_read_part_info(struct flash_bank_s *bank)
{
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
target_t *target = bank->target;
uint32_t did0, did1, ver, fam, status;
int i;
/* provide this for the benefit of the higher flash driver layers */
bank->num_sectors = stellaris_info->num_pages;
- bank->sectors = malloc(sizeof(flash_sector_t) * bank->num_sectors);
+ bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
for (i = 0; i < bank->num_sectors; i++)
{
bank->sectors[i].offset = i * stellaris_info->pagesize;
{
uint32_t status;
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
if (bank->target->state != TARGET_HALTED)
{
{
int banknr;
uint32_t flash_fmc, flash_cris;
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
target_t *target = bank->target;
if (bank->target->state != TARGET_HALTED)
uint32_t fmppe, flash_fmc, flash_cris;
int lockregion;
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
target_t *target = bank->target;
if (bank->target->state != TARGET_HALTED)
working_area_t *source;
working_area_t *write_algorithm;
uint32_t address = bank->base + offset;
- reg_param_t reg_params[3];
+ struct reg_param reg_params[3];
armv7m_algorithm_t armv7m_info;
int retval = ERROR_OK;
static int stellaris_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
{
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
target_t *target = bank->target;
uint32_t address = offset;
uint32_t flash_cris, flash_fmc;
static int stellaris_auto_probe(struct flash_bank_s *bank)
{
- stellaris_flash_bank_t *stellaris_info = bank->driver_priv;
+ struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
if (stellaris_info->did1)
return ERROR_OK;
return stellaris_probe(bank);
static int stellaris_mass_erase(struct flash_bank_s *bank)
{
target_t *target = NULL;
- stellaris_flash_bank_t *stellaris_info = NULL;
+ struct stellaris_flash_bank *stellaris_info = NULL;
uint32_t flash_fmc;
stellaris_info = bank->driver_priv;
return ERROR_OK;
}
-static int stellaris_handle_mass_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(stellaris_handle_mass_erase_command)
{
int i;
return ERROR_OK;
}
+
+static int stellaris_register_commands(struct command_context_s *cmd_ctx)
+{
+ command_t *stm32x_cmd = register_command(cmd_ctx, NULL, "stellaris",
+ NULL, COMMAND_ANY, "stellaris flash specific commands");
+
+ register_command(cmd_ctx, stm32x_cmd, "mass_erase",
+ stellaris_handle_mass_erase_command, COMMAND_EXEC,
+ "mass erase device");
+ return ERROR_OK;
+}
+
+
+struct flash_driver stellaris_flash = {
+ .name = "stellaris",
+ .register_commands = &stellaris_register_commands,
+ .flash_bank_command = &stellaris_flash_bank_command,
+ .erase = &stellaris_erase,
+ .protect = &stellaris_protect,
+ .write = &stellaris_write,
+ .probe = &stellaris_probe,
+ .auto_probe = &stellaris_auto_probe,
+ .erase_check = &default_flash_mem_blank_check,
+ .protect_check = &stellaris_protect_check,
+ .info = &stellaris_info,
+ };