]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
authorDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 12 Aug 2008 10:28:00 +0000 (11:28 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 12 Aug 2008 10:28:00 +0000 (11:28 +0100)
Conflicts:

include/asm-arm/arch-omap/onenand.h

34 files changed:
arch/arm/plat-omap/include/mach/onenand.h
drivers/mtd/Kconfig
drivers/mtd/chips/Kconfig
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_probe.c
drivers/mtd/chips/cfi_util.c
drivers/mtd/chips/gen_probe.c
drivers/mtd/devices/Kconfig
drivers/mtd/devices/m25p80.c
drivers/mtd/devices/mtd_dataflash.c
drivers/mtd/maps/Kconfig
drivers/mtd/maps/Makefile
drivers/mtd/maps/ebony.c [deleted file]
drivers/mtd/maps/ocotea.c [deleted file]
drivers/mtd/maps/omap-toto-flash.c [deleted file]
drivers/mtd/maps/walnut.c [deleted file]
drivers/mtd/mtdchar.c
drivers/mtd/mtdconcat.c
drivers/mtd/mtdpart.c
drivers/mtd/nand/Kconfig
drivers/mtd/nand/Makefile
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/nandsim.c
drivers/mtd/nand/toto.c [deleted file]
drivers/mtd/onenand/Kconfig
drivers/mtd/onenand/Makefile
drivers/mtd/onenand/omap2.c [new file with mode: 0644]
drivers/mtd/onenand/onenand_base.c
drivers/mtd/ssfdc.c
fs/jffs2/erase.c
include/linux/mtd/cfi.h
include/linux/mtd/flashchip.h
include/linux/mtd/mtd.h
include/linux/mtd/onenand_regs.h

index d57f20226b28733743c35455bb798836ba34f299..4649d302c263723abb48c6c33579d39f96813e4f 100644 (file)
@@ -16,6 +16,10 @@ struct omap_onenand_platform_data {
        int                     gpio_irq;
        struct mtd_partition    *parts;
        int                     nr_parts;
-       int                     (*onenand_setup)(void __iomem *);
+       int                     (*onenand_setup)(void __iomem *, int freq);
        int                     dma_channel;
 };
+
+int omap2_onenand_rephase(void);
+
+#define ONENAND_MAX_PARTITIONS 8
index 14f11f8b9e5fd556fcd71dbe4d6178634c851bcc..a90d50c2c3e5535343e859c5df1c40c3be7e464a 100644 (file)
@@ -172,6 +172,11 @@ config MTD_CHAR
          memory chips, and also use ioctl() to obtain information about
          the device, or to erase parts of it.
 
+config HAVE_MTD_OTP
+       bool
+       help
+         Enable access to OTP regions using MTD_CHAR.
+
 config MTD_BLKDEVS
        tristate "Common interface to block layer for MTD 'translation layers'"
        depends on BLOCK
index 479d32b57a1eb54b20b731855274bd9d343a62ae..9401bfec46235aa76a4d866f45a6270fe6925528 100644 (file)
@@ -154,6 +154,7 @@ config MTD_CFI_I8
 config MTD_OTP
        bool "Protection Registers aka one-time programmable (OTP) bits"
        depends on MTD_CFI_ADV_OPTIONS
+       select HAVE_MTD_OTP
        default n
        help
          This enables support for reading, writing and locking so called
@@ -187,7 +188,7 @@ config MTD_CFI_INTELEXT
          StrataFlash and other parts.
 
 config MTD_CFI_AMDSTD
-       tristate "Support for AMD/Fujitsu flash chips"
+       tristate "Support for AMD/Fujitsu/Spansion flash chips"
        depends on MTD_GEN_PROBE
        select MTD_CFI_UTIL
        help
index 5f1b472137a024b96fcff3ea3f9bcd654c7389f8..5157e3cb4b9e73f13609baf126ef6a40561c3beb 100644 (file)
@@ -478,6 +478,28 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
                else
                        cfi->chips[i].erase_time = 2000000;
 
+               if (cfi->cfiq->WordWriteTimeoutTyp &&
+                   cfi->cfiq->WordWriteTimeoutMax)
+                       cfi->chips[i].word_write_time_max =
+                               1<<(cfi->cfiq->WordWriteTimeoutTyp +
+                                   cfi->cfiq->WordWriteTimeoutMax);
+               else
+                       cfi->chips[i].word_write_time_max = 50000 * 8;
+
+               if (cfi->cfiq->BufWriteTimeoutTyp &&
+                   cfi->cfiq->BufWriteTimeoutMax)
+                       cfi->chips[i].buffer_write_time_max =
+                               1<<(cfi->cfiq->BufWriteTimeoutTyp +
+                                   cfi->cfiq->BufWriteTimeoutMax);
+
+               if (cfi->cfiq->BlockEraseTimeoutTyp &&
+                   cfi->cfiq->BlockEraseTimeoutMax)
+                       cfi->chips[i].erase_time_max =
+                               1000<<(cfi->cfiq->BlockEraseTimeoutTyp +
+                                      cfi->cfiq->BlockEraseTimeoutMax);
+               else
+                       cfi->chips[i].erase_time_max = 2000000 * 8;
+
                cfi->chips[i].ref_point_counter = 0;
                init_waitqueue_head(&(cfi->chips[i].wq));
        }
