Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 May 2013 01:22:50 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r251118 - head/sys/dev/cfi
Message-ID:  <201305300122.r4U1Mo9T041253@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Thu May 30 01:22:50 2013
New Revision: 251118
URL: http://svnweb.freebsd.org/changeset/base/251118

Log:
  MFP4 @217311
  
  Intel and Sharp flash power on with their blocks in a "locked" state.
  Unlocked them before attempting to perform an erase or write action and
  relock when the action is complete.

Modified:
  head/sys/dev/cfi/cfi_core.c
  head/sys/dev/cfi/cfi_reg.h

Modified: head/sys/dev/cfi/cfi_core.c
==============================================================================
--- head/sys/dev/cfi/cfi_core.c	Thu May 30 01:19:02 2013	(r251117)
+++ head/sys/dev/cfi/cfi_core.c	Thu May 30 01:22:50 2013	(r251118)
@@ -409,6 +409,16 @@ cfi_write_block(struct cfi_softc *sc)
 	register_t intr;
 	int error, i;
 
+	/* Intel flash must be unlocked before modification */
+	switch (sc->sc_cmdset) {
+	case CFI_VEND_INTEL_ECS:
+	case CFI_VEND_INTEL_SCS:
+		cfi_write(sc, sc->sc_wrofs, CFI_INTEL_LBS);
+		cfi_write(sc, sc->sc_wrofs, CFI_INTEL_UB);
+		cfi_write(sc, sc->sc_wrofs, CFI_BCS_READ_ARRAY);
+		break;
+	}
+
 	/* Erase the block. */
 	switch (sc->sc_cmdset) {
 	case CFI_VEND_INTEL_ECS:
@@ -477,6 +487,16 @@ cfi_write_block(struct cfi_softc *sc)
 
  out:
 	cfi_write(sc, 0, CFI_BCS_READ_ARRAY);
+
+	/* Relock Intel flash */
+	switch (sc->sc_cmdset) {
+	case CFI_VEND_INTEL_ECS:
+	case CFI_VEND_INTEL_SCS:
+		cfi_write(sc, sc->sc_wrofs, CFI_INTEL_LBS);
+		cfi_write(sc, sc->sc_wrofs, CFI_INTEL_LB);
+		cfi_write(sc, sc->sc_wrofs, CFI_BCS_READ_ARRAY);
+		break;
+	}
 	return (error);
 }
 

Modified: head/sys/dev/cfi/cfi_reg.h
==============================================================================
--- head/sys/dev/cfi/cfi_reg.h	Thu May 30 01:19:02 2013	(r251117)
+++ head/sys/dev/cfi/cfi_reg.h	Thu May 30 01:22:50 2013	(r251118)
@@ -105,8 +105,11 @@ struct cfi_qry {
 #define	CFI_BCS_READ_ARRAY	0xff
 
 /* Intel commands. */
+#define	CFI_INTEL_LB		0x01	/* Lock Block */
+#define	CFI_INTEL_LBS		0x60	/* Lock Block Setup */
 #define	CFI_INTEL_READ_ID	0x90	/* Read Identifier */
 #define	CFI_INTEL_PP_SETUP	0xc0	/* Protection Program Setup */
+#define	CFI_INTEL_UB		0xd0	/* Unlock Block */
 
 /* NB: these are addresses for 16-bit accesses */
 #define	CFI_INTEL_PLR		0x80	/* Protection Lock Register */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305300122.r4U1Mo9T041253>