]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/mtd/nand.h
[MTD NAND] Allocate chip->buffers separately to allow it to be overridden
[linux-2.6-omap-h63xx.git] / include / linux / mtd / nand.h
index 1a749ba6130fedd6e1e24d2db56079ab49e4083f..cd4fe9ae8622197ca5b6d637588fc4a2f2019728 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef __LINUX_MTD_NAND_H
 #define __LINUX_MTD_NAND_H
 
-#include <linux/config.h>
 #include <linux/wait.h>
 #include <linux/spinlock.h>
 #include <linux/mtd/mtd.h>
 struct mtd_info;
 /* Scan and identify a NAND device */
 extern int nand_scan (struct mtd_info *mtd, int max_chips);
+/* Separate phases of nand_scan(), allowing board driver to intervene
+ * and override command or ECC setup according to flash type */
+extern int nand_scan_ident(struct mtd_info *mtd, int max_chips);
+extern int nand_scan_tail(struct mtd_info *mtd);
+
 /* Free resources held by the NAND device */
 extern void nand_release (struct mtd_info *mtd);
 
-/* Read raw data from the device without ECC */
-extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from,
-                         size_t len, size_t ooblen);
-
-
-extern int nand_write_raw(struct mtd_info *mtd, loff_t to, size_t len,
-                         size_t *retlen, const uint8_t *buf, uint8_t *oob);
-
 /* The maximum number of NAND chips in an array */
 #define NAND_MAX_CHIPS         8
 
