Home | History | Annotate | Download | only in mtd
      1 /****************************************************************************
      2  ****************************************************************************
      3  ***
      4  ***   This header was automatically generated from a Linux kernel header
      5  ***   of the same name, to make information necessary for userspace to
      6  ***   call into the kernel available to libc.  It contains only constants,
      7  ***   structures, and macros generated from the original header, and thus,
      8  ***   contains no copyrightable information.
      9  ***
     10  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef __MTD_ABI_H__
     13 #define __MTD_ABI_H__
     14 
     15 struct erase_info_user {
     16  uint32_t start;
     17  uint32_t length;
     18 };
     19 
     20 struct mtd_oob_buf {
     21  uint32_t start;
     22  uint32_t length;
     23  unsigned char __user *ptr;
     24 };
     25 
     26 #define MTD_ABSENT 0
     27 #define MTD_RAM 1
     28 #define MTD_ROM 2
     29 #define MTD_NORFLASH 3
     30 #define MTD_NANDFLASH 4
     31 #define MTD_DATAFLASH 6
     32 
     33 #define MTD_WRITEABLE 0x400
     34 #define MTD_BIT_WRITEABLE 0x800
     35 #define MTD_NO_ERASE 0x1000
     36 #define MTD_STUPID_LOCK 0x2000
     37 
     38 #define MTD_CAP_ROM 0
     39 #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
     40 #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
     41 #define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
     42 
     43 #define MTD_NANDECC_OFF 0
     44 #define MTD_NANDECC_PLACE 1
     45 #define MTD_NANDECC_AUTOPLACE 2
     46 #define MTD_NANDECC_PLACEONLY 3
     47 #define MTD_NANDECC_AUTOPL_USR 4
     48 
     49 #define MTD_OTP_OFF 0
     50 #define MTD_OTP_FACTORY 1
     51 #define MTD_OTP_USER 2
     52 
     53 struct mtd_info_user {
     54  uint8_t type;
     55  uint32_t flags;
     56  uint32_t size;
     57  uint32_t erasesize;
     58  uint32_t writesize;
     59  uint32_t oobsize;
     60 
     61  uint32_t ecctype;
     62  uint32_t eccsize;
     63 };
     64 
     65 struct region_info_user {
     66  uint32_t offset;
     67  uint32_t erasesize;
     68  uint32_t numblocks;
     69  uint32_t regionindex;
     70 };
     71 
     72 struct otp_info {
     73  uint32_t start;
     74  uint32_t length;
     75  uint32_t locked;
     76 };
     77 
     78 #define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
     79 #define MEMERASE _IOW('M', 2, struct erase_info_user)
     80 #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf)
     81 #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf)
     82 #define MEMLOCK _IOW('M', 5, struct erase_info_user)
     83 #define MEMUNLOCK _IOW('M', 6, struct erase_info_user)
     84 #define MEMGETREGIONCOUNT _IOR('M', 7, int)
     85 #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
     86 #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo)
     87 #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
     88 #define MEMGETBADBLOCK _IOW('M', 11, loff_t)
     89 #define MEMSETBADBLOCK _IOW('M', 12, loff_t)
     90 #define OTPSELECT _IOR('M', 13, int)
     91 #define OTPGETREGIONCOUNT _IOW('M', 14, int)
     92 #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
     93 #define OTPLOCK _IOR('M', 16, struct otp_info)
     94 #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout)
     95 #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
     96 #define MTDFILEMODE _IO('M', 19)
     97 
     98 struct nand_oobinfo {
     99  uint32_t useecc;
    100  uint32_t eccbytes;
    101  uint32_t oobfree[8][2];
    102  uint32_t eccpos[32];
    103 };
    104 
    105 struct nand_oobfree {
    106  uint32_t offset;
    107  uint32_t length;
    108 };
    109 
    110 #define MTD_MAX_OOBFREE_ENTRIES 8
    111 
    112 struct nand_ecclayout {
    113  uint32_t eccbytes;
    114  uint32_t eccpos[64];
    115  uint32_t oobavail;
    116  struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
    117 };
    118 
    119 struct mtd_ecc_stats {
    120  uint32_t corrected;
    121  uint32_t failed;
    122  uint32_t badblocks;
    123  uint32_t bbtblocks;
    124 };
    125 
    126 enum mtd_file_modes {
    127  MTD_MODE_NORMAL = MTD_OTP_OFF,
    128  MTD_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
    129  MTD_MODE_OTP_USER = MTD_OTP_USER,
    130  MTD_MODE_RAW,
    131 };
    132 
    133 #endif
    134