122851890Sopenharmony_ci/* 222851890Sopenharmony_ci * This header was generated from the Linux kernel headers by update_headers.py, 322851890Sopenharmony_ci * to provide necessary information from kernel to userspace, such as constants, 422851890Sopenharmony_ci * structures, and macros, and thus, contains no copyrightable information. 522851890Sopenharmony_ci */ 622851890Sopenharmony_ci#ifndef __MTD_ABI_H__ 722851890Sopenharmony_ci#define __MTD_ABI_H__ 822851890Sopenharmony_ci#include <linux/types.h> 922851890Sopenharmony_cistruct erase_info_user { 1022851890Sopenharmony_ci __u32 start; 1122851890Sopenharmony_ci __u32 length; 1222851890Sopenharmony_ci}; 1322851890Sopenharmony_cistruct erase_info_user64 { 1422851890Sopenharmony_ci __u64 start; 1522851890Sopenharmony_ci __u64 length; 1622851890Sopenharmony_ci}; 1722851890Sopenharmony_cistruct mtd_oob_buf { 1822851890Sopenharmony_ci __u32 start; 1922851890Sopenharmony_ci __u32 length; 2022851890Sopenharmony_ci unsigned char __user *ptr; 2122851890Sopenharmony_ci}; 2222851890Sopenharmony_cistruct mtd_oob_buf64 { 2322851890Sopenharmony_ci __u64 start; 2422851890Sopenharmony_ci __u32 pad; 2522851890Sopenharmony_ci __u32 length; 2622851890Sopenharmony_ci __u64 usr_ptr; 2722851890Sopenharmony_ci}; 2822851890Sopenharmony_cienum { 2922851890Sopenharmony_ci MTD_OPS_PLACE_OOB = 0, 3022851890Sopenharmony_ci MTD_OPS_AUTO_OOB = 1, 3122851890Sopenharmony_ci MTD_OPS_RAW = 2, 3222851890Sopenharmony_ci}; 3322851890Sopenharmony_cistruct mtd_write_req { 3422851890Sopenharmony_ci __u64 start; 3522851890Sopenharmony_ci __u64 len; 3622851890Sopenharmony_ci __u64 ooblen; 3722851890Sopenharmony_ci __u64 usr_data; 3822851890Sopenharmony_ci __u64 usr_oob; 3922851890Sopenharmony_ci __u8 mode; 4022851890Sopenharmony_ci __u8 padding[7]; 4122851890Sopenharmony_ci}; 4222851890Sopenharmony_ci#define MTD_ABSENT 0 4322851890Sopenharmony_ci#define MTD_RAM 1 4422851890Sopenharmony_ci#define MTD_ROM 2 4522851890Sopenharmony_ci#define MTD_NORFLASH 3 4622851890Sopenharmony_ci#define MTD_NANDFLASH 4 4722851890Sopenharmony_ci#define MTD_DATAFLASH 6 4822851890Sopenharmony_ci#define MTD_UBIVOLUME 7 4922851890Sopenharmony_ci#define MTD_MLCNANDFLASH 8 5022851890Sopenharmony_ci#define MTD_WRITEABLE 0x400 5122851890Sopenharmony_ci#define MTD_BIT_WRITEABLE 0x800 5222851890Sopenharmony_ci#define MTD_NO_ERASE 0x1000 5322851890Sopenharmony_ci#define MTD_POWERUP_LOCK 0x2000 5422851890Sopenharmony_ci#define MTD_CAP_ROM 0 5522851890Sopenharmony_ci#define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) 5622851890Sopenharmony_ci#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE) 5722851890Sopenharmony_ci#define MTD_CAP_NANDFLASH (MTD_WRITEABLE) 5822851890Sopenharmony_ci#define MTD_CAP_NVRAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) 5922851890Sopenharmony_ci#define MTD_NANDECC_OFF 0 6022851890Sopenharmony_ci#define MTD_NANDECC_PLACE 1 6122851890Sopenharmony_ci#define MTD_NANDECC_AUTOPLACE 2 6222851890Sopenharmony_ci#define MTD_NANDECC_PLACEONLY 3 6322851890Sopenharmony_ci#define MTD_NANDECC_AUTOPL_USR 4 6422851890Sopenharmony_ci#define MTD_OTP_OFF 0 6522851890Sopenharmony_ci#define MTD_OTP_FACTORY 1 6622851890Sopenharmony_ci#define MTD_OTP_USER 2 6722851890Sopenharmony_cistruct mtd_info_user { 6822851890Sopenharmony_ci __u8 type; 6922851890Sopenharmony_ci __u32 flags; 7022851890Sopenharmony_ci __u32 size; 7122851890Sopenharmony_ci __u32 erasesize; 7222851890Sopenharmony_ci __u32 writesize; 7322851890Sopenharmony_ci __u32 oobsize; 7422851890Sopenharmony_ci __u64 padding; 7522851890Sopenharmony_ci}; 7622851890Sopenharmony_cistruct region_info_user { 7722851890Sopenharmony_ci __u32 offset; 7822851890Sopenharmony_ci __u32 erasesize; 7922851890Sopenharmony_ci __u32 numblocks; 8022851890Sopenharmony_ci __u32 regionindex; 8122851890Sopenharmony_ci}; 8222851890Sopenharmony_cistruct otp_info { 8322851890Sopenharmony_ci __u32 start; 8422851890Sopenharmony_ci __u32 length; 8522851890Sopenharmony_ci __u32 locked; 8622851890Sopenharmony_ci}; 8722851890Sopenharmony_ci#define MEMGETINFO _IOR('M', 1, struct mtd_info_user) 8822851890Sopenharmony_ci#define MEMERASE _IOW('M', 2, struct erase_info_user) 8922851890Sopenharmony_ci#define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) 9022851890Sopenharmony_ci#define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) 9122851890Sopenharmony_ci#define MEMLOCK _IOW('M', 5, struct erase_info_user) 9222851890Sopenharmony_ci#define MEMUNLOCK _IOW('M', 6, struct erase_info_user) 9322851890Sopenharmony_ci#define MEMGETREGIONCOUNT _IOR('M', 7, int) 9422851890Sopenharmony_ci#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) 9522851890Sopenharmony_ci#define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo) 9622851890Sopenharmony_ci#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t) 9722851890Sopenharmony_ci#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t) 9822851890Sopenharmony_ci#define OTPSELECT _IOR('M', 13, int) 9922851890Sopenharmony_ci#define OTPGETREGIONCOUNT _IOW('M', 14, int) 10022851890Sopenharmony_ci#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) 10122851890Sopenharmony_ci#define OTPLOCK _IOR('M', 16, struct otp_info) 10222851890Sopenharmony_ci#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user) 10322851890Sopenharmony_ci#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) 10422851890Sopenharmony_ci#define MTDFILEMODE _IO('M', 19) 10522851890Sopenharmony_ci#define MEMERASE64 _IOW('M', 20, struct erase_info_user64) 10622851890Sopenharmony_ci#define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64) 10722851890Sopenharmony_ci#define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64) 10822851890Sopenharmony_ci#define MEMISLOCKED _IOR('M', 23, struct erase_info_user) 10922851890Sopenharmony_ci#define MEMWRITE _IOWR('M', 24, struct mtd_write_req) 11022851890Sopenharmony_cistruct nand_oobinfo { 11122851890Sopenharmony_ci __u32 useecc; 11222851890Sopenharmony_ci __u32 eccbytes; 11322851890Sopenharmony_ci __u32 oobfree[8][2]; 11422851890Sopenharmony_ci __u32 eccpos[32]; 11522851890Sopenharmony_ci}; 11622851890Sopenharmony_cistruct nand_oobfree { 11722851890Sopenharmony_ci __u32 offset; 11822851890Sopenharmony_ci __u32 length; 11922851890Sopenharmony_ci}; 12022851890Sopenharmony_ci#define MTD_MAX_OOBFREE_ENTRIES 8 12122851890Sopenharmony_ci#define MTD_MAX_ECCPOS_ENTRIES 64 12222851890Sopenharmony_cistruct nand_ecclayout_user { 12322851890Sopenharmony_ci __u32 eccbytes; 12422851890Sopenharmony_ci __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES]; 12522851890Sopenharmony_ci __u32 oobavail; 12622851890Sopenharmony_ci struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; 12722851890Sopenharmony_ci}; 12822851890Sopenharmony_cistruct mtd_ecc_stats { 12922851890Sopenharmony_ci __u32 corrected; 13022851890Sopenharmony_ci __u32 failed; 13122851890Sopenharmony_ci __u32 badblocks; 13222851890Sopenharmony_ci __u32 bbtblocks; 13322851890Sopenharmony_ci}; 13422851890Sopenharmony_cienum mtd_file_modes { 13522851890Sopenharmony_ci MTD_FILE_MODE_NORMAL = MTD_OTP_OFF, 13622851890Sopenharmony_ci MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY, 13722851890Sopenharmony_ci MTD_FILE_MODE_OTP_USER = MTD_OTP_USER, 13822851890Sopenharmony_ci MTD_FILE_MODE_RAW, 13922851890Sopenharmony_ci}; 14022851890Sopenharmony_cistatic inline int mtd_type_is_nand_user(const struct mtd_info_user *mtd) 14122851890Sopenharmony_ci{ 14222851890Sopenharmony_ci return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; 14322851890Sopenharmony_ci} 14422851890Sopenharmony_ci#endif 145