linux-omap 2.6.37: replace various patch with upstream versions and rediff
[openembedded.git] / recipes / linux / linux-2.6.18 / mtd-unlock-nor-flash-automatically-where-necessary.patch
blob1cb1f8e6d349b83bcce2ef514a3019ba5a87f671
1 From 187ef15268e638603dea55a91fdfa29feaed6d13 Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?H=C3=A5vard_Skinnemoen?= <hskinnemoen@atmel.com>
3 Date: Fri, 22 Sep 2006 10:07:08 +0100
4 Subject: [PATCH] [MTD] Unlock NOR flash automatically where necessary
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 Introduce the MTD_STUPID_LOCK flag which indicates that the flash chip is
9 always locked after power-up, so all sectors need to be unlocked before it
10 is usable.
12 If this flag is set, and the chip provides an unlock() operation,
13 mtd_add_device will unlock the whole MTD device if it's writeable. This
14 means that non-writeable partitions will stay locked.
16 Set MTD_STUPID_LOCK in fixup_use_atmel_lock() so that these chips will work
17 as expected.
19 Signed-off-by: HÃ¥vard Skinnemoen <hskinnemoen@atmel.com>
20 Signed-off-by: Andrew Morton <akpm@osdl.org>
21 Signed-off-by: David Woodhouse <dwmw2@infradead.org>
22 ---
23 drivers/mtd/chips/cfi_cmdset_0002.c | 1 +
24 drivers/mtd/mtdcore.c | 10 ++++++++++
25 include/mtd/mtd-abi.h | 1 +
26 3 files changed, 12 insertions(+), 0 deletions(-)
28 diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
29 index a482e89..702ae4c 100644
30 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
31 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
32 @@ -212,6 +212,7 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param)
34 mtd->lock = cfi_atmel_lock;
35 mtd->unlock = cfi_atmel_unlock;
36 + mtd->flags |= MTD_STUPID_LOCK;
39 static struct cfi_fixup cfi_fixup_table[] = {
40 diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
41 index 168d3ba..c4d26de 100644
42 --- a/drivers/mtd/mtdcore.c
43 +++ b/drivers/mtd/mtdcore.c
44 @@ -57,6 +57,16 @@ int add_mtd_device(struct mtd_info *mtd)
45 mtd->index = i;
46 mtd->usecount = 0;
48 + /* Some chips always power up locked. Unlock them now */
49 + if ((mtd->flags & MTD_WRITEABLE)
50 + && (mtd->flags & MTD_STUPID_LOCK) && mtd->unlock) {
51 + if (mtd->unlock(mtd, 0, mtd->size))
52 + printk(KERN_WARNING
53 + "%s: unlock failed, "
54 + "writes may not work\n",
55 + mtd->name);
56 + }
58 DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
59 /* No need to get a refcount on the module containing
60 the notifier, since we hold the mtd_table_mutex */
61 diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
62 index 1da3f7f..b0a67b7 100644
63 --- a/include/mtd/mtd-abi.h
64 +++ b/include/mtd/mtd-abi.h
65 @@ -34,6 +34,7 @@ struct mtd_oob_buf {
66 #define MTD_WRITEABLE 0x400 /* Device is writeable */
67 #define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
68 #define MTD_NO_ERASE 0x1000 /* No erase necessary */
69 +#define MTD_STUPID_LOCK 0x2000 /* Always locked after reset */
71 // Some common devices / combinations of capabilities
72 #define MTD_CAP_ROM 0
73 --
74 1.4.4.1