@@ -1012,7 +1034,7 @@ static void __xipram xip_enable(struct map_info *map, struct flchip *chip,
 
 static int __xipram xip_wait_for_operation(
                struct map_info *map, struct flchip *chip,
-               unsigned long adr, unsigned int chip_op_time )
+               unsigned long adr, unsigned int chip_op_time_max)
 {
        struct cfi_private *cfi = map->fldrv_priv;
        struct cfi_pri_intelext *cfip = cfi->cmdset_priv;
@@ -1021,7 +1043,7 @@ static int __xipram xip_wait_for_operation(
        flstate_t oldstate, newstate;
 
                start = xip_currtime();
-       usec = chip_op_time * 8;
+       usec = chip_op_time_max;
        if (usec == 0)
                usec = 500000;
        done = 0;
@@ -1131,8 +1153,8 @@ static int __xipram xip_wait_for_operation(
 #define XIP_INVAL_CACHED_RANGE(map, from, size)  \
        INVALIDATE_CACHED_RANGE(map, from, size)
 
-#define INVAL_CACHE_AND_WAIT(map, chip, cmd_adr, inval_adr, inval_len, usec) \
-       xip_wait_for_operation(map, chip, cmd_adr, usec)
+#define INVAL_CACHE_AND_WAIT(map, chip, cmd_adr, inval_adr, inval_len, usec, usec_max) \
+       xip_wait_for_operation(map, chip, cmd_adr, usec_max)
 
 #else
 
@@ -1144,7 +1166,7 @@ static int __xipram xip_wait_for_operation(
 static int inval_cache_and_wait_for_operation(
                struct map_info *map, struct flchip *chip,
                unsigned long cmd_adr, unsigned long inval_adr, int inval_len,
-               unsigned int chip_op_time)
+               unsigned int chip_op_time, unsigned int chip_op_time_max)
 {
        struct cfi_private *cfi = map->fldrv_priv;
        map_word status, status_OK = CMD(0x80);
@@ -1156,8 +1178,7 @@ static int inval_cache_and_wait_for_operation(
                INVALIDATE_CACHED_RANGE(map, inval_adr, inval_len);
        spin_lock(chip->mutex);
 
-       /* set our timeout to 8 times the expected delay */
-       timeo = chip_op_time * 8;
+       timeo = chip_op_time_max;
        if (!timeo)
                timeo = 500000;
        reset_timeo = timeo;
@@ -1217,8 +1238,8 @@ static int inval_cache_and_wait_for_operation(
 
 #endif
 
-#define WAIT_TIMEOUT(map, chip, adr, udelay) \
-       INVAL_CACHE_AND_WAIT(map, chip, adr, 0, 0, udelay);
+#define WAIT_TIMEOUT(map, chip, adr, udelay, udelay_max) \
+       INVAL_CACHE_AND_WAIT(map, chip, adr, 0, 0, udelay, udelay_max);
 
 
 static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t adr, size_t len)
@@ -1452,7 +1473,8 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
 
        ret = INVAL_CACHE_AND_WAIT(map, chip, adr,
                                   adr, map_bankwidth(map),
-                                  chip->word_write_time);
+                                  chip->word_write_time,
+                                  chip->word_write_time_max);
        if (ret) {
                xip_enable(map, chip, adr);
                printk(KERN_ERR "%s: word write error (status timeout)\n", map->name);
@@ -1623,7 +1645,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 
        chip->state = FL_WRITING_TO_BUFFER;
        map_write(map, write_cmd, cmd_adr);
-       ret = WAIT_TIMEOUT(map, chip, cmd_adr, 0);
+       ret = WAIT_TIMEOUT(map, chip, cmd_adr, 0, 0);
        if (ret) {
                /* Argh. Not ready for write to buffer */
                map_word Xstatus = map_read(map, cmd_adr);
@@ -1640,7 +1662,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 
        /* Figure out the number of words to write */
        word_gap = (-adr & (map_bankwidth(map)-1));
-       words = (len - word_gap + map_bankwidth(map) - 1) / map_bankwidth(map);
+       words = DIV_ROUND_UP(len - word_gap, map_bankwidth(map));
        if (!word_gap) {
                words--;
        } else {
@@ -1692,7 +1714,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 
        ret = INVAL_CACHE_AND_WAIT(map, chip, cmd_adr,
                                   initial_adr, initial_len,
-                                  chip->buffer_write_time);
+                                  chip->buffer_write_time,
+                                  chip->buffer_write_time_max);
        if (ret) {
                map_write(map, CMD(0x70), cmd_adr);
                chip->state = FL_STATUS;
@@ -1827,7 +1850,8 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
 
        ret = INVAL_CACHE_AND_WAIT(map, chip, adr,
                                   adr, len,
-                                  chip->erase_time);
+                                  chip->erase_time,
+                                  chip->erase_time_max);
        if (ret) {
                map_write(map, CMD(0x70), adr);
                chip->state = FL_STATUS;
@@ -2006,7 +2030,7 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
         */
        udelay = (!extp || !(extp->FeatureSupport & (1 << 5))) ? 1000000/HZ : 0;
 
-       ret = WAIT_TIMEOUT(map, chip, adr, udelay);
+       ret = WAIT_TIMEOUT(map, chip, adr, udelay, udelay * 100);
        if (ret) {
                map_write(map, CMD(0x70), adr);
                chip->state = FL_STATUS;
index c418e92e1d92b79286f46a173bd1f93ff3591939..e63e6749429a29c282323ebc7c5d5949ef284616 100644 (file)
@@ -44,17 +44,14 @@ do { \
 
 #define xip_enable(base, map, cfi) \
 do { \
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); \
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); \
+       cfi_qry_mode_off(base, map, cfi);               \
        xip_allowed(base, map); \
 } while (0)
 
 #define xip_disable_qry(base, map, cfi) \
 do { \
        xip_disable(); \
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); \
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); \
-       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL); \
+       cfi_qry_mode_on(base, map, cfi); \
 } while (0)
 
 #else
@@ -70,32 +67,6 @@ do { \
    in: interleave,type,mode
    ret: table index, <0 for error
  */
-static int __xipram qry_present(struct map_info *map, __u32 base,
-                               struct cfi_private *cfi)
-{
-       int osf = cfi->interleave * cfi->device_type;   // scale factor
-       map_word val[3];
-       map_word qry[3];
-
-       qry[0] = cfi_build_cmd('Q', map, cfi);
-       qry[1] = cfi_build_cmd('R', map, cfi);
-       qry[2] = cfi_build_cmd('Y', map, cfi);
-
-       val[0] = map_read(map, base + osf*0x10);
-       val[1] = map_read(map, base + osf*0x11);
-       val[2] = map_read(map, base + osf*0x12);
-
-       if (!map_word_equal(map, qry[0], val[0]))
-               return 0;
-
-       if (!map_word_equal(map, qry[1], val[1]))
-               return 0;
-
-       if (!map_word_equal(map, qry[2], val[2]))
-               return 0;
-
-       return 1;       // "QRY" found
-}
 
 static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
                                   unsigned long *chip_map, struct cfi_private *cfi)
@@ -116,11 +87,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
        }
 
        xip_disable();
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
-
-       if (!qry_present(map,base,cfi)) {
+       if (!cfi_qry_mode_on(base, map, cfi)) {
                xip_enable(base, map, cfi);
                return 0;
        }
@@ -141,14 +108,13 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
                start = i << cfi->chipshift;
                /* This chip should be in read mode if it's one
                   we've already touched. */
-               if (qry_present(map, start, cfi)) {
+               if (cfi_qry_present(map, start, cfi)) {
                        /* Eep. This chip also had the QRY marker.
                         * Is it an alias for the new one? */
-                       cfi_send_gen_cmd(0xF0, 0, start, map, cfi, cfi->device_type, NULL);
-                       cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL);
+                       cfi_qry_mode_off(start, map, cfi);
 
                        /* If the QRY marker goes away, it's an alias */
-                       if (!qry_present(map, start, cfi)) {
+                       if (!cfi_qry_present(map, start, cfi)) {
                                xip_allowed(base, map);
                                printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n",
                                       map->name, base, start);
@@ -158,10 +124,9 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
                         * unfortunate. Stick the new chip in read mode
                         * too and if it's the same, assume it's an alias. */
                        /* FIXME: Use other modes to do a proper check */
-                       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-                       cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL);
+                       cfi_qry_mode_off(base, map, cfi);
 
-                       if (qry_present(map, base, cfi)) {
+                       if (cfi_qry_present(map, base, cfi)) {
                                xip_allowed(base, map);
                                printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n",
                                       map->name, base, start);
@@ -176,8 +141,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
        cfi->numchips++;
 
        /* Put it back into Read Mode */
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_qry_mode_off(base, map, cfi);
        xip_allowed(base, map);
 
        printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n",
@@ -237,9 +201,7 @@ static int __xipram cfi_chip_setup(struct map_info *map,
                          cfi_read_query(map, base + 0xf * ofs_factor);
 
        /* Put it back into Read Mode */
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-       /* ... even if it's an Intel chip */
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_qry_mode_off(base, map, cfi);
        xip_allowed(base, map);
 
        /* Do any necessary byteswapping */
index 0ee457018016083743ca772a38d77325aa6911ae..34d40e25d312952b3cd2186465e17eff5a55d101 100644 (file)
 #include <linux/mtd/cfi.h>
 #include <linux/mtd/compatmac.h>
 
+int __xipram cfi_qry_present(struct map_info *map, __u32 base,
+                            struct cfi_private *cfi)
+{
+       int osf = cfi->interleave * cfi->device_type;   /* scale factor */
+       map_word val[3];
+       map_word qry[3];
+
+       qry[0] = cfi_build_cmd('Q', map, cfi);
+       qry[1] = cfi_build_cmd('R', map, cfi);
+       qry[2] = cfi_build_cmd('Y', map, cfi);
+
+       val[0] = map_read(map, base + osf*0x10);
+       val[1] = map_read(map, base + osf*0x11);
+       val[2] = map_read(map, base + osf*0x12);
+
+       if (!map_word_equal(map, qry[0], val[0]))
+               return 0;
+
+       if (!map_word_equal(map, qry[1], val[1]))
+               return 0;
+
+       if (!map_word_equal(map, qry[2], val[2]))
+               return 0;
+
+       return 1;       /* "QRY" found */
+}
+EXPORT_SYMBOL_GPL(cfi_qry_present);
+
+int __xipram cfi_qry_mode_on(uint32_t base, struct map_info *map,
+                            struct cfi_private *cfi)
+{
+       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
+       if (cfi_qry_present(map, base, cfi))
+               return 1;
+       /* QRY not found probably we deal with some odd CFI chips */
+       /* Some revisions of some old Intel chips? */
+       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
+       if (cfi_qry_present(map, base, cfi))
+               return 1;
+       /* ST M29DW chips */
+       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0x98, 0x555, base, map, cfi, cfi->device_type, NULL);
+       if (cfi_qry_present(map, base, cfi))
+               return 1;
+       /* QRY not found */
+       return 0;
+}
+EXPORT_SYMBOL_GPL(cfi_qry_mode_on);
+
+void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map,
+                              struct cfi_private *cfi)
+{
+       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+}
+EXPORT_SYMBOL_GPL(cfi_qry_mode_off);
+
 struct cfi_extquery *
 __xipram cfi_read_pri(struct map_info *map, __u16 adr, __u16 size, const char* name)
 {
@@ -48,8 +108,7 @@ __xipram cfi_read_pri(struct map_info *map, __u16 adr, __u16 size, const char* n
 #endif
 
        /* Switch it into Query Mode */
-       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
-
+       cfi_qry_mode_on(base, map, cfi);
        /* Read in the Extended Query Table */
        for (i=0; i<size; i++) {
                ((unsigned char *)extp)[i] =
@@ -57,8 +116,7 @@ __xipram cfi_read_pri(struct map_info *map, __u16 adr, __u16 size, const char* n
        }
 
        /* Make sure it returns to read mode */
-       cfi_send_gen_cmd(0xf0, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0xff, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_qry_mode_off(base, map, cfi);
 
 #ifdef CONFIG_MTD_XIP
        (void) map_read(map, base);
index f061885b2812dc5d04bba96f488aa6fa18a9ae49..e2dc96441e05e0a6affa6c5fa2611fef0f545d9e 100644 (file)
@@ -111,7 +111,7 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
                max_chips = 1;
        }
 
-       mapsize = sizeof(long) * ( (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG );
+       mapsize = sizeof(long) * DIV_ROUND_UP(max_chips, BITS_PER_LONG);
        chip_map = kzalloc(mapsize, GFP_KERNEL);
        if (!chip_map) {
                printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name);
index 9c613f06623cd4d1191eafb7e6d4adfb75736037..6fde0a2e3567d589fb4757a12eb49929b1c6c463 100644 (file)
@@ -59,6 +59,27 @@ config MTD_DATAFLASH
          Sometimes DataFlash chips are packaged inside MMC-format
          cards; at this writing, the MMC stack won't handle those.
 
+config MTD_DATAFLASH_WRITE_VERIFY
+       bool "Verify DataFlash page writes"
+       depends on MTD_DATAFLASH
+       help
+         This adds an extra check when data is written to the flash.
+         It may help if you are verifying chip setup (timings etc) on
+         your board.  There is a rare possibility that even though the
+         device thinks the write was successful, a bit could have been
+         flipped accidentally due to device wear or something else.
+
+config MTD_DATAFLASH_OTP
+       bool "DataFlash OTP support (Security Register)"
+       depends on MTD_DATAFLASH
+       select HAVE_MTD_OTP
+       help
+         Newer DataFlash chips (revisions C and D) support 128 bytes of
+         one-time-programmable (OTP) data.  The first half may be written
+         (once) with up to 64 bytes of data, such as a serial number or
+         other key product data.  The second half is programmed with a
+         unique-to-each-chip bit pattern at the factory.
+
 config MTD_M25P80
        tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)"
        depends on SPI_MASTER && EXPERIMENTAL
index b35c3333e210b61878493d3fd052e1228b38d6db..4d3ae085b1d256c842fd26447a57b5948a8ba2f7 100644 (file)
@@ -39,6 +39,7 @@
 #define        OPCODE_PP               0x02    /* Page program (up to 256 bytes) */
 #define        OPCODE_BE_4K            0x20    /* Erase 4KiB block */
 #define        OPCODE_BE_32K           0x52    /* Erase 32KiB block */
+#define        OPCODE_BE               0xc7    /* Erase whole flash block */
 #define        OPCODE_SE               0xd8    /* Sector erase (usually 64KiB) */
 #define        OPCODE_RDID             0x9f    /* Read JEDEC ID */
 
@@ -133,7 +134,7 @@ static inline int write_enable(struct m25p *flash)
 {
        u8      code = OPCODE_WREN;
 
-       return spi_write_then_read(flash->spi, &code, 1, NULL, 0);
+       return spi_write(flash->spi, &code, 1);
 }
 
 
@@ -161,6 +162,31 @@ static int wait_till_ready(struct m25p *flash)
        return 1;
 }
 
+/*
+ * Erase the whole flash memory
+ *
+ * Returns 0 if successful, non-zero otherwise.
+ */
+static int erase_block(struct m25p *flash)
+{
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n",
+                       flash->spi->dev.bus_id, __func__,
+                       flash->mtd.size / 1024);
+
+       /* Wait until finished previous write command. */
+       if (wait_till_ready(flash))
+               return 1;
+
+       /* Send write enable, then erase commands. */
+       write_enable(flash);
+
+       /* Set up command buffer. */
+       flash->command[0] = OPCODE_BE;
+
+       spi_write(flash->spi, flash->command, 1);
+
+       return 0;
+}
 
 /*
  * Erase one sector of flash memory at offset ``offset'' which is any
@@ -229,15 +255,21 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
         */
 
        /* now erase those sectors */
-       while (len) {
-               if (erase_sector(flash, addr)) {
-                       instr->state = MTD_ERASE_FAILED;
-                       mutex_unlock(&flash->lock);
-                       return -EIO;
-               }
+       if (len == flash->mtd.size && erase_block(flash)) {
+               instr->state = MTD_ERASE_FAILED;
+               mutex_unlock(&flash->lock);
+               return -EIO;
+       } else {
+               while (len) {
+                       if (erase_sector(flash, addr)) {
+                               instr->state = MTD_ERASE_FAILED;
+                               mutex_unlock(&flash->lock);
+                               return -EIO;
+                       }
 
-               addr += mtd->erasesize;
-               len -= mtd->erasesize;
+                       addr += mtd->erasesize;
+                       len -= mtd->erasesize;
+               }
        }
 
        mutex_unlock(&flash->lock);
@@ -437,6 +469,7 @@ struct flash_info {
         * then a two byte device id.
         */
        u32             jedec_id;
+       u16             ext_id;
 
        /* The size listed here is what works with OPCODE_SE, which isn't
         * necessarily called a "sector" by the vendor.
@@ -456,57 +489,59 @@ struct flash_info {
 static struct flash_info __devinitdata m25p_data [] = {
 
        /* Atmel -- some are (confusingly) marketed as "DataFlash" */
-       { "at25fs010",  0x1f6601, 32 * 1024, 4, SECT_4K, },
-       { "at25fs040",  0x1f6604, 64 * 1024, 8, SECT_4K, },
+       { "at25fs010",  0x1f6601, 0, 32 * 1024, 4, SECT_4K, },
+       { "at25fs040",  0x1f6604, 0, 64 * 1024, 8, SECT_4K, },
 
-       { "at25df041a", 0x1f4401, 64 * 1024, 8, SECT_4K, },
-       { "at25df641",  0x1f4800, 64 * 1024, 128, SECT_4K, },
+       { "at25df041a", 0x1f4401, 0, 64 * 1024, 8, SECT_4K, },
+       { "at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K, },
 
-       { "at26f004",   0x1f0400, 64 * 1024, 8, SECT_4K, },
-       { "at26df081a", 0x1f4501, 64 * 1024, 16, SECT_4K, },
-       { "at26df161a", 0x1f4601, 64 * 1024, 32, SECT_4K, },
-       { "at26df321",  0x1f4701, 64 * 1024, 64, SECT_4K, },
+       { "at26f004",   0x1f0400, 0, 64 * 1024, 8, SECT_4K, },
+       { "at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K, },
+       { "at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K, },
+       { "at26df321",  0x1f4701, 0, 64 * 1024, 64, SECT_4K, },
 
        /* Spansion -- single (large) sector size only, at least
         * for the chips listed here (without boot sectors).
         */
-       { "s25sl004a", 0x010212, 64 * 1024, 8, },
-       { "s25sl008a", 0x010213, 64 * 1024, 16, },
-       { "s25sl016a", 0x010214, 64 * 1024, 32, },
-       { "s25sl032a", 0x010215, 64 * 1024, 64, },
-       { "s25sl064a", 0x010216, 64 * 1024, 128, },
+       { "s25sl004a", 0x010212, 0, 64 * 1024, 8, },
+       { "s25sl008a", 0x010213, 0, 64 * 1024, 16, },
+       { "s25sl016a", 0x010214, 0, 64 * 1024, 32, },
+       { "s25sl032a", 0x010215, 0, 64 * 1024, 64, },
+       { "s25sl064a", 0x010216, 0, 64 * 1024, 128, },
+        { "s25sl12800", 0x012018, 0x0300, 256 * 1024, 64, },
+       { "s25sl12801", 0x012018, 0x0301, 64 * 1024, 256, },
 
        /* SST -- large erase sizes are "overlays", "sectors" are 4K */
-       { "sst25vf040b", 0xbf258d, 64 * 1024, 8, SECT_4K, },
-       { "sst25vf080b", 0xbf258e, 64 * 1024, 16, SECT_4K, },
-       { "sst25vf016b", 0xbf2541, 64 * 1024, 32, SECT_4K, },
-       { "sst25vf032b", 0xbf254a, 64 * 1024, 64, SECT_4K, },
+       { "sst25vf040b", 0xbf258d, 0, 64 * 1024, 8, SECT_4K, },
+       { "sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K, },
+       { "sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K, },
+       { "sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K, },
 
        /* ST Microelectronics -- newer production may have feature updates */
-       { "m25p05",  0x202010,  32 * 1024, 2, },
-       { "m25p10",  0x202011,  32 * 1024, 4, },
-       { "m25p20",  0x202012,  64 * 1024, 4, },
-       { "m25p40",  0x202013,  64 * 1024, 8, },
-       { "m25p80",         0,  64 * 1024, 16, },
-       { "m25p16",  0x202015,  64 * 1024, 32, },
-       { "m25p32",  0x202016,  64 * 1024, 64, },
-       { "m25p64",  0x202017,  64 * 1024, 128, },
-       { "m25p128", 0x202018, 256 * 1024, 64, },
-
-       { "m45pe80", 0x204014,  64 * 1024, 16, },
-       { "m45pe16", 0x204015,  64 * 1024, 32, },
-
-       { "m25pe80", 0x208014,  64 * 1024, 16, },
-       { "m25pe16", 0x208015,  64 * 1024, 32, SECT_4K, },
+       { "m25p05",  0x202010,  0, 32 * 1024, 2, },
+       { "m25p10",  0x202011,  0, 32 * 1024, 4, },
+       { "m25p20",  0x202012,  0, 64 * 1024, 4, },
+       { "m25p40",  0x202013,  0, 64 * 1024, 8, },
+       { "m25p80",         0,  0, 64 * 1024, 16, },
+       { "m25p16",  0x202015,  0, 64 * 1024, 32, },
+       { "m25p32",  0x202016,  0, 64 * 1024, 64, },
+       { "m25p64",  0x202017,  0, 64 * 1024, 128, },
+       { "m25p128", 0x202018, 0, 256 * 1024, 64, },
+
+       { "m45pe80", 0x204014,  0, 64 * 1024, 16, },
+       { "m45pe16", 0x204015,  0, 64 * 1024, 32, },
+
+       { "m25pe80", 0x208014,  0, 64 * 1024, 16, },
+       { "m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K, },
 
        /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-       { "w25x10", 0xef3011, 64 * 1024, 2, SECT_4K, },
-       { "w25x20", 0xef3012, 64 * 1024, 4, SECT_4K, },
-       { "w25x40", 0xef3013, 64 * 1024, 8, SECT_4K, },
-       { "w25x80", 0xef3014, 64 * 1024, 16, SECT_4K, },
-       { "w25x16", 0xef3015, 64 * 1024, 32, SECT_4K, },
-       { "w25x32", 0xef3016, 64 * 1024, 64, SECT_4K, },
-       { "w25x64", 0xef3017, 64 * 1024, 128, SECT_4K, },
+       { "w25x10", 0xef3011, 0, 64 * 1024, 2, SECT_4K, },
+       { "w25x20", 0xef3012, 0, 64 * 1024, 4, SECT_4K, },
+       { "w25x40", 0xef3013, 0, 64 * 1024, 8, SECT_4K, },
+       { "w25x80", 0xef3014, 0, 64 * 1024, 16, SECT_4K, },
+       { "w25x16", 0xef3015, 0, 64 * 1024, 32, SECT_4K, },
+       { "w25x32", 0xef3016, 0, 64 * 1024, 64, SECT_4K, },
+       { "w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K, },
 };
 
 static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
@@ -515,6 +550,7 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
        u8                      code = OPCODE_RDID;
        u8                      id[3];
        u32                     jedec;
+       u16                     ext_jedec;
        struct flash_info       *info;
 
        /* JEDEC also defines an optional "extended device information"
@@ -533,10 +569,14 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
        jedec = jedec << 8;
        jedec |= id[2];
 
+       ext_jedec = id[3] << 8 | id[4];
+
        for (tmp = 0, info = m25p_data;
                        tmp < ARRAY_SIZE(m25p_data);
                        tmp++, info++) {
                if (info->jedec_id == jedec)
+                       if (ext_jedec != 0 && info->ext_id != ext_jedec)
+                               continue;
                        return info;
        }
        dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec);
index 8bd0dea6885f4ad91288d8f5313f08cb636fe10e..6dd9aff8bb2d37181fb711c98f9d839f1fd52a15 100644 (file)
  * doesn't (yet) use these for any kind of i/o overlap or prefetching.
  *
  * Sometimes DataFlash is packaged in MMC-format cards, although the
- * MMC stack can't use SPI (yet), or distinguish between MMC and DataFlash
+ * MMC stack can't (yet?) distinguish between MMC and DataFlash
  * protocols during enumeration.
  */
 
-#define CONFIG_DATAFLASH_WRITE_VERIFY
-
 /* reads can bypass the buffers */
 #define OP_READ_CONTINUOUS     0xE8
 #define OP_READ_PAGE           0xD2
@@ -80,7 +78,8 @@
  */
 #define OP_READ_ID             0x9F
 #define OP_READ_SECURITY       0x77
-#define OP_WRITE_SECURITY      0x9A    /* OTP bits */
+#define OP_WRITE_SECURITY_REVC 0x9A
+#define OP_WRITE_SECURITY      0x9B    /* revision D */
 
 
 struct dataflash {
@@ -402,7 +401,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
                (void) dataflash_waitready(priv->spi);
 
 
-#ifdef CONFIG_DATAFLASH_WRITE_VERIFY
+#ifdef CONFIG_MTD_DATAFLASH_VERIFY_WRITE
 
                /* (3) Compare to Buffer1 */
                addr = pageaddr << priv->page_offset;
@@ -431,7 +430,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
                } else
                        status = 0;
 
-#endif /* CONFIG_DATAFLASH_WRITE_VERIFY */
+#endif /* CONFIG_MTD_DATAFLASH_VERIFY_WRITE */
 
                remaining = remaining - writelen;
                pageaddr++;
@@ -451,16 +450,192 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 /* ......................................................................... */
 
+#ifdef CONFIG_MTD_DATAFLASH_OTP
+
+static int dataflash_get_otp_info(struct mtd_info *mtd,
+               struct otp_info *info, size_t len)
+{
+       /* Report both blocks as identical:  bytes 0..64, locked.
+        * Unless the user block changed from all-ones, we can't
+        * tell whether it's still writable; so we assume it isn't.
+        */
+       info->start = 0;
+       info->length = 64;
+       info->locked = 1;
+       return sizeof(*info);
+}
+
+static ssize_t otp_read(struct spi_device *spi, unsigned base,
+               uint8_t *buf, loff_t off, size_t len)
+{
+       struct spi_message      m;
+       size_t                  l;
+       uint8_t                 *scratch;
+       struct spi_transfer     t;
+       int                     status;
+
+       if (off > 64)
+               return -EINVAL;
+
+       if ((off + len) > 64)
+               len = 64 - off;
+       if (len == 0)
+               return len;
+
+       spi_message_init(&m);
+
+       l = 4 + base + off + len;
+       scratch = kzalloc(l, GFP_KERNEL);
+       if (!scratch)
+               return -ENOMEM;
+
+       /* OUT: OP_READ_SECURITY, 3 don't-care bytes, zeroes
+        * IN:  ignore 4 bytes, data bytes 0..N (max 127)
+        */
+       scratch[0] = OP_READ_SECURITY;
+
+       memset(&t, 0, sizeof t);
+       t.tx_buf = scratch;
+       t.rx_buf = scratch;
+       t.len = l;
+       spi_message_add_tail(&t, &m);
+
+       dataflash_waitready(spi);
+
+       status = spi_sync(spi, &m);
+       if (status >= 0) {
+               memcpy(buf, scratch + 4 + base + off, len);
+               status = len;
+       }
+
+       kfree(scratch);
+       return status;
+}
+
+static int dataflash_read_fact_otp(struct mtd_info *mtd,
+               loff_t from, size_t len, size_t *retlen, u_char *buf)
+{
+       struct dataflash        *priv = (struct dataflash *)mtd->priv;
+       int                     status;
+
+       /* 64 bytes, from 0..63 ... start at 64 on-chip */
+       mutex_lock(&priv->lock);
+       status = otp_read(priv->spi, 64, buf, from, len);
+       mutex_unlock(&priv->lock);
+
+       if (status < 0)
+               return status;
+       *retlen = status;
+       return 0;
+}
+
+static int dataflash_read_user_otp(struct mtd_info *mtd,
+               loff_t from, size_t len, size_t *retlen, u_char *buf)
+{
+       struct dataflash        *priv = (struct dataflash *)mtd->priv;
+       int                     status;
+
+       /* 64 bytes, from 0..63 ... start at 0 on-chip */
+       mutex_lock(&priv->lock);
+       status = otp_read(priv->spi, 0, buf, from, len);
+       mutex_unlock(&priv->lock);
+
+       if (status < 0)
+               return status;
+       *retlen = status;
+       return 0;
+}
+
+static int dataflash_write_user_otp(struct mtd_info *mtd,
+               loff_t from, size_t len, size_t *retlen, u_char *buf)
+{
+       struct spi_message      m;
+       const size_t            l = 4 + 64;
+       uint8_t                 *scratch;
+       struct spi_transfer     t;
+       struct dataflash        *priv = (struct dataflash *)mtd->priv;
+       int                     status;
+
+       if (len > 64)
+               return -EINVAL;
+
+       /* Strictly speaking, we *could* truncate the write ... but
+        * let's not do that for the only write that's ever possible.
+        */
+       if ((from + len) > 64)
+               return -EINVAL;
+
+       /* OUT: OP_WRITE_SECURITY, 3 zeroes, 64 data-or-zero bytes
+        * IN:  ignore all
+        */
+       scratch = kzalloc(l, GFP_KERNEL);
+       if (!scratch)
+               return -ENOMEM;
+       scratch[0] = OP_WRITE_SECURITY;
+       memcpy(scratch + 4 + from, buf, len);
+
+       spi_message_init(&m);
+
+       memset(&t, 0, sizeof t);
+       t.tx_buf = scratch;
+       t.len = l;
+       spi_message_add_tail(&t, &m);
+
+       /* Write the OTP bits, if they've not yet been written.
+        * This modifies SRAM buffer1.
+        */
+       mutex_lock(&priv->lock);
+       dataflash_waitready(priv->spi);
+       status = spi_sync(priv->spi, &m);
+       mutex_unlock(&priv->lock);
+
+       kfree(scratch);
+
+       if (status >= 0) {
+               status = 0;
+               *retlen = len;
+       }
+       return status;
+}
+
+static char *otp_setup(struct mtd_info *device, char revision)
+{
+       device->get_fact_prot_info = dataflash_get_otp_info;
+       device->read_fact_prot_reg = dataflash_read_fact_otp;
+       device->get_user_prot_info = dataflash_get_otp_info;
+       device->read_user_prot_reg = dataflash_read_user_otp;
+
+       /* rev c parts (at45db321c and at45db1281 only!) use a
+        * different write procedure; not (yet?) implemented.
+        */
+       if (revision > 'c')
+               device->write_user_prot_reg = dataflash_write_user_otp;
+
+       return ", OTP";
+}
+
+#else
+
+static char *otp_setup(struct mtd_info *device, char revision)
+{
+       return " (OTP)";
+}
+
+#endif
+
+/* ......................................................................... */
+
 /*
  * Register DataFlash device with MTD subsystem.
  */
 static int __devinit
-add_dataflash(struct spi_device *spi, char *name,
-               int nr_pages, int pagesize, int pageoffset)
+add_dataflash_otp(struct spi_device *spi, char *name,
+               int nr_pages, int pagesize, int pageoffset, char revision)
 {
        struct dataflash                *priv;
        struct mtd_info                 *device;
        struct flash_platform_data      *pdata = spi->dev.platform_data;
+       char                            *otp_tag = "";
 
        priv = kzalloc(sizeof *priv, GFP_KERNEL);
        if (!priv)
@@ -489,8 +664,12 @@ add_dataflash(struct spi_device *spi, char *name,
        device->write = dataflash_write;
        device->priv = priv;
 
-       dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes\n",
-                       name, DIV_ROUND_UP(device->size, 1024), pagesize);
+       if (revision >= 'c')
+               otp_tag = otp_setup(device, revision);
+
+       dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes%s\n",
+                       name, DIV_ROUND_UP(device->size, 1024),
+                       pagesize, otp_tag);
        dev_set_drvdata(&spi->dev, priv);
 
        if (mtd_has_partitions()) {
@@ -519,6 +698,14 @@ add_dataflash(struct spi_device *spi, char *name,
        return add_mtd_device(device) == 1 ? -ENODEV : 0;
 }
 
+static inline int __devinit
+add_dataflash(struct spi_device *spi, char *name,
+               int nr_pages, int pagesize, int pageoffset)
+{
+       return add_dataflash_otp(spi, name, nr_pages, pagesize,
+                       pageoffset, 0);
+}
+
 struct flash_info {
        char            *name;
 
@@ -664,13 +851,16 @@ static int __devinit dataflash_probe(struct spi_device *spi)
         * Try to detect dataflash by JEDEC ID.
         * If it succeeds we know we have either a C or D part.
         * D will support power of 2 pagesize option.
+        * Both support the security register, though with different
+        * write procedures.
         */
        info = jedec_probe(spi);
        if (IS_ERR(info))
                return PTR_ERR(info);
        if (info != NULL)
-               return add_dataflash(spi, info->name, info->nr_pages,
-                                info->pagesize, info->pageoffset);
+               return add_dataflash_otp(spi, info->name, info->nr_pages,
+                               info->pagesize, info->pageoffset,
+                               (info->flags & SUP_POW2PS) ? 'd' : 'c');
 
        /*
         * Older chips support only legacy commands, identifing
index df8e00bba07b2726f71fbf02b6b1d27ff0cf396a..3ae76ecc07d70fbfa6d57016c3dbbf7755f4cb36 100644 (file)
@@ -332,30 +332,6 @@ config MTD_CFI_FLAGADM
          Mapping for the Flaga digital module. If you don't have one, ignore
          this setting.
 
-config MTD_WALNUT
-       tristate "Flash device mapped on IBM 405GP Walnut"
-       depends on MTD_JEDECPROBE && WALNUT && !PPC_MERGE
-       help
-         This enables access routines for the flash chips on the IBM 405GP
-         Walnut board. If you have one of these boards and would like to
-         use the flash chips on it, say 'Y'.
-
-config MTD_EBONY
-       tristate "Flash devices mapped on IBM 440GP Ebony"
-       depends on MTD_JEDECPROBE && EBONY && !PPC_MERGE
-       help
-         This enables access routines for the flash chips on the IBM 440GP
-         Ebony board. If you have one of these boards and would like to
-         use the flash chips on it, say 'Y'.
-
-config MTD_OCOTEA
-       tristate "Flash devices mapped on IBM 440GX Ocotea"
-       depends on MTD_CFI && OCOTEA && !PPC_MERGE
-       help
-         This enables access routines for the flash chips on the IBM 440GX
-         Ocotea board. If you have one of these boards and would like to
-         use the flash chips on it, say 'Y'.
-
 config MTD_REDWOOD
        tristate "CFI Flash devices mapped on IBM Redwood"
        depends on MTD_CFI && ( REDWOOD_4 || REDWOOD_5 || REDWOOD_6 )
@@ -458,13 +434,6 @@ config MTD_CEIVA
          PhotoMax Digital Picture Frame.
          If you have such a device, say 'Y'.
 
-config MTD_NOR_TOTO
-       tristate "NOR Flash device on TOTO board"
-       depends on ARCH_OMAP && OMAP_TOTO
-       help
-         This enables access to the NOR flash on the Texas Instruments
-         TOTO board.
-
 config MTD_H720X
        tristate "Hynix evaluation board mappings"
        depends on MTD_CFI && ( ARCH_H7201 || ARCH_H7202 )
index 6cda6df973e5d11c187533e48534ac5ff60c6038..6d9ba35caf11a26bbeb4caefec9eae1dddcd9940 100644 (file)
@@ -50,12 +50,8 @@ obj-$(CONFIG_MTD_REDWOOD)    += redwood.o
 obj-$(CONFIG_MTD_UCLINUX)      += uclinux.o
 obj-$(CONFIG_MTD_NETtel)       += nettel.o
 obj-$(CONFIG_MTD_SCB2_FLASH)   += scb2_flash.o
-obj-$(CONFIG_MTD_EBONY)                += ebony.o
-obj-$(CONFIG_MTD_OCOTEA)       += ocotea.o
-obj-$(CONFIG_MTD_WALNUT)        += walnut.o
 obj-$(CONFIG_MTD_H720X)                += h720x-flash.o
 obj-$(CONFIG_MTD_SBC8240)      += sbc8240.o
-obj-$(CONFIG_MTD_NOR_TOTO)     += omap-toto-flash.o
 obj-$(CONFIG_MTD_IXP4XX)       += ixp4xx.o
 obj-$(CONFIG_MTD_IXP2000)      += ixp2000.o
 obj-$(CONFIG_MTD_WRSBC8260)    += wr_sbc82xx_flash.o
diff --git a/drivers/mtd/maps/ebony.c b/drivers/mtd/maps/ebony.c
deleted file mode 100644 (file)
index d92b7c7..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Mapping for Ebony user flash
- *
- * Matt Porter <mporter@kernel.crashing.org>
- *
- * Copyright 2002-2004 MontaVista Software Inc.
- *
- * 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.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-#include <asm/io.h>
-#include <asm/ibm44x.h>
-#include <platforms/4xx/ebony.h>
-
-static struct mtd_info *flash;
-
-static struct map_info ebony_small_map = {
-       .name =         "Ebony small flash",
-       .size =         EBONY_SMALL_FLASH_SIZE,
-       .bankwidth =    1,
-};
-
-static struct map_info ebony_large_map = {
-       .name =         "Ebony large flash",
-       .size =         EBONY_LARGE_FLASH_SIZE,
-       .bankwidth =    1,
-};
-
-static struct mtd_partition ebony_small_partitions[] = {
-       {
-               .name =   "OpenBIOS",
-               .offset = 0x0,
-               .size =   0x80000,
-       }
-};
-
-static struct mtd_partition ebony_large_partitions[] = {
-       {
-               .name =   "fs",
-               .offset = 0,
-               .size =   0x380000,
-       },
-       {
-               .name =   "firmware",
-               .offset = 0x380000,
-               .size =   0x80000,
-       }
-};
-
-int __init init_ebony(void)
-{
-       u8 fpga0_reg;
-       u8 __iomem *fpga0_adr;
-       unsigned long long small_flash_base, large_flash_base;
-
-       fpga0_adr = ioremap64(EBONY_FPGA_ADDR, 16);
-       if (!fpga0_adr)
-               return -ENOMEM;
-
-       fpga0_reg = readb(fpga0_adr);
-       iounmap(fpga0_adr);
-
-       if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
-                       !EBONY_FLASH_SEL(fpga0_reg))
-               small_flash_base = EBONY_SMALL_FLASH_HIGH2;
-       else if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
-                       EBONY_FLASH_SEL(fpga0_reg))
-               small_flash_base = EBONY_SMALL_FLASH_HIGH1;
-       else if (!EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
-                       !EBONY_FLASH_SEL(fpga0_reg))
-               small_flash_base = EBONY_SMALL_FLASH_LOW2;
-       else
-               small_flash_base = EBONY_SMALL_FLASH_LOW1;
-
-       if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
-                       !EBONY_ONBRD_FLASH_EN(fpga0_reg))
-               large_flash_base = EBONY_LARGE_FLASH_LOW;
-       else
-               large_flash_base = EBONY_LARGE_FLASH_HIGH;
-
-       ebony_small_map.phys = small_flash_base;
-       ebony_small_map.virt = ioremap64(small_flash_base,
-                                        ebony_small_map.size);
-
-       if (!ebony_small_map.virt) {
-               printk("Failed to ioremap flash\n");
-               return -EIO;
-       }
-
-       simple_map_init(&ebony_small_map);
-
-       flash = do_map_probe("jedec_probe", &ebony_small_map);
-       if (flash) {
-               flash->owner = THIS_MODULE;
-               add_mtd_partitions(flash, ebony_small_partitions,
-                                       ARRAY_SIZE(ebony_small_partitions));
-       } else {
-               printk("map probe failed for flash\n");
-               iounmap(ebony_small_map.virt);
-               return -ENXIO;
-       }
-
-       ebony_large_map.phys = large_flash_base;
-       ebony_large_map.virt = ioremap64(large_flash_base,
-                                        ebony_large_map.size);
-
-       if (!ebony_large_map.virt) {
-               printk("Failed to ioremap flash\n");
-               iounmap(ebony_small_map.virt);
-               return -EIO;
-       }
-
-       simple_map_init(&ebony_large_map);
-
-       flash = do_map_probe("jedec_probe", &ebony_large_map);
-       if (flash) {
-               flash->owner = THIS_MODULE;
-               add_mtd_partitions(flash, ebony_large_partitions,
-                                       ARRAY_SIZE(ebony_large_partitions));
-       } else {
-               printk("map probe failed for flash\n");
-               iounmap(ebony_small_map.virt);
-               iounmap(ebony_large_map.virt);
-               return -ENXIO;
-       }
-
-       return 0;
-}
-
-static void __exit cleanup_ebony(void)
-{
-       if (flash) {
-               del_mtd_partitions(flash);
-               map_destroy(flash);
-       }
-
-       if (ebony_small_map.virt) {
-               iounmap(ebony_small_map.virt);
-               ebony_small_map.virt = NULL;
-       }
-
-       if (ebony_large_map.virt) {
-               iounmap(ebony_large_map.virt);
-               ebony_large_map.virt = NULL;
-       }
-}
-
-module_init(init_ebony);
-module_exit(cleanup_ebony);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
-MODULE_DESCRIPTION("MTD map and partitions for IBM 440GP Ebony boards");
diff --git a/drivers/mtd/maps/ocotea.c b/drivers/mtd/maps/ocotea.c
deleted file mode 100644 (file)
index 5522eac..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Mapping for Ocotea user flash
- *
- * Matt Porter <mporter@kernel.crashing.org>
- *
- * Copyright 2002-2004 MontaVista Software Inc.
- *
- * 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.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-#include <asm/io.h>
-#include <asm/ibm44x.h>
-#include <platforms/4xx/ocotea.h>
-
-static struct mtd_info *flash;
-
-static struct map_info ocotea_small_map = {
-       .name =         "Ocotea small flash",
-       .size =         OCOTEA_SMALL_FLASH_SIZE,
-       .buswidth =     1,
-};
-
-static struct map_info ocotea_large_map = {
-       .name =         "Ocotea large flash",
-       .size =         OCOTEA_LARGE_FLASH_SIZE,
-       .buswidth =     1,
-};
-
-static struct mtd_partition ocotea_small_partitions[] = {
-       {
-               .name =   "pibs",
-               .offset = 0x0,
-               .size =   0x100000,
-       }
-};
-
-static struct mtd_partition ocotea_large_partitions[] = {
-       {
-               .name =   "fs",
-               .offset = 0,
-               .size =   0x300000,
-       },
-       {
-               .name =   "firmware",
-               .offset = 0x300000,
-               .size =   0x100000,
-       }
-};
-
-int __init init_ocotea(void)
-{
-       u8 fpga0_reg;
-       u8 *fpga0_adr;
-       unsigned long long small_flash_base, large_flash_base;
-
-       fpga0_adr = ioremap64(OCOTEA_FPGA_ADDR, 16);
-       if (!fpga0_adr)
-               return -ENOMEM;
-
-       fpga0_reg = readb((unsigned long)fpga0_adr);
-       iounmap(fpga0_adr);
-
-       if (OCOTEA_BOOT_LARGE_FLASH(fpga0_reg)) {
-               small_flash_base = OCOTEA_SMALL_FLASH_HIGH;
-               large_flash_base = OCOTEA_LARGE_FLASH_LOW;
-       }
-       else {
-               small_flash_base = OCOTEA_SMALL_FLASH_LOW;
-               large_flash_base = OCOTEA_LARGE_FLASH_HIGH;
-       }
-
-       ocotea_small_map.phys = small_flash_base;
-       ocotea_small_map.virt = ioremap64(small_flash_base,
-                                        ocotea_small_map.size);
-
-       if (!ocotea_small_map.virt) {
-               printk("Failed to ioremap flash\n");
-               return -EIO;
-       }
-
-       simple_map_init(&ocotea_small_map);
-
-       flash = do_map_probe("map_rom", &ocotea_small_map);
-       if (flash) {
-               flash->owner = THIS_MODULE;
-               add_mtd_partitions(flash, ocotea_small_partitions,
-                                       ARRAY_SIZE(ocotea_small_partitions));
-       } else {
-               printk("map probe failed for flash\n");
-               iounmap(ocotea_small_map.virt);
-               return -ENXIO;
-       }
-
-       ocotea_large_map.phys = large_flash_base;
-       ocotea_large_map.virt = ioremap64(large_flash_base,
-                                        ocotea_large_map.size);
-
-       if (!ocotea_large_map.virt) {
-               printk("Failed to ioremap flash\n");
-               iounmap(ocotea_small_map.virt);
-               return -EIO;
-       }
-
-       simple_map_init(&ocotea_large_map);
-
-       flash = do_map_probe("cfi_probe", &ocotea_large_map);
-       if (flash) {
-               flash->owner = THIS_MODULE;
-               add_mtd_partitions(flash, ocotea_large_partitions,
-                                       ARRAY_SIZE(ocotea_large_partitions));
-       } else {
-               printk("map probe failed for flash\n");
-               iounmap(ocotea_small_map.virt);
-               iounmap(ocotea_large_map.virt);
-               return -ENXIO;
-       }
-
-       return 0;
-}
-
-static void __exit cleanup_ocotea(void)
-{
-       if (flash) {
-               del_mtd_partitions(flash);
-               map_destroy(flash);
-       }
-
-       if (ocotea_small_map.virt) {
-               iounmap((void *)ocotea_small_map.virt);
-               ocotea_small_map.virt = 0;
-       }
-
-       if (ocotea_large_map.virt) {
-               iounmap((void *)ocotea_large_map.virt);
-               ocotea_large_map.virt = 0;
-       }
-}
-
-module_init(init_ocotea);
-module_exit(cleanup_ocotea);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
-MODULE_DESCRIPTION("MTD map and partitions for IBM 440GX Ocotea boards");
diff --git a/drivers/mtd/maps/omap-toto-flash.c b/drivers/mtd/maps/omap-toto-flash.c
deleted file mode 100644 (file)
index 0a60ebb..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * NOR Flash memory access on TI Toto board
- *
- * jzhang@ti.com (C) 2003 Texas Instruments.
- *
- *  (C) 2002 MontVista Software, Inc.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-
-
-#ifndef CONFIG_ARCH_OMAP
-#error This is for OMAP architecture only
-#endif
-
-//these lines need be moved to a hardware header file
-#define OMAP_TOTO_FLASH_BASE 0xd8000000
-#define OMAP_TOTO_FLASH_SIZE 0x80000
-
-static struct map_info omap_toto_map_flash = {
-       .name =         "OMAP Toto flash",
-       .bankwidth =    2,
-       .virt =         (void __iomem *)OMAP_TOTO_FLASH_BASE,
-};
-
-
-static struct mtd_partition toto_flash_partitions[] = {
-       {
-               .name =         "BootLoader",
-               .size =         0x00040000,     /* hopefully u-boot will stay 128k + 128*/
-               .offset =       0,
-               .mask_flags =   MTD_WRITEABLE,  /* force read-only */
-       }, {
-               .name =         "ReservedSpace",
-               .size =         0x00030000,
-               .offset =       MTDPART_OFS_APPEND,
-               //mask_flags:   MTD_WRITEABLE,  /* force read-only */
-       }, {
-               .name =         "EnvArea",      /* bottom 64KiB for env vars */
-               .size =         MTDPART_SIZ_FULL,
-               .offset =       MTDPART_OFS_APPEND,
-       }
-};
-
-static struct mtd_partition *parsed_parts;
-
-static struct mtd_info *flash_mtd;
-
-static int __init init_flash (void)
-{
-
-       struct mtd_partition *parts;
-       int nb_parts = 0;
-       int parsed_nr_parts = 0;
-       const char *part_type;
-
-       /*
-        * Static partition definition selection
-        */
-       part_type = "static";
-
-       parts = toto_flash_partitions;
-       nb_parts = ARRAY_SIZE(toto_flash_partitions);
-       omap_toto_map_flash.size = OMAP_TOTO_FLASH_SIZE;
-       omap_toto_map_flash.phys = virt_to_phys(OMAP_TOTO_FLASH_BASE);
-
-       simple_map_init(&omap_toto_map_flash);
-       /*
-        * Now let's probe for the actual flash.  Do it here since
-        * specific machine settings might have been set above.
-        */
-       printk(KERN_NOTICE "OMAP toto flash: probing %d-bit flash bus\n",
-               omap_toto_map_flash.bankwidth*8);
-       flash_mtd = do_map_probe("jedec_probe", &omap_toto_map_flash);
-       if (!flash_mtd)
-               return -ENXIO;
-
-       if (parsed_nr_parts > 0) {
-               parts = parsed_parts;
-               nb_parts = parsed_nr_parts;
-       }
-
-       if (nb_parts == 0) {
-               printk(KERN_NOTICE "OMAP toto flash: no partition info available,"
-                       "registering whole flash at once\n");
-               if (add_mtd_device(flash_mtd)){
-            return -ENXIO;
-        }
-       } else {
-               printk(KERN_NOTICE "Using %s partition definition\n",
-                       part_type);
-               return add_mtd_partitions(flash_mtd, parts, nb_parts);
-       }
-       return 0;
-}
-
-int __init omap_toto_mtd_init(void)
-{
-       int status;
-
-       if (status = init_flash()) {
-               printk(KERN_ERR "OMAP Toto Flash: unable to init map for toto flash\n");
-       }
-    return status;
-}
-
-static void  __exit omap_toto_mtd_cleanup(void)
-{
-       if (flash_mtd) {
-               del_mtd_partitions(flash_mtd);
-               map_destroy(flash_mtd);
-               kfree(parsed_parts);
-       }
-}
-
-module_init(omap_toto_mtd_init);
-module_exit(omap_toto_mtd_cleanup);
-
-MODULE_AUTHOR("Jian Zhang");
-MODULE_DESCRIPTION("OMAP Toto board map driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/walnut.c b/drivers/mtd/maps/walnut.c
deleted file mode 100644 (file)
index e243476..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Mapping for Walnut flash
- * (used ebony.c as a "framework")
- *
- * Heikki Lindholm <holindho@infradead.org>
- *
- *
- * 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.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-#include <asm/io.h>
-#include <asm/ibm4xx.h>
-#include <platforms/4xx/walnut.h>
-
-/* these should be in platforms/4xx/walnut.h ? */
-#define WALNUT_FLASH_ONBD_N(x)         (x & 0x02)
-#define WALNUT_FLASH_SRAM_SEL(x)       (x & 0x01)
-#define WALNUT_FLASH_LOW               0xFFF00000
-#define WALNUT_FLASH_HIGH              0xFFF80000
-#define WALNUT_FLASH_SIZE              0x80000
-
-static struct mtd_info *flash;
-
-static struct map_info walnut_map = {
-       .name =         "Walnut flash",
-       .size =         WALNUT_FLASH_SIZE,
-       .bankwidth =    1,
-};
-
-/* Actually, OpenBIOS is the last 128 KiB of the flash - better
- * partitioning could be made */
-static struct mtd_partition walnut_partitions[] = {
-       {
-               .name =   "OpenBIOS",
-               .offset = 0x0,
-               .size =   WALNUT_FLASH_SIZE,
-               /*.mask_flags = MTD_WRITEABLE, */ /* force read-only */
-       }
-};
-
-int __init init_walnut(void)
-{
-       u8 fpga_brds1;
-       void *fpga_brds1_adr;
-       void *fpga_status_adr;
-       unsigned long flash_base;
-
-       /* this should already be mapped (platform/4xx/walnut.c) */
-       fpga_status_adr = ioremap(WALNUT_FPGA_BASE, 8);
-       if (!fpga_status_adr)
-               return -ENOMEM;
-
-       fpga_brds1_adr = fpga_status_adr+5;
-       fpga_brds1 = readb(fpga_brds1_adr);
-       /* iounmap(fpga_status_adr); */
-
-       if (WALNUT_FLASH_ONBD_N(fpga_brds1)) {
-               printk("The on-board flash is disabled (U79 sw 5)!");
-               iounmap(fpga_status_adr);
-               return -EIO;
-       }
-       if (WALNUT_FLASH_SRAM_SEL(fpga_brds1))
-               flash_base = WALNUT_FLASH_LOW;
-       else
-               flash_base = WALNUT_FLASH_HIGH;
-
-       walnut_map.phys = flash_base;
-       walnut_map.virt =
-               (void __iomem *)ioremap(flash_base, walnut_map.size);
-
-       if (!walnut_map.virt) {
-               printk("Failed to ioremap flash.\n");
-               iounmap(fpga_status_adr);
-               return -EIO;
-       }
-
-       simple_map_init(&walnut_map);
-
-       flash = do_map_probe("jedec_probe", &walnut_map);
-       if (flash) {
-               flash->owner = THIS_MODULE;
-               add_mtd_partitions(flash, walnut_partitions,
-                                       ARRAY_SIZE(walnut_partitions));
-       } else {
-               printk("map probe failed for flash\n");
-               iounmap(fpga_status_adr);
-               return -ENXIO;
-       }
-
-       iounmap(fpga_status_adr);
-       return 0;
-}
-
-static void __exit cleanup_walnut(void)
-{
-       if (flash) {
-               del_mtd_partitions(flash);
-               map_destroy(flash);
-       }
-
-       if (walnut_map.virt) {
-               iounmap((void *)walnut_map.virt);
-               walnut_map.virt = 0;
-       }
-}
-
-module_init(init_walnut);
-module_exit(cleanup_walnut);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Heikki Lindholm <holindho@infradead.org>");
-MODULE_DESCRIPTION("MTD map and partitions for IBM 405GP Walnut boards");
index d2f331876e4c86a9b8ee74a36541a1baf01b4b9a..13cc67ad272a682ee11313326fdcbc07acbd5c7b 100644 (file)
@@ -350,7 +350,7 @@ static void mtdchar_erase_callback (struct erase_info *instr)
        wake_up((wait_queue_head_t *)instr->priv);
 }
 
-#if defined(CONFIG_MTD_OTP) || defined(CONFIG_MTD_ONENAND_OTP)
+#ifdef CONFIG_HAVE_MTD_OTP
 static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
 {
        struct mtd_info *mtd = mfi->mtd;
@@ -663,7 +663,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                break;
        }
 
-#if defined(CONFIG_MTD_OTP) || defined(CONFIG_MTD_ONENAND_OTP)
+#ifdef CONFIG_HAVE_MTD_OTP
        case OTPSELECT:
        {
                int mode;
index 2972a5edb73d507e60b9b633b5e85e14a9070074..789842d0e6f21352023729c4037327205dccc067 100644 (file)
@@ -444,7 +444,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
                        return -EINVAL;
        }
 
-       instr->fail_addr = 0xffffffff;
+       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
 
        /* make a local copy of instr to avoid modifying the caller's struct */
        erase = kmalloc(sizeof (struct erase_info), GFP_KERNEL);
@@ -493,7 +493,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
                        /* sanity check: should never happen since
                         * block alignment has been checked above */
                        BUG_ON(err == -EINVAL);
-                       if (erase->fail_addr != 0xffffffff)
+                       if (erase->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                                instr->fail_addr = erase->fail_addr + offset;
                        break;
                }
index edb90b58a9b16980bd42066f6026bbd1ca7c0667..8e77e36e75ee33cb8f8271714e4138dd5ce4f7e0 100644 (file)
@@ -214,7 +214,7 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr)
        instr->addr += part->offset;
        ret = part->master->erase(part->master, instr);
        if (ret) {
-               if (instr->fail_addr != 0xffffffff)
+               if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
        }
@@ -226,7 +226,7 @@ void mtd_erase_callback(struct erase_info *instr)
        if (instr->mtd->erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
 
-               if (instr->fail_addr != 0xffffffff)
+               if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
        }
index 41f361c49b32b73344b62f0838eb35647328dceb..8eb2b06cf0d94d61a08e3a6dc801898c4df88de3 100644 (file)
@@ -68,12 +68,6 @@ config MTD_NAND_AMS_DELTA
        help
          Support for NAND flash on Amstrad E3 (Delta).
 
-config MTD_NAND_TOTO
-       tristate "NAND Flash device on TOTO board"
-       depends on ARCH_OMAP && BROKEN
-       help
-         Support for NAND flash on Texas Instruments Toto platform.
-
 config MTD_NAND_TS7250
        tristate "NAND Flash device on TS-7250 board"
        depends on MACH_TS72XX
index b786c5da82da227fe388bf468c6dc370caee49ea..8540c46ffba9bd6bd6b830f3cccba3e98d259f93 100644 (file)
@@ -8,7 +8,6 @@ obj-$(CONFIG_MTD_NAND_IDS)              += nand_ids.o
 obj-$(CONFIG_MTD_NAND_CAFE)            += cafe_nand.o
 obj-$(CONFIG_MTD_NAND_SPIA)            += spia.o
 obj-$(CONFIG_MTD_NAND_AMS_DELTA)       += ams-delta.o
-obj-$(CONFIG_MTD_NAND_TOTO)            += toto.o
 obj-$(CONFIG_MTD_NAND_AUTCPU12)                += autcpu12.o
 obj-$(CONFIG_MTD_NAND_EDB7312)         += edb7312.o
 obj-$(CONFIG_MTD_NAND_AU1550)          += au1550nd.o
index d1129bae6c27d20731ef0ead6b86a863e590e7f4..582280560c89417199bd0a142c2247160cb3f2e0 100644 (file)
@@ -2042,7 +2042,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
                return -EINVAL;
        }
 
-       instr->fail_addr = 0xffffffff;
+       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
 
        /* Grab the lock and see if the device is available */
        nand_get_device(chip, mtd, FL_ERASING);
index 556e8131ecdcd68c9a685e5f5bea5f036d839222..ae7c57781a68e76885ca286b9a68a16d218358be 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/delay.h>
 #include <linux/list.h>
 #include <linux/random.h>
-#include <asm/div64.h>
 
 /* Default simulator parameters values */
 #if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE)  || \
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c
deleted file mode 100644 (file)
index bbf492e..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- *  drivers/mtd/nand/toto.c
- *
- *  Copyright (c) 2003 Texas Instruments
- *
- *  Derived from drivers/mtd/autcpu12.c
- *
- *  Copyright (c) 2002 Thomas Gleixner <tgxl@linutronix.de>
- *
- * 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
- * published by the Free Software Foundation.
- *
- *  Overview:
- *   This is a device driver for the NAND flash device found on the
- *   TI fido board. It supports 32MiB and 64MiB cards
- */
-
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/partitions.h>
-#include <asm/io.h>
-#include <asm/arch/hardware.h>
-#include <asm/sizes.h>
-#include <asm/arch/toto.h>
-#include <asm/arch-omap1510/hardware.h>
-#include <asm/arch/gpio.h>
-
-#define CONFIG_NAND_WORKAROUND 1
-
-/*
- * MTD structure for TOTO board
- */
-static struct mtd_info *toto_mtd = NULL;
-
-static unsigned long toto_io_base = OMAP_FLASH_1_BASE;
-
-/*
- * Define partitions for flash devices
- */
-
-static struct mtd_partition partition_info64M[] = {
-       { .name =       "toto kernel partition 1",
-         .offset =     0,
-         .size =       2 * SZ_1M },
-       { .name =       "toto file sys partition 2",
-         .offset =     2 * SZ_1M,
-         .size =       14 * SZ_1M },
-       { .name =       "toto user partition 3",
-         .offset =     16 * SZ_1M,
-         .size =       16 * SZ_1M },
-       { .name =       "toto devboard extra partition 4",
-         .offset =     32 * SZ_1M,
-         .size =       32 * SZ_1M },
-};
-
-static struct mtd_partition partition_info32M[] = {
-       { .name =       "toto kernel partition 1",
-         .offset =     0,
-         .size =       2 * SZ_1M },
-       { .name =       "toto file sys partition 2",
-         .offset =     2 * SZ_1M,
-         .size =       14 * SZ_1M },
-       { .name =       "toto user partition 3",
-         .offset =     16 * SZ_1M,
-         .size =       16 * SZ_1M },
-};
-
-#define NUM_PARTITIONS32M 3
-#define NUM_PARTITIONS64M 4
-
-/*
- *     hardware specific access to control-lines
- *
- *     ctrl:
- *     NAND_NCE: bit 0 -> bit 14 (0x4000)
- *     NAND_CLE: bit 1 -> bit 12 (0x1000)
- *     NAND_ALE: bit 2 -> bit 1  (0x0002)
- */
-static void toto_hwcontrol(struct mtd_info *mtd, int cmd,
-                          unsigned int ctrl)
-{
-       struct nand_chip *chip = mtd->priv;
-
-       if (ctrl & NAND_CTRL_CHANGE) {
-               unsigned long bits;
-
-               /* hopefully enough time for tc make proceding write to clear */
-               udelay(1);
-
-               bits = (~ctrl & NAND_NCE) << 14;
-               bits |= (ctrl & NAND_CLE) << 12;
-               bits |= (ctrl & NAND_ALE) >> 1;
-
-#warning Wild guess as gpiosetout() is nowhere defined in the kernel source - tglx
-               gpiosetout(0x5002, bits);
-
-#ifdef CONFIG_NAND_WORKAROUND
-               /* "some" dev boards busted, blue wired to rts2 :( */
-               rts2setout(2, (ctrl & NAND_CLE) << 1);
-#endif
-               /* allow time to ensure gpio state to over take memory write */
-               udelay(1);
-       }
-
-       if (cmd != NAND_CMD_NONE)
-               writeb(cmd, chip->IO_ADDR_W);
-}
-
-/*
- * Main initialization routine
- */
-static int __init toto_init(void)
-{
-       struct nand_chip *this;
-       int err = 0;
-
-       /* Allocate memory for MTD device structure and private data */
-       toto_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
-       if (!toto_mtd) {
-               printk(KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n");
-               err = -ENOMEM;
-               goto out;
-       }
-
-       /* Get pointer to private data */
-       this = (struct nand_chip *)(&toto_mtd[1]);
-
-       /* Initialize structures */
-       memset(toto_mtd, 0, sizeof(struct mtd_info));
-       memset(this, 0, sizeof(struct nand_chip));
-
-       /* Link the private data with the MTD structure */
-       toto_mtd->priv = this;
-       toto_mtd->owner = THIS_MODULE;
-
-       /* Set address of NAND IO lines */
-       this->IO_ADDR_R = toto_io_base;
-       this->IO_ADDR_W = toto_io_base;
-       this->cmd_ctrl = toto_hwcontrol;
-       this->dev_ready = NULL;
-       /* 25 us command delay time */
-       this->chip_delay = 30;
-       this->ecc.mode = NAND_ECC_SOFT;
-
-       /* Scan to find existance of the device */
-       if (nand_scan(toto_mtd, 1)) {
-               err = -ENXIO;
-               goto out_mtd;
-       }
-
-       /* Register the partitions */
-       switch (toto_mtd->size) {
-       case SZ_64M:
-               add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M);
-               break;
-       case SZ_32M:
-               add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M);
-               break;
-       default:{
-                       printk(KERN_WARNING "Unsupported Nand device\n");
-                       err = -ENXIO;
-                       goto out_buf;
-               }
-       }
-
-       gpioreserve(NAND_MASK); /* claim our gpios */
-       archflashwp(0, 0);      /* open up flash for writing */
-
-       goto out;
-
- out_mtd:
-       kfree(toto_mtd);
- out:
-       return err;
-}
-
-module_init(toto_init);
-
-/*
- * Clean up routine
- */
-static void __exit toto_cleanup(void)
-{
-       /* Release resources, unregister device */
-       nand_release(toto_mtd);
-
-       /* Free the MTD device structure */
-       kfree(toto_mtd);
-
-       /* stop flash writes */
-       archflashwp(0, 1);
-
-       /* release gpios to system */
-       gpiorelease(NAND_MASK);
-}
-
-module_exit(toto_cleanup);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Richard Woodruff <r-woodruff2@ti.com>");
-MODULE_DESCRIPTION("Glue layer for NAND flash on toto board");
index cb41cbca64f7e63394f352820eb90cc610bac6f8..79fa79e8f8de9b67a5949888d029f93b7dbebb27 100644 (file)
@@ -27,8 +27,16 @@ config MTD_ONENAND_GENERIC
        help
          Support for OneNAND flash via platform device driver.
 
+config MTD_ONENAND_OMAP2
+       tristate "OneNAND on OMAP2/OMAP3 support"
+       depends on MTD_ONENAND && (ARCH_OMAP2 || ARCH_OMAP3)
+       help
+         Support for a OneNAND flash device connected to an OMAP2/OMAP3 CPU
+         via the GPMC memory controller.
+
 config MTD_ONENAND_OTP
        bool "OneNAND OTP Support"
+       select HAVE_MTD_OTP
        help
          One Block of the NAND Flash Array memory is reserved as
          a One-Time Programmable Block memory area.
index 4d2eacfd7e11a761c3cec319f34c735d0fc0222b..64b6cc61a5209241145a4a3e1856dcb39a96d19c 100644 (file)
@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD_ONENAND)               += onenand.o
 
 # Board specific.
 obj-$(CONFIG_MTD_ONENAND_GENERIC)      += generic.o
+obj-$(CONFIG_MTD_ONENAND_OMAP2)                += omap2.o
 
 # Simulator
 obj-$(CONFIG_MTD_ONENAND_SIM)          += onenand_sim.o
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
new file mode 100644 (file)
index 0000000..40153ac
--- /dev/null
@@ -0,0 +1,777 @@
+/*
+ *  linux/drivers/mtd/onenand/omap2.c
+ *
+ *  OneNAND driver for OMAP2 / OMAP3
+ *
+ *  Copyright Â© 2005-2006 Nokia Corporation
+ *
+ *  Author: Jarkko Lavinen <jarkko.lavinen@nokia.com> and Juha Yrjölä
+ *  IRQ and DMA support written by Timo Teras
+ *
+ * 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 published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; see the file COPYING. If not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/onenand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+
+#include <asm/io.h>
+#include <asm/mach/flash.h>
+#include <asm/arch/gpmc.h>
+#include <asm/arch/onenand.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/gpmc.h>
+#include <asm/arch/pm.h>
+
+#include <linux/dma-mapping.h>
+#include <asm/dma-mapping.h>
+#include <asm/arch/dma.h>
+
+#include <asm/arch/board.h>
+
+#define DRIVER_NAME "omap2-onenand"
+
+#define ONENAND_IO_SIZE                SZ_128K
+#define ONENAND_BUFRAM_SIZE    (1024 * 5)
+
+struct omap2_onenand {
+       struct platform_device *pdev;
+       int gpmc_cs;
+       unsigned long phys_base;
+       int gpio_irq;
+       struct mtd_info mtd;
+       struct mtd_partition *parts;
+       struct onenand_chip onenand;
+       struct completion irq_done;
+       struct completion dma_done;
+       int dma_channel;
+       int freq;
+       int (*setup)(void __iomem *base, int freq);
+};
+
+static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
+{
+       struct omap2_onenand *c = data;
+
+       complete(&c->dma_done);
+}
+
+static irqreturn_t omap2_onenand_interrupt(int irq, void *dev_id)
+{
+       struct omap2_onenand *c = dev_id;
+
+       complete(&c->irq_done);
+
+       return IRQ_HANDLED;
+}
+
+static inline unsigned short read_reg(struct omap2_onenand *c, int reg)
+{
+       return readw(c->onenand.base + reg);
+}
+
+static inline void write_reg(struct omap2_onenand *c, unsigned short value,
+                            int reg)
+{
+       writew(value, c->onenand.base + reg);
+}
+
+static void wait_err(char *msg, int state, unsigned int ctrl, unsigned int intr)
+{
+       printk(KERN_ERR "onenand_wait: %s! state %d ctrl 0x%04x intr 0x%04x\n",
+              msg, state, ctrl, intr);
+}
+
+static void wait_warn(char *msg, int state, unsigned int ctrl,
+                     unsigned int intr)
+{
+       printk(KERN_WARNING "onenand_wait: %s! state %d ctrl 0x%04x "
+              "intr 0x%04x\n", msg, state, ctrl, intr);
+}
+
+static int omap2_onenand_wait(struct mtd_info *mtd, int state)
+{
+       struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
+       unsigned int intr = 0;
+       unsigned int ctrl;
+       unsigned long timeout;
+       u32 syscfg;
+
+       if (state == FL_RESETING) {
+               int i;
+
+               for (i = 0; i < 20; i++) {
+                       udelay(1);
+                       intr = read_reg(c, ONENAND_REG_INTERRUPT);
+                       if (intr & ONENAND_INT_MASTER)
+                               break;
+               }
+               ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
+               if (ctrl & ONENAND_CTRL_ERROR) {
+                       wait_err("controller error", state, ctrl, intr);
+                       return -EIO;
+               }
+               if (!(intr & ONENAND_INT_RESET)) {
+                       wait_err("timeout", state, ctrl, intr);
+                       return -EIO;
+               }
+               return 0;
+       }
+
+       if (state != FL_READING) {
+               int result;
+
+               /* Turn interrupts on */
+               syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
+               syscfg |= ONENAND_SYS_CFG1_IOBE;
+               write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);
+
+               INIT_COMPLETION(c->irq_done);
+               if (c->gpio_irq) {
+                       result = omap_get_gpio_datain(c->gpio_irq);
+                       if (result == -1) {
+                               ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
+                               intr = read_reg(c, ONENAND_REG_INTERRUPT);
+                               wait_err("gpio error", state, ctrl, intr);
+                               return -EIO;
+                       }
+               } else
+                       result = 0;
+               if (result == 0) {
+                       int retry_cnt = 0;
+retry:
+                       result = wait_for_completion_timeout(&c->irq_done,
+                                                   msecs_to_jiffies(20));
+                       if (result == 0) {
+                               /* Timeout after 20ms */
+                               ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
+                               if (ctrl & ONENAND_CTRL_ONGO) {
+                                       /*
+                                        * The operation seems to be still going
+                                        * so give it some more time.
+                                        */
+                                       retry_cnt += 1;
+                                       if (retry_cnt < 3)
+                                               goto retry;
+                                       intr = read_reg(c,
+                                                       ONENAND_REG_INTERRUPT);
+                                       wait_err("timeout", state, ctrl, intr);
+                                       return -EIO;
+                               }
+                               intr = read_reg(c, ONENAND_REG_INTERRUPT);
+                               if ((intr & ONENAND_INT_MASTER) == 0)
+                                       wait_warn("timeout", state, ctrl, intr);
+                       }
+               }
+       } else {
+               /* Turn interrupts off */
+               syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
+               syscfg &= ~ONENAND_SYS_CFG1_IOBE;
+               write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);
+
+               timeout = jiffies + msecs_to_jiffies(20);
+               while (time_before(jiffies, timeout)) {
+                       intr = read_reg(c, ONENAND_REG_INTERRUPT);
+                       if (intr & ONENAND_INT_MASTER)
+                               break;
+               }
+       }
+
+       intr = read_reg(c, ONENAND_REG_INTERRUPT);
+       ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
+
+       if (intr & ONENAND_INT_READ) {
+               int ecc = read_reg(c, ONENAND_REG_ECC_STATUS);
+
+               if (ecc) {
+                       unsigned int addr1, addr8;
+
+                       addr1 = read_reg(c, ONENAND_REG_START_ADDRESS1);
+                       addr8 = read_reg(c, ONENAND_REG_START_ADDRESS8);
+                       if (ecc & ONENAND_ECC_2BIT_ALL) {
+                               printk(KERN_ERR "onenand_wait: ECC error = "
+                                      "0x%04x, addr1 %#x, addr8 %#x\n",
+                                      ecc, addr1, addr8);
+                               mtd->ecc_stats.failed++;
+                               return -EBADMSG;
+                       } else if (ecc & ONENAND_ECC_1BIT_ALL) {
+                               printk(KERN_NOTICE "onenand_wait: correctable "
+                                      "ECC error = 0x%04x, addr1 %#x, "
+                                      "addr8 %#x\n", ecc, addr1, addr8);
+                               mtd->ecc_stats.corrected++;
+                       }
+               }
+       } else if (state == FL_READING) {
+               wait_err("timeout", state, ctrl, intr);
+               return -EIO;
+       }
+
+       if (ctrl & ONENAND_CTRL_ERROR) {
+               wait_err("controller error", state, ctrl, intr);
+               if (ctrl & ONENAND_CTRL_LOCK)
+                       printk(KERN_ERR "onenand_wait: "
+                                       "Device is write protected!!!\n");
+               return -EIO;
+       }
+
+       if (ctrl & 0xFE9F)
+               wait_warn("unexpected controller status", state, ctrl, intr);
+
+       return 0;
+}
+
+static inline int omap2_onenand_bufferram_offset(struct mtd_info *mtd, int area)
+{
+       struct onenand_chip *this = mtd->priv;
+
+       if (ONENAND_CURRENT_BUFFERRAM(this)) {
+               if (area == ONENAND_DATARAM)
+                       return mtd->writesize;
+               if (area == ONENAND_SPARERAM)
+                       return mtd->oobsize;
+       }
+
+       return 0;
+}
+
+#if defined(CONFIG_ARCH_OMAP3) || defined(MULTI_OMAP2)
+
+static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,
+                                       unsigned char *buffer, int offset,
+                                       size_t count)
+{
+       struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
+       struct onenand_chip *this = mtd->priv;
+       dma_addr_t dma_src, dma_dst;
+       int bram_offset;
+       unsigned long timeout;
+       void *buf = (void *)buffer;
+       size_t xtra;
+       volatile unsigned *done;
+
+       bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
+       if (bram_offset & 3 || (size_t)buf & 3 || count < 384)
+               goto out_copy;
+
+       if (buf >= high_memory) {
+               struct page *p1;
+
+               if (((size_t)buf & PAGE_MASK) !=
+                   ((size_t)(buf + count - 1) & PAGE_MASK))
+                       goto out_copy;
+               p1 = vmalloc_to_page(buf);
+               if (!p1)
+                       goto out_copy;
+               buf = page_address(p1) + ((size_t)buf & ~PAGE_MASK);
+       }
+
+       xtra = count & 3;
+       if (xtra) {
+               count -= xtra;
+               memcpy(buf + count, this->base + bram_offset + count, xtra);
+       }
+
+       dma_src = c->phys_base + bram_offset;
+       dma_dst = dma_map_single(&c->pdev->dev, buf, count, DMA_FROM_DEVICE);
+       if (dma_mapping_error(&c->pdev->dev, dma_dst)) {
+               dev_err(&c->pdev->dev,
+                       "Couldn't DMA map a %d byte buffer\n",
+                       count);
+               goto out_copy;
+       }
+
+       omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S32,
+                                    count >> 2, 1, 0, 0, 0);
+       omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                               dma_src, 0, 0);
+       omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                                dma_dst, 0, 0);
+
+       INIT_COMPLETION(c->dma_done);
+       omap_start_dma(c->dma_channel);
+
+       timeout = jiffies + msecs_to_jiffies(20);
+       done = &c->dma_done.done;
+       while (time_before(jiffies, timeout))
+               if (*done)
+                       break;
+
+       dma_unmap_single(&c->pdev->dev, dma_dst, count, DMA_FROM_DEVICE);
+
+       if (!*done) {
+               dev_err(&c->pdev->dev, "timeout waiting for DMA\n");
+               goto out_copy;
+       }
+
+       return 0;
+
+out_copy:
+       memcpy(buf, this->base + bram_offset, count);
+       return 0;
+}
+
+static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,
+                                        const unsigned char *buffer,
+                                        int offset, size_t count)
+{
+       struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
+       struct onenand_chip *this = mtd->priv;
+       dma_addr_t dma_src, dma_dst;
+       int bram_offset;
+       unsigned long timeout;
+       void *buf = (void *)buffer;
+       volatile unsigned *done;
+
+       bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
+       if (bram_offset & 3 || (size_t)buf & 3 || count < 384)
+               goto out_copy;
+
+       /* panic_write() may be in an interrupt context */
+       if (in_interrupt())
+               goto out_copy;
+
+       if (buf >= high_memory) {
+               struct page *p1;
+
+               if (((size_t)buf & PAGE_MASK) !=
+                   ((size_t)(buf + count - 1) & PAGE_MASK))
+                       goto out_copy;
+               p1 = vmalloc_to_page(buf);
+               if (!p1)
+                       goto out_copy;
+               buf = page_address(p1) + ((size_t)buf & ~PAGE_MASK);
+       }
+
+       dma_src = dma_map_single(&c->pdev->dev, buf, count, DMA_TO_DEVICE);
+       dma_dst = c->phys_base + bram_offset;
+       if (dma_mapping_error(&c->pdev->dev, dma_dst)) {
+               dev_err(&c->pdev->dev,
+                       "Couldn't DMA map a %d byte buffer\n",
+                       count);
+               return -1;
+       }
+
+       omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S32,
+                                    count >> 2, 1, 0, 0, 0);
+       omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                               dma_src, 0, 0);
+       omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                                dma_dst, 0, 0);
+
+       INIT_COMPLETION(c->dma_done);
+       omap_start_dma(c->dma_channel);
+
+       timeout = jiffies + msecs_to_jiffies(20);
+       done = &c->dma_done.done;
+       while (time_before(jiffies, timeout))
+               if (*done)
+                       break;
+
+       dma_unmap_single(&c->pdev->dev, dma_dst, count, DMA_TO_DEVICE);
+
+       if (!*done) {
+               dev_err(&c->pdev->dev, "timeout waiting for DMA\n");
+               goto out_copy;
+       }
+
+       return 0;
+
+out_copy:
+       memcpy(this->base + bram_offset, buf, count);
+       return 0;
+}
+
+#else
+
+int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,
+                                unsigned char *buffer, int offset,
+                                size_t count);
+
+int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,
+                                 const unsigned char *buffer,
+                                 int offset, size_t count);
+
+#endif
+
+#if defined(CONFIG_ARCH_OMAP2) || defined(MULTI_OMAP2)
+
+static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,
+                                       unsigned char *buffer, int offset,
+                                       size_t count)
+{
+       struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
+       struct onenand_chip *this = mtd->priv;
+       dma_addr_t dma_src, dma_dst;
+       int bram_offset;
+
+       bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
+       /* DMA is not used.  Revisit PM requirements before enabling it. */
+       if (1 || (c->dma_channel < 0) ||
+           ((void *) buffer >= (void *) high_memory) || (bram_offset & 3) ||
+           (((unsigned int) buffer) & 3) || (count < 1024) || (count & 3)) {
+               memcpy(buffer, (__force void *)(this->base + bram_offset),
+                      count);
+               return 0;
+       }
+
+       dma_src = c->phys_base + bram_offset;
+       dma_dst = dma_map_single(&c->pdev->dev, buffer, count,
+                                DMA_FROM_DEVICE);
+       if (dma_mapping_error(&c->pdev->dev, dma_dst)) {
+               dev_err(&c->pdev->dev,
+                       "Couldn't DMA map a %d byte buffer\n",
+                       count);
+               return -1;
+       }
+
+       omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S32,
+                                    count / 4, 1, 0, 0, 0);
+       omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                               dma_src, 0, 0);
+       omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                                dma_dst, 0, 0);
+
+       INIT_COMPLETION(c->dma_done);
+       omap_start_dma(c->dma_channel);
+       wait_for_completion(&c->dma_done);
+
+       dma_unmap_single(&c->pdev->dev, dma_dst, count, DMA_FROM_DEVICE);
+
+       return 0;
+}
+
+static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
+                                        const unsigned char *buffer,
+                                        int offset, size_t count)
+{
+       struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
+       struct onenand_chip *this = mtd->priv;
+       dma_addr_t dma_src, dma_dst;
+       int bram_offset;
+
+       bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
+       /* DMA is not used.  Revisit PM requirements before enabling it. */
+       if (1 || (c->dma_channel < 0) ||
+           ((void *) buffer >= (void *) high_memory) || (bram_offset & 3) ||
+           (((unsigned int) buffer) & 3) || (count < 1024) || (count & 3)) {
+               memcpy((__force void *)(this->base + bram_offset), buffer,
+                      count);
+               return 0;
+       }
+
+       dma_src = dma_map_single(&c->pdev->dev, (void *) buffer, count,
+                                DMA_TO_DEVICE);
+       dma_dst = c->phys_base + bram_offset;
+       if (dma_mapping_error(&c->pdev->dev, dma_dst)) {
+               dev_err(&c->pdev->dev,
+                       "Couldn't DMA map a %d byte buffer\n",
+                       count);
+               return -1;
+       }
+
+       omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S16,
+                                    count / 2, 1, 0, 0, 0);
+       omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                               dma_src, 0, 0);
+       omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
+                                dma_dst, 0, 0);
+
+       INIT_COMPLETION(c->dma_done);
+       omap_start_dma(c->dma_channel);
+       wait_for_completion(&c->dma_done);
+
+       dma_unmap_single(&c->pdev->dev, dma_dst, count, DMA_TO_DEVICE);
+
+       return 0;
+}
+
+#else
+
+int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,
+                                unsigned char *buffer, int offset,
+                                size_t count);
+
+int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
+                                 const unsigned char *buffer,
+                                 int offset, size_t count);
+
+#endif
+
+static struct platform_driver omap2_onenand_driver;
+
+static int __adjust_timing(struct device *dev, void *data)
+{
+       int ret = 0;
+       struct omap2_onenand *c;
+
+       c = dev_get_drvdata(dev);
+
+       BUG_ON(c->setup == NULL);
+
+       /* DMA is not in use so this is all that is needed */
+       /* Revisit for OMAP3! */
+       ret = c->setup(c->onenand.base, c->freq);
+
+       return ret;
+}
+
+int omap2_onenand_rephase(void)
+{
+       return driver_for_each_device(&omap2_onenand_driver.driver, NULL,
+                                     NULL, __adjust_timing);
+}
+
+static void __devexit omap2_onenand_shutdown(struct platform_device *pdev)
+{
+       struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
+
+       /* With certain content in the buffer RAM, the OMAP boot ROM code
+        * can recognize the flash chip incorrectly. Zero it out before
+        * soft reset.
+        */
+       memset((__force void *)c->onenand.base, 0, ONENAND_BUFRAM_SIZE);
+}
+
+static int __devinit omap2_onenand_probe(struct platform_device *pdev)
+{
+       struct omap_onenand_platform_data *pdata;
+       struct omap2_onenand *c;
+       int r;
+
+       pdata = pdev->dev.platform_data;
+       if (pdata == NULL) {
+               dev_err(&pdev->dev, "platform data missing\n");
+               return -ENODEV;
+       }
+
+       c = kzalloc(sizeof(struct omap2_onenand), GFP_KERNEL);
+       if (!c)
+               return -ENOMEM;
+
+       init_completion(&c->irq_done);
+       init_completion(&c->dma_done);
+       c->gpmc_cs = pdata->cs;
+       c->gpio_irq = pdata->gpio_irq;
+       c->dma_channel = pdata->dma_channel;
+       if (c->dma_channel < 0) {
+               /* if -1, don't use DMA */
+               c->gpio_irq = 0;
+       }
+
+       r = gpmc_cs_request(c->gpmc_cs, ONENAND_IO_SIZE, &c->phys_base);
+       if (r < 0) {
+               dev_err(&pdev->dev, "Cannot request GPMC CS\n");
+               goto err_kfree;
+       }
+
+       if (request_mem_region(c->phys_base, ONENAND_IO_SIZE,
+                              pdev->dev.driver->name) == NULL) {
+               dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, "
+                       "size: 0x%x\n", c->phys_base, ONENAND_IO_SIZE);
+               r = -EBUSY;
+               goto err_free_cs;
+       }
+       c->onenand.base = ioremap(c->phys_base, ONENAND_IO_SIZE);
+       if (c->onenand.base == NULL) {
+               r = -ENOMEM;
+               goto err_release_mem_region;
+       }
+
+       if (pdata->onenand_setup != NULL) {
+               r = pdata->onenand_setup(c->onenand.base, c->freq);
+               if (r < 0) {
+                       dev_err(&pdev->dev, "Onenand platform setup failed: "
+                               "%d\n", r);
+                       goto err_iounmap;
+               }
+               c->setup = pdata->onenand_setup;
+       }
+
+       if (c->gpio_irq) {
+               if ((r = omap_request_gpio(c->gpio_irq)) < 0) {
+                       dev_err(&pdev->dev,  "Failed to request GPIO%d for "
+                               "OneNAND\n", c->gpio_irq);
+                       goto err_iounmap;
+       }
+       omap_set_gpio_direction(c->gpio_irq, 1);
+
+       if ((r = request_irq(OMAP_GPIO_IRQ(c->gpio_irq),
+                            omap2_onenand_interrupt, IRQF_TRIGGER_RISING,
+                            pdev->dev.driver->name, c)) < 0)
+               goto err_release_gpio;
+       }
+
+       if (c->dma_channel >= 0) {
+               r = omap_request_dma(0, pdev->dev.driver->name,
+                                    omap2_onenand_dma_cb, (void *) c,
+                                    &c->dma_channel);
+               if (r == 0) {
+                       omap_set_dma_write_mode(c->dma_channel,
+                                               OMAP_DMA_WRITE_NON_POSTED);
+                       omap_set_dma_src_data_pack(c->dma_channel, 1);
+                       omap_set_dma_src_burst_mode(c->dma_channel,
+                                                   OMAP_DMA_DATA_BURST_8);
+                       omap_set_dma_dest_data_pack(c->dma_channel, 1);
+                       omap_set_dma_dest_burst_mode(c->dma_channel,
+                                                    OMAP_DMA_DATA_BURST_8);
+               } else {
+                       dev_info(&pdev->dev,
+                                "failed to allocate DMA for OneNAND, "
+                                "using PIO instead\n");
+                       c->dma_channel = -1;
+               }
+       }
+
+       dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual "
+                "base %p\n", c->gpmc_cs, c->phys_base,
+                c->onenand.base);
+
+       c->pdev = pdev;
+       c->mtd.name = pdev->dev.bus_id;
+       c->mtd.priv = &c->onenand;
+       c->mtd.owner = THIS_MODULE;
+
+       if (c->dma_channel >= 0) {
+               struct onenand_chip *this = &c->onenand;
+
+               this->wait = omap2_onenand_wait;
+               if (cpu_is_omap34xx()) {
+                       this->read_bufferram = omap3_onenand_read_bufferram;
+                       this->write_bufferram = omap3_onenand_write_bufferram;
+               } else {
+                       this->read_bufferram = omap2_onenand_read_bufferram;
+                       this->write_bufferram = omap2_onenand_write_bufferram;
+               }
+       }
+
+       if ((r = onenand_scan(&c->mtd, 1)) < 0)
+               goto err_release_dma;
+
+       switch ((c->onenand.version_id >> 4) & 0xf) {
+       case 0:
+               c->freq = 40;
+               break;
+       case 1:
+               c->freq = 54;
+               break;
+       case 2:
+               c->freq = 66;
+               break;
+       case 3:
+               c->freq = 83;
+               break;
+       }
+
+#ifdef CONFIG_MTD_PARTITIONS
+       if (pdata->parts != NULL)
+               r = add_mtd_partitions(&c->mtd, pdata->parts,
+                                      pdata->nr_parts);
+       else
+#endif
+               r = add_mtd_device(&c->mtd);
+       if (r < 0)
+               goto err_release_onenand;
+
+       platform_set_drvdata(pdev, c);
+
+       return 0;
+
+err_release_onenand:
+       onenand_release(&c->mtd);
+err_release_dma:
+       if (c->dma_channel != -1)
+               omap_free_dma(c->dma_channel);
+       if (c->gpio_irq)
+               free_irq(OMAP_GPIO_IRQ(c->gpio_irq), c);
+err_release_gpio:
+       if (c->gpio_irq)
+               omap_free_gpio(c->gpio_irq);
+err_iounmap:
+       iounmap(c->onenand.base);
+err_release_mem_region:
+       release_mem_region(c->phys_base, ONENAND_IO_SIZE);
+err_free_cs:
+       gpmc_cs_free(c->gpmc_cs);
+err_kfree:
+       kfree(c);
+
+       return r;
+}
+
+static int __devexit omap2_onenand_remove(struct platform_device *pdev)
+{
+       struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
+
+       BUG_ON(c == NULL);
+
+#ifdef CONFIG_MTD_PARTITIONS
+       if (c->parts)
+               del_mtd_partitions(&c->mtd);
+       else
+               del_mtd_device(&c->mtd);
+#else
+       del_mtd_device(&c->mtd);
+#endif
+
+       onenand_release(&c->mtd);
+       if (c->dma_channel != -1)
+               omap_free_dma(c->dma_channel);
+       omap2_onenand_shutdown(pdev);
+       platform_set_drvdata(pdev, NULL);
+       if (c->gpio_irq) {
+               free_irq(OMAP_GPIO_IRQ(c->gpio_irq), c);
+               omap_free_gpio(c->gpio_irq);
+       }
+       iounmap(c->onenand.base);
+       release_mem_region(c->phys_base, ONENAND_IO_SIZE);
+       kfree(c);
+
+       return 0;
+}
+
+static struct platform_driver omap2_onenand_driver = {
+       .probe          = omap2_onenand_probe,
+       .remove         = omap2_onenand_remove,
+       .shutdown       = omap2_onenand_shutdown,
+       .driver         = {
+               .name   = DRIVER_NAME,
+               .owner  = THIS_MODULE,
+       },
+};
+
+static int __init omap2_onenand_init(void)
+{
+       printk(KERN_INFO "OneNAND driver initializing\n");
+       return platform_driver_register(&omap2_onenand_driver);
+}
+
+static void __exit omap2_onenand_exit(void)
+{
+       platform_driver_unregister(&omap2_onenand_driver);
+}
+
+module_init(omap2_onenand_init);
+module_exit(omap2_onenand_exit);
+
+MODULE_ALIAS(DRIVER_NAME);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jarkko Lavinen <jarkko.lavinen@nokia.com>");
+MODULE_DESCRIPTION("Glue layer for OneNAND flash on OMAP2 / OMAP3");
index 926cf3a4135d1ca84094c40d018803709d059334..90ed319f26e6843c98d26dafba79762b2fd4abbc 100644 (file)
@@ -1794,7 +1794,7 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
                return -EINVAL;
        }
 
