Commit ac1b7c37 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.infradead.org/mtd-2.6

* git://git.infradead.org/mtd-2.6: (63 commits)
  mtd: OneNAND: Allow setting of boundary information when built as module
  jffs2: leaking jffs2_summary in function jffs2_scan_medium
  mtd: nand: Fix memory leak on txx9ndfmc probe failure.
  mtd: orion_nand: use burst reads with double word accesses
  mtd/nand: s3c6400 support for s3c2410 driver
  [MTD] [NAND] S3C2410: Use DIV_ROUND_UP
  [MTD] [NAND] S3C2410: Deal with unaligned lengths in S3C2440 buffer read/write
  [MTD] [NAND] S3C2410: Allow the machine code to get the BBT table from NAND
  [MTD] [NAND] S3C2410: Added a kerneldoc for s3c2410_nand_set
  mtd: physmap_of: Add multiple regions and concatenation support
  mtd: nand: max_retries off by one in mxc_nand
  mtd: nand: s3c2410_nand_setrate(): use correct macros for 2412/2440
  mtd: onenand: add bbt_wait & unlock_all as replaceable for some platform
  mtd: Flex-OneNAND support
  mtd: nand: add OMAP2/OMAP3 NAND driver
  mtd: maps: Blackfin async: fix memory leaks in probe/remove funcs
  mtd: uclinux: mark local stuff static
  mtd: uclinux: do not allow to be built as a module
  mtd: uclinux: allow systems to override map addr/size
  mtd: blackfin NFC: fix hang when using NAND on BF527-EZKITs
  ...
