]> git.sur5r.net Git - openocd/blobdiff - src/flash/nor/stellaris.c
stellaris: remove needless code
[openocd] / src / flash / nor / stellaris.c
index 103202d2c973dd169eadbdd1d7a6b3f7f029b32d..0ae65dc8ac195242cfc79f42ecebf1e21111d450 100644 (file)
@@ -37,7 +37,6 @@
 #define DID0_VER(did0) ((did0 >> 28)&0x07)
 
 static int stellaris_read_part_info(struct flash_bank *bank);
-static uint32_t stellaris_get_flash_status(struct flash_bank *bank);
 
 static int stellaris_mass_erase(struct flash_bank *bank);
 
@@ -335,18 +334,8 @@ static int stellaris_info(struct flash_bank *bank, char *buf, int buf_size)
 *      chip identification and status                                         *
 ***************************************************************************/
 
-static uint32_t stellaris_get_flash_status(struct flash_bank *bank)
-{
-       struct target *target = bank->target;
-       uint32_t fmc;
-
-       target_read_u32(target, FLASH_CONTROL_BASE | FLASH_FMC, &fmc);
-
-       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;
@@ -471,53 +460,14 @@ static void stellaris_read_clock_info(struct flash_bank *bank)
                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
-static uint32_t stellaris_wait_status_busy(struct flash_bank *bank, uint32_t waitbits, int timeout)
-{
-       uint32_t status;
-
-       /* Stellaris waits for cmdbit to clear */
-       while (((status = stellaris_get_flash_status(bank)) & waitbits) && (timeout-- > 0))
-       {
-               LOG_DEBUG("status: 0x%x", status);
-               alive_sleep(1);
-       }
-
-       /* Flash errors are reflected in the FLASH_CRIS register */
-
-       return status;
-}
-
-/* Send one command to the flash controller */
-static int stellaris_flash_command(struct flash_bank *bank,uint8_t cmd,uint16_t pagen)
-{
-       uint32_t fmc;
-       struct target *target = bank->target;
-
-       fmc = FMC_WRKEY | cmd;
-       target_write_u32(target, FLASH_CONTROL_BASE | FLASH_FMC, fmc);
-       LOG_DEBUG("Flash command: 0x%x", fmc);
-
-       if (stellaris_wait_status_busy(bank, cmd, 100))
-       {
-               return ERROR_FLASH_OPERATION_FAILED;
-       }
-
-       return ERROR_OK;
-}
-#endif
-
 /* Read device id register, main clock frequency register and fill in driver info structure */
 static int stellaris_read_part_info(struct flash_bank *bank)
 {
        struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
        struct target *target = bank->target;
-       uint32_t did0, did1, ver, fam, status;
+       uint32_t did0, did1, ver, fam;
        int i;
 
        /* Read and parse chip identification register */
@@ -621,8 +571,6 @@ static int stellaris_read_part_info(struct flash_bank *bank)
        /* Read main and master clock freqency register */
        stellaris_read_clock_info(bank);
 
-       status = stellaris_get_flash_status(bank);
-
        return ERROR_OK;
 }
 
@@ -714,9 +662,9 @@ static int stellaris_erase(struct flash_bank *bank, int first, int last)
                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);
@@ -791,9 +739,9 @@ static int stellaris_protect(struct flash_bank *bank, int set, int first, int la
                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;
@@ -1011,9 +959,9 @@ static int stellaris_write(struct flash_bank *bank, uint8_t *buffer, uint32_t of
        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);
@@ -1156,9 +1104,9 @@ static int stellaris_mass_erase(struct flash_bank *bank)
                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);