-       instr->fail_addr = 0xffffffff;
+       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
 
        /* Grab the lock and see if the device is available */
        onenand_get_device(mtd, FL_ERASING);
index a5f3d60047d47f50da60ce7b8569ef326542173d..33a5d6ed6f18aa66181feb4ac84774343e68d5d3 100644 (file)
@@ -321,8 +321,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
        DEBUG(MTD_DEBUG_LEVEL1,
                "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n",
                ssfdc->cis_block, ssfdc->erase_size, ssfdc->map_len,
-               (ssfdc->map_len + MAX_PHYS_BLK_PER_ZONE - 1) /
-               MAX_PHYS_BLK_PER_ZONE);
+               DIV_ROUND_UP(ssfdc->map_len, MAX_PHYS_BLK_PER_ZONE));
 
        /* Set geometry */
        ssfdc->heads = 16;
index dddb2a6c9e2cfc087b6becc7f88d9e85ab1d02b4..259461b910afec4542ea5f13af00bf0c63b3bf42 100644 (file)
@@ -68,7 +68,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
        instr->len = c->sector_size;
        instr->callback = jffs2_erase_callback;
        instr->priv = (unsigned long)(&instr[1]);
-       instr->fail_addr = 0xffffffff;
+       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
 
        ((struct erase_priv_struct *)instr->priv)->jeb = jeb;
        ((struct erase_priv_struct *)instr->priv)->c = c;
