00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __MTD_ABI_H__
00012 #define __MTD_ABI_H__
00013
00014 #ifndef __KERNEL__
00015
00016 #define __user
00017 #endif
00018
00019 struct erase_info_user {
00020 uint32_t start;
00021 uint32_t length;
00022 };
00023
00024 struct mtd_oob_buf {
00025 uint32_t start;
00026 uint32_t length;
00027 unsigned char __user *ptr;
00028 };
00029
00030 #define MTD_ABSENT 0
00031 #define MTD_RAM 1
00032 #define MTD_ROM 2
00033 #define MTD_NORFLASH 3
00034 #define MTD_NANDFLASH 4
00035 #define MTD_PEROM 5
00036 #define MTD_DATAFLASH 6
00037 #define MTD_OTHER 14
00038 #define MTD_UNKNOWN 15
00039
00040 #define MTD_CLEAR_BITS 1 // Bits can be cleared (flash)
00041 #define MTD_SET_BITS 2 // Bits can be set
00042 #define MTD_ERASEABLE 4 // Has an erase function
00043 #define MTD_WRITEB_WRITEABLE 8 // Direct IO is possible
00044 #define MTD_VOLATILE 16 // Set for RAMs
00045 #define MTD_XIP 32 // eXecute-In-Place possible
00046 #define MTD_OOB 64 // Out-of-band data (NAND flash)
00047 #define MTD_ECC 128 // Device capable of automatic ECC
00048 #define MTD_NO_VIRTBLOCKS 256 // Virtual blocks not allowed
00049 #define MTD_PROGRAM_REGIONS 512 // Configurable Programming Regions
00050
00051
00052 #define MTD_CAP_ROM 0
00053 #define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEB_WRITEABLE)
00054 #define MTD_CAP_NORFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE)
00055 #define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE|MTD_OOB)
00056 #define MTD_WRITEABLE (MTD_CLEAR_BITS|MTD_SET_BITS)
00057
00058
00059
00060 #define MTD_ECC_NONE 0 // No automatic ECC available
00061 #define MTD_ECC_RS_DiskOnChip 1 // Automatic ECC on DiskOnChip
00062 #define MTD_ECC_SW 2 // SW ECC for Toshiba & Samsung devices
00063
00064
00065 #define MTD_NANDECC_OFF 0 // Switch off ECC (Not recommended)
00066 #define MTD_NANDECC_PLACE 1 // Use the given placement in the structure (YAFFS1 legacy mode)
00067 #define MTD_NANDECC_AUTOPLACE 2 // Use the default placement scheme
00068 #define MTD_NANDECC_PLACEONLY 3 // Use the given placement in the structure (Do not store ecc result on read)
00069 #define MTD_NANDECC_AUTOPL_USR 4 // Use the given autoplacement scheme rather than using the default
00070
00071
00072 #define MTD_OTP_OFF 0
00073 #define MTD_OTP_FACTORY 1
00074 #define MTD_OTP_USER 2
00075
00076 struct mtd_info_user {
00077 uint8_t type;
00078 uint32_t flags;
00079 uint32_t size;
00080 uint32_t erasesize;
00081 uint32_t oobblock;
00082 uint32_t oobsize;
00083 uint32_t ecctype;
00084 uint32_t eccsize;
00085 };
00086
00087 struct region_info_user {
00088 uint32_t offset;
00089
00090 uint32_t erasesize;
00091 uint32_t numblocks;
00092 uint32_t regionindex;
00093 };
00094
00095 struct otp_info {
00096 uint32_t start;
00097 uint32_t length;
00098 uint32_t locked;
00099 };
00100
00101 #define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
00102 #define MEMERASE _IOW('M', 2, struct erase_info_user)
00103 #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf)
00104 #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf)
00105 #define MEMLOCK _IOW('M', 5, struct erase_info_user)
00106 #define MEMUNLOCK _IOW('M', 6, struct erase_info_user)
00107 #define MEMGETREGIONCOUNT _IOR('M', 7, int)
00108 #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
00109 #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo)
00110 #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
00111 #define MEMGETBADBLOCK _IOW('M', 11, loff_t)
00112 #define MEMSETBADBLOCK _IOW('M', 12, loff_t)
00113 #define OTPSELECT _IOR('M', 13, int)
00114 #define OTPGETREGIONCOUNT _IOW('M', 14, int)
00115 #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
00116 #define OTPLOCK _IOR('M', 16, struct otp_info)
00117
00118 struct nand_oobinfo {
00119 uint32_t useecc;
00120 uint32_t eccbytes;
00121 uint32_t oobfree[8][2];
00122 uint32_t eccpos[32];
00123 };
00124
00125 #endif