summaryrefslogtreecommitdiffstats
path: root/stm50flw0x0x.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-09-12 08:28:56 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-09-12 08:28:56 +0000
commit4404f73bd9ba7b4014bcd7a38e533f67027aa854 (patch)
tree6e759d9d533e8d1bd7e736607c411232412b18f8 /stm50flw0x0x.c
parent4c6d3a4b732732eb20bfb0fc9d857abaa4c41c88 (diff)
downloadast2050-flashrom-4404f73bd9ba7b4014bcd7a38e533f67027aa854.zip
ast2050-flashrom-4404f73bd9ba7b4014bcd7a38e533f67027aa854.tar.gz
Cleanup ST M50 driver
There are two locking strategies used by this umbrella family, one uniform and one that matches the sector layout of the chip. Refactor the functions involved and rename the overly complicated file to just stm50.c and the functions accordingly. This fixes unlocking of some of the non-uniform chips and gets rid of the abuse of page_size. Corresponding to flashrom svn r1736. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'stm50flw0x0x.c')
-rw-r--r--stm50flw0x0x.c115
1 files changed, 0 insertions, 115 deletions
diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c
deleted file mode 100644
index e6c7c05..0000000
--- a/stm50flw0x0x.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * This file is part of the flashrom project.
- *
- * Copyright (C) 2008 Claus Gindhart <claus.gindhart@kontron.com>
- * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This module is designed for supporting the devices
- * ST M50FLW040A (not yet tested)
- * ST M50FLW040B (not yet tested)
- * ST M50FLW080A
- * ST M50FLW080B (not yet tested)
- */
-
-#include "flash.h"
-#include "flashchips.h"
-#include "chipdrivers.h"
-
-/*
- * claus.gindhart@kontron.com
- * The ST M50FLW080B and STM50FLW080B chips have to be unlocked,
- * before you can erase them or write to them.
- */
-static int unlock_block_stm50flw0x0x(struct flashctx *flash, int offset)
-{
- chipaddr wrprotect = flash->virtual_registers + 2;
- static const uint8_t unlock_sector = 0x00;
- int j;
-
- /*
- * These chips have to be unlocked before you can erase them or write
- * to them. The size of the locking sectors depends on the type
- * of chip.
- *
- * Sometimes, the BIOS does this for you; so you probably
- * don't need to worry about that.
- */
-
- /* Check, if it's is a top/bottom-block with 4k-sectors. */
- /* TODO: What about the other types? */
- if ((offset == 0) ||
- (offset == (flash->chip->model_id == ST_M50FLW080A ? 0xE0000 : 0x10000))
- || (offset == 0xF0000)) {
-
- // unlock each 4k-sector
- for (j = 0; j < 0x10000; j += 0x1000) {
- msg_cdbg("unlocking at 0x%x\n", offset + j);
- chip_writeb(flash, unlock_sector,
- wrprotect + offset + j);
- if (chip_readb(flash, wrprotect + offset + j) !=
- unlock_sector) {
- msg_cerr("Cannot unlock sector @ 0x%x\n",
- offset + j);
- return -1;
- }
- }
- } else {
- msg_cdbg("unlocking at 0x%x\n", offset);
- chip_writeb(flash, unlock_sector, wrprotect + offset);
- if (chip_readb(flash, wrprotect + offset) != unlock_sector) {
- msg_cerr("Cannot unlock sector @ 0x%x\n", offset);
- return -1;
- }
- }
-
- return 0;
-}
-
-int unlock_stm50flw0x0x(struct flashctx *flash)
-{
- int i;
-
- for (i = 0; i < flash->chip->total_size * 1024; i+= flash->chip->page_size) {
- if(unlock_block_stm50flw0x0x(flash, i)) {
- msg_cerr("UNLOCK FAILED!\n");
- return -1;
- }
- }
-
- return 0;
-}
-
-/* This function is unused. */
-int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int sector,
- unsigned int sectorsize)
-{
- chipaddr bios = flash->virtual_memory + sector;
-
- // clear status register
- chip_writeb(flash, 0x50, bios);
- // now start it
- chip_writeb(flash, 0x32, bios);
- chip_writeb(flash, 0xd0, bios);
- programmer_delay(10);
-
- wait_82802ab(flash);
-
- /* FIXME: Check the status register for errors. */
- return 0;
-}
OpenPOWER on IntegriCloud