Author: stefanct
Date: Thu Sep 12 10:29:06 2013
New Revision: 1738
URL: http://flashrom.org/trac/flashrom/changeset/1738

Log:
Enable sector erase function for selected ST M50 chips.

Affected chips: M50FLW040A, M50FLW040B, M50FLW080A, M50FLW080B.

Signed-off-by: Stefan Tauner <[email protected]>
Acked-by: Stefan Tauner <[email protected]>

Modified:
   trunk/flashchips.c
   trunk/stm50.c

Modified: trunk/flashchips.c
==============================================================================
--- trunk/flashchips.c  Thu Sep 12 10:29:00 2013        (r1737)
+++ trunk/flashchips.c  Thu Sep 12 10:29:06 2013        (r1738)
@@ -11022,7 +11022,7 @@
                                        {4 * 1024, 16}, /* sector */
                                        {4 * 1024, 16}, /* sector */
                                },
-                               .block_erase = NULL,
+                               .block_erase = erase_sector_stm50,
                        }, {
                                .eraseblocks = { {64 * 1024, 8}, },
                                .block_erase = erase_block_82802ab,
@@ -11055,7 +11055,7 @@
                                        {64 * 1024, 5}, /* block */
                                        {4 * 1024, 16}, /* sector */
                                },
-                               .block_erase = NULL,
+                               .block_erase = erase_sector_stm50,
                        }, {
                                .eraseblocks = { {64 * 1024, 8}, },
                                .block_erase = erase_block_82802ab,
@@ -11088,7 +11088,7 @@
                                        {4 * 1024, 16}, /* sector */
                                        {4 * 1024, 16}, /* sector */
                                },
-                               .block_erase = NULL,
+                               .block_erase = erase_sector_stm50,
                        }, {
                                .eraseblocks = { {64 * 1024, 16}, },
                                .block_erase = erase_block_82802ab,
@@ -11121,7 +11121,7 @@
                                        {64 * 1024, 13}, /* block */
                                        {4 * 1024, 16}, /* sector */
                                },
-                               .block_erase = NULL,
+                               .block_erase = erase_sector_stm50,
                        }, {
                                .eraseblocks = { {64 * 1024, 16}, },
                                .block_erase = erase_block_82802ab,

Modified: trunk/stm50.c
==============================================================================
--- trunk/stm50.c       Thu Sep 12 10:29:00 2013        (r1737)
+++ trunk/stm50.c       Thu Sep 12 10:29:06 2013        (r1738)
@@ -84,10 +84,9 @@
        return 0;
 }
 
-/* This function is unused. */
-int erase_sector_stm50(struct flashctx *flash, unsigned int sector, unsigned 
int sectorsize)
+static int stm50_erase_sector(struct flashctx *flash, unsigned int addr)
 {
-       chipaddr bios = flash->virtual_memory + sector;
+       chipaddr bios = flash->virtual_memory + addr;
 
        // clear status register
        chip_writeb(flash, 0x50, bios);
@@ -96,8 +95,21 @@
        chip_writeb(flash, 0xd0, bios);
        programmer_delay(10);
 
-       wait_82802ab(flash);
+       uint8_t status = wait_82802ab(flash);
+       print_status_82802ab(status);
 
-       /* FIXME: Check the status register for errors. */
-       return 0;
+       return status == 0x80;
+}
+
+/* Some ST M50* chips do support erasing of sectors. This function will derive 
the erase function to use from
+ * the length of the of the block. For calls that apparently do not address a 
sector (but a block) we just call
+ * the block erase function instead. FIXME: This duplicates the behavior of 
the remaining erasers for blocks and
+ * might be fixed when flashrom supports multiple functions per eraser or 
erasers that do erase parts of the
+ * chip only. */
+int erase_sector_stm50(struct flashctx *flash, unsigned int addr, unsigned int 
len)
+{
+       if (len == 4096)
+               return stm50_erase_sector(flash, addr);
+       else
+               return erase_block_82802ab(flash, addr, len);
 }

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to