Skip to content

Commit

Permalink
Merge git://git.infradead.org/mtd-2.6
Browse files Browse the repository at this point in the history
* git://git.infradead.org/mtd-2.6: (46 commits)
  [MTD] [MAPS] drivers/mtd/maps/ck804xrom.c: convert pci_module_init()
  [MTD] [NAND] CM-x270 MTD driver
  [MTD] [NAND] Wrong calculation of page number in nand_block_bad()
  [MTD] [MAPS] fix plat-ram printk format
  [JFFS2] Fix compr_rubin.c build after include file elimination.
  [JFFS2] Handle inodes with only a single metadata node with non-zero isize
  [JFFS2] Tidy up licensing/copyright boilerplate.
  [MTD] [OneNAND] Exit loop only when column start with 0
  [MTD] [OneNAND] Fix access the past of the real oobfree array
  [MTD] [OneNAND] Update Samsung OneNAND official URL
  [JFFS2] Better fix for all-zero node headers
  [JFFS2] Improve read_inode memory usage, v2.
  [JFFS2] Improve failure mode if inode checking leaves unchecked space.
  [JFFS2] Fix cross-endian build.
  [MTD] Finish conversion mtd_blkdevs to use the kthread API
  [JFFS2] Obsolete dirent nodes immediately on unlink, where possible.
  Use menuconfig objects: MTD
  [MTD] mtd_blkdevs: Convert to use the kthread API
  [MTD] Fix fwh_lock locking
  [JFFS2] Speed up mount for directly-mapped NOR flash
  ...
  • Loading branch information
Linus Torvalds committed Apr 27, 2007
2 parents 50f732e + 28b57cd commit f005463
Show file tree
Hide file tree
Showing 75 changed files with 2,678 additions and 1,724 deletions.
30 changes: 12 additions & 18 deletions drivers/mtd/Kconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# $Id: Kconfig,v 1.11 2005/11/07 11:14:19 gleixner Exp $

menu "Memory Technology Devices (MTD)"

config MTD
menuconfig MTD
tristate "Memory Technology Device (MTD) support"
help
Memory Technology Devices are flash, RAM and similar chips, often
Expand All @@ -13,9 +11,10 @@ config MTD
them. It will also allow you to select individual drivers for
particular hardware and users of MTD devices. If unsure, say N.

if MTD

config MTD_DEBUG
bool "Debugging"
depends on MTD
help
This turns on low-level debugging for the entire MTD sub-system.
Normally, you should say 'N'.
Expand All @@ -29,7 +28,6 @@ config MTD_DEBUG_VERBOSE

config MTD_CONCAT
tristate "MTD concatenating support"
depends on MTD
help
Support for concatenating several MTD devices into a single
(virtual) one. This allows you to have -for example- a JFFS(2)
Expand All @@ -38,7 +36,6 @@ config MTD_CONCAT

config MTD_PARTITIONS
bool "MTD partitioning support"
depends on MTD
help
If you have a device which needs to divide its flash chip(s) up
into multiple 'partitions', each of which appears to the user as
Expand Down Expand Up @@ -153,11 +150,9 @@ config MTD_AFS_PARTS
'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example.

comment "User Modules And Translation Layers"
depends on MTD

config MTD_CHAR
tristate "Direct char device access to MTD devices"
depends on MTD
help
This provides a character device for each MTD device present in
the system, allowing the user to read and write directly to the
Expand All @@ -166,12 +161,12 @@ config MTD_CHAR

config MTD_BLKDEVS
tristate "Common interface to block layer for MTD 'translation layers'"
depends on MTD && BLOCK
depends on BLOCK
default n

config MTD_BLOCK
tristate "Caching block device access to MTD devices"
depends on MTD && BLOCK
depends on BLOCK
select MTD_BLKDEVS
---help---
Although most flash chips have an erase size too large to be useful
Expand All @@ -194,7 +189,7 @@ config MTD_BLOCK

config MTD_BLOCK_RO
tristate "Readonly block device access to MTD devices"
depends on MTD_BLOCK!=y && MTD && BLOCK
depends on MTD_BLOCK!=y && BLOCK
select MTD_BLKDEVS
help
This allows you to mount read-only file systems (such as cramfs)
Expand All @@ -206,7 +201,7 @@ config MTD_BLOCK_RO

config FTL
tristate "FTL (Flash Translation Layer) support"
depends on MTD && BLOCK
depends on BLOCK
select MTD_BLKDEVS
---help---
This provides support for the original Flash Translation Layer which
Expand All @@ -223,7 +218,7 @@ config FTL

config NFTL
tristate "NFTL (NAND Flash Translation Layer) support"
depends on MTD && BLOCK
depends on BLOCK
select MTD_BLKDEVS
---help---
This provides support for the NAND Flash Translation Layer which is
Expand All @@ -247,7 +242,7 @@ config NFTL_RW

