summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudolf Marek <r.marek@assembler.cz>2012-04-14 22:51:40 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2012-04-14 22:51:40 +0000
commit47eff6b5b4e924627583f45f9b321119899a589c (patch)
tree758809500d91966064fb5ba3cd4c598e9525db8e
parent1525b2ad16e07f035b1de70fadd05a7018ea5756 (diff)
downloadast2050-flashrom-47eff6b5b4e924627583f45f9b321119899a589c.zip
ast2050-flashrom-47eff6b5b4e924627583f45f9b321119899a589c.tar.gz
Add support for the Eon EN29LV640B chip
This chip needs special command sequences in 8 bit mode. Also, 8 bit programming needs actually 16bit double byte program. The chip is found on the Bifferos Bifferboard, for example. Corresponding to flashrom svn r1521. Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
-rw-r--r--Makefile2
-rw-r--r--chipdrivers.h6
-rw-r--r--en29lv640b.c138
-rw-r--r--flashchips.c34
-rw-r--r--flashchips.h1
5 files changed, 178 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 4de89e0..352ca29 100644
--- a/Makefile
+++ b/Makefile
@@ -261,7 +261,7 @@ endif
CHIP_OBJS = jedec.o stm50flw0x0x.o w39.o w29ee011.o \
sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o spi25.o sharplhf00l04.o \
- a25.o at25.o opaque.o sfdp.o
+ a25.o at25.o opaque.o sfdp.o en29lv640b.o
LIB_OBJS = layout.o
diff --git a/chipdrivers.h b/chipdrivers.h
index bd81098..e3eb978 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -157,4 +157,10 @@ int probe_w29ee011(struct flashctx *flash);
int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize);
int unlock_stm50flw0x0x(struct flashctx *flash);
+/* en29lv640b.c */
+int probe_en29lv640b(struct flashctx *flash);
+int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len);
+int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len);
+int write_en29lv640b(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
+
#endif /* !__CHIPDRIVERS_H__ */
diff --git a/en29lv640b.c b/en29lv640b.c
new file mode 100644
index 0000000..0dff2d1
--- /dev/null
+++ b/en29lv640b.c
@@ -0,0 +1,138 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2000 Silicon Integrated System Corporation
+ * Copyright (C) 2012 Rudolf Marek <r.marek@assembler.cz>
+ *
+ * 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
+ */
+
+#include "flash.h"
+#include "chipdrivers.h"
+
+/*
+ * WARNING!
+ * This chip uses the standard JEDEC addresses in 16-bit mode as word
+ * addresses. In byte mode, 0xAAA has to be used instead of 0x555 and
+ * 0x555 instead of 0x2AA. Do *not* blindly replace with standard JEDEC
+ * functions.
+ */
+
+/* chunksize is 1 */
+int write_en29lv640b(struct flashctx *flash, uint8_t *src, unsigned int start,
+ unsigned int len)
+{
+ int i;
+ chipaddr bios = flash->virtual_memory;
+ chipaddr dst = flash->virtual_memory + start;
+
+ for (i = 0; i < len; i += 2) {
+ chip_writeb(flash, 0xAA, bios + 0xAAA);
+ chip_writeb(flash, 0x55, bios + 0x555);
+ chip_writeb(flash, 0xA0, bios + 0xAAA);
+
+ /* Transfer data from source to destination. */
+ chip_writew(flash, (*src) | ((*(src + 1)) << 8 ), dst);
+ toggle_ready_jedec(flash, dst);
+#if 0
+ /* We only want to print something in the error case. */
+ msg_cerr("Value in the flash at address 0x%lx = %#x, want %#x\n",
+ (dst - bios), chip_readb(flash, dst), *src);
+#endif
+ dst += 2;
+ src += 2;
+ }
+
+ /* FIXME: Ignore errors for now. */
+ return 0;
+}
+
+int probe_en29lv640b(struct flashctx *flash)
+{
+ chipaddr bios = flash->virtual_memory;
+ uint16_t id1, id2;
+
+ chip_writeb(flash, 0xAA, bios + 0xAAA);
+ chip_writeb(flash, 0x55, bios + 0x555);
+ chip_writeb(flash, 0x90, bios + 0xAAA);
+
+ programmer_delay(10);
+
+ id1 = chip_readb(flash, bios + 0x200);
+ id1 |= (chip_readb(flash, bios) << 8);
+
+ id2 = chip_readb(flash, bios + 0x02);
+
+ chip_writeb(flash, 0xF0, bios + 0xAAA);
+
+ programmer_delay(10);
+
+ msg_cdbg("%s: id1 0x%04x, id2 0x%04x\n", __func__, id1, id2);
+
+ if (id1 == flash->manufacture_id && id2 == flash->model_id)
+ return 1;
+
+ return 0;
+}
+
+int erase_en29lv640b(struct flashctx *flash)
+{
+ chipaddr bios = flash->virtual_memory;
+
+ chip_writeb(flash, 0xAA, bios + 0xAAA);
+ chip_writeb(flash, 0x55, bios + 0x555);
+ chip_writeb(flash, 0x80, bios + 0xAAA);
+
+ chip_writeb(flash, 0xAA, bios + 0xAAA);
+ chip_writeb(flash, 0x55, bios + 0x555);
+ chip_writeb(flash, 0x10, bios + 0xAAA);
+
+ programmer_delay(10);
+ toggle_ready_jedec(flash, bios);
+
+ /* FIXME: Check the status register for errors. */
+ return 0;
+}
+
+int block_erase_en29lv640b(struct flashctx *flash, unsigned int start,
+ unsigned int len)
+{
+ chipaddr bios = flash->virtual_memory;
+ chipaddr dst = bios + start;
+
+ chip_writeb(flash, 0xAA, bios + 0xAAA);
+ chip_writeb(flash, 0x55, bios + 0x555);
+ chip_writeb(flash, 0x80, bios + 0xAAA);
+
+ chip_writeb(flash, 0xAA, bios + 0xAAA);
+ chip_writeb(flash, 0x55, bios + 0x555);
+ chip_writeb(flash, 0x30, dst);
+
+ programmer_delay(10);
+ toggle_ready_jedec(flash, bios);
+
+ /* FIXME: Check the status register for errors. */
+ return 0;
+}
+
+int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int address,
+ unsigned int blocklen)
+{
+ if ((address != 0) || (blocklen != flash->total_size * 1024)) {
+ msg_cerr("%s called with incorrect arguments\n", __func__);
+ return -1;
+ }
+ return erase_en29lv640b(flash);
+}
diff --git a/flashchips.c b/flashchips.c
index 4d77cf1..6d997be 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -3530,7 +3530,7 @@ const struct flashchip flashchips[] = {
.block_erasers =
{
{
- .eraseblocks = {
+ .eraseblocks = {
{16 * 1024, 1},
{8 * 1024, 2},
{32 * 1024, 1},
@@ -3562,7 +3562,7 @@ const struct flashchip flashchips[] = {
.block_erasers =
{
{
- .eraseblocks = {
+ .eraseblocks = {
{64 * 1024, 3},
{32 * 1024, 1},
{8 * 1024, 2},
@@ -3580,6 +3580,36 @@ const struct flashchip flashchips[] = {
},
{
+ .vendor = "Eon",
+ .name = "EN29LV640B",
+ .bustype = BUS_PARALLEL,
+ .manufacture_id = EON_ID,
+ .model_id = EON_EN29LV640B,
+ .total_size = 8192,
+ .page_size = 8192,
+ .feature_bits = 0,
+ .tested = TEST_OK_PREW,
+ .probe = probe_en29lv640b,
+ .probe_timing = TIMING_ZERO, /* Datasheet has no timing info specified */
+ .block_erasers =
+ {
+ {
+ .eraseblocks = {
+ {8 * 1024, 8},
+ {64 * 1024, 127},
+ },
+ .block_erase = block_erase_en29lv640b,
+ }, {
+ .eraseblocks = { {8 * 1024 * 1024, 1} },
+ .block_erase = block_erase_chip_en29lv640b,
+ },
+ },
+ .write = write_en29lv640b,
+ .read = read_memmapped,
+ .voltage = {2700, 3600},
+ },
+
+ {
.vendor = "Fujitsu",
.name = "MBM29F004BC",
.bustype = BUS_PARALLEL,
diff --git a/flashchips.h b/flashchips.h
index 2625afd..d6cf757 100644
--- a/flashchips.h
+++ b/flashchips.h
@@ -256,6 +256,7 @@
#define EON_EN29F040A 0x7F04
#define EON_EN29LV010 0x7F6E
#define EON_EN29LV040A 0x7F4F /* EN29LV040(A) */
+#define EON_EN29LV640B 0xCB
#define EON_EN29F002T 0x7F92 /* Same as EN29F002A */
#define EON_EN29F002B 0x7F97 /* Same as EN29F002AN */
OpenPOWER on IntegriCloud