parents 9e268beb c90173f0
What: /sys/class/mtd/
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
The mtd/ class subdirectory belongs to the MTD subsystem
(MTD core).
What: /sys/class/mtd/mtdX/
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
The /sys/class/mtd/mtd{0,1,2,3,...} directories correspond
to each /dev/mtdX character device. These may represent
physical/simulated flash devices, partitions on a flash
device, or concatenated flash devices. They exist regardless
of whether CONFIG_MTD_CHAR is actually enabled.
What: /sys/class/mtd/mtdXro/
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
These directories provide the corresponding read-only device
nodes for /sys/class/mtd/mtdX/ . They are only created
(for the benefit of udev) if CONFIG_MTD_CHAR is enabled.
What: /sys/class/mtd/mtdX/dev
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
Major and minor numbers of the character device corresponding
to this MTD device (in <major>:<minor> format). This is the
read-write device so <minor> will be even.
What: /sys/class/mtd/mtdXro/dev
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
Major and minor numbers of the character device corresponding
to the read-only variant of thie MTD device (in
<major>:<minor> format). In this case <minor> will be odd.
What: /sys/class/mtd/mtdX/erasesize
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
"Major" erase size for the device. If numeraseregions is
zero, this is the eraseblock size for the entire device.
Otherwise, the MEMGETREGIONCOUNT/MEMGETREGIONINFO ioctls
can be used to determine the actual eraseblock layout.
What: /sys/class/mtd/mtdX/flags
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
A hexadecimal value representing the device flags, ORed
together:
0x0400: MTD_WRITEABLE - device is writable
0x0800: MTD_BIT_WRITEABLE - single bits can be flipped
0x1000: MTD_NO_ERASE - no erase necessary
0x2000: MTD_POWERUP_LOCK - always locked after reset
What: /sys/class/mtd/mtdX/name
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
A human-readable ASCII name for the device or partition.
This will match the name in /proc/mtd .
What: /sys/class/mtd/mtdX/numeraseregions
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
For devices that have variable eraseblock sizes, this
provides the total number of erase regions. Otherwise,
it will read back as zero.
What: /sys/class/mtd/mtdX/oobsize
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
Number of OOB bytes per page.
What: /sys/class/mtd/mtdX/size
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
Total size of the device/partition, in bytes.
What: /sys/class/mtd/mtdX/type
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
One of the following ASCII strings, representing the device
type:
absent, ram, rom, nor, nand, dataflash, ubi, unknown
What: /sys/class/mtd/mtdX/writesize
Date: April 2009
KernelVersion: 2.6.29
Contact: linux-mtd@lists.infradead.org
Description:
Minimal writable flash unit size. This will always be
a positive integer.
In the case of NOR flash it is 1 (even though individual
bits can be cleared).
In the case of NAND flash it is one NAND page (or a
half page, or a quarter page).
In the case of ECC NOR, it is the ECC block size.
...@@ -1431,6 +1431,16 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -1431,6 +1431,16 @@ and is between 256 and 4096 characters. It is defined in the file
mtdparts= [MTD] mtdparts= [MTD]
See drivers/mtd/cmdlinepart.c. See drivers/mtd/cmdlinepart.c.
onenand.bdry= [HW,MTD] Flex-OneNAND Boundary Configuration
Format: [die0_boundary][,die0_lock][,die1_boundary][,die1_lock]
boundary - index of last SLC block on Flex-OneNAND.
The remaining blocks are configured as MLC blocks.
lock - Configure if Flex-OneNAND boundary should be locked.
Once locked, the boundary cannot be changed.
1 indicates lock status, 0 indicates unlock status.
mtdset= [ARM] mtdset= [ARM]
ARM/S3C2412 JIVE boot control ARM/S3C2412 JIVE boot control
......
...@@ -3252,7 +3252,6 @@ W: http://www.linux-mtd.infradead.org/doc/jffs2.html ...@@ -3252,7 +3252,6 @@ W: http://www.linux-mtd.infradead.org/doc/jffs2.html
S: Maintained S: Maintained
F: fs/jffs2/ F: fs/jffs2/
F: include/linux/jffs2.h F: include/linux/jffs2.h
F: include/mtd/jffs2-user.h
JOURNALLING LAYER FOR BLOCK DEVICES (JBD) JOURNALLING LAYER FOR BLOCK DEVICES (JBD)
P: Stephen Tweedie P: Stephen Tweedie
......
...@@ -68,10 +68,14 @@ struct davinci_nand_pdata { /* platform_data */ ...@@ -68,10 +68,14 @@ struct davinci_nand_pdata { /* platform_data */
/* none == NAND_ECC_NONE (strongly *not* advised!!) /* none == NAND_ECC_NONE (strongly *not* advised!!)
* soft == NAND_ECC_SOFT * soft == NAND_ECC_SOFT
* 1-bit == NAND_ECC_HW * else == NAND_ECC_HW, according to ecc_bits
* 4-bit == NAND_ECC_HW_SYNDROME (not on all chips) *
* All DaVinci-family chips support 1-bit hardware ECC.
* Newer ones also support 4-bit ECC, but are awkward
* using it with large page chips.
*/ */
nand_ecc_modes_t ecc_mode; nand_ecc_modes_t ecc_mode;
u8 ecc_bits;
/* e.g. NAND_BUSWIDTH_16 or NAND_USE_FLASH_BBT */ /* e.g. NAND_BUSWIDTH_16 or NAND_USE_FLASH_BBT */
unsigned options; unsigned options;
......
...@@ -10,19 +10,26 @@ ...@@ -10,19 +10,26 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
/* struct s3c2410_nand_set /**
* struct s3c2410_nand_set - define a set of one or more nand chips
* @disable_ecc: Entirely disable ECC - Dangerous
* @flash_bbt: Openmoko u-boot can create a Bad Block Table
* Setting this flag will allow the kernel to
* look for it at boot time and also skip the NAND
* scan.
* @nr_chips: Number of chips in this set
* @nr_partitions: Number of partitions pointed to by @partitions
* @name: Name of set (optional)
* @nr_map: Map for low-layer logical to physical chip numbers (option)
* @partitions: The mtd partition list
* *
* define an set of one or more nand chips registered with an unique mtd * define a set of one or more nand chips registered with an unique mtd. Also
* * allows to pass flag to the underlying NAND layer. 'disable_ecc' will trigger
* nr_chips = number of chips in this set * a warning at boot time.
* nr_partitions = number of partitions pointed to be partitoons (or zero) */
* name = name of set (optional)
* nr_map = map for low-layer logical to physical chip numbers (option)
* partitions = mtd partition list
*/
struct s3c2410_nand_set { struct s3c2410_nand_set {
unsigned int disable_ecc : 1; unsigned int disable_ecc:1;
unsigned int flash_bbt:1;
int nr_chips; int nr_chips;
int nr_partitions; int nr_partitions;
...@@ -39,7 +46,7 @@ struct s3c2410_platform_nand { ...@@ -39,7 +46,7 @@ struct s3c2410_platform_nand {
int twrph0; /* active time for nWE/nOE */ int twrph0; /* active time for nWE/nOE */
int twrph1; /* time for release CLE/ALE from nWE/nOE inactive */ int twrph1; /* time for release CLE/ALE from nWE/nOE inactive */
unsigned int ignore_unset_ecc : 1; unsigned int ignore_unset_ecc:1;
int nr_sets; int nr_sets;
struct s3c2410_nand_set *sets; struct s3c2410_nand_set *sets;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#define MANUFACTURER_INTEL 0x0089 #define MANUFACTURER_INTEL 0x0089
#define I82802AB 0x00ad #define I82802AB 0x00ad
#define I82802AC 0x00ac #define I82802AC 0x00ac
#define PF38F4476 0x881c
#define MANUFACTURER_ST 0x0020 #define MANUFACTURER_ST 0x0020
#define M50LPW080 0x002F #define M50LPW080 0x002F
#define M50FLW080A 0x0080 #define M50FLW080A 0x0080
...@@ -315,10 +316,20 @@ static struct cfi_fixup fixup_table[] = { ...@@ -315,10 +316,20 @@ static struct cfi_fixup fixup_table[] = {
{ 0, 0, NULL, NULL } { 0, 0, NULL, NULL }
}; };
static void cfi_fixup_major_minor(struct cfi_private *cfi,
struct cfi_pri_intelext *extp)
{
if (cfi->mfr == MANUFACTURER_INTEL &&
cfi->id == PF38F4476 && extp->MinorVersion == '3')
extp->MinorVersion = '1';
}
static inline struct cfi_pri_intelext * static inline struct cfi_pri_intelext *
read_pri_intelext(struct map_info *map, __u16 adr) read_pri_intelext(struct map_info *map, __u16 adr)
{ {
struct cfi_private *cfi = map->fldrv_priv;
struct cfi_pri_intelext *extp; struct cfi_pri_intelext *extp;
unsigned int extra_size = 0;
unsigned int extp_size = sizeof(*extp); unsigned int extp_size = sizeof(*extp);
again: again:
...@@ -326,6 +337,8 @@ read_pri_intelext(struct map_info *map, __u16 adr) ...@@ -326,6 +337,8 @@ read_pri_intelext(struct map_info *map, __u16 adr)
if (!extp) if (!extp)
return NULL; return NULL;
cfi_fixup_major_minor(cfi, extp);
if (extp->MajorVersion != '1' || if (extp->MajorVersion != '1' ||
(extp->MinorVersion < '0' || extp->MinorVersion > '5')) { (extp->MinorVersion < '0' || extp->MinorVersion > '5')) {
printk(KERN_ERR " Unknown Intel/Sharp Extended Query " printk(KERN_ERR " Unknown Intel/Sharp Extended Query "
...@@ -340,19 +353,24 @@ read_pri_intelext(struct map_info *map, __u16 adr) ...@@ -340,19 +353,24 @@ read_pri_intelext(struct map_info *map, __u16 adr)
extp->BlkStatusRegMask = le16_to_cpu(extp->BlkStatusRegMask); extp->BlkStatusRegMask = le16_to_cpu(extp->BlkStatusRegMask);
extp->ProtRegAddr = le16_to_cpu(extp->ProtRegAddr); extp->ProtRegAddr = le16_to_cpu(extp->ProtRegAddr);
if (extp->MajorVersion == '1' && extp->MinorVersion >= '3') { if (extp->MinorVersion >= '0') {
unsigned int extra_size = 0; extra_size = 0;
int nb_parts, i;
/* Protection Register info */ /* Protection Register info */
extra_size += (extp->NumProtectionFields - 1) * extra_size += (extp->NumProtectionFields - 1) *
sizeof(struct cfi_intelext_otpinfo); sizeof(struct cfi_intelext_otpinfo);
}
if (extp->MinorVersion >= '1') {
/* Burst Read info */ /* Burst Read info */
extra_size += 2; extra_size += 2;
if (extp_size < sizeof(*extp) + extra_size) if (extp_size < sizeof(*extp) + extra_size)
goto need_more; goto need_more;
extra_size += extp->extra[extra_size-1]; extra_size += extp->extra[extra_size - 1];
}
if (extp->MinorVersion >= '3') {
int nb_parts, i;
/* Number of hardware-partitions */ /* Number of hardware-partitions */
extra_size += 1; extra_size += 1;
......
...@@ -166,6 +166,7 @@ ...@@ -166,6 +166,7 @@
#define SST39LF040 0x00D7 #define SST39LF040 0x00D7
#define SST39SF010A 0x00B5 #define SST39SF010A 0x00B5
#define SST39SF020A 0x00B6 #define SST39SF020A 0x00B6
#define SST39SF040 0x00B7
#define SST49LF004B 0x0060 #define SST49LF004B 0x0060
#define SST49LF040B 0x0050 #define SST49LF040B 0x0050
#define SST49LF008A 0x005a #define SST49LF008A 0x005a
...@@ -1391,6 +1392,18 @@ static const struct amd_flash_info jedec_table[] = { ...@@ -1391,6 +1392,18 @@ static const struct amd_flash_info jedec_table[] = {
.regions = { .regions = {
ERASEINFO(0x01000,64), ERASEINFO(0x01000,64),
} }
}, {
.mfr_id = MANUFACTURER_SST,
.dev_id = SST39SF040,
.name = "SST 39SF040",
.devtypes = CFI_DEVICETYPE_X8,
.uaddr = MTD_UADDR_0x5555_0x2AAA,
.dev_size = SIZE_512KiB,
.cmd_set = P_ID_AMD_STD,
.nr_regions = 1,
.regions = {
ERASEINFO(0x01000,128),
}
}, { }, {
.mfr_id = MANUFACTURER_SST, .mfr_id = MANUFACTURER_SST,
.dev_id = SST49LF040B, .dev_id = SST49LF040B,
......
...@@ -500,6 +500,9 @@ static struct flash_info __devinitdata m25p_data [] = { ...@@ -500,6 +500,9 @@ static struct flash_info __devinitdata m25p_data [] = {
{ "at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K, }, { "at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K, },
{ "at26df321", 0x1f4701, 0, 64 * 1024, 64, SECT_4K, }, { "at26df321", 0x1f4701, 0, 64 * 1024, 64, SECT_4K, },
/* Macronix */
{ "mx25l12805d", 0xc22018, 0, 64 * 1024, 256, },
/* Spansion -- single (large) sector size only, at least /* Spansion -- single (large) sector size only, at least
* for the chips listed here (without boot sectors). * for the chips listed here (without boot sectors).
*/ */
...@@ -528,6 +531,7 @@ static struct flash_info __devinitdata m25p_data [] = { ...@@ -528,6 +531,7 @@ static struct flash_info __devinitdata m25p_data [] = {
{ "m25p64", 0x202017, 0, 64 * 1024, 128, }, { "m25p64", 0x202017, 0, 64 * 1024, 128, },
{ "m25p128", 0x202018, 0, 256 * 1024, 64, }, { "m25p128", 0x202018, 0, 256 * 1024, 64, },
{ "m45pe10", 0x204011, 0, 64 * 1024, 2, },
{ "m45pe80", 0x204014, 0, 64 * 1024, 16, }, { "m45pe80", 0x204014, 0, 64 * 1024, 16, },
{ "m45pe16", 0x204015, 0, 64 * 1024, 32, }, { "m45pe16", 0x204015, 0, 64 * 1024, 32, },
......
...@@ -105,15 +105,6 @@ config MSP_FLASH_MAP_LIMIT ...@@ -105,15 +105,6 @@ config MSP_FLASH_MAP_LIMIT
default "0x02000000" default "0x02000000"
depends on MSP_FLASH_MAP_LIMIT_32M depends on MSP_FLASH_MAP_LIMIT_32M
config MTD_PMC_MSP_RAMROOT
tristate "Embedded RAM block device for root on PMC-Sierra MSP"
depends on PMC_MSP_EMBEDDED_ROOTFS && \
(MTD_BLOCK || MTD_BLOCK_RO) && \
MTD_RAM
help
This provides support for the embedded root file system
on PMC MSP devices. This memory is mapped as a MTD block device.
config MTD_SUN_UFLASH config MTD_SUN_UFLASH
tristate "Sun Microsystems userflash support" tristate "Sun Microsystems userflash support"
depends on SPARC && MTD_CFI && PCI depends on SPARC && MTD_CFI && PCI
...@@ -270,7 +261,7 @@ config MTD_ALCHEMY ...@@ -270,7 +261,7 @@ config MTD_ALCHEMY
config MTD_DILNETPC config MTD_DILNETPC
tristate "CFI Flash device mapped on DIL/Net PC" tristate "CFI Flash device mapped on DIL/Net PC"
depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN
help help
MTD map driver for SSV DIL/Net PC Boards "DNP" and "ADNP". MTD map driver for SSV DIL/Net PC Boards "DNP" and "ADNP".
For details, see <http://www.ssv-embedded.de/ssv/pc104/p169.htm> For details, see <http://www.ssv-embedded.de/ssv/pc104/p169.htm>
...@@ -501,7 +492,7 @@ config MTD_BFIN_ASYNC ...@@ -501,7 +492,7 @@ config MTD_BFIN_ASYNC
If compiled as a module, it will be called bfin-async-flash. If compiled as a module, it will be called bfin-async-flash.
config MTD_UCLINUX config MTD_UCLINUX
tristate "Generic uClinux RAM/ROM filesystem support" bool "Generic uClinux RAM/ROM filesystem support"
depends on MTD_PARTITIONS && MTD_RAM && !MMU depends on MTD_PARTITIONS && MTD_RAM && !MMU
help help
Map driver to support image based filesystems for uClinux. Map driver to support image based filesystems for uClinux.
......
...@@ -25,7 +25,6 @@ obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o ...@@ -25,7 +25,6 @@ obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o
obj-$(CONFIG_MTD_PHYSMAP) += physmap.o obj-$(CONFIG_MTD_PHYSMAP) += physmap.o
obj-$(CONFIG_MTD_PHYSMAP_OF) += physmap_of.o obj-$(CONFIG_MTD_PHYSMAP_OF) += physmap_of.o
obj-$(CONFIG_MTD_PMC_MSP_EVM) += pmcmsp-flash.o obj-$(CONFIG_MTD_PMC_MSP_EVM) += pmcmsp-flash.o
obj-$(CONFIG_MTD_PMC_MSP_RAMROOT)+= pmcmsp-ramroot.o
obj-$(CONFIG_MTD_PCMCIA) += pcmciamtd.o obj-$(CONFIG_MTD_PCMCIA) += pcmciamtd.o
obj-$(CONFIG_MTD_RPXLITE) += rpxlite.o obj-$(CONFIG_MTD_RPXLITE) += rpxlite.o
obj-$(CONFIG_MTD_TQM8XXL) += tqm8xxl.o obj-$(CONFIG_MTD_TQM8XXL) += tqm8xxl.o
......
...@@ -40,6 +40,9 @@ struct async_state { ...@@ -40,6 +40,9 @@ struct async_state {
uint32_t flash_ambctl0, flash_ambctl1; uint32_t flash_ambctl0, flash_ambctl1;
uint32_t save_ambctl0, save_ambctl1; uint32_t save_ambctl0, save_ambctl1;
unsigned long irq_flags; unsigned long irq_flags;
#ifdef CONFIG_MTD_PARTITIONS
struct mtd_partition *parts;
#endif
}; };
static void switch_to_flash(struct async_state *state) static void switch_to_flash(struct async_state *state)
...@@ -170,6 +173,7 @@ static int __devinit bfin_flash_probe(struct platform_device *pdev) ...@@ -170,6 +173,7 @@ static int __devinit bfin_flash_probe(struct platform_device *pdev)
if (ret > 0) { if (ret > 0) {
pr_devinit(KERN_NOTICE DRIVER_NAME ": Using commandline partition definition\n"); pr_devinit(KERN_NOTICE DRIVER_NAME ": Using commandline partition definition\n");
add_mtd_partitions(state->mtd, pdata->parts, ret); add_mtd_partitions(state->mtd, pdata->parts, ret);
state->parts = pdata->parts;
} else if (pdata->nr_parts) { } else if (pdata->nr_parts) {
pr_devinit(KERN_NOTICE DRIVER_NAME ": Using board partition definition\n"); pr_devinit(KERN_NOTICE DRIVER_NAME ": Using board partition definition\n");
...@@ -193,6 +197,7 @@ static int __devexit bfin_flash_remove(struct platform_device *pdev) ...@@ -193,6 +197,7 @@ static int __devexit bfin_flash_remove(struct platform_device *pdev)
gpio_free(state->enet_flash_pin); gpio_free(state->enet_flash_pin);
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
del_mtd_partitions(state->mtd); del_mtd_partitions(state->mtd);
kfree(state->parts);
#endif #endif
map_destroy(state->mtd); map_destroy(state->mtd);
kfree(state); kfree(state);
......
...@@ -36,27 +36,33 @@ ...@@ -36,27 +36,33 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/map.h> #include <linux/mtd/map.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/concat.h>
#include <asm/mach/flash.h> #include <asm/mach/flash.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <asm/system.h> #include <asm/system.h>
#ifdef CONFIG_ARCH_P720T #define SUBDEV_NAME_SIZE (BUS_ID_SIZE + 2)
#define FLASH_BASE (0x04000000)
#define FLASH_SIZE (64*1024*1024)
#endif
struct armflash_info { struct armflash_subdev_info {
char name[SUBDEV_NAME_SIZE];
struct mtd_info *mtd;
struct map_info map;
struct flash_platform_data *plat; struct flash_platform_data *plat;
};
struct armflash_info {
struct resource *res; struct resource *res;
struct mtd_partition *parts; struct mtd_partition *parts;
struct mtd_info *mtd; struct mtd_info *mtd;
struct map_info map; int nr_subdev;
struct armflash_subdev_info subdev[0];
}; };
static void armflash_set_vpp(struct map_info *map, int on) static void armflash_set_vpp(struct map_info *map, int on)
{ {
struct armflash_info *info = container_of(map, struct armflash_info, map); struct armflash_subdev_info *info =
container_of(map, struct armflash_subdev_info, map);
if (info->plat && info->plat->set_vpp) if (info->plat && info->plat->set_vpp)
info->plat->set_vpp(on); info->plat->set_vpp(on);
...@@ -64,32 +70,17 @@ static void armflash_set_vpp(struct map_info *map, int on) ...@@ -64,32 +70,17 @@ static void armflash_set_vpp(struct map_info *map, int on)
static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL }; static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL };
static int armflash_probe(struct platform_device *dev) static int armflash_subdev_probe(struct armflash_subdev_info *subdev,
struct resource *res)
{ {
struct flash_platform_data *plat = dev->dev.platform_data; struct flash_platform_data *plat = subdev->plat;
struct resource *res = dev->resource; resource_size_t size = res->end - res->start + 1;
unsigned int size = res->end - res->start + 1;
struct armflash_info *info;
int err;
void __iomem *base; void __iomem *base;
int err = 0;
info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL); if (!request_mem_region(res->start, size, subdev->name)) {
if (!info) {
err = -ENOMEM;
goto out;
}
info->plat = plat;
if (plat && plat->init) {
err = plat->init();
if (err)
goto no_resource;
}
info->res = request_mem_region(res->start, size, "armflash");
if (!info->res) {
err = -EBUSY; err = -EBUSY;
goto no_resource; goto out;
} }
base = ioremap(res->start, size); base = ioremap(res->start, size);
...@@ -101,27 +92,132 @@ static int armflash_probe(struct platform_device *dev) ...@@ -101,27 +92,132 @@ static int armflash_probe(struct platform_device *dev)
/* /*
* look for CFI based flash parts fitted to this board * look for CFI based flash parts fitted to this board
*/ */
info->map.size = size; subdev->map.size = size;
info->map.bankwidth = plat->width; subdev->map.bankwidth = plat->width;
info->map.phys = res->start; subdev->map.phys = res->start;
info->map.virt = base; subdev->map.virt = base;
info->map.name = dev_name(&dev->dev); subdev->map.name = subdev->name;
info->map.set_vpp = armflash_set_vpp; subdev->map.set_vpp = armflash_set_vpp;
simple_map_init(&info->map); simple_map_init(&subdev->map);
/* /*
* Also, the CFI layer automatically works out what size * Also, the CFI layer automatically works out what size
* of chips we have, and does the necessary identification * of chips we have, and does the necessary identification
* for us automatically. * for us automatically.
*/ */
info->mtd = do_map_probe(plat->map_name, &info->map); subdev->mtd = do_map_probe(plat->map_name, &subdev->map);
if (!info->mtd) { if (!subdev->mtd) {
err = -ENXIO; err = -ENXIO;
goto no_device; goto no_device;
} }
info->mtd->owner = THIS_MODULE; subdev->mtd->owner = THIS_MODULE;
/* Successful? */
if (err == 0)
return err;
if (subdev->mtd)
map_destroy(subdev->mtd);
no_device:
iounmap(base);
no_mem:
release_mem_region(res->start, size);
out:
return err;
}
static void armflash_subdev_remove(struct armflash_subdev_info *subdev)
{
if (subdev->mtd)
map_destroy(subdev->mtd);
if (subdev->map.virt)
iounmap(subdev->map.virt);
release_mem_region(subdev->map.phys, subdev->map.size);
}
static int armflash_probe(struct platform_device *dev)
{
struct flash_platform_data *plat = dev->dev.platform_data;
unsigned int size;
struct armflash_info *info;
int i, nr, err;
/* Count the number of devices */
for (nr = 0; ; nr++)
if (!platform_get_resource(dev, IORESOURCE_MEM, nr))
break;
if (nr == 0) {
err = -ENODEV;
goto out;
}
size = sizeof(struct armflash_info) +
sizeof(struct armflash_subdev_info) * nr;
info = kzalloc(size, GFP_KERNEL);
if (!info) {
err = -ENOMEM;
goto out;
}
if (plat && plat->init) {
err = plat->init();
if (err)
goto no_resource;
}
for (i = 0; i < nr; i++) {
struct armflash_subdev_info *subdev = &info->subdev[i];
struct resource *res;
res = platform_get_resource(dev, IORESOURCE_MEM, i);
if (!res)
break;
if (nr == 1)
/* No MTD concatenation, just use the default name */
snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s",
dev_name(&dev->dev));
else
snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s-%d",
dev_name(&dev->dev), i);
subdev->plat = plat;
err = armflash_subdev_probe(subdev, res);
if (err)
break;
}
info->nr_subdev = i;
if (err)
goto subdev_err;
if (info->nr_subdev == 1)
info->mtd = info->subdev[0].mtd;
else if (info->nr_subdev > 1) {
#ifdef CONFIG_MTD_CONCAT
struct mtd_info *cdev[info->nr_subdev];
/*
* We detected multiple devices. Concatenate them together.
*/
for (i = 0; i < info->nr_subdev; i++)
cdev[i] = info->subdev[i].mtd;
info->mtd = mtd_concat_create(cdev, info->nr_subdev,
dev_name(&dev->dev));
if (info->mtd == NULL)
err = -ENXIO;
#else
printk(KERN_ERR "armflash: multiple devices found but "
"MTD concat support disabled.\n");
err = -ENXIO;
#endif
}
if (err < 0)
goto cleanup;
err = parse_mtd_partitions(info->mtd, probes, &info->parts, 0); err = parse_mtd_partitions(info->mtd, probes, &info->parts, 0);
if (err > 0) { if (err > 0) {
...@@ -131,28 +227,30 @@ static int armflash_probe(struct platform_device *dev) ...@@ -131,28 +227,30 @@ static int armflash_probe(struct platform_device *dev)
"mtd partition registration failed: %d\n", err); "mtd partition registration failed: %d\n", err);
} }
if (err == 0) if (err == 0) {
platform_set_drvdata(dev, info); platform_set_drvdata(dev, info);
return err;
}
/* /*
* If we got an error, free all resources. * We got an error, free all resources.
*/ */
if (err < 0) { cleanup:
if (info->mtd) { if (info->mtd) {
del_mtd_partitions(info->mtd); del_mtd_partitions(info->mtd);
map_destroy(info->mtd); #ifdef CONFIG_MTD_CONCAT
if (info->mtd != info->subdev[0].mtd)
mtd_concat_destroy(info->mtd);
#endif
} }
kfree(info->parts); kfree(info->parts);
subdev_err:
no_device: for (i = info->nr_subdev - 1; i >= 0; i--)
iounmap(base); armflash_subdev_remove(&info->subdev[i]);
no_mem:
release_mem_region(res->start, size);
no_resource: no_resource:
if (plat && plat->exit) if (plat && plat->exit)
plat->exit(); plat->exit();
kfree(info); kfree(info);
}
out: out:
return err; return err;
} }
...@@ -160,22 +258,26 @@ static int armflash_probe(struct platform_device *dev) ...@@ -160,22 +258,26 @@ static int armflash_probe(struct platform_device *dev)
static int armflash_remove(struct platform_device *dev) static int armflash_remove(struct platform_device *dev)
{ {
struct armflash_info *info = platform_get_drvdata(dev); struct armflash_info *info = platform_get_drvdata(dev);
struct flash_platform_data *plat = dev->dev.platform_data;
int i;
platform_set_drvdata(dev, NULL); platform_set_drvdata(dev, NULL);
if (info) { if (info) {
if (info->mtd) { if (info->mtd) {
del_mtd_partitions(info->mtd); del_mtd_partitions(info->mtd);
map_destroy(info->mtd); #ifdef CONFIG_MTD_CONCAT
if (info->mtd != info->subdev[0].mtd)
mtd_concat_destroy(info->mtd);
#endif
} }
kfree(info->parts); kfree(info->parts);
iounmap(info->map.virt); for (i = info->nr_subdev - 1; i >= 0; i--)
release_resource(info->res); armflash_subdev_remove(&info->subdev[i]);
kfree(info->res);
if (info->plat && info->plat->exit) if (plat && plat->exit)
info->plat->exit(); plat->exit();
kfree(info); kfree(info);
} }
......
...@@ -195,42 +195,6 @@ static int physmap_flash_probe(struct platform_device *dev) ...@@ -195,42 +195,6 @@ static int physmap_flash_probe(struct platform_device *dev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state)
{
struct physmap_flash_info *info = platform_get_drvdata(dev);
int ret = 0;
int i;
for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
if (info->mtd[i]->suspend) {
ret = info->mtd[i]->suspend(info->mtd[i]);
if (ret)
goto fail;
}
return 0;
fail:
for (--i; i >= 0; --i)
if (info->mtd[i]->suspend) {
BUG_ON(!info->mtd[i]->resume);
info->mtd[i]->resume(info->mtd[i]);
}
return ret;
}
static int physmap_flash_resume(struct platform_device *dev)
{
struct physmap_flash_info *info = platform_get_drvdata(dev);
int i;
for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
if (info->mtd[i]->resume)
info->mtd[i]->resume(info->mtd[i]);
return 0;
}
static void physmap_flash_shutdown(struct platform_device *dev) static void physmap_flash_shutdown(struct platform_device *dev)
{ {
struct physmap_flash_info *info = platform_get_drvdata(dev); struct physmap_flash_info *info = platform_get_drvdata(dev);
...@@ -242,16 +206,12 @@ static void physmap_flash_shutdown(struct platform_device *dev) ...@@ -242,16 +206,12 @@ static void physmap_flash_shutdown(struct platform_device *dev)
info->mtd[i]->resume(info->mtd[i]); info->mtd[i]->resume(info->mtd[i]);
} }
#else #else
#define physmap_flash_suspend NULL
#define physmap_flash_resume NULL
#define physmap_flash_shutdown NULL #define physmap_flash_shutdown NULL
#endif #endif
static struct platform_driver physmap_flash_driver = { static struct platform_driver physmap_flash_driver = {
.probe = physmap_flash_probe, .probe = physmap_flash_probe,
.remove = physmap_flash_remove, .remove = physmap_flash_remove,
.suspend = physmap_flash_suspend,
.resume = physmap_flash_resume,
.shutdown = physmap_flash_shutdown, .shutdown = physmap_flash_shutdown,
.driver = { .driver = {
.name = "physmap-flash", .name = "physmap-flash",
......
...@@ -20,16 +20,23 @@ ...@@ -20,16 +20,23 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/map.h> #include <linux/mtd/map.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/concat.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
struct of_flash { struct of_flash_list {
struct mtd_info *mtd; struct mtd_info *mtd;
struct map_info map; struct map_info map;
struct resource *res; struct resource *res;
};
struct of_flash {
struct mtd_info *cmtd;
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
struct mtd_partition *parts; struct mtd_partition *parts;
#endif #endif
int list_size; /* number of elements in of_flash_list */
struct of_flash_list list[0];
}; };
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
...@@ -88,29 +95,43 @@ static int parse_obsolete_partitions(struct of_device *dev, ...@@ -88,29 +95,43 @@ static int parse_obsolete_partitions(struct of_device *dev,
static int of_flash_remove(struct of_device *dev) static int of_flash_remove(struct of_device *dev)
{ {
struct of_flash *info; struct of_flash *info;
int i;
info = dev_get_drvdata(&dev->dev); info = dev_get_drvdata(&dev->dev);
if (!info) if (!info)
return 0; return 0;
dev_set_drvdata(&dev->dev, NULL); dev_set_drvdata(&dev->dev, NULL);
if (info->mtd) { #ifdef CONFIG_MTD_CONCAT
if (info->cmtd != info->list[0].mtd) {
del_mtd_device(info->cmtd);
mtd_concat_destroy(info->cmtd);
}
#endif
if (info->cmtd) {
if (OF_FLASH_PARTS(info)) { if (OF_FLASH_PARTS(info)) {
del_mtd_partitions(info->mtd); del_mtd_partitions(info->cmtd);
kfree(OF_FLASH_PARTS(info)); kfree(OF_FLASH_PARTS(info));
} else { } else {
del_mtd_device(info->mtd); del_mtd_device(info->cmtd);
} }
map_destroy(info->mtd);
} }
if (info->map.virt) for (i = 0; i < info->list_size; i++) {
iounmap(info->map.virt); if (info->list[i].mtd)
map_destroy(info->list[i].mtd);
if (info->list[i].map.virt)
iounmap(info->list[i].map.virt);
if (info->res) { if (info->list[i].res) {
release_resource(info->res); release_resource(info->list[i].res);
kfree(info->res); kfree(info->list[i].res);
} }
}
kfree(info);
return 0; return 0;
} }
...@@ -164,67 +185,129 @@ static int __devinit of_flash_probe(struct of_device *dev, ...@@ -164,67 +185,129 @@ static int __devinit of_flash_probe(struct of_device *dev,
const char *probe_type = match->data; const char *probe_type = match->data;
const u32 *width; const u32 *width;
int err; int err;
int i;
err = -ENXIO; int count;
if (of_address_to_resource(dp, 0, &res)) { const u32 *p;
dev_err(&dev->dev, "Can't get IO address from device tree\n"); int reg_tuple_size;
struct mtd_info **mtd_list = NULL;
reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32);
/*
* Get number of "reg" tuples. Scan for MTD devices on area's
* described by each "reg" region. This makes it possible (including
* the concat support) to support the Intel P30 48F4400 chips which
* consists internally of 2 non-identical NOR chips on one die.
*/
p = of_get_property(dp, "reg", &count);
if (count % reg_tuple_size != 0) {
dev_err(&dev->dev, "Malformed reg property on %s\n",
dev->node->full_name);
err = -EINVAL;
goto err_out; goto err_out;
} }
count /= reg_tuple_size;
dev_dbg(&dev->dev, "of_flash device: %.8llx-%.8llx\n",
(unsigned long long)res.start, (unsigned long long)res.end);
err = -ENOMEM; err = -ENOMEM;
info = kzalloc(sizeof(*info), GFP_KERNEL); info = kzalloc(sizeof(struct of_flash) +
sizeof(struct of_flash_list) * count, GFP_KERNEL);
if (!info)
goto err_out;
mtd_list = kzalloc(sizeof(struct mtd_info) * count, GFP_KERNEL);
if (!info) if (!info)
goto err_out; goto err_out;
dev_set_drvdata(&dev->dev, info); dev_set_drvdata(&dev->dev, info);
for (i = 0; i < count; i++) {
err = -ENXIO;
if (of_address_to_resource(dp, i, &res)) {
dev_err(&dev->dev, "Can't get IO address from device"
" tree\n");
goto err_out;
}
dev_dbg(&dev->dev, "of_flash device: %.8llx-%.8llx\n",
(unsigned long long)res.start,
(unsigned long long)res.end);
err = -EBUSY; err = -EBUSY;
info->res = request_mem_region(res.start, res.end - res.start + 1, info->list[i].res = request_mem_region(res.start, res.end -
res.start + 1,
dev_name(&dev->dev)); dev_name(&dev->dev));
if (!info->res) if (!info->list[i].res)
goto err_out; goto err_out;
err = -ENXIO; err = -ENXIO;
width = of_get_property(dp, "bank-width", NULL); width = of_get_property(dp, "bank-width", NULL);
if (!width) { if (!width) {
dev_err(&dev->dev, "Can't get bank width from device tree\n"); dev_err(&dev->dev, "Can't get bank width from device"
" tree\n");
goto err_out; goto err_out;
} }
info->map.name = dev_name(&dev->dev); info->list[i].map.name = dev_name(&dev->dev);
info->map.phys = res.start; info->list[i].map.phys = res.start;
info->map.size = res.end - res.start + 1; info->list[i].map.size = res.end - res.start + 1;
info->map.bankwidth = *width; info->list[i].map.bankwidth = *width;
err = -ENOMEM; err = -ENOMEM;
info->map.virt = ioremap(info->map.phys, info->map.size); info->list[i].map.virt = ioremap(info->list[i].map.phys,
if (!info->map.virt) { info->list[i].map.size);
dev_err(&dev->dev, "Failed to ioremap() flash region\n"); if (!info->list[i].map.virt) {
dev_err(&dev->dev, "Failed to ioremap() flash"
" region\n");
goto err_out; goto err_out;
} }
simple_map_init(&info->map); simple_map_init(&info->list[i].map);
if (probe_type) if (probe_type) {
info->mtd = do_map_probe(probe_type, &info->map); info->list[i].mtd = do_map_probe(probe_type,
else &info->list[i].map);
info->mtd = obsolete_probe(dev, &info->map); } else {
info->list[i].mtd = obsolete_probe(dev,
&info->list[i].map);
}
mtd_list[i] = info->list[i].mtd;
err = -ENXIO; err = -ENXIO;
if (!info->mtd) { if (!info->list[i].mtd) {
dev_err(&dev->dev, "do_map_probe() failed\n"); dev_err(&dev->dev, "do_map_probe() failed\n");
goto err_out; goto err_out;
} else {
info->list_size++;
}
info->list[i].mtd->owner = THIS_MODULE;
info->list[i].mtd->dev.parent = &dev->dev;
} }
info->mtd->owner = THIS_MODULE;
info->mtd->dev.parent = &dev->dev; err = 0;
if (info->list_size == 1) {
info->cmtd = info->list[0].mtd;
} else if (info->list_size > 1) {
/*
* We detected multiple devices. Concatenate them together.
*/
#ifdef CONFIG_MTD_CONCAT
info->cmtd = mtd_concat_create(mtd_list, info->list_size,
dev_name(&dev->dev));
if (info->cmtd == NULL)
err = -ENXIO;
#else
printk(KERN_ERR "physmap_of: multiple devices "
"found but MTD concat support disabled.\n");
err = -ENXIO;
#endif
}
if (err)
goto err_out;
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
/* First look for RedBoot table or partitions on the command /* First look for RedBoot table or partitions on the command
* line, these take precedence over device tree information */ * line, these take precedence over device tree information */
err = parse_mtd_partitions(info->mtd, part_probe_types, err = parse_mtd_partitions(info->cmtd, part_probe_types,
&info->parts, 0); &info->parts, 0);
if (err < 0) if (err < 0)
return err; return err;
...@@ -244,15 +327,19 @@ static int __devinit of_flash_probe(struct of_device *dev, ...@@ -244,15 +327,19 @@ static int __devinit of_flash_probe(struct of_device *dev,
} }
if (err > 0) if (err > 0)
add_mtd_partitions(info->mtd, info->parts, err); add_mtd_partitions(info->cmtd, info->parts, err);
else else
#endif #endif
add_mtd_device(info->mtd); add_mtd_device(info->cmtd);
kfree(mtd_list);
return 0; return 0;
err_out: err_out:
kfree(mtd_list);
of_flash_remove(dev); of_flash_remove(dev);
return err; return err;
} }
......
/*
* Mapping of the rootfs in a physical region of memory
*
* Copyright (C) 2005-2007 PMC-Sierra Inc.
* Author: Andrew Hughes, Andrew_Hughes@pmc-sierra.com
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/root_dev.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <asm/io.h>
#include <msp_prom.h>
static struct mtd_info *rr_mtd;
struct map_info rr_map = {
.name = "ramroot",
.bankwidth = 4,
};
static int __init init_rrmap(void)
{
void *ramroot_start;
unsigned long ramroot_size;
/* Check for supported rootfs types */
if (get_ramroot(&ramroot_start, &ramroot_size)) {
rr_map.phys = CPHYSADDR(ramroot_start);
rr_map.size = ramroot_size;
printk(KERN_NOTICE
"PMC embedded root device: 0x%08lx @ 0x%08lx\n",
rr_map.size, (unsigned long)rr_map.phys);
} else {
printk(KERN_ERR
"init_rrmap: no supported embedded rootfs detected!\n");
return -ENXIO;
}
/* Map rootfs to I/O space for block device driver */
rr_map.virt = ioremap(rr_map.phys, rr_map.size);
if (!rr_map.virt) {
printk(KERN_ERR "Failed to ioremap\n");
return -EIO;
}
simple_map_init(&rr_map);
rr_mtd = do_map_probe("map_ram", &rr_map);
if (rr_mtd) {
rr_mtd->owner = THIS_MODULE;
add_mtd_device(rr_mtd);
return 0;
}
iounmap(rr_map.virt);
return -ENXIO;
}
static void __exit cleanup_rrmap(void)
{
del_mtd_device(rr_mtd);
map_destroy(rr_mtd);
iounmap(rr_map.virt);
rr_map.virt = NULL;
}
MODULE_AUTHOR("PMC-Sierra, Inc");
MODULE_DESCRIPTION("MTD map driver for embedded PMC-Sierra MSP filesystem");
MODULE_LICENSE("GPL");
module_init(init_rrmap);
module_exit(cleanup_rrmap);
...@@ -140,24 +140,6 @@ static int __devexit pxa2xx_flash_remove(struct platform_device *dev) ...@@ -140,24 +140,6 @@ static int __devexit pxa2xx_flash_remove(struct platform_device *dev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int pxa2xx_flash_suspend(struct platform_device *dev, pm_message_t state)
{
struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
int ret = 0;
if (info->mtd && info->mtd->suspend)
ret = info->mtd->suspend(info->mtd);
return ret;
}
static int pxa2xx_flash_resume(struct platform_device *dev)
{
struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
if (info->mtd && info->mtd->resume)
info->mtd->resume(info->mtd);
return 0;
}
static void pxa2xx_flash_shutdown(struct platform_device *dev) static void pxa2xx_flash_shutdown(struct platform_device *dev)
{ {
struct pxa2xx_flash_info *info = platform_get_drvdata(dev); struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
...@@ -166,8 +148,6 @@ static void pxa2xx_flash_shutdown(struct platform_device *dev) ...@@ -166,8 +148,6 @@ static void pxa2xx_flash_shutdown(struct platform_device *dev)
info->mtd->resume(info->mtd); info->mtd->resume(info->mtd);
} }
#else #else
#define pxa2xx_flash_suspend NULL
#define pxa2xx_flash_resume NULL
#define pxa2xx_flash_shutdown NULL #define pxa2xx_flash_shutdown NULL
#endif #endif
...@@ -178,8 +158,6 @@ static struct platform_driver pxa2xx_flash_driver = { ...@@ -178,8 +158,6 @@ static struct platform_driver pxa2xx_flash_driver = {
}, },
.probe = pxa2xx_flash_probe, .probe = pxa2xx_flash_probe,
.remove = __devexit_p(pxa2xx_flash_remove), .remove = __devexit_p(pxa2xx_flash_remove),
.suspend = pxa2xx_flash_suspend,
.resume = pxa2xx_flash_resume,
.shutdown = pxa2xx_flash_shutdown, .shutdown = pxa2xx_flash_shutdown,
}; };
......
...@@ -145,25 +145,6 @@ static int rbtx4939_flash_probe(struct platform_device *dev) ...@@ -145,25 +145,6 @@ static int rbtx4939_flash_probe(struct platform_device *dev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int rbtx4939_flash_suspend(struct platform_device *dev,
pm_message_t state)
{
struct rbtx4939_flash_info *info = platform_get_drvdata(dev);
if (info->mtd->suspend)
return info->mtd->suspend(info->mtd);
return 0;
}
static int rbtx4939_flash_resume(struct platform_device *dev)
{
struct rbtx4939_flash_info *info = platform_get_drvdata(dev);
if (info->mtd->resume)
info->mtd->resume(info->mtd);
return 0;
}
static void rbtx4939_flash_shutdown(struct platform_device *dev) static void rbtx4939_flash_shutdown(struct platform_device *dev)
{ {
struct rbtx4939_flash_info *info = platform_get_drvdata(dev); struct rbtx4939_flash_info *info = platform_get_drvdata(dev);
...@@ -173,16 +154,12 @@ static void rbtx4939_flash_shutdown(struct platform_device *dev) ...@@ -173,16 +154,12 @@ static void rbtx4939_flash_shutdown(struct platform_device *dev)
info->mtd->resume(info->mtd); info->mtd->resume(info->mtd);
} }
#else #else
#define rbtx4939_flash_suspend NULL
#define rbtx4939_flash_resume NULL
#define rbtx4939_flash_shutdown NULL #define rbtx4939_flash_shutdown NULL
#endif #endif
static struct platform_driver rbtx4939_flash_driver = { static struct platform_driver rbtx4939_flash_driver = {
.probe = rbtx4939_flash_probe, .probe = rbtx4939_flash_probe,
.remove = rbtx4939_flash_remove, .remove = rbtx4939_flash_remove,
.suspend = rbtx4939_flash_suspend,
.resume = rbtx4939_flash_resume,
.shutdown = rbtx4939_flash_shutdown, .shutdown = rbtx4939_flash_shutdown,
.driver = { .driver = {
.name = "rbtx4939-flash", .name = "rbtx4939-flash",
......
...@@ -415,25 +415,6 @@ static int __exit sa1100_mtd_remove(struct platform_device *pdev) ...@@ -415,25 +415,6 @@ static int __exit sa1100_mtd_remove(struct platform_device *pdev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int sa1100_mtd_suspend(struct platform_device *dev, pm_message_t state)
{
struct sa_info *info = platform_get_drvdata(dev);
int ret = 0;
if (info)
ret = info->mtd->suspend(info->mtd);
return ret;
}
static int sa1100_mtd_resume(struct platform_device *dev)
{
struct sa_info *info = platform_get_drvdata(dev);
if (info)
info->mtd->resume(info->mtd);
return 0;
}
static void sa1100_mtd_shutdown(struct platform_device *dev) static void sa1100_mtd_shutdown(struct platform_device *dev)
{ {
struct sa_info *info = platform_get_drvdata(dev); struct sa_info *info = platform_get_drvdata(dev);
...@@ -441,16 +422,12 @@ static void sa1100_mtd_shutdown(struct platform_device *dev) ...@@ -441,16 +422,12 @@ static void sa1100_mtd_shutdown(struct platform_device *dev)
info->mtd->resume(info->mtd); info->mtd->resume(info->mtd);
} }
#else #else
#define sa1100_mtd_suspend NULL
#define sa1100_mtd_resume NULL
#define sa1100_mtd_shutdown NULL #define sa1100_mtd_shutdown NULL
#endif #endif
static struct platform_driver sa1100_mtd_driver = { static struct platform_driver sa1100_mtd_driver = {
.probe = sa1100_mtd_probe, .probe = sa1100_mtd_probe,
.remove = __exit_p(sa1100_mtd_remove), .remove = __exit_p(sa1100_mtd_remove),
.suspend = sa1100_mtd_suspend,
.resume = sa1100_mtd_resume,
.shutdown = sa1100_mtd_shutdown, .shutdown = sa1100_mtd_shutdown,
.driver = { .driver = {
.name = "sa1100-mtd", .name = "sa1100-mtd",
......
...@@ -22,15 +22,19 @@ ...@@ -22,15 +22,19 @@
/****************************************************************************/ /****************************************************************************/
extern char _ebss;
struct map_info uclinux_ram_map = { struct map_info uclinux_ram_map = {
.name = "RAM", .name = "RAM",
.phys = (unsigned long)&_ebss,
.size = 0,
}; };
struct mtd_info *uclinux_ram_mtdinfo; static struct mtd_info *uclinux_ram_mtdinfo;
/****************************************************************************/ /****************************************************************************/
struct mtd_partition uclinux_romfs[] = { static struct mtd_partition uclinux_romfs[] = {
{ .name = "ROMfs" } { .name = "ROMfs" }
}; };
...@@ -38,7 +42,7 @@ struct mtd_partition uclinux_romfs[] = { ...@@ -38,7 +42,7 @@ struct mtd_partition uclinux_romfs[] = {
/****************************************************************************/ /****************************************************************************/
int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len, static int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, void **virt, resource_size_t *phys) size_t *retlen, void **virt, resource_size_t *phys)
{ {
struct map_info *map = mtd->priv; struct map_info *map = mtd->priv;
...@@ -55,12 +59,10 @@ static int __init uclinux_mtd_init(void) ...@@ -55,12 +59,10 @@ static int __init uclinux_mtd_init(void)
{ {
struct mtd_info *mtd; struct mtd_info *mtd;
struct map_info *mapp; struct map_info *mapp;
extern char _ebss;
unsigned long addr = (unsigned long) &_ebss;
mapp = &uclinux_ram_map; mapp = &uclinux_ram_map;
mapp->phys = addr; if (!mapp->size)
mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(addr + 8)))); mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(mapp->phys + 8))));
mapp->bankwidth = 4; mapp->bankwidth = 4;
printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n", printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n",
......
...@@ -291,7 +291,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -291,7 +291,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
gd->private_data = new; gd->private_data = new;
new->blkcore_priv = gd; new->blkcore_priv = gd;
gd->queue = tr->blkcore_priv->rq; gd->queue = tr->blkcore_priv->rq;
gd->driverfs_dev = new->mtd->dev.parent; gd->driverfs_dev = &new->mtd->dev;
if (new->readonly) if (new->readonly)
set_disk_ro(gd, 1); set_disk_ro(gd, 1);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#include <linux/compat.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/compatmac.h> #include <linux/mtd/compatmac.h>
...@@ -355,6 +356,100 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode) ...@@ -355,6 +356,100 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
# define otp_select_filemode(f,m) -EOPNOTSUPP # define otp_select_filemode(f,m) -EOPNOTSUPP
#endif #endif
static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
uint64_t start, uint32_t length, void __user *ptr,
uint32_t __user *retp)
{
struct mtd_oob_ops ops;
uint32_t retlen;
int ret = 0;
if (!(file->f_mode & FMODE_WRITE))
return -EPERM;
if (length > 4096)
return -EINVAL;
if (!mtd->write_oob)
ret = -EOPNOTSUPP;
else
ret = access_ok(VERIFY_READ, ptr, length) ? 0 : EFAULT;
if (ret)
return ret;
ops.ooblen = length;
ops.ooboffs = start & (mtd->oobsize - 1);
ops.datbuf = NULL;
ops.mode = MTD_OOB_PLACE;
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
return -EINVAL;
ops.oobbuf = kmalloc(length, GFP_KERNEL);
if (!ops.oobbuf)
return -ENOMEM;
if (copy_from_user(ops.oobbuf, ptr, length)) {
kfree(ops.oobbuf);
return -EFAULT;
}
start &= ~((uint64_t)mtd->oobsize - 1);
ret = mtd->write_oob(mtd, start, &ops);
if (ops.oobretlen > 0xFFFFFFFFU)
ret = -EOVERFLOW;
retlen = ops.oobretlen;
if (copy_to_user(retp, &retlen, sizeof(length)))
ret = -EFAULT;
kfree(ops.oobbuf);
return ret;
}
static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
uint32_t length, void __user *ptr, uint32_t __user *retp)
{
struct mtd_oob_ops ops;
int ret = 0;
if (length > 4096)
return -EINVAL;
if (!mtd->read_oob)
ret = -EOPNOTSUPP;
else
ret = access_ok(VERIFY_WRITE, ptr,
length) ? 0 : -EFAULT;
if (ret)
return ret;
ops.ooblen = length;
ops.ooboffs = start & (mtd->oobsize - 1);
ops.datbuf = NULL;
ops.mode = MTD_OOB_PLACE;
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
return -EINVAL;
ops.oobbuf = kmalloc(length, GFP_KERNEL);
if (!ops.oobbuf)
return -ENOMEM;
start &= ~((uint64_t)mtd->oobsize - 1);
ret = mtd->read_oob(mtd, start, &ops);
if (put_user(ops.oobretlen, retp))
ret = -EFAULT;
else if (ops.oobretlen && copy_to_user(ptr, ops.oobbuf,
ops.oobretlen))
ret = -EFAULT;
kfree(ops.oobbuf);
return ret;
}
static int mtd_ioctl(struct inode *inode, struct file *file, static int mtd_ioctl(struct inode *inode, struct file *file,
u_int cmd, u_long arg) u_int cmd, u_long arg)
{ {
...@@ -417,6 +512,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -417,6 +512,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
break; break;
case MEMERASE: case MEMERASE:
case MEMERASE64:
{ {
struct erase_info *erase; struct erase_info *erase;
...@@ -427,20 +523,32 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -427,20 +523,32 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
if (!erase) if (!erase)
ret = -ENOMEM; ret = -ENOMEM;
else { else {
struct erase_info_user einfo;
wait_queue_head_t waitq; wait_queue_head_t waitq;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
init_waitqueue_head(&waitq); init_waitqueue_head(&waitq);
if (copy_from_user(&einfo, argp, if (cmd == MEMERASE64) {
struct erase_info_user64 einfo64;
if (copy_from_user(&einfo64, argp,
sizeof(struct erase_info_user64))) {
kfree(erase);
return -EFAULT;
}
erase->addr = einfo64.start;
erase->len = einfo64.length;
} else {
struct erase_info_user einfo32;
if (copy_from_user(&einfo32, argp,
sizeof(struct erase_info_user))) { sizeof(struct erase_info_user))) {
kfree(erase); kfree(erase);
return -EFAULT; return -EFAULT;
} }
erase->addr = einfo.start; erase->addr = einfo32.start;
erase->len = einfo.length; erase->len = einfo32.length;
}
erase->mtd = mtd; erase->mtd = mtd;
erase->callback = mtdchar_erase_callback; erase->callback = mtdchar_erase_callback;
erase->priv = (unsigned long)&waitq; erase->priv = (unsigned long)&waitq;
...@@ -474,100 +582,56 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -474,100 +582,56 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
case MEMWRITEOOB: case MEMWRITEOOB:
{ {
struct mtd_oob_buf buf; struct mtd_oob_buf buf;
struct mtd_oob_ops ops; struct mtd_oob_buf __user *buf_user = argp;
struct mtd_oob_buf __user *user_buf = argp;
uint32_t retlen;
if(!(file->f_mode & FMODE_WRITE))
return -EPERM;
if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
return -EFAULT;
if (buf.length > 4096)
return -EINVAL;
if (!mtd->write_oob)
ret = -EOPNOTSUPP;
else
ret = access_ok(VERIFY_READ, buf.ptr,
buf.length) ? 0 : EFAULT;
if (ret) /* NOTE: writes return length to buf_user->length */
return ret; if (copy_from_user(&buf, argp, sizeof(buf)))
ops.ooblen = buf.length;
ops.ooboffs = buf.start & (mtd->oobsize - 1);
ops.datbuf = NULL;
ops.mode = MTD_OOB_PLACE;
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
return -EINVAL;
ops.oobbuf = kmalloc(buf.length, GFP_KERNEL);
if (!ops.oobbuf)
return -ENOMEM;
if (copy_from_user(ops.oobbuf, buf.ptr, buf.length)) {
kfree(ops.oobbuf);
return -EFAULT;
}
buf.start &= ~(mtd->oobsize - 1);
ret = mtd->write_oob(mtd, buf.start, &ops);
if (ops.oobretlen > 0xFFFFFFFFU)
ret = -EOVERFLOW;
retlen = ops.oobretlen;
if (copy_to_user(&user_buf->length, &retlen, sizeof(buf.length)))
ret = -EFAULT; ret = -EFAULT;
else
kfree(ops.oobbuf); ret = mtd_do_writeoob(file, mtd, buf.start, buf.length,
buf.ptr, &buf_user->length);
break; break;
} }
case MEMREADOOB: case MEMREADOOB:
{ {
struct mtd_oob_buf buf; struct mtd_oob_buf buf;
struct mtd_oob_ops ops; struct mtd_oob_buf __user *buf_user = argp;
if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
return -EFAULT;
if (buf.length > 4096)
return -EINVAL;
if (!mtd->read_oob) /* NOTE: writes return length to buf_user->start */
ret = -EOPNOTSUPP; if (copy_from_user(&buf, argp, sizeof(buf)))
ret = -EFAULT;
else else
ret = access_ok(VERIFY_WRITE, buf.ptr, ret = mtd_do_readoob(mtd, buf.start, buf.length,
buf.length) ? 0 : -EFAULT; buf.ptr, &buf_user->start);
if (ret) break;
return ret; }
ops.ooblen = buf.length;
ops.ooboffs = buf.start & (mtd->oobsize - 1);
ops.datbuf = NULL;
ops.mode = MTD_OOB_PLACE;
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) case MEMWRITEOOB64:
return -EINVAL; {
struct mtd_oob_buf64 buf;
struct mtd_oob_buf64 __user *buf_user = argp;
ops.oobbuf = kmalloc(buf.length, GFP_KERNEL); if (copy_from_user(&buf, argp, sizeof(buf)))
if (!ops.oobbuf) ret = -EFAULT;
return -ENOMEM; else
ret = mtd_do_writeoob(file, mtd, buf.start, buf.length,
(void __user *)(uintptr_t)buf.usr_ptr,
&buf_user->length);
break;
}
buf.start &= ~(mtd->oobsize - 1); case MEMREADOOB64:
ret = mtd->read_oob(mtd, buf.start, &ops); {
struct mtd_oob_buf64 buf;
struct mtd_oob_buf64 __user *buf_user = argp;
if (put_user(ops.oobretlen, (uint32_t __user *)argp)) if (copy_from_user(&buf, argp, sizeof(buf)))
ret = -EFAULT;
else if (ops.oobretlen && copy_to_user(buf.ptr, ops.oobbuf,
ops.oobretlen))
ret = -EFAULT; ret = -EFAULT;
else
kfree(ops.oobbuf); ret = mtd_do_readoob(mtd, buf.start, buf.length,
(void __user *)(uintptr_t)buf.usr_ptr,
&buf_user->length);
break; break;
} }
...@@ -758,6 +822,68 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -758,6 +822,68 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
return ret; return ret;
} /* memory_ioctl */ } /* memory_ioctl */
#ifdef CONFIG_COMPAT
struct mtd_oob_buf32 {
u_int32_t start;
u_int32_t length;
compat_caddr_t ptr; /* unsigned char* */
};
#define MEMWRITEOOB32 _IOWR('M', 3, struct mtd_oob_buf32)
#define MEMREADOOB32 _IOWR('M', 4, struct mtd_oob_buf32)
static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
struct inode *inode = file->f_path.dentry->d_inode;
struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd;
void __user *argp = compat_ptr(arg);
int ret = 0;
lock_kernel();
switch (cmd) {
case MEMWRITEOOB32:
{
struct mtd_oob_buf32 buf;
struct mtd_oob_buf32 __user *buf_user = argp;
if (copy_from_user(&buf, argp, sizeof(buf)))
ret = -EFAULT;
else
ret = mtd_do_writeoob(file, mtd, buf.start,
buf.length, compat_ptr(buf.ptr),
&buf_user->length);
break;
}
case MEMREADOOB32:
{
struct mtd_oob_buf32 buf;
struct mtd_oob_buf32 __user *buf_user = argp;
/* NOTE: writes return length to buf->start */
if (copy_from_user(&buf, argp, sizeof(buf)))
ret = -EFAULT;
else
ret = mtd_do_readoob(mtd, buf.start,
buf.length, compat_ptr(buf.ptr),
&buf_user->start);
break;
}
default:
ret = mtd_ioctl(inode, file, cmd, (unsigned long)argp);
}
unlock_kernel();
return ret;
}
#endif /* CONFIG_COMPAT */
/* /*
* try to determine where a shared mapping can be made * try to determine where a shared mapping can be made
* - only supported for NOMMU at the moment (MMU can't doesn't copy private * - only supported for NOMMU at the moment (MMU can't doesn't copy private
...@@ -817,6 +943,9 @@ static const struct file_operations mtd_fops = { ...@@ -817,6 +943,9 @@ static const struct file_operations mtd_fops = {
.read = mtd_read, .read = mtd_read,
.write = mtd_write, .write = mtd_write,
.ioctl = mtd_ioctl, .ioctl = mtd_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mtd_compat_ioctl,
#endif
.open = mtd_open, .open = mtd_open,
.release = mtd_close, .release = mtd_close,
.mmap = mtd_mmap, .mmap = mtd_mmap,
......
...@@ -23,8 +23,15 @@ ...@@ -23,8 +23,15 @@
#include "mtdcore.h" #include "mtdcore.h"
static int mtd_cls_suspend(struct device *dev, pm_message_t state);
static int mtd_cls_resume(struct device *dev);
static struct class *mtd_class; static struct class mtd_class = {
.name = "mtd",
.owner = THIS_MODULE,
.suspend = mtd_cls_suspend,
.resume = mtd_cls_resume,
};
/* These are exported solely for the purpose of mtd_blkdevs.c. You /* These are exported solely for the purpose of mtd_blkdevs.c. You
should not use them for _anything_ else */ should not use them for _anything_ else */
...@@ -52,7 +59,26 @@ static void mtd_release(struct device *dev) ...@@ -52,7 +59,26 @@ static void mtd_release(struct device *dev)
/* remove /dev/mtdXro node if needed */ /* remove /dev/mtdXro node if needed */
if (index) if (index)
device_destroy(mtd_class, index + 1); device_destroy(&mtd_class, index + 1);
}
static int mtd_cls_suspend(struct device *dev, pm_message_t state)
{
struct mtd_info *mtd = dev_to_mtd(dev);
if (mtd->suspend)
return mtd->suspend(mtd);
else
return 0;
}
static int mtd_cls_resume(struct device *dev)
{
struct mtd_info *mtd = dev_to_mtd(dev);
if (mtd->resume)
mtd->resume(mtd);
return 0;
} }
static ssize_t mtd_type_show(struct device *dev, static ssize_t mtd_type_show(struct device *dev,
...@@ -269,7 +295,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -269,7 +295,7 @@ int add_mtd_device(struct mtd_info *mtd)
* physical device. * physical device.
*/ */
mtd->dev.type = &mtd_devtype; mtd->dev.type = &mtd_devtype;
mtd->dev.class = mtd_class; mtd->dev.class = &mtd_class;
mtd->dev.devt = MTD_DEVT(i); mtd->dev.devt = MTD_DEVT(i);
dev_set_name(&mtd->dev, "mtd%d", i); dev_set_name(&mtd->dev, "mtd%d", i);
if (device_register(&mtd->dev) != 0) { if (device_register(&mtd->dev) != 0) {
...@@ -278,7 +304,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -278,7 +304,7 @@ int add_mtd_device(struct mtd_info *mtd)
} }
if (MTD_DEVT(i)) if (MTD_DEVT(i))
device_create(mtd_class, mtd->dev.parent, device_create(&mtd_class, mtd->dev.parent,
MTD_DEVT(i) + 1, MTD_DEVT(i) + 1,
NULL, "mtd%dro", i); NULL, "mtd%dro", i);
...@@ -604,11 +630,12 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count, ...@@ -604,11 +630,12 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count,
static int __init init_mtd(void) static int __init init_mtd(void)
{ {
mtd_class = class_create(THIS_MODULE, "mtd"); int ret;
ret = class_register(&mtd_class);
if (IS_ERR(mtd_class)) { if (ret) {
pr_err("Error creating mtd class.\n"); pr_err("Error registering mtd class: %d\n", ret);
return PTR_ERR(mtd_class); return ret;
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
...@@ -623,7 +650,7 @@ static void __exit cleanup_mtd(void) ...@@ -623,7 +650,7 @@ static void __exit cleanup_mtd(void)
if (proc_mtd) if (proc_mtd)
remove_proc_entry( "mtd", NULL); remove_proc_entry( "mtd", NULL);
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
class_destroy(mtd_class); class_unregister(&mtd_class);
} }
module_init(init_mtd); module_init(init_mtd);
......
...@@ -27,9 +27,7 @@ struct mtd_part { ...@@ -27,9 +27,7 @@ struct mtd_part {
struct mtd_info mtd; struct mtd_info mtd;
struct mtd_info *master; struct mtd_info *master;
uint64_t offset; uint64_t offset;
int index;
struct list_head list; struct list_head list;
int registered;
}; };
/* /*
...@@ -321,7 +319,6 @@ int del_mtd_partitions(struct mtd_info *master) ...@@ -321,7 +319,6 @@ int del_mtd_partitions(struct mtd_info *master)
list_for_each_entry_safe(slave, next, &mtd_partitions, list) list_for_each_entry_safe(slave, next, &mtd_partitions, list)
if (slave->master == master) { if (slave->master == master) {
list_del(&slave->list); list_del(&slave->list);
if (slave->registered)
del_mtd_device(&slave->mtd); del_mtd_device(&slave->mtd);
kfree(slave); kfree(slave);
} }
...@@ -395,7 +392,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, ...@@ -395,7 +392,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
slave->mtd.get_fact_prot_info = part_get_fact_prot_info; slave->mtd.get_fact_prot_info = part_get_fact_prot_info;
if (master->sync) if (master->sync)
slave->mtd.sync = part_sync; slave->mtd.sync = part_sync;
if (!partno && master->suspend && master->resume) { if (!partno && !master->dev.class && master->suspend && master->resume) {
slave->mtd.suspend = part_suspend; slave->mtd.suspend = part_suspend;
slave->mtd.resume = part_resume; slave->mtd.resume = part_resume;
} }
...@@ -412,7 +409,6 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, ...@@ -412,7 +409,6 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
slave->mtd.erase = part_erase; slave->mtd.erase = part_erase;
slave->master = master; slave->master = master;
slave->offset = part->offset; slave->offset = part->offset;
slave->index = partno;
if (slave->offset == MTDPART_OFS_APPEND) if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset; slave->offset = cur_offset;
...@@ -500,15 +496,9 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, ...@@ -500,15 +496,9 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
} }
out_register: out_register:
if (part->mtdp) {
/* store the object pointer (caller may or may not register it*/
*part->mtdp = &slave->mtd;
slave->registered = 0;
} else {
/* register our partition */ /* register our partition */
add_mtd_device(&slave->mtd); add_mtd_device(&slave->mtd);
slave->registered = 1;
}
return slave; return slave;
} }
......
...@@ -74,6 +74,12 @@ config MTD_NAND_AMS_DELTA ...@@ -74,6 +74,12 @@ config MTD_NAND_AMS_DELTA
help help
Support for NAND flash on Amstrad E3 (Delta). Support for NAND flash on Amstrad E3 (Delta).
config MTD_NAND_OMAP2
tristate "NAND Flash device on OMAP2 and OMAP3"
depends on ARM && MTD_NAND && (ARCH_OMAP2 || ARCH_OMAP3)
help
Support for NAND flash on Texas Instruments OMAP2 and OMAP3 platforms.
config MTD_NAND_TS7250 config MTD_NAND_TS7250
tristate "NAND Flash device on TS-7250 board" tristate "NAND Flash device on TS-7250 board"
depends on MACH_TS72XX depends on MACH_TS72XX
...@@ -139,27 +145,27 @@ config MTD_NAND_PPCHAMELEONEVB ...@@ -139,27 +145,27 @@ config MTD_NAND_PPCHAMELEONEVB
This enables the NAND flash driver on the PPChameleon EVB Board. This enables the NAND flash driver on the PPChameleon EVB Board.
config MTD_NAND_S3C2410 config MTD_NAND_S3C2410
tristate "NAND Flash support for S3C2410/S3C2440 SoC" tristate "NAND Flash support for Samsung S3C SoCs"
depends on ARCH_S3C2410 depends on ARCH_S3C2410 || ARCH_S3C64XX
help help
This enables the NAND flash controller on the S3C2410 and S3C2440 This enables the NAND flash controller on the S3C24xx and S3C64xx
SoCs SoCs
No board specific support is done by this driver, each board No board specific support is done by this driver, each board
must advertise a platform_device for the driver to attach. must advertise a platform_device for the driver to attach.
config MTD_NAND_S3C2410_DEBUG config MTD_NAND_S3C2410_DEBUG
bool "S3C2410 NAND driver debug" bool "Samsung S3C NAND driver debug"
depends on MTD_NAND_S3C2410 depends on MTD_NAND_S3C2410
help help
Enable debugging of the S3C2410 NAND driver Enable debugging of the S3C NAND driver
config MTD_NAND_S3C2410_HWECC config MTD_NAND_S3C2410_HWECC
bool "S3C2410 NAND Hardware ECC" bool "Samsung S3C NAND Hardware ECC"
depends on MTD_NAND_S3C2410 depends on MTD_NAND_S3C2410
help help
Enable the use of the S3C2410's internal ECC generator when Enable the use of the controller's internal ECC generator when
using NAND. Early versions of the chip have had problems with using NAND. Early versions of the chips have had problems with
incorrect ECC generation, and if using these, the default of incorrect ECC generation, and if using these, the default of
software ECC is preferable. software ECC is preferable.
...@@ -171,7 +177,7 @@ config MTD_NAND_NDFC ...@@ -171,7 +177,7 @@ config MTD_NAND_NDFC
NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
config MTD_NAND_S3C2410_CLKSTOP config MTD_NAND_S3C2410_CLKSTOP
bool "S3C2410 NAND IDLE clock stop" bool "Samsung S3C NAND IDLE clock stop"
depends on MTD_NAND_S3C2410 depends on MTD_NAND_S3C2410
default n default n
help help
......
...@@ -25,6 +25,7 @@ obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o ...@@ -25,6 +25,7 @@ obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o
obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o
obj-$(CONFIG_MTD_NAND_ATMEL) += atmel_nand.o obj-$(CONFIG_MTD_NAND_ATMEL) += atmel_nand.o
obj-$(CONFIG_MTD_NAND_GPIO) += gpio.o obj-$(CONFIG_MTD_NAND_GPIO) += gpio.o
obj-$(CONFIG_MTD_NAND_OMAP2) += omap2.o
obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o
obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
...@@ -47,6 +48,9 @@ ...@@ -47,6 +48,9 @@
#define no_ecc 0 #define no_ecc 0
#endif #endif
static int on_flash_bbt = 0;
module_param(on_flash_bbt, int, 0);
/* Register access macros */ /* Register access macros */
#define ecc_readl(add, reg) \ #define ecc_readl(add, reg) \
__raw_readl(add + ATMEL_ECC_##reg) __raw_readl(add + ATMEL_ECC_##reg)
...@@ -459,12 +463,17 @@ static int __init atmel_nand_probe(struct platform_device *pdev) ...@@ -459,12 +463,17 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
if (host->board->det_pin) { if (host->board->det_pin) {
if (gpio_get_value(host->board->det_pin)) { if (gpio_get_value(host->board->det_pin)) {
printk("No SmartMedia card inserted.\n"); printk(KERN_INFO "No SmartMedia card inserted.\n");
res = ENXIO; res = ENXIO;
goto err_no_card; goto err_no_card;
} }
} }
if (on_flash_bbt) {
printk(KERN_INFO "atmel_nand: Use On Flash BBT\n");
nand_chip->options |= NAND_USE_FLASH_BBT;
}
/* first scan to find the device and get the page size */ /* first scan to find the device and get the page size */
if (nand_scan_ident(mtd, 1)) { if (nand_scan_ident(mtd, 1)) {
res = -ENXIO; res = -ENXIO;
......
...@@ -458,7 +458,7 @@ static irqreturn_t bf5xx_nand_dma_irq(int irq, void *dev_id) ...@@ -458,7 +458,7 @@ static irqreturn_t bf5xx_nand_dma_irq(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int bf5xx_nand_dma_rw(struct mtd_info *mtd, static void bf5xx_nand_dma_rw(struct mtd_info *mtd,
uint8_t *buf, int is_read) uint8_t *buf, int is_read)
{ {
struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);
...@@ -496,11 +496,20 @@ static int bf5xx_nand_dma_rw(struct mtd_info *mtd, ...@@ -496,11 +496,20 @@ static int bf5xx_nand_dma_rw(struct mtd_info *mtd,
/* setup DMA register with Blackfin DMA API */ /* setup DMA register with Blackfin DMA API */
set_dma_config(CH_NFC, 0x0); set_dma_config(CH_NFC, 0x0);
set_dma_start_addr(CH_NFC, (unsigned long) buf); set_dma_start_addr(CH_NFC, (unsigned long) buf);
/* The DMAs have different size on BF52x and BF54x */
#ifdef CONFIG_BF52x
set_dma_x_count(CH_NFC, (page_size >> 1));
set_dma_x_modify(CH_NFC, 2);
val = DI_EN | WDSIZE_16;
#endif
#ifdef CONFIG_BF54x
set_dma_x_count(CH_NFC, (page_size >> 2)); set_dma_x_count(CH_NFC, (page_size >> 2));
set_dma_x_modify(CH_NFC, 4); set_dma_x_modify(CH_NFC, 4);
/* setup write or read operation */
val = DI_EN | WDSIZE_32; val = DI_EN | WDSIZE_32;
#endif
/* setup write or read operation */
if (is_read) if (is_read)
val |= WNR; val |= WNR;
set_dma_config(CH_NFC, val); set_dma_config(CH_NFC, val);
...@@ -512,8 +521,6 @@ static int bf5xx_nand_dma_rw(struct mtd_info *mtd, ...@@ -512,8 +521,6 @@ static int bf5xx_nand_dma_rw(struct mtd_info *mtd,
else else
bfin_write_NFC_PGCTL(0x2); bfin_write_NFC_PGCTL(0x2);
wait_for_completion(&info->dma_completion); wait_for_completion(&info->dma_completion);
return 0;
} }
static void bf5xx_nand_dma_read_buf(struct mtd_info *mtd, static void bf5xx_nand_dma_read_buf(struct mtd_info *mtd,
......
This diff is collapsed.
...@@ -138,7 +138,14 @@ static struct nand_ecclayout nand_hw_eccoob_8 = { ...@@ -138,7 +138,14 @@ static struct nand_ecclayout nand_hw_eccoob_8 = {
static struct nand_ecclayout nand_hw_eccoob_16 = { static struct nand_ecclayout nand_hw_eccoob_16 = {
.eccbytes = 5, .eccbytes = 5,
.eccpos = {6, 7, 8, 9, 10}, .eccpos = {6, 7, 8, 9, 10},
.oobfree = {{0, 6}, {12, 4}, } .oobfree = {{0, 5}, {11, 5}, }
};
static struct nand_ecclayout nand_hw_eccoob_64 = {
.eccbytes = 20,
.eccpos = {6, 7, 8, 9, 10, 22, 23, 24, 25, 26,
38, 39, 40, 41, 42, 54, 55, 56, 57, 58},
.oobfree = {{2, 4}, {11, 10}, {27, 10}, {43, 10}, {59, 5}, }
}; };
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
...@@ -192,7 +199,7 @@ static void wait_op_done(struct mxc_nand_host *host, int max_retries, ...@@ -192,7 +199,7 @@ static void wait_op_done(struct mxc_nand_host *host, int max_retries,
} }
udelay(1); udelay(1);
} }
if (max_retries <= 0) if (max_retries < 0)
DEBUG(MTD_DEBUG_LEVEL0, "%s(%d): INT not set\n", DEBUG(MTD_DEBUG_LEVEL0, "%s(%d): INT not set\n",
__func__, param); __func__, param);
} }
...@@ -795,9 +802,13 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, ...@@ -795,9 +802,13 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
send_addr(host, (page_addr & 0xff), false); send_addr(host, (page_addr & 0xff), false);
if (host->pagesize_2k) { if (host->pagesize_2k) {
send_addr(host, (page_addr >> 8) & 0xFF, false); if (mtd->size >= 0x10000000) {
if (mtd->size >= 0x40000000) /* paddr_8 - paddr_15 */
send_addr(host, (page_addr >> 8) & 0xff, false);
send_addr(host, (page_addr >> 16) & 0xff, true); send_addr(host, (page_addr >> 16) & 0xff, true);
} else
/* paddr_8 - paddr_15 */
send_addr(host, (page_addr >> 8) & 0xff, true);
} else { } else {
/* One more address cycle for higher density devices */ /* One more address cycle for higher density devices */
if (mtd->size >= 0x4000000) { if (mtd->size >= 0x4000000) {
...@@ -923,7 +934,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) ...@@ -923,7 +934,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->ecc.mode = NAND_ECC_HW; this->ecc.mode = NAND_ECC_HW;
this->ecc.size = 512; this->ecc.size = 512;
this->ecc.bytes = 3; this->ecc.bytes = 3;
this->ecc.layout = &nand_hw_eccoob_8;
tmp = readw(host->regs + NFC_CONFIG1); tmp = readw(host->regs + NFC_CONFIG1);
tmp |= NFC_ECC_EN; tmp |= NFC_ECC_EN;
writew(tmp, host->regs + NFC_CONFIG1); writew(tmp, host->regs + NFC_CONFIG1);
...@@ -957,12 +967,44 @@ static int __init mxcnd_probe(struct platform_device *pdev) ...@@ -957,12 +967,44 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->ecc.layout = &nand_hw_eccoob_16; this->ecc.layout = &nand_hw_eccoob_16;
} }
host->pagesize_2k = 0; /* first scan to find the device and get the page size */
if (nand_scan_ident(mtd, 1)) {
err = -ENXIO;
goto escan;
}
host->pagesize_2k = (mtd->writesize == 2048) ? 1 : 0;
/* Scan to find existence of the device */ if (this->ecc.mode == NAND_ECC_HW) {
if (nand_scan(mtd, 1)) { switch (mtd->oobsize) {
DEBUG(MTD_DEBUG_LEVEL0, case 8:
"MXC_ND: Unable to find any NAND device.\n"); this->ecc.layout = &nand_hw_eccoob_8;
break;
case 16:
this->ecc.layout = &nand_hw_eccoob_16;
break;
case 64:
this->ecc.layout = &nand_hw_eccoob_64;
break;
default:
/* page size not handled by HW ECC */
/* switching back to soft ECC */
this->ecc.size = 512;
this->ecc.bytes = 3;
this->ecc.layout = &nand_hw_eccoob_8;
this->ecc.mode = NAND_ECC_SOFT;
this->ecc.calculate = NULL;
this->ecc.correct = NULL;
this->ecc.hwctl = NULL;
tmp = readw(host->regs + NFC_CONFIG1);
tmp &= ~NFC_ECC_EN;
writew(tmp, host->regs + NFC_CONFIG1);
break;
}
}
/* second phase scan */
if (nand_scan_tail(mtd)) {
err = -ENXIO; err = -ENXIO;
goto escan; goto escan;
} }
...@@ -985,7 +1027,7 @@ static int __init mxcnd_probe(struct platform_device *pdev) ...@@ -985,7 +1027,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
return 0; return 0;
escan: escan:
free_irq(host->irq, NULL); free_irq(host->irq, host);
eirq: eirq:
iounmap(host->regs); iounmap(host->regs);
eres: eres:
...@@ -1005,7 +1047,7 @@ static int __devexit mxcnd_remove(struct platform_device *pdev) ...@@ -1005,7 +1047,7 @@ static int __devexit mxcnd_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
nand_release(&host->mtd); nand_release(&host->mtd);
free_irq(host->irq, NULL); free_irq(host->irq, host);
iounmap(host->regs); iounmap(host->regs);
kfree(host); kfree(host);
......
...@@ -2756,7 +2756,8 @@ int nand_scan_tail(struct mtd_info *mtd) ...@@ -2756,7 +2756,8 @@ int nand_scan_tail(struct mtd_info *mtd)
* the out of band area * the out of band area
*/ */
chip->ecc.layout->oobavail = 0; chip->ecc.layout->oobavail = 0;
for (i = 0; chip->ecc.layout->oobfree[i].length; i++) for (i = 0; chip->ecc.layout->oobfree[i].length
&& i < ARRAY_SIZE(chip->ecc.layout->oobfree); i++)
chip->ecc.layout->oobavail += chip->ecc.layout->oobavail +=
chip->ecc.layout->oobfree[i].length; chip->ecc.layout->oobfree[i].length;
mtd->oobavail = chip->ecc.layout->oobavail; mtd->oobavail = chip->ecc.layout->oobavail;
......
...@@ -428,8 +428,8 @@ EXPORT_SYMBOL(nand_calculate_ecc); ...@@ -428,8 +428,8 @@ EXPORT_SYMBOL(nand_calculate_ecc);
int nand_correct_data(struct mtd_info *mtd, unsigned char *buf, int nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
unsigned char *read_ecc, unsigned char *calc_ecc) unsigned char *read_ecc, unsigned char *calc_ecc)
{ {
unsigned char b0, b1, b2; unsigned char b0, b1, b2, bit_addr;
unsigned char byte_addr, bit_addr; unsigned int byte_addr;
/* 256 or 512 bytes/ecc */ /* 256 or 512 bytes/ecc */
const uint32_t eccsize_mult = const uint32_t eccsize_mult =
(((struct nand_chip *)mtd->priv)->ecc.size) >> 8; (((struct nand_chip *)mtd->priv)->ecc.size) >> 8;
......
This diff is collapsed.
...@@ -47,6 +47,28 @@ static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl ...@@ -47,6 +47,28 @@ static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl
writeb(cmd, nc->IO_ADDR_W + offs); writeb(cmd, nc->IO_ADDR_W + offs);
} }
static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
{
struct nand_chip *chip = mtd->priv;
void __iomem *io_base = chip->IO_ADDR_R;
uint64_t *buf64;
int i = 0;
while (len && (unsigned long)buf & 7) {
*buf++ = readb(io_base);
len--;
}
buf64 = (uint64_t *)buf;
while (i < len/8) {
uint64_t x;
asm ("ldrd\t%0, [%1]" : "=r" (x) : "r" (io_base));
buf64[i++] = x;
}
i *= 8;
while (i < len)
buf[i++] = readb(io_base);
}
static int __init orion_nand_probe(struct platform_device *pdev) static int __init orion_nand_probe(struct platform_device *pdev)
{ {
struct mtd_info *mtd; struct mtd_info *mtd;
...@@ -83,6 +105,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -83,6 +105,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
nc->priv = board; nc->priv = board;
nc->IO_ADDR_R = nc->IO_ADDR_W = io_base; nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
nc->cmd_ctrl = orion_nand_cmd_ctrl; nc->cmd_ctrl = orion_nand_cmd_ctrl;
nc->read_buf = orion_nand_read_buf;
nc->ecc.mode = NAND_ECC_SOFT; nc->ecc.mode = NAND_ECC_SOFT;
if (board->chip_delay) if (board->chip_delay)
......
...@@ -61,6 +61,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) ...@@ -61,6 +61,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl; data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl;
data->chip.dev_ready = pdata->ctrl.dev_ready; data->chip.dev_ready = pdata->ctrl.dev_ready;
data->chip.select_chip = pdata->ctrl.select_chip; data->chip.select_chip = pdata->ctrl.select_chip;
data->chip.write_buf = pdata->ctrl.write_buf;
data->chip.read_buf = pdata->ctrl.read_buf;
data->chip.chip_delay = pdata->chip.chip_delay; data->chip.chip_delay = pdata->chip.chip_delay;
data->chip.options |= pdata->chip.options; data->chip.options |= pdata->chip.options;
...@@ -70,6 +72,13 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) ...@@ -70,6 +72,13 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
/* Handle any platform specific setup */
if (pdata->ctrl.probe) {
res = pdata->ctrl.probe(pdev);
if (res)
goto out;
}
/* Scan to find existance of the device */ /* Scan to find existance of the device */
if (nand_scan(&data->mtd, 1)) { if (nand_scan(&data->mtd, 1)) {
res = -ENXIO; res = -ENXIO;
...@@ -86,6 +95,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) ...@@ -86,6 +95,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
return 0; return 0;
} }
} }
if (pdata->chip.set_parts)
pdata->chip.set_parts(data->mtd.size, &pdata->chip);
if (pdata->chip.partitions) { if (pdata->chip.partitions) {
data->parts = pdata->chip.partitions; data->parts = pdata->chip.partitions;
res = add_mtd_partitions(&data->mtd, data->parts, res = add_mtd_partitions(&data->mtd, data->parts,
...@@ -99,6 +110,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) ...@@ -99,6 +110,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
nand_release(&data->mtd); nand_release(&data->mtd);
out: out:
if (pdata->ctrl.remove)
pdata->ctrl.remove(pdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
iounmap(data->io_base); iounmap(data->io_base);
kfree(data); kfree(data);
...@@ -111,15 +124,15 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) ...@@ -111,15 +124,15 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
static int __devexit plat_nand_remove(struct platform_device *pdev) static int __devexit plat_nand_remove(struct platform_device *pdev)
{ {
struct plat_nand_data *data = platform_get_drvdata(pdev); struct plat_nand_data *data = platform_get_drvdata(pdev);
#ifdef CONFIG_MTD_PARTITIONS
struct platform_nand_data *pdata = pdev->dev.platform_data; struct platform_nand_data *pdata = pdev->dev.platform_data;
#endif
nand_release(&data->mtd); nand_release(&data->mtd);
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
if (data->parts && data->parts != pdata->chip.partitions) if (data->parts && data->parts != pdata->chip.partitions)
kfree(data->parts); kfree(data->parts);
#endif #endif
if (pdata->ctrl.remove)
pdata->ctrl.remove(pdev);
iounmap(data->io_base); iounmap(data->io_base);
kfree(data); kfree(data);
...@@ -128,7 +141,7 @@ static int __devexit plat_nand_remove(struct platform_device *pdev) ...@@ -128,7 +141,7 @@ static int __devexit plat_nand_remove(struct platform_device *pdev)
static struct platform_driver plat_nand_driver = { static struct platform_driver plat_nand_driver = {
.probe = plat_nand_probe, .probe = plat_nand_probe,
.remove = plat_nand_remove, .remove = __devexit_p(plat_nand_remove),
.driver = { .driver = {
.name = "gen_nand", .name = "gen_nand",
.owner = THIS_MODULE, .owner = THIS_MODULE,
......
This diff is collapsed.
...@@ -64,7 +64,7 @@ struct txx9ndfmc_priv { ...@@ -64,7 +64,7 @@ struct txx9ndfmc_priv {
struct nand_chip chip; struct nand_chip chip;
struct mtd_info mtd; struct mtd_info mtd;
int cs; int cs;
char mtdname[BUS_ID_SIZE + 2]; const char *mtdname;
}; };
#define MAX_TXX9NDFMC_DEV 4 #define MAX_TXX9NDFMC_DEV 4
...@@ -334,16 +334,23 @@ static int __init txx9ndfmc_probe(struct platform_device *dev) ...@@ -334,16 +334,23 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
if (plat->ch_mask != 1) { if (plat->ch_mask != 1) {
txx9_priv->cs = i; txx9_priv->cs = i;
sprintf(txx9_priv->mtdname, "%s.%u", txx9_priv->mtdname = kasprintf(GFP_KERNEL, "%s.%u",
dev_name(&dev->dev), i); dev_name(&dev->dev), i);
} else { } else {
txx9_priv->cs = -1; txx9_priv->cs = -1;
strcpy(txx9_priv->mtdname, dev_name(&dev->dev)); txx9_priv->mtdname = kstrdup(dev_name(&dev->dev),
GFP_KERNEL);
}
if (!txx9_priv->mtdname) {
kfree(txx9_priv);
dev_err(&dev->dev, "Unable to allocate MTD name.\n");
continue;
} }
if (plat->wide_mask & (1 << i)) if (plat->wide_mask & (1 << i))
chip->options |= NAND_BUSWIDTH_16; chip->options |= NAND_BUSWIDTH_16;
if (nand_scan(mtd, 1)) { if (nand_scan(mtd, 1)) {
kfree(txx9_priv->mtdname);
kfree(txx9_priv); kfree(txx9_priv);
continue; continue;
} }
...@@ -385,6 +392,7 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev) ...@@ -385,6 +392,7 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev)
kfree(drvdata->parts[i]); kfree(drvdata->parts[i]);
#endif #endif
del_mtd_device(mtd); del_mtd_device(mtd);
kfree(txx9_priv->mtdname);
kfree(txx9_priv); kfree(txx9_priv);
} }
return 0; return 0;
......
...@@ -565,7 +565,7 @@ int omap2_onenand_rephase(void) ...@@ -565,7 +565,7 @@ int omap2_onenand_rephase(void)
NULL, __adjust_timing); NULL, __adjust_timing);
} }
static void __devexit omap2_onenand_shutdown(struct platform_device *pdev) static void omap2_onenand_shutdown(struct platform_device *pdev)
{ {
struct omap2_onenand *c = dev_get_drvdata(&pdev->dev); struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
...@@ -777,7 +777,7 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev) ...@@ -777,7 +777,7 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
static struct platform_driver omap2_onenand_driver = { static struct platform_driver omap2_onenand_driver = {
.probe = omap2_onenand_probe, .probe = omap2_onenand_probe,
.remove = omap2_onenand_remove, .remove = __devexit_p(omap2_onenand_remove),
.shutdown = omap2_onenand_shutdown, .shutdown = omap2_onenand_shutdown,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
......
This diff is collapsed.
...@@ -63,6 +63,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -63,6 +63,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
loff_t from; loff_t from;
size_t readlen, ooblen; size_t readlen, ooblen;
struct mtd_oob_ops ops; struct mtd_oob_ops ops;
int rgn;
printk(KERN_INFO "Scanning device for bad blocks\n"); printk(KERN_INFO "Scanning device for bad blocks\n");
...@@ -76,7 +77,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -76,7 +77,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
/* Note that numblocks is 2 * (real numblocks) here; /* Note that numblocks is 2 * (real numblocks) here;
* see i += 2 below as it makses shifting and masking less painful * see i += 2 below as it makses shifting and masking less painful
*/ */
numblocks = mtd->size >> (bbm->bbt_erase_shift - 1); numblocks = this->chipsize >> (bbm->bbt_erase_shift - 1);
startblock = 0; startblock = 0;
from = 0; from = 0;
...@@ -106,6 +107,11 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -106,6 +107,11 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
} }
} }
i += 2; i += 2;
if (FLEXONENAND(this)) {
rgn = flexonenand_region(mtd, from);
from += mtd->eraseregions[rgn].erasesize;
} else
from += (1 << bbm->bbt_erase_shift); from += (1 << bbm->bbt_erase_shift);
} }
...@@ -143,7 +149,7 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) ...@@ -143,7 +149,7 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
uint8_t res; uint8_t res;
/* Get block number * 2 */ /* Get block number * 2 */
block = (int) (offs >> (bbm->bbt_erase_shift - 1)); block = (int) (onenand_block(this, offs) << 1);
res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03; res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03;
DEBUG(MTD_DEBUG_LEVEL2, "onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n", DEBUG(MTD_DEBUG_LEVEL2, "onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
...@@ -178,7 +184,7 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) ...@@ -178,7 +184,7 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
struct bbm_info *bbm = this->bbm; struct bbm_info *bbm = this->bbm;
int len, ret = 0; int len, ret = 0;
len = mtd->size >> (this->erase_shift + 2); len = this->chipsize >> (this->erase_shift + 2);
/* Allocate memory (2bit per block) and clear the memory bad block table */ /* Allocate memory (2bit per block) and clear the memory bad block table */
bbm->bbt = kzalloc(len, GFP_KERNEL); bbm->bbt = kzalloc(len, GFP_KERNEL);
if (!bbm->bbt) { if (!bbm->bbt) {
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
* Copyright © 2005-2007 Samsung Electronics * Copyright © 2005-2007 Samsung Electronics
* Kyungmin Park <kyungmin.park@samsung.com> * Kyungmin Park <kyungmin.park@samsung.com>
* *
* Vishak G <vishak.g at samsung.com>, Rohit Hagargundgi <h.rohit at samsung.com>
* Flex-OneNAND simulator support
* Copyright (C) Samsung Electronics, 2008
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
...@@ -24,16 +28,38 @@ ...@@ -24,16 +28,38 @@
#ifndef CONFIG_ONENAND_SIM_MANUFACTURER #ifndef CONFIG_ONENAND_SIM_MANUFACTURER
#define CONFIG_ONENAND_SIM_MANUFACTURER 0xec #define CONFIG_ONENAND_SIM_MANUFACTURER 0xec
#endif #endif
#ifndef CONFIG_ONENAND_SIM_DEVICE_ID #ifndef CONFIG_ONENAND_SIM_DEVICE_ID
#define CONFIG_ONENAND_SIM_DEVICE_ID 0x04 #define CONFIG_ONENAND_SIM_DEVICE_ID 0x04
#endif #endif
#define CONFIG_FLEXONENAND ((CONFIG_ONENAND_SIM_DEVICE_ID >> 9) & 1)
#ifndef CONFIG_ONENAND_SIM_VERSION_ID #ifndef CONFIG_ONENAND_SIM_VERSION_ID
#define CONFIG_ONENAND_SIM_VERSION_ID 0x1e #define CONFIG_ONENAND_SIM_VERSION_ID 0x1e
#endif #endif
#ifndef CONFIG_ONENAND_SIM_TECHNOLOGY_ID
#define CONFIG_ONENAND_SIM_TECHNOLOGY_ID CONFIG_FLEXONENAND
#endif
/* Initial boundary values for Flex-OneNAND Simulator */
#ifndef CONFIG_FLEXONENAND_SIM_DIE0_BOUNDARY
#define CONFIG_FLEXONENAND_SIM_DIE0_BOUNDARY 0x01
#endif
#ifndef CONFIG_FLEXONENAND_SIM_DIE1_BOUNDARY
#define CONFIG_FLEXONENAND_SIM_DIE1_BOUNDARY 0x01
#endif
static int manuf_id = CONFIG_ONENAND_SIM_MANUFACTURER; static int manuf_id = CONFIG_ONENAND_SIM_MANUFACTURER;
static int device_id = CONFIG_ONENAND_SIM_DEVICE_ID; static int device_id = CONFIG_ONENAND_SIM_DEVICE_ID;
static int version_id = CONFIG_ONENAND_SIM_VERSION_ID; static int version_id = CONFIG_ONENAND_SIM_VERSION_ID;
static int technology_id = CONFIG_ONENAND_SIM_TECHNOLOGY_ID;
static int boundary[] = {
CONFIG_FLEXONENAND_SIM_DIE0_BOUNDARY,
CONFIG_FLEXONENAND_SIM_DIE1_BOUNDARY,
};
struct onenand_flash { struct onenand_flash {
void __iomem *base; void __iomem *base;
...@@ -57,12 +83,18 @@ struct onenand_flash { ...@@ -57,12 +83,18 @@ struct onenand_flash {
(writew(v, this->base + ONENAND_REG_WP_STATUS)) (writew(v, this->base + ONENAND_REG_WP_STATUS))
/* It has all 0xff chars */ /* It has all 0xff chars */
#define MAX_ONENAND_PAGESIZE (2048 + 64) #define MAX_ONENAND_PAGESIZE (4096 + 128)
static unsigned char *ffchars; static unsigned char *ffchars;
#if CONFIG_FLEXONENAND
#define PARTITION_NAME "Flex-OneNAND simulator partition"
#else
#define PARTITION_NAME "OneNAND simulator partition"
#endif
static struct mtd_partition os_partitions[] = { static struct mtd_partition os_partitions[] = {
{ {
.name = "OneNAND simulator partition", .name = PARTITION_NAME,
.offset = 0, .offset = 0,
.size = MTDPART_SIZ_FULL, .size = MTDPART_SIZ_FULL,
}, },
...@@ -104,6 +136,7 @@ static void onenand_lock_handle(struct onenand_chip *this, int cmd) ...@@ -104,6 +136,7 @@ static void onenand_lock_handle(struct onenand_chip *this, int cmd)
switch (cmd) { switch (cmd) {
case ONENAND_CMD_UNLOCK: case ONENAND_CMD_UNLOCK:
case ONENAND_CMD_UNLOCK_ALL:
if (block_lock_scheme) if (block_lock_scheme)
ONENAND_SET_WP_STATUS(ONENAND_WP_US, this); ONENAND_SET_WP_STATUS(ONENAND_WP_US, this);
else else
...@@ -228,10 +261,12 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd, ...@@ -228,10 +261,12 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd,
{ {
struct mtd_info *mtd = &info->mtd; struct mtd_info *mtd = &info->mtd;
struct onenand_flash *flash = this->priv; struct onenand_flash *flash = this->priv;
int main_offset, spare_offset; int main_offset, spare_offset, die = 0;
void __iomem *src; void __iomem *src;
void __iomem *dest; void __iomem *dest;
unsigned int i; unsigned int i;
static int pi_operation;
int erasesize, rgn;
if (dataram) { if (dataram) {
main_offset = mtd->writesize; main_offset = mtd->writesize;
...@@ -241,10 +276,27 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd, ...@@ -241,10 +276,27 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd,
spare_offset = 0; spare_offset = 0;
} }
if (pi_operation) {
die = readw(this->base + ONENAND_REG_START_ADDRESS2);
die >>= ONENAND_DDP_SHIFT;
}
switch (cmd) { switch (cmd) {
case FLEXONENAND_CMD_PI_ACCESS:
pi_operation = 1;
break;
case ONENAND_CMD_RESET:
pi_operation = 0;
break;
case ONENAND_CMD_READ: case ONENAND_CMD_READ:
src = ONENAND_CORE(flash) + offset; src = ONENAND_CORE(flash) + offset;
dest = ONENAND_MAIN_AREA(this, main_offset); dest = ONENAND_MAIN_AREA(this, main_offset);
if (pi_operation) {
writew(boundary[die], this->base + ONENAND_DATARAM);
break;
}
memcpy(dest, src, mtd->writesize); memcpy(dest, src, mtd->writesize);
/* Fall through */ /* Fall through */
...@@ -257,6 +309,10 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd, ...@@ -257,6 +309,10 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd,
case ONENAND_CMD_PROG: case ONENAND_CMD_PROG:
src = ONENAND_MAIN_AREA(this, main_offset); src = ONENAND_MAIN_AREA(this, main_offset);
dest = ONENAND_CORE(flash) + offset; dest = ONENAND_CORE(flash) + offset;
if (pi_operation) {
boundary[die] = readw(this->base + ONENAND_DATARAM);
break;
}
/* To handle partial write */ /* To handle partial write */
for (i = 0; i < (1 << mtd->subpage_sft); i++) { for (i = 0; i < (1 << mtd->subpage_sft); i++) {
int off = i * this->subpagesize; int off = i * this->subpagesize;
...@@ -284,9 +340,18 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd, ...@@ -284,9 +340,18 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd,
break; break;
case ONENAND_CMD_ERASE: case ONENAND_CMD_ERASE:
memset(ONENAND_CORE(flash) + offset, 0xff, mtd->erasesize); if (pi_operation)
break;
if (FLEXONENAND(this)) {
rgn = flexonenand_region(mtd, offset);
erasesize = mtd->eraseregions[rgn].erasesize;
} else
erasesize = mtd->erasesize;
memset(ONENAND_CORE(flash) + offset, 0xff, erasesize);
memset(ONENAND_CORE_SPARE(flash, this, offset), 0xff, memset(ONENAND_CORE_SPARE(flash, this, offset), 0xff,
(mtd->erasesize >> 5)); (erasesize >> 5));
break; break;
default: default:
...@@ -339,7 +404,7 @@ static void onenand_command_handle(struct onenand_chip *this, int cmd) ...@@ -339,7 +404,7 @@ static void onenand_command_handle(struct onenand_chip *this, int cmd)
} }
if (block != -1) if (block != -1)
offset += block << this->erase_shift; offset = onenand_addr(this, block);
if (page != -1) if (page != -1)
offset += page << this->page_shift; offset += page << this->page_shift;
...@@ -390,6 +455,7 @@ static int __init flash_init(struct onenand_flash *flash) ...@@ -390,6 +455,7 @@ static int __init flash_init(struct onenand_flash *flash)
} }
density = device_id >> ONENAND_DEVICE_DENSITY_SHIFT; density = device_id >> ONENAND_DEVICE_DENSITY_SHIFT;
density &= ONENAND_DEVICE_DENSITY_MASK;
size = ((16 << 20) << density); size = ((16 << 20) << density);
ONENAND_CORE(flash) = vmalloc(size + (size >> 5)); ONENAND_CORE(flash) = vmalloc(size + (size >> 5));
...@@ -405,8 +471,9 @@ static int __init flash_init(struct onenand_flash *flash) ...@@ -405,8 +471,9 @@ static int __init flash_init(struct onenand_flash *flash)
writew(manuf_id, flash->base + ONENAND_REG_MANUFACTURER_ID); writew(manuf_id, flash->base + ONENAND_REG_MANUFACTURER_ID);
writew(device_id, flash->base + ONENAND_REG_DEVICE_ID); writew(device_id, flash->base + ONENAND_REG_DEVICE_ID);
writew(version_id, flash->base + ONENAND_REG_VERSION_ID); writew(version_id, flash->base + ONENAND_REG_VERSION_ID);
writew(technology_id, flash->base + ONENAND_REG_TECHNOLOGY);
if (density < 2) if (density < 2 && (!CONFIG_FLEXONENAND))
buffer_size = 0x0400; /* 1KiB page */ buffer_size = 0x0400; /* 1KiB page */
else else
buffer_size = 0x0800; /* 2KiB page */ buffer_size = 0x0800; /* 2KiB page */
......
...@@ -94,7 +94,6 @@ ...@@ -94,7 +94,6 @@
#include <linux/atm_tcp.h> #include <linux/atm_tcp.h>
#include <linux/sonet.h> #include <linux/sonet.h>
#include <linux/atm_suni.h> #include <linux/atm_suni.h>
#include <linux/mtd/mtd.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usbdevice_fs.h> #include <linux/usbdevice_fs.h>
...@@ -1405,46 +1404,6 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) ...@@ -1405,46 +1404,6 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
#define HIDPGETCONNLIST _IOR('H', 210, int) #define HIDPGETCONNLIST _IOR('H', 210, int)
#define HIDPGETCONNINFO _IOR('H', 211, int) #define HIDPGETCONNINFO _IOR('H', 211, int)
struct mtd_oob_buf32 {
u_int32_t start;
u_int32_t length;
compat_caddr_t ptr; /* unsigned char* */
};
#define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
#define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
{
struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
u32 data;
char __user *datap;
unsigned int real_cmd;
int err;
real_cmd = (cmd == MEMREADOOB32) ?
MEMREADOOB : MEMWRITEOOB;
if (copy_in_user(&buf->start, &buf32->start,
2 * sizeof(u32)) ||
get_user(data, &buf32->ptr))
return -EFAULT;
datap = compat_ptr(data);
if (put_user(datap, &buf->ptr))
return -EFAULT;
err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
if (!err) {
if (copy_in_user(&buf32->start, &buf->start,
2 * sizeof(u32)))
err = -EFAULT;
}
return err;
}
#ifdef CONFIG_BLOCK #ifdef CONFIG_BLOCK
struct raw32_config_request struct raw32_config_request
{ {
...@@ -2426,15 +2385,6 @@ COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32) ...@@ -2426,15 +2385,6 @@ COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
COMPATIBLE_IOCTL(USBDEVFS_REAPURB32) COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
/* MTD */
COMPATIBLE_IOCTL(MEMGETINFO)
COMPATIBLE_IOCTL(MEMERASE)
COMPATIBLE_IOCTL(MEMLOCK)
COMPATIBLE_IOCTL(MEMUNLOCK)
COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
COMPATIBLE_IOCTL(MEMGETREGIONINFO)
COMPATIBLE_IOCTL(MEMGETBADBLOCK)
COMPATIBLE_IOCTL(MEMSETBADBLOCK)
/* NBD */ /* NBD */
ULONG_IOCTL(NBD_SET_SOCK) ULONG_IOCTL(NBD_SET_SOCK)
ULONG_IOCTL(NBD_SET_BLKSIZE) ULONG_IOCTL(NBD_SET_BLKSIZE)
...@@ -2544,8 +2494,6 @@ COMPATIBLE_IOCTL(JSIOCGBUTTONS) ...@@ -2544,8 +2494,6 @@ COMPATIBLE_IOCTL(JSIOCGBUTTONS)
COMPATIBLE_IOCTL(JSIOCGNAME(0)) COMPATIBLE_IOCTL(JSIOCGNAME(0))
/* now things that need handlers */ /* now things that need handlers */
HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
#ifdef CONFIG_NET #ifdef CONFIG_NET
HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32) HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf) HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
......
...@@ -196,7 +196,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -196,7 +196,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
if (c->nextblock) { if (c->nextblock) {
ret = file_dirty(c, c->nextblock); ret = file_dirty(c, c->nextblock);
if (ret) if (ret)
return ret; goto out;
/* deleting summary information of the old nextblock */ /* deleting summary information of the old nextblock */
jffs2_sum_reset_collected(c->summary); jffs2_sum_reset_collected(c->summary);
} }
...@@ -207,7 +207,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -207,7 +207,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
} else { } else {
ret = file_dirty(c, jeb); ret = file_dirty(c, jeb);
if (ret) if (ret)
return ret; goto out;
} }
break; break;
......
...@@ -563,6 +563,7 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -563,6 +563,7 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
* @options: Option flags, e.g. 16bit buswidth * @options: Option flags, e.g. 16bit buswidth
* @ecclayout: ecc layout info structure * @ecclayout: ecc layout info structure
* @part_probe_types: NULL-terminated array of probe types * @part_probe_types: NULL-terminated array of probe types
* @set_parts: platform specific function to set partitions
* @priv: hardware controller specific settings * @priv: hardware controller specific settings
*/ */
struct platform_nand_chip { struct platform_nand_chip {
...@@ -574,26 +575,41 @@ struct platform_nand_chip { ...@@ -574,26 +575,41 @@ struct platform_nand_chip {
int chip_delay; int chip_delay;
unsigned int options; unsigned int options;
const char **part_probe_types; const char **part_probe_types;
void (*set_parts)(uint64_t size,
struct platform_nand_chip *chip);
void *priv; void *priv;
}; };
/* Keep gcc happy */
struct platform_device;
/** /**
* struct platform_nand_ctrl - controller level device structure * struct platform_nand_ctrl - controller level device structure
* @probe: platform specific function to probe/setup hardware
* @remove: platform specific function to remove/teardown hardware
* @hwcontrol: platform specific hardware control structure * @hwcontrol: platform specific hardware control structure
* @dev_ready: platform specific function to read ready/busy pin * @dev_ready: platform specific function to read ready/busy pin
* @select_chip: platform specific chip select function * @select_chip: platform specific chip select function
* @cmd_ctrl: platform specific function for controlling * @cmd_ctrl: platform specific function for controlling
* ALE/CLE/nCE. Also used to write command and address * ALE/CLE/nCE. Also used to write command and address
* @write_buf: platform specific function for write buffer
* @read_buf: platform specific function for read buffer
* @priv: private data to transport driver specific settings * @priv: private data to transport driver specific settings
* *
* All fields are optional and depend on the hardware driver requirements * All fields are optional and depend on the hardware driver requirements
*/ */
struct platform_nand_ctrl { struct platform_nand_ctrl {
int (*probe)(struct platform_device *pdev);
void (*remove)(struct platform_device *pdev);
void (*hwcontrol)(struct mtd_info *mtd, int cmd); void (*hwcontrol)(struct mtd_info *mtd, int cmd);
int (*dev_ready)(struct mtd_info *mtd); int (*dev_ready)(struct mtd_info *mtd);
void (*select_chip)(struct mtd_info *mtd, int chip); void (*select_chip)(struct mtd_info *mtd, int chip);
void (*cmd_ctrl)(struct mtd_info *mtd, int dat, void (*cmd_ctrl)(struct mtd_info *mtd, int dat,
unsigned int ctrl); unsigned int ctrl);
void (*write_buf)(struct mtd_info *mtd,
const uint8_t *buf, int len);
void (*read_buf)(struct mtd_info *mtd,
uint8_t *buf, int len);
void *priv; void *priv;
}; };
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/mtd/onenand_regs.h> #include <linux/mtd/onenand_regs.h>
#include <linux/mtd/bbm.h> #include <linux/mtd/bbm.h>
#define MAX_DIES 2
#define MAX_BUFFERRAM 2 #define MAX_BUFFERRAM 2
/* Scan and identify a OneNAND device */ /* Scan and identify a OneNAND device */
...@@ -51,7 +52,12 @@ struct onenand_bufferram { ...@@ -51,7 +52,12 @@ struct onenand_bufferram {
/** /**
* struct onenand_chip - OneNAND Private Flash Chip Data * struct onenand_chip - OneNAND Private Flash Chip Data
* @base: [BOARDSPECIFIC] address to access OneNAND * @base: [BOARDSPECIFIC] address to access OneNAND
* @dies: [INTERN][FLEX-ONENAND] number of dies on chip
* @boundary: [INTERN][FLEX-ONENAND] Boundary of the dies
* @diesize: [INTERN][FLEX-ONENAND] Size of the dies
* @chipsize: [INTERN] the size of one chip for multichip arrays * @chipsize: [INTERN] the size of one chip for multichip arrays
* FIXME For Flex-OneNAND, chipsize holds maximum possible
* device size ie when all blocks are considered MLC
* @device_id: [INTERN] device ID * @device_id: [INTERN] device ID
* @density_mask: chip density, used for DDP devices * @density_mask: chip density, used for DDP devices
* @verstion_id: [INTERN] version ID * @verstion_id: [INTERN] version ID
...@@ -68,6 +74,8 @@ struct onenand_bufferram { ...@@ -68,6 +74,8 @@ struct onenand_bufferram {
* @command: [REPLACEABLE] hardware specific function for writing * @command: [REPLACEABLE] hardware specific function for writing
* commands to the chip * commands to the chip
* @wait: [REPLACEABLE] hardware specific function for wait on ready * @wait: [REPLACEABLE] hardware specific function for wait on ready
* @bbt_wait: [REPLACEABLE] hardware specific function for bbt wait on ready
* @unlock_all: [REPLACEABLE] hardware specific function for unlock all
* @read_bufferram: [REPLACEABLE] hardware specific function for BufferRAM Area * @read_bufferram: [REPLACEABLE] hardware specific function for BufferRAM Area
* @write_bufferram: [REPLACEABLE] hardware specific function for BufferRAM Area * @write_bufferram: [REPLACEABLE] hardware specific function for BufferRAM Area
* @read_word: [REPLACEABLE] hardware specific function for read * @read_word: [REPLACEABLE] hardware specific function for read
...@@ -92,9 +100,13 @@ struct onenand_bufferram { ...@@ -92,9 +100,13 @@ struct onenand_bufferram {
*/ */
struct onenand_chip { struct onenand_chip {
void __iomem *base; void __iomem *base;
unsigned dies;
unsigned boundary[MAX_DIES];
loff_t diesize[MAX_DIES];
unsigned int chipsize; unsigned int chipsize;
unsigned int device_id; unsigned int device_id;
unsigned int version_id; unsigned int version_id;
unsigned int technology;
unsigned int density_mask; unsigned int density_mask;
unsigned int options; unsigned int options;
...@@ -108,6 +120,8 @@ struct onenand_chip { ...@@ -108,6 +120,8 @@ struct onenand_chip {
int (*command)(struct mtd_info *mtd, int cmd, loff_t address, size_t len); int (*command)(struct mtd_info *mtd, int cmd, loff_t address, size_t len);
int (*wait)(struct mtd_info *mtd, int state); int (*wait)(struct mtd_info *mtd, int state);
int (*bbt_wait)(struct mtd_info *mtd, int state);
void (*unlock_all)(struct mtd_info *mtd);
int (*read_bufferram)(struct mtd_info *mtd, int area, int (*read_bufferram)(struct mtd_info *mtd, int area,
unsigned char *buffer, int offset, size_t count); unsigned char *buffer, int offset, size_t count);
int (*write_bufferram)(struct mtd_info *mtd, int area, int (*write_bufferram)(struct mtd_info *mtd, int area,
...@@ -145,6 +159,8 @@ struct onenand_chip { ...@@ -145,6 +159,8 @@ struct onenand_chip {
#define ONENAND_SET_BUFFERRAM0(this) (this->bufferram_index = 0) #define ONENAND_SET_BUFFERRAM0(this) (this->bufferram_index = 0)
#define ONENAND_SET_BUFFERRAM1(this) (this->bufferram_index = 1) #define ONENAND_SET_BUFFERRAM1(this) (this->bufferram_index = 1)
#define FLEXONENAND(this) \
(this->device_id & DEVICE_IS_FLEXONENAND)
#define ONENAND_GET_SYS_CFG1(this) \ #define ONENAND_GET_SYS_CFG1(this) \
(this->read_word(this->base + ONENAND_REG_SYS_CFG1)) (this->read_word(this->base + ONENAND_REG_SYS_CFG1))
#define ONENAND_SET_SYS_CFG1(v, this) \ #define ONENAND_SET_SYS_CFG1(v, this) \
...@@ -153,6 +169,9 @@ struct onenand_chip { ...@@ -153,6 +169,9 @@ struct onenand_chip {
#define ONENAND_IS_DDP(this) \ #define ONENAND_IS_DDP(this) \
(this->device_id & ONENAND_DEVICE_IS_DDP) (this->device_id & ONENAND_DEVICE_IS_DDP)
#define ONENAND_IS_MLC(this) \
(this->technology & ONENAND_TECHNOLOGY_IS_MLC)
#ifdef CONFIG_MTD_ONENAND_2X_PROGRAM #ifdef CONFIG_MTD_ONENAND_2X_PROGRAM
#define ONENAND_IS_2PLANE(this) \ #define ONENAND_IS_2PLANE(this) \
(this->options & ONENAND_HAS_2PLANE) (this->options & ONENAND_HAS_2PLANE)
...@@ -169,6 +188,7 @@ struct onenand_chip { ...@@ -169,6 +188,7 @@ struct onenand_chip {
#define ONENAND_HAS_CONT_LOCK (0x0001) #define ONENAND_HAS_CONT_LOCK (0x0001)
#define ONENAND_HAS_UNLOCK_ALL (0x0002) #define ONENAND_HAS_UNLOCK_ALL (0x0002)
#define ONENAND_HAS_2PLANE (0x0004) #define ONENAND_HAS_2PLANE (0x0004)
#define ONENAND_SKIP_UNLOCK_CHECK (0x0100)
#define ONENAND_PAGEBUF_ALLOC (0x1000) #define ONENAND_PAGEBUF_ALLOC (0x1000)
#define ONENAND_OOBBUF_ALLOC (0x2000) #define ONENAND_OOBBUF_ALLOC (0x2000)
...@@ -176,6 +196,7 @@ struct onenand_chip { ...@@ -176,6 +196,7 @@ struct onenand_chip {
* OneNAND Flash Manufacturer ID Codes * OneNAND Flash Manufacturer ID Codes
*/ */
#define ONENAND_MFR_SAMSUNG 0xec #define ONENAND_MFR_SAMSUNG 0xec
#define ONENAND_MFR_NUMONYX 0x20
/** /**
* struct onenand_manufacturers - NAND Flash Manufacturer ID Structure * struct onenand_manufacturers - NAND Flash Manufacturer ID Structure
...@@ -189,5 +210,8 @@ struct onenand_manufacturers { ...@@ -189,5 +210,8 @@ struct onenand_manufacturers {
int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from, int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops); struct mtd_oob_ops *ops);
unsigned onenand_block(struct onenand_chip *this, loff_t addr);
loff_t onenand_addr(struct onenand_chip *this, int block);
int flexonenand_region(struct mtd_info *mtd, loff_t addr);
#endif /* __LINUX_MTD_ONENAND_H */ #endif /* __LINUX_MTD_ONENAND_H */
...@@ -67,6 +67,9 @@ ...@@ -67,6 +67,9 @@
/* /*
* Device ID Register F001h (R) * Device ID Register F001h (R)
*/ */
#define DEVICE_IS_FLEXONENAND (1 << 9)
#define FLEXONENAND_PI_MASK (0x3ff)
#define FLEXONENAND_PI_UNLOCK_SHIFT (14)
#define ONENAND_DEVICE_DENSITY_MASK (0xf) #define ONENAND_DEVICE_DENSITY_MASK (0xf)
#define ONENAND_DEVICE_DENSITY_SHIFT (4) #define ONENAND_DEVICE_DENSITY_SHIFT (4)
#define ONENAND_DEVICE_IS_DDP (1 << 3) #define ONENAND_DEVICE_IS_DDP (1 << 3)
...@@ -83,6 +86,11 @@ ...@@ -83,6 +86,11 @@
*/ */
#define ONENAND_VERSION_PROCESS_SHIFT (8) #define ONENAND_VERSION_PROCESS_SHIFT (8)
/*
* Technology Register F006h (R)
*/
#define ONENAND_TECHNOLOGY_IS_MLC (1 << 0)
/* /*
* Start Address 1 F100h (R/W) & Start Address 2 F101h (R/W) * Start Address 1 F100h (R/W) & Start Address 2 F101h (R/W)
*/ */
...@@ -93,7 +101,8 @@ ...@@ -93,7 +101,8 @@
/* /*
* Start Address 8 F107h (R/W) * Start Address 8 F107h (R/W)
*/ */
#define ONENAND_FPA_MASK (0x3f) /* Note: It's actually 0x3f in case of SLC */
#define ONENAND_FPA_MASK (0x7f)
#define ONENAND_FPA_SHIFT (2) #define ONENAND_FPA_SHIFT (2)
#define ONENAND_FSA_MASK (0x03) #define ONENAND_FSA_MASK (0x03)
...@@ -105,7 +114,8 @@ ...@@ -105,7 +114,8 @@
#define ONENAND_BSA_BOOTRAM (0 << 2) #define ONENAND_BSA_BOOTRAM (0 << 2)
#define ONENAND_BSA_DATARAM0 (2 << 2) #define ONENAND_BSA_DATARAM0 (2 << 2)
#define ONENAND_BSA_DATARAM1 (3 << 2) #define ONENAND_BSA_DATARAM1 (3 << 2)
#define ONENAND_BSC_MASK (0x03) /* Note: It's actually 0x03 in case of SLC */
#define ONENAND_BSC_MASK (0x07)
/* /*
* Command Register F220h (R/W) * Command Register F220h (R/W)
...@@ -124,9 +134,13 @@ ...@@ -124,9 +134,13 @@
#define ONENAND_CMD_RESET (0xF0) #define ONENAND_CMD_RESET (0xF0)
#define ONENAND_CMD_OTP_ACCESS (0x65) #define ONENAND_CMD_OTP_ACCESS (0x65)
#define ONENAND_CMD_READID (0x90) #define ONENAND_CMD_READID (0x90)
#define FLEXONENAND_CMD_PI_UPDATE (0x05)
#define FLEXONENAND_CMD_PI_ACCESS (0x66)
#define FLEXONENAND_CMD_RECOVER_LSB (0x05)
/* NOTE: Those are not *REAL* commands */ /* NOTE: Those are not *REAL* commands */
#define ONENAND_CMD_BUFFERRAM (0x1978) #define ONENAND_CMD_BUFFERRAM (0x1978)
#define FLEXONENAND_CMD_READ_PI (0x1985)
/* /*
* System Configuration 1 Register F221h (R, R/W) * System Configuration 1 Register F221h (R, R/W)
...@@ -192,10 +206,12 @@ ...@@ -192,10 +206,12 @@
#define ONENAND_ECC_1BIT_ALL (0x5555) #define ONENAND_ECC_1BIT_ALL (0x5555)
#define ONENAND_ECC_2BIT (1 << 1) #define ONENAND_ECC_2BIT (1 << 1)
#define ONENAND_ECC_2BIT_ALL (0xAAAA) #define ONENAND_ECC_2BIT_ALL (0xAAAA)
#define FLEXONENAND_UNCORRECTABLE_ERROR (0x1010)
/* /*
* One-Time Programmable (OTP) * One-Time Programmable (OTP)
*/ */
#define FLEXONENAND_OTP_LOCK_OFFSET (2048)
#define ONENAND_OTP_LOCK_OFFSET (14) #define ONENAND_OTP_LOCK_OFFSET (14)
#endif /* __ONENAND_REG_H */ #endif /* __ONENAND_REG_H */
...@@ -40,7 +40,6 @@ struct mtd_partition { ...@@ -40,7 +40,6 @@ struct mtd_partition {
uint64_t offset; /* offset within the master MTD space */ uint64_t offset; /* offset within the master MTD space */
uint32_t mask_flags; /* master MTD flags to mask out for this partition */ uint32_t mask_flags; /* master MTD flags to mask out for this partition */
struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/ struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/
struct mtd_info **mtdp; /* pointer to store the MTD object */
}; };
#define MTDPART_OFS_NXTBLK (-2) #define MTDPART_OFS_NXTBLK (-2)
......
header-y += inftl-user.h header-y += inftl-user.h
header-y += jffs2-user.h
header-y += mtd-abi.h header-y += mtd-abi.h
header-y += mtd-user.h header-y += mtd-user.h
header-y += nftl-user.h header-y += nftl-user.h
......
/*
* JFFS2 definitions for use in user space only
*/
#ifndef __JFFS2_USER_H__
#define __JFFS2_USER_H__
/* This file is blessed for inclusion by userspace */
#include <linux/jffs2.h>
#include <linux/types.h>
#include <endian.h>
#include <byteswap.h>
#undef cpu_to_je16
#undef cpu_to_je32
#undef cpu_to_jemode
#undef je16_to_cpu
#undef je32_to_cpu
#undef jemode_to_cpu
extern int target_endian;
#define t16(x) ({ __u16 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
#define t32(x) ({ __u32 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })
#define cpu_to_je16(x) ((jint16_t){t16(x)})
#define cpu_to_je32(x) ((jint32_t){t32(x)})
#define cpu_to_jemode(x) ((jmode_t){t32(x)})
#define je16_to_cpu(x) (t16((x).v16))
#define je32_to_cpu(x) (t32((x).v32))
#define jemode_to_cpu(x) (t32((x).m))
#endif /* __JFFS2_USER_H__ */
...@@ -12,12 +12,24 @@ struct erase_info_user { ...@@ -12,12 +12,24 @@ struct erase_info_user {
__u32 length; __u32 length;
}; };
struct erase_info_user64 {
__u64 start;
__u64 length;
};
struct mtd_oob_buf { struct mtd_oob_buf {
__u32 start; __u32 start;
__u32 length; __u32 length;
unsigned char __user *ptr; unsigned char __user *ptr;
}; };
struct mtd_oob_buf64 {
__u64 start;
__u32 pad;
__u32 length;
__u64 usr_ptr;
};
#define MTD_ABSENT 0 #define MTD_ABSENT 0
#define MTD_RAM 1 #define MTD_RAM 1
#define MTD_ROM 2 #define MTD_ROM 2
...@@ -95,6 +107,9 @@ struct otp_info { ...@@ -95,6 +107,9 @@ struct otp_info {
#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout) #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout)
#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
#define MTDFILEMODE _IO('M', 19) #define MTDFILEMODE _IO('M', 19)
#define MEMERASE64 _IOW('M', 20, struct erase_info_user64)
#define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
#define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64)
/* /*
* Obsolete legacy interface. Keep it in order not to break userspace * Obsolete legacy interface. Keep it in order not to break userspace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment