mtd: dataflash OTP support
PATCH 1/1 mtd: dataflash OTP support
Now that we can tell when we have one of the newer DataFlash chips, optionally expose the 128 bytes of OTP memory they provide. Tested on at45db642 revision B and D chips and latest mtd-utils.
---
This goes on top of the patch I sent earlier, "v3" based on "v2" from Michael, teaching this driver to use the JEDEC query command to detect new chip revisions which may be using binary page sizes.
drivers/mtd/devices/Kconfig | 10 + drivers/mtd/devices/mtd_dataflash.c | 206 ++++++++++++++++++++++++++++++++-- drivers/mtd/mtdchar.c | 16 ++ 3 files changed, 223 insertions(+), 9 deletions(-)
drivers/mtd/devices/Kconfig +10 -0
@@ -60,6 +60,16 @@ config MTD_DATAFLASH Sometimes DataFlash chips are packaged inside MMC-format cards; at this writing, the MMC stack won't handle those. +config MTD_DATAFLASH_OTP + bool "DataFlash OTP support (Security Register)" + depends on MTD_DATAFLASH + help + Newer DataFlash chips (revisions C and D) support 128 bytes of + one-time-programmable (OTP) data. The first half may be written + (once) with up to 64 bytes of data, such as a serial number or + other key product data. The second half is programmed with a + unique-to-each-chip bit pattern at the factory. + config MTD_M25P80 tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)" depends on SPI_MASTER && EXPERIMENTAL
drivers/mtd/devices/mtd_dataflash.c +199 -7
249 lines not on this page · raw message
drivers/mtd/mtdchar.c +14 -2
@@ -20,6 +20,18 @@#include <asm/uaccess.h> +#ifdef CONFIG_MTD_OTP +#define HAVE_OTP +#endif + +#ifdef CONFIG_MTD_ONENAND_OTP +#define HAVE_OTP +#endif + +#ifdef CONFIG_MTD_DATAFLASH_OTP +#define HAVE_OTP +#endif +static struct class *mtd_class;static void mtd_notify_add (struct mtd_info * mtd)
@@ -339,7 +351,7 @@ static void mtdchar_erase_callback (struwake_up ((wait_queue_head_t *)instr->priv); } -#if defined(CONFIG_MTD_OTP ) || defined(CONFIG_MTD_ONENAND_OTP ) +#ifdef HAVE_OTP static int otp_select_filemode (struct mtd_file_info *mfi,int mode) {struct mtd_info *mtd = mfi->mtd;
@@ -652,7 +664,7 @@ static int mtd_ioctl(struct inode *inodebreak ; } -#if defined(CONFIG_MTD_OTP ) || defined(CONFIG_MTD_ONENAND_OTP ) +#ifdef HAVE_OTP case OTPSELECT : {int mode;
Hi David,
drivers/mtd/mtdchar.c line 34
Quoted 13 lines
drivers/mtd/mtdchar.c +12
-0+#ifdef CONFIG_MTD_OTP +#define HAVE_OTP +#endif + +#ifdef CONFIG_MTD_ONENAND_OTP +#define HAVE_OTP +#endif + +#ifdef CONFIG_MTD_DATAFLASH_OTP +#define HAVE_OTP +#endif +
How about to add these at Kconfig like this,
config MTD_HAVE_OTP
bool
default n
and NOR, OneNAND, and DATAFLASH select MTD_HAVE_OTP if OTP support.
Thank you,
Kyungmin Park
Quoted 15 lines · Kyungmin Park
drivers/mtd/mtdchar.c line 34
Quoted 12 lines
drivers/mtd/mtdchar.c +12
-0+#ifdef CONFIG_MTD_OTP +#define HAVE_OTP +#endif + +#ifdef CONFIG_MTD_ONENAND_OTP +#define HAVE_OTP +#endif + +#ifdef CONFIG_MTD_DATAFLASH_OTP +#define HAVE_OTP +#endif +How about to add these at
Kconfiglike this,
Quoted 5 lines
config
MTD_HAVE_OTP
bool
default nand NOR, OneNAND, and DATAFLASH select
MTD_HAVE_OTPif OTP support.
Shouldn't it be HAVE_MTD_OTP?
That'd be prettier, yes. MTD_OTP would have been the obvious choice for the generic symbol, but that's specific to CFI. (And for that matter, CFI command set 1 ... I have set 2 chips that can't yet expose their OTP data!)
I'd rather see that as a separate patch though -- either before or after this one, I don't much care.
- Dave