]> git.sur5r.net Git - u-boot/blobdiff - include/linux/mtd/mtd.h
OneNAND: Remove unused read_spareram
[u-boot] / include / linux / mtd / mtd.h
index 14815c219b3daac59423eac9af0e0e84fb6785d4..16556c4798da0c41cb3fa3f91c13239d278ff6ec 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: mtd.h,v 1.61 2005/11/07 11:14:54 gleixner Exp $
- *
  * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al.
  *
  * Released under GPL
@@ -10,6 +8,7 @@
 #define __MTD_MTD_H__
 
 #include <linux/types.h>
+#include <div64.h>
 #include <linux/mtd/mtd-abi.h>
 
 #define MTD_CHAR_MAJOR 90
@@ -22,6 +21,8 @@
 #define MTD_ERASE_DONE          0x08
 #define MTD_ERASE_FAILED        0x10
 
+#define MTD_FAIL_ADDR_UNKNOWN  -1LL
+
 /*
  * Enumeration for NAND/OneNAND flash chip state
  */
@@ -39,13 +40,13 @@ enum {
 };
 
 /* 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;
-       u_int32_t addr;
-       u_int32_t len;
-       u_int32_t fail_addr;
+       uint64_t addr;
+       uint64_t len;
+       uint64_t fail_addr;
        u_long time;
        u_long retries;
        u_int dev;
@@ -57,7 +58,7 @@ struct erase_info {
 };
 
 struct mtd_erase_region_info {
-       u_int32_t offset;                       /* At which this region starts, from the beginning of the MTD */
+       uint64_t offset;                        /* At which this region starts, from the beginning of the MTD */
        u_int32_t erasesize;            /* For this region */
        u_int32_t numblocks;            /* Number of blocks of erasesize in this region */
        unsigned long *lockmap;         /* If keeping bitmap of locks */
@@ -112,9 +113,9 @@ struct mtd_oob_ops {
 struct mtd_info {
        u_char type;
        u_int32_t flags;
-       u_int32_t size;  // Total size of the MTD
+       uint64_t size;   /* Total size of the MTD */
 
-       /* "Major" erase size for the device. Naïve users may take this
+       /* "Major" erase size for the device. Naïve users may take this
         * to be the only erase size available, or may use the more detailed
         * information below if they desire
         */
@@ -128,11 +129,11 @@ struct mtd_info {
         */
        u_int32_t writesize;
 
-       u_int32_t oobsize;   // Amount of OOB data per block (e.g. 16)
-       u_int32_t oobavail;  // Available OOB bytes per block
+       u_int32_t oobsize;   /* Amount of OOB data per block (e.g. 16) */
+       u_int32_t oobavail;  /* Available OOB bytes per block */
 
-       // Kernel-only stuff starts here.
-       char *name;
+       /* Kernel-only stuff starts here. */
+       const char *name;
        int index;
 
        /* ecc layout structure pointer - read only ! */
@@ -144,18 +145,36 @@ struct mtd_info {
        int numeraseregions;
        struct mtd_erase_region_info *eraseregions;
 
+       /*
+        * Erase is an asynchronous operation.  Device drivers are supposed
+        * to call instr->callback() whenever the operation completes, even
+        * if it completes with a failure.
+        * Callers are supposed to pass a callback function and wait for it
+        * to be called before writing to the block.
+        */
        int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
 
        /* This stuff for eXecute-In-Place */
-       int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf);
+       /* phys is optional and may be set to NULL */
+       int (*point) (struct mtd_info *mtd, loff_t from, size_t len,
+                       size_t *retlen, void **virt, phys_addr_t *phys);
 
        /* We probably shouldn't allow XIP if the unpoint isn't a NULL */
-       void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len);
+       void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
 
 
        int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
        int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
 
+       /* In blackbox flight recorder like scenarios we want to make successful
+          writes in interrupt context. panic_write() is only intended to be
+          called when its known the kernel is about to panic and we need the
+          write to succeed. Since the kernel is not going to be running for much
+          longer, this function can break locks and delay to ensure the write
+          succeeds (but not sleep). */
+
+       int (*panic_write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
+
        int (*read_oob) (struct mtd_info *mtd, loff_t from,
                         struct mtd_oob_ops *ops);
        int (*write_oob) (struct mtd_info *mtd, loff_t to,
@@ -186,8 +205,8 @@ struct mtd_info {
        void (*sync) (struct mtd_info *mtd);
 
        /* Chip-supported device locking */
-       int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);
-       int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);
+       int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
+       int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
 
        /* Power Management functions */
        int (*suspend) (struct mtd_info *mtd);
@@ -220,6 +239,16 @@ struct mtd_info {
        void (*put_device) (struct mtd_info *mtd);
 };
 
+static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
+{
+       do_div(sz, mtd->erasesize);
+       return sz;
+}
+
+static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd)
+{
+       return do_div(sz, mtd->erasesize);
+}
 
        /* Kernel-side ioctl definitions */
 
@@ -274,7 +303,11 @@ static inline void mtd_erase_callback(struct erase_info *instr)
                        printk(KERN_INFO args);         \
        } while(0)
 #else /* CONFIG_MTD_DEBUG */
-#define MTDDEBUG(n, args...) do { } while(0)
+#define MTDDEBUG(n, args...)                           \
+       do {                                            \
+               if (0)                                  \
+                       printk(KERN_INFO args);         \
+       } while(0)
 #endif /* CONFIG_MTD_DEBUG */
 
 #endif /* __MTD_MTD_H__ */