Skip to contentSkip to conversation

cfi-flash: Added support to flash_real_protect for Atmel flash devices (tested with AT49BV6416)

PATCH New Rafael Campos 3 participants 3 messages Jul 31, 2008 – Aug 6, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cfi-flash: Added support to flash_real_protect for Atmel flash devices (tested with AT49BV6416)

Some of the flash memories produced by ATMEL start in read-only mode. We need to unprotect it.
This patch allows the AT49BV6416 to work with cfi_flash memories. Tested in the at91rm9200ek board.

Style modifications suggested by Stefan Roese.

---
 drivers/mtd/cfi_flash.c |   49 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 43 insertions(+), 6 deletions(-)
drivers/mtd/cfi_flash.c +43 -6
index 12647ef..b72c144 100644
@@ -103,6 +103,10 @@
 #define AMD_STATUS_TOGGLE		0x40
 #define AMD_STATUS_ERROR		0x20
 
+#define ATM_CMD_UNLOCK_SECT		0x70
+#define ATM_CMD_SOFTLOCK_START		0x80
+#define ATM_CMD_LOCK_SECT		0x40
+
 #define FLASH_OFFSET_MANUFACTURER_ID	0x00
 #define FLASH_OFFSET_DEVICE_ID		0x01
 #define FLASH_OFFSET_DEVICE_ID2		0x0E
@@ -1351,12 +1355,45 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 {
 	int retcode = 0;
 
-	flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-	flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT);
-	if (prot)
-		flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT_SET);
-	else
-		flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
+	switch (info->vendor) {
+		case CFI_CMDSET_INTEL_PROG_REGIONS:
+		case CFI_CMDSET_INTEL_STANDARD:
+			flash_write_cmd (info, sector, 0,
+					 FLASH_CMD_CLEAR_STATUS);
+			flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT);
+			if (prot)
+				flash_write_cmd (info, sector, 0,
+					FLASH_CMD_PROTECT_SET);
+			else
+				flash_write_cmd (info, sector, 0,
+					FLASH_CMD_PROTECT_CLEAR);
+			break;
+		case CFI_CMDSET_AMD_EXTENDED:
+		case CFI_CMDSET_AMD_STANDARD:
+#ifdef CONFIG_FLASH_CFI_LEGACY
+		case CFI_CMDSET_AMD_LEGACY:
+#endif
+			/* U-Boot only checks the first byte */
+			if (info->manufacturer_id == (uchar)ATM_MANUFACT) {
+				if (prot) {
+					flash_unlock_seq (info, 0);
+					flash_write_cmd (info, 0,
+							info->addr_unlock1,
+							ATM_CMD_SOFTLOCK_START);
+					flash_unlock_seq (info, 0);
+					flash_write_cmd (info, sector, 0, 
+							ATM_CMD_LOCK_SECT);
+				} else {
+					flash_write_cmd (info, 0, 
+							info->addr_unlock1,
+							AMD_CMD_UNLOCK_START);
+					if (info->device_id == ATM_ID_BV6416)
+						flash_write_cmd (info, sector, 
+							0, ATM_CMD_UNLOCK_SECT);
+				}
+			}
+			break;
+	};
 
 	if ((retcode =
 	     flash_full_status_check (info, sector, info->erase_blk_tout,
Signature · 1 line
1.5.6.3
#1 lore raw

PATCH v2 1/1 cfi-flash: Added support to flash_real_protect for Atmel flash devices (tested with AT49BV6416)

Quoted 5 lines · In message <[email protected]> you wrote:

Some of the flash memories produced by ATMEL start in read-only mode. We need to unprotect it.
This patch allows the AT49BV6416 to work with cfi_flash memories. Tested in the at91rm9200ek board.

This is really maddening.

Did we not just discuss the issue of identifying patches?

Now you write: "[UPDATED] [PATCH v2]"

So is this patch version 2 once more, as the "v2" suggests (then what was "updated"?), or ist thi s anew version of the patch? (then why don't you mark it as "v3" ?)

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
God made the integers; all else is the work of Man.       - Kronecker
#2 lore raw

PATCH v2 1/1 cfi-flash: Added support to flash_real_protect for Atmel flash devices (tested with AT49BV6416)

In reply to Rafael Campos
Quoted 8 lines · Rafael Campos

Some of the flash memories produced by ATMEL start in read-only mode. We need to unprotect it.
This patch allows the AT49BV6416 to work with cfi_flash memories. Tested in the at91rm9200ek board.

Style modifications suggested by Stefan Roese.

Applied to next brach of u-boot-cfi-flash repository.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================