return fmc;
}
-/* Setup the timimg registers */
-static void stellaris_set_flash_mode(struct flash_bank *bank,int mode)
+/* Set the flash timimg register to match current clocking */
+static void stellaris_set_flash_timing(struct flash_bank *bank)
{
struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
struct target *target = bank->target;
stellaris_info->mck_freq = mainfreq/(1 + sysdiv);
else
stellaris_info->mck_freq = mainfreq;
-
- /* Forget old flash timing */
- stellaris_set_flash_mode(bank, 0);
}
#if 0
return stellaris_mass_erase(bank);
}
- /* Configure the flash controller timing */
+ /* Refresh flash controller timing */
stellaris_read_clock_info(bank);
- stellaris_set_flash_mode(bank,0);
+ stellaris_set_flash_timing(bank);
/* Clear and disable flash programming interrupts */
target_write_u32(target, FLASH_CIM, 0);
return ERROR_FLASH_OPERATION_FAILED;
}
- /* Configure the flash controller timing */
+ /* Refresh flash controller timing */
stellaris_read_clock_info(bank);
- stellaris_set_flash_mode(bank, 0);
+ stellaris_set_flash_timing(bank);
/* convert from pages to lockregions */
first /= 2;
if (offset + count > bank->size)
return ERROR_FLASH_DST_OUT_OF_BANK;
- /* Configure the flash controller timing */
+ /* Refresh flash controller timing */
stellaris_read_clock_info(bank);
- stellaris_set_flash_mode(bank, 0);
+ stellaris_set_flash_timing(bank);
/* Clear and disable flash programming interrupts */
target_write_u32(target, FLASH_CIM, 0);
return ERROR_FLASH_OPERATION_FAILED;
}
- /* Configure the flash controller timing */
+ /* Refresh flash controller timing */
stellaris_read_clock_info(bank);
- stellaris_set_flash_mode(bank, 0);
+ stellaris_set_flash_timing(bank);
/* Clear and disable flash programming interrupts */
target_write_u32(target, FLASH_CIM, 0);