aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorJustin Treon <justin_treon@yahoo.com>2008-01-30 13:25:49 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2008-02-03 02:25:16 -0500
commite619a75ff6201b567a539e787aa9af9bc63a3187 (patch)
treef13113ce617958181d5cd6b2c56ae9f7b87d0014 /drivers/mtd
parent842b1a105c95d22c3e4257879539413d3152629e (diff)
[MTD] Unlocking all Intel flash that is locked on power up.
Patch for unlocking all Intel flash that has instant locking on power up. The patch has been tested on Intel M18, P30 and J3D Strata Flash. 1. The automatic unlocking can be disabled for a particular partition in the map or the command line. a. For the bit mask in the map it should look like: .mask_flags = MTD_POWERUP_LOCK, b. For the command line parsing it should look like: mtdparts=0x80000(bootloader)lk 2. This will only unlock parts with instant individual block locking. Intel parts with legacy unlocking will not be unlocked. Signed-off-by: Justin Treon <justin_treon@yahoo.com> Signed-off-by: Jared Hulbert <jaredeh@gmail.com> Acked-by: Nicolas Pitre <nico@cam.org> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c18
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c2
-rw-r--r--drivers/mtd/cmdlinepart.c9
-rw-r--r--drivers/mtd/mtdcore.c2
4 files changed, 22 insertions, 9 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 350671ec5226..8189adfefaef 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -269,10 +269,16 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
269/* 269/*
270 * Some chips power-up with all sectors locked by default. 270 * Some chips power-up with all sectors locked by default.
271 */ 271 */
272static void fixup_use_powerup_lock(struct mtd_info *mtd, void *param) 272static void fixup_unlock_powerup_lock(struct mtd_info *mtd, void *param)
273{ 273{
274 printk(KERN_INFO "Using auto-unlock on power-up/resume\n" ); 274 struct map_info *map = mtd->priv;
275 mtd->flags |= MTD_STUPID_LOCK; 275 struct cfi_private *cfi = map->fldrv_priv;
276 struct cfi_pri_intelext *cfip = cfi->cmdset_priv;
277
278 if (cfip->FeatureSupport&32) {
279 printk(KERN_INFO "Using auto-unlock on power-up/resume\n" );
280 mtd->flags |= MTD_POWERUP_LOCK;
281 }
276} 282}
277 283
278static struct cfi_fixup cfi_fixup_table[] = { 284static struct cfi_fixup cfi_fixup_table[] = {
@@ -288,7 +294,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
288#endif 294#endif
289 { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct, NULL }, 295 { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct, NULL },
290 { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb, NULL }, 296 { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb, NULL },
291 { MANUFACTURER_INTEL, 0x891c, fixup_use_powerup_lock, NULL, }, 297 { MANUFACTURER_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock, NULL, },
292 { 0, 0, NULL, NULL } 298 { 0, 0, NULL, NULL }
293}; 299};
294 300
@@ -2349,7 +2355,7 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2349 struct flchip *chip; 2355 struct flchip *chip;
2350 int ret = 0; 2356 int ret = 0;
2351 2357
2352 if ((mtd->flags & MTD_STUPID_LOCK) 2358 if ((mtd->flags & MTD_POWERUP_LOCK)
2353 && extp && (extp->FeatureSupport & (1 << 5))) 2359 && extp && (extp->FeatureSupport & (1 << 5)))
2354 cfi_intelext_save_locks(mtd); 2360 cfi_intelext_save_locks(mtd);
2355 2361
@@ -2460,7 +2466,7 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
2460 spin_unlock(chip->mutex); 2466 spin_unlock(chip->mutex);
2461 } 2467 }
2462 2468
2463 if ((mtd->flags & MTD_STUPID_LOCK) 2469 if ((mtd->flags & MTD_POWERUP_LOCK)
2464 && extp && (extp->FeatureSupport & (1 << 5))) 2470 && extp && (extp->FeatureSupport & (1 << 5)))
2465 cfi_intelext_restore_locks(mtd); 2471 cfi_intelext_restore_locks(mtd);
2466} 2472}
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 796bfeadea21..d072e87ce4e2 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -217,7 +217,7 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param)
217{ 217{
218 mtd->lock = cfi_atmel_lock; 218 mtd->lock = cfi_atmel_lock;
219 mtd->unlock = cfi_atmel_unlock; 219 mtd->unlock = cfi_atmel_unlock;
220 mtd->flags |= MTD_STUPID_LOCK; 220 mtd->flags |= MTD_POWERUP_LOCK;
221} 221}
222 222
223static struct cfi_fixup cfi_fixup_table[] = { 223static struct cfi_fixup cfi_fixup_table[] = {
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 23fab14f1637..b44292abd9f7 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * mtdparts=<mtddef>[;<mtddef] 10 * mtdparts=<mtddef>[;<mtddef]
11 * <mtddef> := <mtd-id>:<partdef>[,<partdef>] 11 * <mtddef> := <mtd-id>:<partdef>[,<partdef>]
12 * <partdef> := <size>[@offset][<name>][ro] 12 * <partdef> := <size>[@offset][<name>][ro][lk]
13 * <mtd-id> := unique name used in mapping driver/device (mtd->name) 13 * <mtd-id> := unique name used in mapping driver/device (mtd->name)
14 * <size> := standard linux memsize OR "-" to denote all remaining space 14 * <size> := standard linux memsize OR "-" to denote all remaining space
15 * <name> := '(' NAME ')' 15 * <name> := '(' NAME ')'
@@ -143,6 +143,13 @@ static struct mtd_partition * newpart(char *s,
143 s += 2; 143 s += 2;
144 } 144 }
145 145
146 /* if lk is found do NOT unlock the MTD partition*/
147 if (strncmp(s, "lk", 2) == 0)
148 {
149 mask_flags |= MTD_POWERUP_LOCK;
150 s += 2;
151 }
152
146 /* test if more partitions are following */ 153 /* test if more partitions are following */
147 if (*s == ',') 154 if (*s == ',')
148 { 155 {
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 6c2645e28371..f7e7890e5bc6 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -61,7 +61,7 @@ int add_mtd_device(struct mtd_info *mtd)
61 61
62 /* Some chips always power up locked. Unlock them now */ 62 /* Some chips always power up locked. Unlock them now */
63 if ((mtd->flags & MTD_WRITEABLE) 63 if ((mtd->flags & MTD_WRITEABLE)
64 && (mtd->flags & MTD_STUPID_LOCK) && mtd->unlock) { 64 && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) {
65 if (mtd->unlock(mtd, 0, mtd->size)) 65 if (mtd->unlock(mtd, 0, mtd->size))
66 printk(KERN_WARNING 66 printk(KERN_WARNING
67 "%s: unlock failed, " 67 "%s: unlock failed, "