The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 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_MTD_H__ |
| 13 | #define __MTD_MTD_H__ |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 14 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 15 | #error This is a kernel header. Perhaps include mtd-user.h instead? |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 16 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 17 | #include <linux/types.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/uio.h> |
| 20 | #include <linux/notifier.h> |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 21 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 22 | #include <linux/mtd/compatmac.h> |
| 23 | #include <mtd/mtd-abi.h> |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 24 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 25 | #define MTD_CHAR_MAJOR 90 |
| 26 | #define MTD_BLOCK_MAJOR 31 |
| 27 | #define MAX_MTD_DEVICES 16 |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 28 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 29 | #define MTD_ERASE_PENDING 0x01 |
| 30 | #define MTD_ERASING 0x02 |
| 31 | #define MTD_ERASE_SUSPEND 0x04 |
| 32 | #define MTD_ERASE_DONE 0x08 |
| 33 | #define MTD_ERASE_FAILED 0x10 |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 34 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 35 | struct erase_info { |
| 36 | struct mtd_info *mtd; |
| 37 | u_int32_t addr; |
| 38 | u_int32_t len; |
| 39 | u_int32_t fail_addr; |
| 40 | u_long time; |
| 41 | u_long retries; |
| 42 | u_int dev; |
| 43 | u_int cell; |
| 44 | void (*callback) (struct erase_info *self); |
| 45 | u_long priv; |
| 46 | u_char state; |
| 47 | struct erase_info *next; |
| 48 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 49 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 50 | struct mtd_erase_region_info { |
| 51 | u_int32_t offset; |
| 52 | u_int32_t erasesize; |
| 53 | u_int32_t numblocks; |
| 54 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 55 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 56 | typedef enum { |
| 57 | MTD_OOB_PLACE, |
| 58 | MTD_OOB_AUTO, |
| 59 | MTD_OOB_RAW, |
| 60 | } mtd_oob_mode_t; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 61 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 62 | struct mtd_oob_ops { |
| 63 | mtd_oob_mode_t mode; |
| 64 | size_t len; |
| 65 | size_t retlen; |
| 66 | size_t ooblen; |
| 67 | uint32_t ooboffs; |
| 68 | uint8_t *datbuf; |
| 69 | uint8_t *oobbuf; |
| 70 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 71 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 72 | struct mtd_info { |
| 73 | u_char type; |
| 74 | u_int32_t flags; |
| 75 | u_int32_t size; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 76 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 77 | u_int32_t erasesize; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 78 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 79 | u_int32_t writesize; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 80 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 81 | u_int32_t oobsize; |
| 82 | u_int32_t ecctype; |
| 83 | u_int32_t eccsize; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 84 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 85 | #define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize |
| 86 | #define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 87 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 88 | char *name; |
| 89 | int index; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 90 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 91 | struct nand_ecclayout *ecclayout; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 92 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 93 | int numeraseregions; |
| 94 | struct mtd_erase_region_info *eraseregions; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 95 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 96 | u_int32_t bank_size; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 97 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 98 | int (*erase) (struct mtd_info *mtd, struct erase_info *instr); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 99 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 100 | int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 101 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 102 | void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 103 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 104 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
| 105 | int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 106 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 107 | int (*read_oob) (struct mtd_info *mtd, loff_t from, |
| 108 | struct mtd_oob_ops *ops); |
| 109 | int (*write_oob) (struct mtd_info *mtd, loff_t to, |
| 110 | struct mtd_oob_ops *ops); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 111 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 112 | int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len); |
| 113 | int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
| 114 | int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len); |
| 115 | int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
| 116 | int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
| 117 | int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 118 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 119 | int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 120 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 121 | void (*sync) (struct mtd_info *mtd); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 122 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 123 | int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len); |
| 124 | int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 125 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 126 | int (*suspend) (struct mtd_info *mtd); |
| 127 | void (*resume) (struct mtd_info *mtd); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 128 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 129 | int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); |
| 130 | int (*block_markbad) (struct mtd_info *mtd, loff_t ofs); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 131 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 132 | struct notifier_block reboot_notifier; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 133 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 134 | struct mtd_ecc_stats ecc_stats; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 135 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 136 | void *priv; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 137 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 138 | struct module *owner; |
| 139 | int usecount; |
| 140 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 141 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 142 | struct mtd_notifier { |
| 143 | void (*add)(struct mtd_info *mtd); |
| 144 | void (*remove)(struct mtd_info *mtd); |
| 145 | struct list_head list; |
| 146 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 147 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 148 | #define MTD_DEBUG_LEVEL0 (0) |
| 149 | #define MTD_DEBUG_LEVEL1 (1) |
| 150 | #define MTD_DEBUG_LEVEL2 (2) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 151 | #define MTD_DEBUG_LEVEL3 (3) |
| 152 | #define DEBUG(n, args...) do { } while(0) |
| 153 | #endif |