All of lore.kernel.org
 help / color / mirror / Atom feed
From: George McCollister <george.mccollister@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/5] sf: Add status register protection mechanism
Date: Mon, 10 Oct 2016 13:57:57 -0500	[thread overview]
Message-ID: <20161010185801.27991-2-george.mccollister@gmail.com> (raw)
In-Reply-To: <20161010185801.27991-1-george.mccollister@gmail.com>

Many SPI NOR flash devices support status register protection through
one or two status register protection bits. Status register protection
enables protection of block protect and other bits from manipulation.

So far, four different status register protection methods have been
observed:

 Software         - Writes to the status register are blocked until
                    a write enable bit is set by software.
 Hardware         - Writes to the status register are blocked while
                    a pin is in a certain state.
 Power            - Writes to the status register are blocked until
                    the next power-down.
 One Time Program - Writes to the status register are permanently
                    blocked.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
---
 include/spi_flash.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/spi_flash.h b/include/spi_flash.h
index be2fe3f..d1f63c7 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -26,6 +26,13 @@
 # define CONFIG_SF_DEFAULT_BUS		0
 #endif
 
+enum srp_method {
+	SRP_SOFTWARE,
+	SRP_HARDWARE,
+	SRP_POWER,
+	SRP_OTP,
+};
+
 struct spi_slave;
 
 /**
@@ -89,6 +96,7 @@ struct spi_flash {
 	int (*flash_lock)(struct spi_flash *flash, u32 ofs, size_t len);
 	int (*flash_unlock)(struct spi_flash *flash, u32 ofs, size_t len);
 	int (*flash_is_locked)(struct spi_flash *flash, u32 ofs, size_t len);
+	int (*sr_protect)(struct spi_flash *flash, enum srp_method method);
 #ifndef CONFIG_DM_SPI_FLASH
 	/*
 	 * These are not strictly needed for driver model, but keep them here
@@ -239,4 +247,13 @@ static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
 		return flash->flash_unlock(flash, ofs, len);
 }
 
+static inline int spi_flash_sr_protect(struct spi_flash *flash,
+		enum srp_method method)
+{
+	if (!flash->sr_protect)
+		return -EOPNOTSUPP;
+
+	return flash->sr_protect(flash, method);
+}
+
 #endif /* _SPI_FLASH_H_ */
-- 
2.9.3

  reply	other threads:[~2016-10-10 18:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 18:57 [U-Boot] [PATCH 0/5] sf: Add support for status register protect George McCollister
2016-10-10 18:57 ` George McCollister [this message]
2016-10-11  2:05   ` [U-Boot] [PATCH 1/5] sf: Add status register protection mechanism Bin Meng
2016-10-10 18:57 ` [U-Boot] [PATCH 2/5] sf: Add status register protect for STMICRO, SST George McCollister
2016-10-11  2:05   ` Bin Meng
2016-10-10 18:57 ` [U-Boot] [PATCH 3/5] sf: Use stm_lock/unlock for Spansion and Winbond George McCollister
2016-10-11  2:05   ` Bin Meng
2016-10-10 18:58 ` [U-Boot] [PATCH 4/5] sf: Add status register protect for Winbond George McCollister
2016-10-11  2:05   ` Bin Meng
2016-10-10 18:58 ` [U-Boot] [PATCH 5/5] sf: Add sr-protect sub-command George McCollister
2016-10-11  2:05   ` Bin Meng
2016-10-28 17:06 ` [U-Boot] [PATCH 0/5] sf: Add support for status register protect George McCollister
2016-10-28 17:24   ` Jagan Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161010185801.27991-2-george.mccollister@gmail.com \
    --to=george.mccollister@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.