Supporting flash that is locked by default

Christopher Hoover ch at murgatroid.com
Fri Sep 24 22:18:57 EDT 2004


> Various flash chips may be locked (at a chip or block level) 
> at power-on 
> (perhaps depending on the board wiring), requiring an unlock before 
> writing to the device.

I raised this issue several years ago.  There wasn't (to me at least) a
satisfactory answer.  I carry a private patch forward from release to
release that performs the unlock operation in the mtd map code.  

Basically I do this which gets called in the probe:

static void __init xxxx_unlock_mtd(struct mtd_info *mtd)
{
	int i;

	/* argh, no way to get to the slaves that make up the parts of
	   our device, so instead cruise over all the available
	   devices */
	for (i = 0;; i++) {
		struct mtd_info *info;

		info = get_mtd_device(0, i);
		if (!info)
			break;

		if ((info->flags & MTD_WRITEABLE) &&
		    (info->unlock)) {
			int ret;
		
			printk(KERN_DEBUG "unlocking mtd device %s\n",
info->name);
			ret = info->unlock(info, 0, info->size);
			if (ret)
				printk(KERN_ERR "failed (%d) to unlock mtd
device %s\n", ret, info->name);
		}

		put_mtd_device(info);
	}
}               

Somone (either rmk or David -- I don't recall whom) didn't feel the unlock
belonged in the mapping code and didn't want the patch.   It would be nice
to come up with a solution that pleased everyone.

-ch





More information about the linux-mtd mailing list