stellaris: avoid chip writes
authorDavid Brownell <dbrownell@users.sourceforge.net>
Wed, 16 Dec 2009 22:17:31 +0000 (14:17 -0800)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Wed, 16 Dec 2009 22:17:31 +0000 (14:17 -0800)
Previously "reading" clock info (and part info) also, as a side
effect, wrote the flash timing register.  Instead, be more safe:
"reading" should only read.  Write paths still refresh timing,
coping with changes the application code may have made.

Also rename the routine which sets flash timing, indicating what
it's really doing; it's got nothing to do with a "mode".

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
src/flash/nor/stellaris.c

index 103202d2c973dd169eadbdd1d7a6b3f7f029b32d..8b0d9d30e6eb3c7edca9d87e77ef55e37eb7c0f1 100644 (file)
@@ -345,8 +345,8 @@ static uint32_t stellaris_get_flash_status(struct flash_bank *bank)
        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,9 +471,6 @@ 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
@@ -714,9 +711,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 +788,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 +1008,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 +1153,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);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)