config INFTL
tristate "INFTL (Inverse NAND Flash Translation Layer) support"
depends on MTD && BLOCK
depends on BLOCK
select MTD_BLKDEVS
---help---
This provides support for the Inverse NAND Flash Translation
Expand All @@ -265,7 +260,7 @@ config INFTL

config RFD_FTL
tristate "Resident Flash Disk (Flash Translation Layer) support"
depends on MTD && BLOCK
depends on BLOCK
select MTD_BLKDEVS
---help---
This provides support for the flash translation layer known
Expand All @@ -276,7 +271,7 @@ config RFD_FTL

config SSFDC
tristate "NAND SSFDC (SmartMedia) read only translation layer"
depends on MTD && BLOCK
depends on BLOCK
select MTD_BLKDEVS
help
This enables read only access to SmartMedia formatted NAND
Expand All @@ -294,5 +289,4 @@ source "drivers/mtd/onenand/Kconfig"

source "drivers/mtd/ubi/Kconfig"

endmenu

endif # MTD
12 changes: 3 additions & 9 deletions drivers/mtd/chips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ menu "RAM/ROM/Flash chip drivers"

config MTD_CFI
tristate "Detect flash chips by Common Flash Interface (CFI) probe"
depends on MTD
select MTD_GEN_PROBE
help
The Common Flash Interface specification was developed by Intel,
Expand All @@ -18,7 +17,6 @@ config MTD_CFI

config MTD_JEDECPROBE
tristate "Detect non-CFI AMD/JEDEC-compatible flash chips"
depends on MTD
select MTD_GEN_PROBE
help
This option enables JEDEC-style probing of flash chips which are not
Expand Down Expand Up @@ -213,21 +211,18 @@ config MTD_CFI_UTIL

config MTD_RAM
tristate "Support for RAM chips in bus mapping"
depends on MTD
help
This option enables basic support for RAM chips accessed through
a bus mapping driver.

config MTD_ROM
tristate "Support for ROM chips in bus mapping"
depends on MTD
help
This option enables basic support for ROM chips accessed through
a bus mapping driver.

config MTD_ABSENT
tristate "Support for absent chips in bus mapping"
depends on MTD
help
This option enables support for a dummy probing driver used to
allocated placeholder MTD devices on systems that have socketed
Expand All @@ -237,7 +232,6 @@ config MTD_ABSENT
with this driver will return -ENODEV upon access.

config MTD_OBSOLETE_CHIPS
depends on MTD
bool "Older (theoretically obsoleted now) drivers for non-CFI chips"
help
This option does not enable any code directly, but will allow you to
Expand All @@ -250,7 +244,7 @@ config MTD_OBSOLETE_CHIPS

config MTD_AMDSTD
tristate "AMD compatible flash chip support (non-CFI)"
depends on MTD && MTD_OBSOLETE_CHIPS && BROKEN
depends on MTD_OBSOLETE_CHIPS && BROKEN
help
This option enables support for flash chips using AMD-compatible
commands, including some which are not CFI-compatible and hence
Expand All @@ -260,15 +254,15 @@ config MTD_AMDSTD

config MTD_SHARP
tristate "pre-CFI Sharp chip support"
depends on MTD && MTD_OBSOLETE_CHIPS
depends on MTD_OBSOLETE_CHIPS
help
This option enables support for flash chips using Sharp-compatible
commands, including some which are not CFI-compatible and hence
cannot be used with the CONFIG_MTD_CFI_INTELxxx options.

config MTD_JEDEC
tristate "JEDEC device support"
depends on MTD && MTD_OBSOLETE_CHIPS && BROKEN
depends on MTD_OBSOLETE_CHIPS && BROKEN
help
Enable older JEDEC flash interface devices for self
programming flash. It is commonly used in older AMD chips. It is
Expand Down
93 changes: 90 additions & 3 deletions drivers/mtd/chips/cfi_cmdset_0001.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* - optimized write buffer method
* 02/05/2002 Christopher Hoover <ch@hpl.hp.com>/<ch@murgatroid.com>
* - reworked lock/unlock/erase support for var size flash
* 21/03/2007 Rodolfo Giometti <giometti@linux.it>
* - auto unlock sectors on resume for auto locking flash on power up
*/

#include <linux/module.h>
Expand All @@ -30,6 +32,7 @@
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/reboot.h>
#include <linux/bitmap.h>
#include <linux/mtd/xip.h>
#include <linux/mtd/map.h>
#include <linux/mtd/mtd.h>
Expand Down Expand Up @@ -220,6 +223,15 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
}
}

/*
* Some chips power-up with all sectors locked by default.
*/
static void fixup_use_powerup_lock(struct mtd_info *mtd, void *param)
{
printk(KERN_INFO "Using auto-unlock on power-up/resume\n" );
mtd->flags |= MTD_STUPID_LOCK;
}