@@ -175,7 +175,7 @@ static void jffs2_erase_failed(struct jffs2_sb_info *c, struct jffs2_eraseblock
 {
        /* For NAND, if the failure did not occur at the device level for a
           specific physical page, don't bother updating the bad block table. */
-       if (jffs2_cleanmarker_oob(c) && (bad_offset != 0xffffffff)) {
+       if (jffs2_cleanmarker_oob(c) && (bad_offset != MTD_FAIL_ADDR_UNKNOWN)) {
                /* We had a device-level failure to erase.  Let's see if we've
                   failed too many times. */
                if (!jffs2_write_nand_badblock(c, jeb, bad_offset)) {
index d6fb115f5a0714794c077ea6ff98ea18243d537e..ee5124ec319e4e036f1f139dff39c428c6732190 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mtd/flashchip.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/cfi_endian.h>
+#include <linux/mtd/xip.h>
 
 #ifdef CONFIG_MTD_CFI_I1
 #define cfi_interleave(cfi) 1
@@ -430,7 +431,6 @@ static inline uint32_t cfi_send_gen_cmd(u_char cmd, uint32_t cmd_addr, uint32_t
 {
        map_word val;
        uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type);
-
        val = cfi_build_cmd(cmd, map, cfi);
 
        if (prev_val)
@@ -483,6 +483,13 @@ static inline void cfi_udelay(int us)
        }
 }
 
+int __xipram cfi_qry_present(struct map_info *map, __u32 base,
+                            struct cfi_private *cfi);
+int __xipram cfi_qry_mode_on(uint32_t base, struct map_info *map,
+                            struct cfi_private *cfi);
+void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map,
+                              struct cfi_private *cfi);
+
 struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size,
                             const char* name);
 struct cfi_fixup {
index 08dd131301c1fe98e87d900f9173cc054f953a84..d4f38c5fd44ec1d1affcc5876e23dfaadc727fd8 100644 (file)
@@ -73,6 +73,10 @@ struct flchip {
        int buffer_write_time;
        int erase_time;
 
+       int word_write_time_max;
+       int buffer_write_time_max;
+       int erase_time_max;
+
        void *priv;
 };
 
index 922636548558943d7af9007074cb8d2e7e91fcb0..eae26bb6430ae0e8db2c70385d1b1c72c3e32d5b 100644 (file)
 #define MTD_ERASE_DONE          0x08
 #define MTD_ERASE_FAILED        0x10
 
+#define MTD_FAIL_ADDR_UNKNOWN 0xffffffff
+
 /* If the erase fails, fail_addr might indicate exactly which block failed.  If
-   fail_addr = 0xffffffff, the failure was not at the device level or was not
+   fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not
    specific to any particular block. */
 struct erase_info {
        struct mtd_info *mtd;
index d1b310c92eb45a9272c8ba2ac30c26becb856a5e..0c6bbe28f38ce91e01151faa517c75688300488b 100644 (file)
 #define ONENAND_SYS_CFG1_INT           (1 << 6)
 #define ONENAND_SYS_CFG1_IOBE          (1 << 5)
 #define ONENAND_SYS_CFG1_RDY_CONF      (1 << 4)
+#define ONENAND_SYS_CFG1_HF            (1 << 2)
+#define ONENAND_SYS_CFG1_SYNC_WRITE    (1 << 1)
 
 /*
  * Controller Status Register F240h (R)