Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / include / linux / mtd / mtd.h
index cf5cda15d1ae0906504a4bb4d8af7caf8b919f90..3e1694b3a5d33802fcecd32ad0b38556571a8e0d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> et al.
  *
- * Released under GPL
+ * SPDX-License-Identifier:    GPL-2.0+
  *
  */
 
@@ -20,7 +20,7 @@
 #else
 #include <linux/compat.h>
 #include <mtd/mtd-abi.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <div64.h>
 
 #define MAX_MTD_DEVICES 32
@@ -101,7 +101,7 @@ struct mtd_oob_ops {
 #ifdef CONFIG_SYS_NAND_MAX_ECCPOS
 #define MTD_MAX_ECCPOS_ENTRIES_LARGE   CONFIG_SYS_NAND_MAX_ECCPOS
 #else
-#define MTD_MAX_ECCPOS_ENTRIES_LARGE   640
+#define MTD_MAX_ECCPOS_ENTRIES_LARGE   680
 #endif
 
 /*
@@ -244,6 +244,7 @@ struct mtd_info {
 #ifndef __UBOOT__
        int (*_suspend) (struct mtd_info *mtd);
        void (*_resume) (struct mtd_info *mtd);
+       void (*_reboot) (struct mtd_info *mtd);
 #endif
        /*
         * If the driver is something smart, like UBI, it may need to maintain
@@ -271,10 +272,17 @@ struct mtd_info {
        struct module *owner;
 #ifndef __UBOOT__
        struct device dev;
+#else
+       struct udevice *dev;
 #endif
        int usecount;
 };
 
+static inline int mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops)
+{
+       return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize;
+}
+
 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
 #ifndef __UBOOT__
 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
@@ -444,28 +452,20 @@ static inline void mtd_erase_callback(struct erase_info *instr)
 #define MTD_DEBUG_LEVEL3       (3)     /* Noisy   */
 
 #ifdef CONFIG_MTD_DEBUG
-#define pr_debug(args...)      MTDDEBUG(MTD_DEBUG_LEVEL0, args)
 #define MTDDEBUG(n, args...)                           \
        do {                                            \
                if (n <= CONFIG_MTD_DEBUG_VERBOSE)      \
                        printk(KERN_INFO args);         \
        } while(0)
 #else /* CONFIG_MTD_DEBUG */
-#define pr_debug(args...)
 #define MTDDEBUG(n, args...)                           \
        do {                                            \
                if (0)                                  \
                        printk(KERN_INFO args);         \
        } while(0)
 #endif /* CONFIG_MTD_DEBUG */
-#define pr_info(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_warn(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_err(args...)                MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_crit(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_cont(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_notice(args...)     MTDDEBUG(MTD_DEBUG_LEVEL0, args)
 #endif
+
 static inline int mtd_is_bitflip(int err) {
        return err == -EUCLEAN;
 }
@@ -478,6 +478,8 @@ static inline int mtd_is_bitflip_or_eccerr(int err) {
        return mtd_is_bitflip(err) || mtd_is_eccerr(err);
 }
 
+unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
+
 #ifdef __UBOOT__
 /* drivers/mtd/mtdcore.h */
 int add_mtd_device(struct mtd_info *mtd);
@@ -490,5 +492,10 @@ int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
                     loff_t *size, loff_t *maxsize, int devtype,
                     uint64_t chipsize);
+
+/* drivers/mtd/mtdcore.c */
+void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
+                         const uint64_t length, uint64_t *len_incl_bad,
+                         int *truncated);
 #endif
 #endif /* __MTD_MTD_H__ */