[flashrom] [commit] r1521 - trunk

repository service svn at flashrom.org
Sun Apr 15 00:51:40 CEST 2012


Author: uwe
Date: Sun Apr 15 00:51:40 2012
New Revision: 1521
URL: http://flashrom.org/trac/flashrom/changeset/1521

Log:
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.

Signed-off-by: Rudolf Marek <r.marek at assembler.cz>
Acked-by: Uwe Hermann <uwe at hermann-uwe.de>

Added:
   trunk/en29lv640b.c
Modified:
   trunk/Makefile
   trunk/chipdrivers.h
   trunk/flashchips.c
   trunk/flashchips.h

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Sat Apr 14 23:59:23 2012	(r1520)
+++ trunk/Makefile	Sun Apr 15 00:51:40 2012	(r1521)
@@ -261,7 +261,7 @@
 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
 

Modified: trunk/chipdrivers.h
==============================================================================
--- trunk/chipdrivers.h	Sat Apr 14 23:59:23 2012	(r1520)
+++ trunk/chipdrivers.h	Sun Apr 15 00:51:40 2012	(r1521)
@@ -157,4 +157,10 @@
 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__ */

Added: trunk/en29lv640b.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/en29lv640b.c	Sun Apr 15 00:51:40 2012	(r1521)
@@ -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 at 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);
+}

Modified: trunk/flashchips.c
==============================================================================
--- trunk/flashchips.c	Sat Apr 14 23:59:23 2012	(r1520)
+++ trunk/flashchips.c	Sun Apr 15 00:51:40 2012	(r1521)
@@ -3530,7 +3530,7 @@
 		.block_erasers	=
 		{
 			{
-				.eraseblocks = { 
+				.eraseblocks = {
 					{16 * 1024, 1},
 					{8 * 1024, 2},
 					{32 * 1024, 1},
@@ -3562,7 +3562,7 @@
 		.block_erasers	=
 		{
 			{
-				.eraseblocks = { 
+				.eraseblocks = {
 					{64 * 1024, 3},
 					{32 * 1024, 1},
 					{8 * 1024, 2},
@@ -3580,6 +3580,36 @@
 	},
 
 	{
+		.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,

Modified: trunk/flashchips.h
==============================================================================
--- trunk/flashchips.h	Sat Apr 14 23:59:23 2012	(r1520)
+++ trunk/flashchips.h	Sun Apr 15 00:51:40 2012	(r1521)
@@ -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 */
 




More information about the flashrom mailing list