static struct cfi_fixup cfi_fixup_table[] = {
#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
{ CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL },
Expand All @@ -232,6 +244,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
#endif
{ CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct, NULL },
{ CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb, NULL },
{ MANUFACTURER_INTEL, 0x891c, fixup_use_powerup_lock, NULL, },
{ 0, 0, NULL, NULL }
};

Expand Down Expand Up @@ -460,6 +473,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset;
mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize;
mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum;
mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].lockmap = kmalloc(ernum / 8 + 1, GFP_KERNEL);
}
offset += (ersize * ernum);
}
Expand Down Expand Up @@ -1825,8 +1839,7 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
}
}

#ifdef DEBUG_LOCK_BITS
static int __xipram do_printlockstatus_oneblock(struct map_info *map,
static int __xipram do_getlockstatus_oneblock(struct map_info *map,
struct flchip *chip,
unsigned long adr,
int len, void *thunk)
Expand All @@ -1840,8 +1853,17 @@ static int __xipram do_printlockstatus_oneblock(struct map_info *map,
chip->state = FL_JEDEC_QUERY;
status = cfi_read_query(map, adr+(2*ofs_factor));
xip_enable(map, chip, 0);
return status;
}

#ifdef DEBUG_LOCK_BITS
static int __xipram do_printlockstatus_oneblock(struct map_info *map,
struct flchip *chip,
unsigned long adr,
int len, void *thunk)
{
printk(KERN_DEBUG "block status register for 0x%08lx is %x\n",
adr, status);
adr, do_getlockstatus_oneblock(map, chip, adr, len, thunk));
return 0;
}
#endif
Expand Down Expand Up @@ -2216,14 +2238,45 @@ static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd,

#endif

static void cfi_intelext_save_locks(struct mtd_info *mtd)
{
struct mtd_erase_region_info *region;
int block, status, i;
unsigned long adr;
size_t len;

for (i = 0; i < mtd->numeraseregions; i++) {
region = &mtd->eraseregions[i];
if (!region->lockmap)
continue;

for (block = 0; block < region->numblocks; block++){
len = region->erasesize;
adr = region->offset + block * len;

status = cfi_varsize_frob(mtd,
do_getlockstatus_oneblock, adr, len, 0);
if (status)
set_bit(block, region->lockmap);
else
clear_bit(block, region->lockmap);
}
}
}

static int cfi_intelext_suspend(struct mtd_info *mtd)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
struct cfi_pri_intelext *extp = cfi->cmdset_priv;
int i;
struct flchip *chip;
int ret = 0;

if ((mtd->flags & MTD_STUPID_LOCK)
&& extp && (extp->FeatureSupport & (1 << 5)))
cfi_intelext_save_locks(mtd);

for (i=0; !ret && i<cfi->numchips; i++) {
chip = &cfi->chips[i];

Expand Down Expand Up @@ -2285,10 +2338,33 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
return ret;
}

static void cfi_intelext_restore_locks(struct mtd_info *mtd)
{
struct mtd_erase_region_info *region;
int block, i;
unsigned long adr;
size_t len;

for (i = 0; i < mtd->numeraseregions; i++) {
region = &mtd->eraseregions[i];
if (!region->lockmap)
continue;

for (block = 0; block < region->numblocks; block++) {
len = region->erasesize;
adr = region->offset + block * len;

if (!test_bit(block, region->lockmap))
cfi_intelext_unlock(mtd, adr, len);
}
}
}

static void cfi_intelext_resume(struct mtd_info *mtd)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
struct cfi_pri_intelext *extp = cfi->cmdset_priv;
int i;
struct flchip *chip;

Expand All @@ -2307,6 +2383,10 @@ static void cfi_intelext_resume(struct mtd_info *mtd)

spin_unlock(chip->mutex);
}

if ((mtd->flags & MTD_STUPID_LOCK)
&& extp && (extp->FeatureSupport & (1 << 5)))
cfi_intelext_restore_locks(mtd);
}

static int cfi_intelext_reset(struct mtd_info *mtd)
Expand Down Expand Up @@ -2347,12 +2427,19 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
struct mtd_erase_region_info *region;
int i;
cfi_intelext_reset(mtd);
unregister_reboot_notifier(&mtd->reboot_notifier);
kfree(cfi->cmdset_priv);
kfree(cfi->cfiq);
kfree(cfi->chips[0].priv);
kfree(cfi);
for (i = 0; i < mtd->numeraseregions; i++) {
region = &mtd->eraseregions[i];
if (region->lockmap)
kfree(region->lockmap);
}
kfree(mtd->eraseregions);
}

Expand Down
Loading

0 comments on commit f005463

Please sign in to comment.