@@ -71,18 +67,21 @@ extern int nand_write_raw(struct mtd_info *mtd, loff_t to, size_t len,
  */
 #define NAND_CMD_READ0         0
 #define NAND_CMD_READ1         1
+#define NAND_CMD_RNDOUT                5
 #define NAND_CMD_PAGEPROG      0x10
 #define NAND_CMD_READOOB       0x50
 #define NAND_CMD_ERASE1                0x60
 #define NAND_CMD_STATUS                0x70
 #define NAND_CMD_STATUS_MULTI  0x71
 #define NAND_CMD_SEQIN         0x80
+#define NAND_CMD_RNDIN         0x85
 #define NAND_CMD_READID                0x90
 #define NAND_CMD_ERASE2                0xd0
 #define NAND_CMD_RESET         0xff
 
 /* Extended commands for large page devices */
 #define NAND_CMD_READSTART     0x30
+#define NAND_CMD_RNDOUTSTART   0xE0
 #define NAND_CMD_CACHEDPROG    0x15
 
 /* Extended commands for AG-AND device */
@@ -184,7 +183,9 @@ typedef enum {
 #define NAND_USE_FLASH_BBT     0x00010000
 /* This option skips the bbt scan during initialization. */
 #define NAND_SKIP_BBTSCAN      0x00020000
-
+/* This option is defined if the board driver allocates its own buffers
+   (e.g. because it needs them DMA-coherent */
+#define NAND_OWN_BUFFERS       0x00040000
 /* Options set by nand scan */
 /* Nand scan has allocated controller struct */
 #define NAND_CONTROLLER_ALLOC  0x80000000
@@ -208,7 +209,7 @@ typedef enum {
 struct nand_chip;
 
 /**
- * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independend devices
+ * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices
  * @lock:               protection lock
  * @active:            the mtd device which holds the controller currently
  * @wq:                        wait queue to sleep on if a NAND operation is in progress
@@ -229,12 +230,15 @@ struct nand_hw_control {
  * @total:     total number of ecc bytes per page
  * @prepad:    padding information for syndrome based ecc generators
  * @postpad:   padding information for syndrome based ecc generators
+ * @layout:    ECC layout control struct pointer
  * @hwctl:     function to control hardware ecc generator. Must only
  *             be provided if an hardware ECC is available
  * @calculate: function for ecc calculation or readback from ecc hardware
  * @correct:   function for ecc correction, matching to ecc generator (sw/hw)
  * @read_page: function to read a page according to the ecc generator requirements
  * @write_page:        function to write a page according to the ecc generator requirements
+ * @read_oob:  function to read chip OOB data
+ * @write_oob: function to write chip OOB data
  */
 struct nand_ecc_ctrl {
        nand_ecc_modes_t        mode;
@@ -244,6 +248,7 @@ struct nand_ecc_ctrl {
        int                     total;
        int                     prepad;
        int                     postpad;
+       struct nand_ecclayout   *layout;
        void                    (*hwctl)(struct mtd_info *mtd, int mode);
        int                     (*calculate)(struct mtd_info *mtd,
                                             const uint8_t *dat,
@@ -257,6 +262,13 @@ struct nand_ecc_ctrl {
        void                    (*write_page)(struct mtd_info *mtd,
                                              struct nand_chip *chip,
                                              const uint8_t *buf);
+       int                     (*read_oob)(struct mtd_info *mtd,
+                                           struct nand_chip *chip,
+                                           int page,
+                                           int sndcmd);
+       int                     (*write_oob)(struct mtd_info *mtd,
+                                            struct nand_chip *chip,
+                                            int page);
 };
 
 /**
@@ -298,11 +310,15 @@ struct nand_buffers {
  * @cmdfunc:           [REPLACEABLE] hardwarespecific function for writing commands to the chip
  * @waitfunc:          [REPLACEABLE] hardwarespecific function for wait on ready
  * @ecc:               [BOARDSPECIFIC] ecc control ctructure
+ * @buffers:           buffer structure for read/write
+ * @hwcontrol:         platform-specific hardware control structure
+ * @ops:               oob operation operands
  * @erase_cmd:         [INTERN] erase command write function, selectable due to AND support
  * @scan_bbt:          [REPLACEABLE] function to scan bad block table
  * @chip_delay:                [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR)
  * @wq:                        [INTERN] wait queue to sleep on if a NAND operation is in progress
  * @state:             [INTERN] the current state of the NAND device
+ * @oob_poi:           poison value buffer
  * @page_shift:                [INTERN] number of address bits in a page (column address bits)
  * @phys_erase_shift:  [INTERN] number of address bits in a physical eraseblock
  * @bbt_erase_shift:   [INTERN] number of address bits in a bbt entry
@@ -318,7 +334,7 @@ struct nand_buffers {
  * @chipsize:          [INTERN] the size of one chip for multichip arrays
  * @pagemask:          [INTERN] page number mask = number of (pages / chip) - 1
  * @pagebuf:           [INTERN] holds the pagenumber which is currently in data_buf
- * @autooob:           [REPLACEABLE] the default (auto)placement scheme
+ * @ecclayout:         [REPLACEABLE] the default ecc placement scheme
  * @bbt:               [INTERN] bad block table pointer
  * @bbt_td:            [REPLACEABLE] bad block table descriptor for flash lookup
  * @bbt_md:            [REPLACEABLE] bad block table mirror descriptor
@@ -346,7 +362,7 @@ struct nand_chip {
                                    unsigned int ctrl);
        int             (*dev_ready)(struct mtd_info *mtd);
        void            (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
-       int             (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state);
+       int             (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
        void            (*erase_cmd)(struct mtd_info *mtd, int page);
        int             (*scan_bbt)(struct mtd_info *mtd);
        int             (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page);
@@ -368,12 +384,14 @@ struct nand_chip {
 
        uint8_t         *oob_poi;
        struct nand_hw_control  *controller;
-       struct nand_oobinfo     *autooob;
+       struct nand_ecclayout   *ecclayout;
 
        struct nand_ecc_ctrl ecc;
-       struct nand_buffers buffers;
+       struct nand_buffers *buffers;
        struct nand_hw_control hwcontrol;
 
+       struct mtd_oob_ops ops;
+
        uint8_t         *bbt;
        struct nand_bbt_descr   *bbt_td;
        struct nand_bbt_descr   *bbt_md;
@@ -396,7 +414,6 @@ struct nand_chip {
 
 /**
  * struct nand_flash_dev - NAND Flash Device ID Structure
- *
  * @name:      Identify the device type
  * @id:                device ID code
  * @pagesize:  Pagesize in bytes. Either 256 or 512 or 0
@@ -515,13 +532,13 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
 
 /**
  * struct platform_nand_chip - chip level device structure
- *
  * @nr_chips:          max. number of chips to scan for
- * @chip_offs:         chip number offset
- * @nr_partitions:     number of partitions pointed to be partitoons (or zero)
+ * @chip_offset:       chip number offset
+ * @nr_partitions:     number of partitions pointed to by partitions (or zero)
  * @partitions:                mtd partition list
  * @chip_delay:                R/B delay value in us
  * @options:           Option flags, e.g. 16bit buswidth
+ * @ecclayout:         ecc layout info structure
  * @priv:              hardware controller specific settings
  */
 struct platform_nand_chip {
@@ -529,6 +546,7 @@ struct platform_nand_chip {
        int                     chip_offset;
        int                     nr_partitions;
        struct mtd_partition    *partitions;
+       struct nand_ecclayout   *ecclayout;
        int                     chip_delay;
        unsigned int            options;
        void                    *priv;
@@ -536,11 +554,10 @@ struct platform_nand_chip {
 
 /**
  * struct platform_nand_ctrl - controller level device structure
- *
  * @hwcontrol:         platform specific hardware control structure
  * @dev_ready:         platform specific function to read ready/busy pin
  * @select_chip:       platform specific chip select function
- * @priv_data:         private data to transport driver specific settings
+ * @priv:              private data to transport driver specific settings
  *
  * All fields are optional and depend on the hardware driver requirements
  */