diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-07 12:11:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-07 12:11:16 -0500 |
commit | e0d65113a70f1dc514e625cc4e7a7485a4bf72df (patch) | |
tree | 7320a130dc304623f5cf4b5dd8f67fb1776225ca /include | |
parent | cf5e15fbd72c13977720aa15b7b7e00e1d8fd8f2 (diff) | |
parent | 48e546b7f281f251893baa40769581fd15f085fb (diff) |
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (226 commits)
mtd: tests: annotate as DANGEROUS in Kconfig
mtd: tests: don't use mtd0 as a default
mtd: clean up usage of MTD_DOCPROBE_ADDRESS
jffs2: add compr=lzo and compr=zlib options
jffs2: implement mount option parsing and compression overriding
mtd: nand: initialize ops.mode
mtd: provide an alias for the redboot module name
mtd: m25p80: don't probe device which has status of 'disabled'
mtd: nand_h1900 never worked
mtd: Add DiskOnChip G3 support
mtd: m25p80: add EON flash EN25Q32B into spi flash id table
mtd: mark block device queue as non-rotational
mtd: r852: make r852_pm_ops static
mtd: m25p80: add support for at25df321a spi data flash
mtd: mxc_nand: preset_v1_v2: unlock all NAND flash blocks
mtd: nand: switch `check_pattern()' to standard `memcmp()'
mtd: nand: invalidate cache on unaligned reads
mtd: nand: do not scan bad blocks with NAND_BBT_NO_OOB set
mtd: nand: wait to set BBT version
mtd: nand: scrub BBT on ECC errors
...
Fix up trivial conflicts:
- arch/arm/mach-at91/board-usb-a9260.c
Merged into board-usb-a926x.c
- drivers/mtd/maps/lantiq-flash.c
add_mtd_partitions -> mtd_device_register vs changed to use
mtd_device_parse_register.
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mtd/bbm.h | 39 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 82 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 92 | ||||
-rw-r--r-- | include/linux/mtd/onenand.h | 4 | ||||
-rw-r--r-- | include/linux/mtd/partitions.h | 46 | ||||
-rw-r--r-- | include/linux/mtd/physmap.h | 17 | ||||
-rw-r--r-- | include/mtd/mtd-abi.h | 122 |
7 files changed, 229 insertions, 173 deletions
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h index 57cc0e63714f..c4eec228eef9 100644 --- a/include/linux/mtd/bbm.h +++ b/include/linux/mtd/bbm.h | |||
@@ -86,24 +86,39 @@ struct nand_bbt_descr { | |||
86 | #define NAND_BBT_VERSION 0x00000100 | 86 | #define NAND_BBT_VERSION 0x00000100 |
87 | /* Create a bbt if none exists */ | 87 | /* Create a bbt if none exists */ |
88 | #define NAND_BBT_CREATE 0x00000200 | 88 | #define NAND_BBT_CREATE 0x00000200 |
89 | /* | ||
90 | * Create an empty BBT with no vendor information. Vendor's information may be | ||
91 | * unavailable, for example, if the NAND controller has a different data and OOB | ||
92 | * layout or if this information is already purged. Must be used in conjunction | ||
93 | * with NAND_BBT_CREATE. | ||
94 | */ | ||
95 | #define NAND_BBT_CREATE_EMPTY 0x00000400 | ||
89 | /* Search good / bad pattern through all pages of a block */ | 96 | /* Search good / bad pattern through all pages of a block */ |
90 | #define NAND_BBT_SCANALLPAGES 0x00000400 | 97 | #define NAND_BBT_SCANALLPAGES 0x00000800 |
91 | /* Scan block empty during good / bad block scan */ | 98 | /* Scan block empty during good / bad block scan */ |
92 | #define NAND_BBT_SCANEMPTY 0x00000800 | 99 | #define NAND_BBT_SCANEMPTY 0x00001000 |
93 | /* Write bbt if neccecary */ | 100 | /* Write bbt if neccecary */ |
94 | #define NAND_BBT_WRITE 0x00001000 | 101 | #define NAND_BBT_WRITE 0x00002000 |
95 | /* Read and write back block contents when writing bbt */ | 102 | /* Read and write back block contents when writing bbt */ |
96 | #define NAND_BBT_SAVECONTENT 0x00002000 | 103 | #define NAND_BBT_SAVECONTENT 0x00004000 |
97 | /* Search good / bad pattern on the first and the second page */ | 104 | /* Search good / bad pattern on the first and the second page */ |
98 | #define NAND_BBT_SCAN2NDPAGE 0x00004000 | 105 | #define NAND_BBT_SCAN2NDPAGE 0x00008000 |
99 | /* Search good / bad pattern on the last page of the eraseblock */ | 106 | /* Search good / bad pattern on the last page of the eraseblock */ |
100 | #define NAND_BBT_SCANLASTPAGE 0x00008000 | 107 | #define NAND_BBT_SCANLASTPAGE 0x00010000 |
101 | /* Chip stores bad block marker on BOTH 1st and 6th bytes of OOB */ | 108 | /* |
102 | #define NAND_BBT_SCANBYTE1AND6 0x00100000 | 109 | * Use a flash based bad block table. By default, OOB identifier is saved in |
103 | /* The nand_bbt_descr was created dynamicaly and must be freed */ | 110 | * OOB area. This option is passed to the default bad block table function. |
104 | #define NAND_BBT_DYNAMICSTRUCT 0x00200000 | 111 | */ |
105 | /* The bad block table does not OOB for marker */ | 112 | #define NAND_BBT_USE_FLASH 0x00020000 |
106 | #define NAND_BBT_NO_OOB 0x00400000 | 113 | /* Do not store flash based bad block table in OOB area; store it in-band */ |
114 | #define NAND_BBT_NO_OOB 0x00040000 | ||
115 | |||
116 | /* | ||
117 | * Flag set by nand_create_default_bbt_descr(), marking that the nand_bbt_descr | ||
118 | * was allocated dynamicaly and must be freed in nand_release(). Has no meaning | ||
119 | * in nand_chip.bbt_options. | ||
120 | */ | ||
121 | #define NAND_BBT_DYNAMICSTRUCT 0x80000000 | ||
107 | 122 | ||
108 | /* The maximum number of blocks to scan for a bbt */ | 123 | /* The maximum number of blocks to scan for a bbt */ |
109 | #define NAND_BBT_SCAN_MAXBLOCKS 4 | 124 | #define NAND_BBT_SCAN_MAXBLOCKS 4 |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 37be05bbfbc8..9f5b312af783 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -32,17 +32,19 @@ | |||
32 | #define MTD_CHAR_MAJOR 90 | 32 | #define MTD_CHAR_MAJOR 90 |
33 | #define MTD_BLOCK_MAJOR 31 | 33 | #define MTD_BLOCK_MAJOR 31 |
34 | 34 | ||
35 | #define MTD_ERASE_PENDING 0x01 | 35 | #define MTD_ERASE_PENDING 0x01 |
36 | #define MTD_ERASING 0x02 | 36 | #define MTD_ERASING 0x02 |
37 | #define MTD_ERASE_SUSPEND 0x04 | 37 | #define MTD_ERASE_SUSPEND 0x04 |
38 | #define MTD_ERASE_DONE 0x08 | 38 | #define MTD_ERASE_DONE 0x08 |
39 | #define MTD_ERASE_FAILED 0x10 | 39 | #define MTD_ERASE_FAILED 0x10 |
40 | 40 | ||
41 | #define MTD_FAIL_ADDR_UNKNOWN -1LL | 41 | #define MTD_FAIL_ADDR_UNKNOWN -1LL |
42 | 42 | ||
43 | /* If the erase fails, fail_addr might indicate exactly which block failed. If | 43 | /* |
44 | fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not | 44 | * If the erase fails, fail_addr might indicate exactly which block failed. If |
45 | specific to any particular block. */ | 45 | * fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level |
46 | * or was not specific to any particular block. | ||
47 | */ | ||
46 | struct erase_info { | 48 | struct erase_info { |
47 | struct mtd_info *mtd; | 49 | struct mtd_info *mtd; |
48 | uint64_t addr; | 50 | uint64_t addr; |
@@ -59,26 +61,12 @@ struct erase_info { | |||
59 | }; | 61 | }; |
60 | 62 | ||
61 | struct mtd_erase_region_info { | 63 | struct mtd_erase_region_info { |
62 | uint64_t offset; /* At which this region starts, from the beginning of the MTD */ | 64 | uint64_t offset; /* At which this region starts, from the beginning of the MTD */ |
63 | uint32_t erasesize; /* For this region */ | 65 | uint32_t erasesize; /* For this region */ |
64 | uint32_t numblocks; /* Number of blocks of erasesize in this region */ | 66 | uint32_t numblocks; /* Number of blocks of erasesize in this region */ |
65 | unsigned long *lockmap; /* If keeping bitmap of locks */ | 67 | unsigned long *lockmap; /* If keeping bitmap of locks */ |
66 | }; | 68 | }; |
67 | 69 | ||
68 | /* | ||
69 | * oob operation modes | ||
70 | * | ||
71 | * MTD_OOB_PLACE: oob data are placed at the given offset | ||
72 | * MTD_OOB_AUTO: oob data are automatically placed at the free areas | ||
73 | * which are defined by the ecclayout | ||
74 | * MTD_OOB_RAW: mode to read oob and data without doing ECC checking | ||
75 | */ | ||
76 | typedef enum { | ||
77 | MTD_OOB_PLACE, | ||
78 | MTD_OOB_AUTO, | ||
79 | MTD_OOB_RAW, | ||
80 | } mtd_oob_mode_t; | ||
81 | |||
82 | /** | 70 | /** |
83 | * struct mtd_oob_ops - oob operation operands | 71 | * struct mtd_oob_ops - oob operation operands |
84 | * @mode: operation mode | 72 | * @mode: operation mode |
@@ -90,7 +78,7 @@ typedef enum { | |||
90 | * @ooblen: number of oob bytes to write/read | 78 | * @ooblen: number of oob bytes to write/read |
91 | * @oobretlen: number of oob bytes written/read | 79 | * @oobretlen: number of oob bytes written/read |
92 | * @ooboffs: offset of oob data in the oob area (only relevant when | 80 | * @ooboffs: offset of oob data in the oob area (only relevant when |
93 | * mode = MTD_OOB_PLACE) | 81 | * mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW) |
94 | * @datbuf: data buffer - if NULL only oob data are read/written | 82 | * @datbuf: data buffer - if NULL only oob data are read/written |
95 | * @oobbuf: oob data buffer | 83 | * @oobbuf: oob data buffer |
96 | * | 84 | * |
@@ -99,7 +87,7 @@ typedef enum { | |||
99 | * OOB area. | 87 | * OOB area. |
100 | */ | 88 | */ |
101 | struct mtd_oob_ops { | 89 | struct mtd_oob_ops { |
102 | mtd_oob_mode_t mode; | 90 | unsigned int mode; |
103 | size_t len; | 91 | size_t len; |
104 | size_t retlen; | 92 | size_t retlen; |
105 | size_t ooblen; | 93 | size_t ooblen; |
@@ -173,7 +161,7 @@ struct mtd_info { | |||
173 | const char *name; | 161 | const char *name; |
174 | int index; | 162 | int index; |
175 | 163 | ||
176 | /* ecc layout structure pointer - read only ! */ | 164 | /* ECC layout structure pointer - read only! */ |
177 | struct nand_ecclayout *ecclayout; | 165 | struct nand_ecclayout *ecclayout; |
178 | 166 | ||
179 | /* Data for variable erase regions. If numeraseregions is zero, | 167 | /* Data for variable erase regions. If numeraseregions is zero, |
@@ -324,10 +312,15 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) | |||
324 | /* Kernel-side ioctl definitions */ | 312 | /* Kernel-side ioctl definitions */ |
325 | 313 | ||
326 | struct mtd_partition; | 314 | struct mtd_partition; |
327 | 315 | struct mtd_part_parser_data; | |
328 | extern int mtd_device_register(struct mtd_info *master, | 316 | |
329 | const struct mtd_partition *parts, | 317 | extern int mtd_device_parse_register(struct mtd_info *mtd, |
330 | int nr_parts); | 318 | const char **part_probe_types, |
319 | struct mtd_part_parser_data *parser_data, | ||
320 | const struct mtd_partition *defparts, | ||
321 | int defnr_parts); | ||
322 | #define mtd_device_register(master, parts, nr_parts) \ | ||
323 | mtd_device_parse_register(master, NULL, NULL, parts, nr_parts) | ||
331 | extern int mtd_device_unregister(struct mtd_info *master); | 324 | extern int mtd_device_unregister(struct mtd_info *master); |
332 | extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num); | 325 | extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num); |
333 | extern int __get_mtd_device(struct mtd_info *mtd); | 326 | extern int __get_mtd_device(struct mtd_info *mtd); |
@@ -356,27 +349,16 @@ void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size); | |||
356 | 349 | ||
357 | void mtd_erase_callback(struct erase_info *instr); | 350 | void mtd_erase_callback(struct erase_info *instr); |
358 | 351 | ||
359 | /* | 352 | static inline int mtd_is_bitflip(int err) { |
360 | * Debugging macro and defines | 353 | return err == -EUCLEAN; |
361 | */ | 354 | } |
362 | #define MTD_DEBUG_LEVEL0 (0) /* Quiet */ | 355 | |
363 | #define MTD_DEBUG_LEVEL1 (1) /* Audible */ | 356 | static inline int mtd_is_eccerr(int err) { |
364 | #define MTD_DEBUG_LEVEL2 (2) /* Loud */ | 357 | return err == -EBADMSG; |
365 | #define MTD_DEBUG_LEVEL3 (3) /* Noisy */ | 358 | } |
366 | 359 | ||
367 | #ifdef CONFIG_MTD_DEBUG | 360 | static inline int mtd_is_bitflip_or_eccerr(int err) { |
368 | #define DEBUG(n, args...) \ | 361 | return mtd_is_bitflip(err) || mtd_is_eccerr(err); |
369 | do { \ | 362 | } |
370 | if (n <= CONFIG_MTD_DEBUG_VERBOSE) \ | ||
371 | printk(KERN_INFO args); \ | ||
372 | } while(0) | ||
373 | #else /* CONFIG_MTD_DEBUG */ | ||
374 | #define DEBUG(n, args...) \ | ||
375 | do { \ | ||
376 | if (0) \ | ||
377 | printk(KERN_INFO args); \ | ||
378 | } while(0) | ||
379 | |||
380 | #endif /* CONFIG_MTD_DEBUG */ | ||
381 | 363 | ||
382 | #endif /* __MTD_MTD_H__ */ | 364 | #endif /* __MTD_MTD_H__ */ |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index c2b9ac4fbc4a..904131bab501 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -42,10 +42,10 @@ extern void nand_release(struct mtd_info *mtd); | |||
42 | /* Internal helper for board drivers which need to override command function */ | 42 | /* Internal helper for board drivers which need to override command function */ |
43 | extern void nand_wait_ready(struct mtd_info *mtd); | 43 | extern void nand_wait_ready(struct mtd_info *mtd); |
44 | 44 | ||
45 | /* locks all blockes present in the device */ | 45 | /* locks all blocks present in the device */ |
46 | extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | 46 | extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
47 | 47 | ||
48 | /* unlocks specified locked blockes */ | 48 | /* unlocks specified locked blocks */ |
49 | extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | 49 | extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
50 | 50 | ||
51 | /* The maximum number of NAND chips in an array */ | 51 | /* The maximum number of NAND chips in an array */ |
@@ -150,7 +150,7 @@ typedef enum { | |||
150 | #define NAND_ECC_READ 0 | 150 | #define NAND_ECC_READ 0 |
151 | /* Reset Hardware ECC for write */ | 151 | /* Reset Hardware ECC for write */ |
152 | #define NAND_ECC_WRITE 1 | 152 | #define NAND_ECC_WRITE 1 |
153 | /* Enable Hardware ECC before syndrom is read back from flash */ | 153 | /* Enable Hardware ECC before syndrome is read back from flash */ |
154 | #define NAND_ECC_READSYN 2 | 154 | #define NAND_ECC_READSYN 2 |
155 | 155 | ||
156 | /* Bit mask for flags passed to do_nand_read_ecc */ | 156 | /* Bit mask for flags passed to do_nand_read_ecc */ |
@@ -163,7 +163,7 @@ typedef enum { | |||
163 | */ | 163 | */ |
164 | /* Chip can not auto increment pages */ | 164 | /* Chip can not auto increment pages */ |
165 | #define NAND_NO_AUTOINCR 0x00000001 | 165 | #define NAND_NO_AUTOINCR 0x00000001 |
166 | /* Buswitdh is 16 bit */ | 166 | /* Buswidth is 16 bit */ |
167 | #define NAND_BUSWIDTH_16 0x00000002 | 167 | #define NAND_BUSWIDTH_16 0x00000002 |
168 | /* Device supports partial programming without padding */ | 168 | /* Device supports partial programming without padding */ |
169 | #define NAND_NO_PADDING 0x00000004 | 169 | #define NAND_NO_PADDING 0x00000004 |
@@ -219,27 +219,15 @@ typedef enum { | |||
219 | #define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) | 219 | #define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) |
220 | 220 | ||
221 | /* Non chip related options */ | 221 | /* Non chip related options */ |
222 | /* | ||
223 | * Use a flash based bad block table. OOB identifier is saved in OOB area. | ||
224 | * This option is passed to the default bad block table function. | ||
225 | */ | ||
226 | #define NAND_USE_FLASH_BBT 0x00010000 | ||
227 | /* This option skips the bbt scan during initialization. */ | 222 | /* This option skips the bbt scan during initialization. */ |
228 | #define NAND_SKIP_BBTSCAN 0x00020000 | 223 | #define NAND_SKIP_BBTSCAN 0x00010000 |
229 | /* | 224 | /* |
230 | * This option is defined if the board driver allocates its own buffers | 225 | * This option is defined if the board driver allocates its own buffers |
231 | * (e.g. because it needs them DMA-coherent). | 226 | * (e.g. because it needs them DMA-coherent). |
232 | */ | 227 | */ |
233 | #define NAND_OWN_BUFFERS 0x00040000 | 228 | #define NAND_OWN_BUFFERS 0x00020000 |
234 | /* Chip may not exist, so silence any errors in scan */ | 229 | /* Chip may not exist, so silence any errors in scan */ |
235 | #define NAND_SCAN_SILENT_NODEV 0x00080000 | 230 | #define NAND_SCAN_SILENT_NODEV 0x00040000 |
236 | /* | ||
237 | * If passed additionally to NAND_USE_FLASH_BBT then BBT code will not touch | ||
238 | * the OOB area. | ||
239 | */ | ||
240 | #define NAND_USE_FLASH_BBT_NO_OOB 0x00800000 | ||
241 | /* Create an empty BBT with no vendor information if the BBT is available */ | ||
242 | #define NAND_CREATE_EMPTY_BBT 0x01000000 | ||
243 | 231 | ||
244 | /* Options set by nand scan */ | 232 | /* Options set by nand scan */ |
245 | /* Nand scan has allocated controller struct */ | 233 | /* Nand scan has allocated controller struct */ |
@@ -331,27 +319,29 @@ struct nand_hw_control { | |||
331 | }; | 319 | }; |
332 | 320 | ||
333 | /** | 321 | /** |
334 | * struct nand_ecc_ctrl - Control structure for ecc | 322 | * struct nand_ecc_ctrl - Control structure for ECC |
335 | * @mode: ecc mode | 323 | * @mode: ECC mode |
336 | * @steps: number of ecc steps per page | 324 | * @steps: number of ECC steps per page |
337 | * @size: data bytes per ecc step | 325 | * @size: data bytes per ECC step |
338 | * @bytes: ecc bytes per step | 326 | * @bytes: ECC bytes per step |
339 | * @total: total number of ecc bytes per page | 327 | * @total: total number of ECC bytes per page |
340 | * @prepad: padding information for syndrome based ecc generators | 328 | * @prepad: padding information for syndrome based ECC generators |
341 | * @postpad: padding information for syndrome based ecc generators | 329 | * @postpad: padding information for syndrome based ECC generators |
342 | * @layout: ECC layout control struct pointer | 330 | * @layout: ECC layout control struct pointer |
343 | * @priv: pointer to private ecc control data | 331 | * @priv: pointer to private ECC control data |
344 | * @hwctl: function to control hardware ecc generator. Must only | 332 | * @hwctl: function to control hardware ECC generator. Must only |
345 | * be provided if an hardware ECC is available | 333 | * be provided if an hardware ECC is available |
346 | * @calculate: function for ecc calculation or readback from ecc hardware | 334 | * @calculate: function for ECC calculation or readback from ECC hardware |
347 | * @correct: function for ecc correction, matching to ecc generator (sw/hw) | 335 | * @correct: function for ECC correction, matching to ECC generator (sw/hw) |
348 | * @read_page_raw: function to read a raw page without ECC | 336 | * @read_page_raw: function to read a raw page without ECC |
349 | * @write_page_raw: function to write a raw page without ECC | 337 | * @write_page_raw: function to write a raw page without ECC |
350 | * @read_page: function to read a page according to the ecc generator | 338 | * @read_page: function to read a page according to the ECC generator |
351 | * requirements. | 339 | * requirements. |
352 | * @read_subpage: function to read parts of the page covered by ECC. | 340 | * @read_subpage: function to read parts of the page covered by ECC. |
353 | * @write_page: function to write a page according to the ecc generator | 341 | * @write_page: function to write a page according to the ECC generator |
354 | * requirements. | 342 | * requirements. |
343 | * @write_oob_raw: function to write chip OOB data without ECC | ||
344 | * @read_oob_raw: function to read chip OOB data without ECC | ||
355 | * @read_oob: function to read chip OOB data | 345 | * @read_oob: function to read chip OOB data |
356 | * @write_oob: function to write chip OOB data | 346 | * @write_oob: function to write chip OOB data |
357 | */ | 347 | */ |
@@ -380,6 +370,10 @@ struct nand_ecc_ctrl { | |||
380 | uint32_t offs, uint32_t len, uint8_t *buf); | 370 | uint32_t offs, uint32_t len, uint8_t *buf); |
381 | void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, | 371 | void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, |
382 | const uint8_t *buf); | 372 | const uint8_t *buf); |
373 | int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, | ||
374 | int page); | ||
375 | int (*read_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, | ||
376 | int page, int sndcmd); | ||
383 | int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page, | 377 | int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page, |
384 | int sndcmd); | 378 | int sndcmd); |
385 | int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip, | 379 | int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip, |
@@ -388,8 +382,8 @@ struct nand_ecc_ctrl { | |||
388 | 382 | ||
389 | /** | 383 | /** |
390 | * struct nand_buffers - buffer structure for read/write | 384 | * struct nand_buffers - buffer structure for read/write |
391 | * @ecccalc: buffer for calculated ecc | 385 | * @ecccalc: buffer for calculated ECC |
392 | * @ecccode: buffer for ecc read from flash | 386 | * @ecccode: buffer for ECC read from flash |
393 | * @databuf: buffer for data - dynamically sized | 387 | * @databuf: buffer for data - dynamically sized |
394 | * | 388 | * |
395 | * Do not change the order of buffers. databuf and oobrbuf must be in | 389 | * Do not change the order of buffers. databuf and oobrbuf must be in |
@@ -422,7 +416,7 @@ struct nand_buffers { | |||
422 | * mtd->oobsize, mtd->writesize and so on. | 416 | * mtd->oobsize, mtd->writesize and so on. |
423 | * @id_data contains the 8 bytes values of NAND_CMD_READID. | 417 | * @id_data contains the 8 bytes values of NAND_CMD_READID. |
424 | * Return with the bus width. | 418 | * Return with the bus width. |
425 | * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing | 419 | * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accessing |
426 | * device ready/busy line. If set to NULL no access to | 420 | * device ready/busy line. If set to NULL no access to |
427 | * ready/busy is available and the ready/busy information | 421 | * ready/busy is available and the ready/busy information |
428 | * is read from the chip status register. | 422 | * is read from the chip status register. |
@@ -430,17 +424,17 @@ struct nand_buffers { | |||
430 | * commands to the chip. | 424 | * commands to the chip. |
431 | * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on | 425 | * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on |
432 | * ready. | 426 | * ready. |
433 | * @ecc: [BOARDSPECIFIC] ecc control ctructure | 427 | * @ecc: [BOARDSPECIFIC] ECC control structure |
434 | * @buffers: buffer structure for read/write | 428 | * @buffers: buffer structure for read/write |
435 | * @hwcontrol: platform-specific hardware control structure | 429 | * @hwcontrol: platform-specific hardware control structure |
436 | * @ops: oob operation operands | ||
437 | * @erase_cmd: [INTERN] erase command write function, selectable due | 430 | * @erase_cmd: [INTERN] erase command write function, selectable due |
438 | * to AND support. | 431 | * to AND support. |
439 | * @scan_bbt: [REPLACEABLE] function to scan bad block table | 432 | * @scan_bbt: [REPLACEABLE] function to scan bad block table |
440 | * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transferring | 433 | * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transferring |
441 | * data from array to read regs (tR). | 434 | * data from array to read regs (tR). |
442 | * @state: [INTERN] the current state of the NAND device | 435 | * @state: [INTERN] the current state of the NAND device |
443 | * @oob_poi: poison value buffer | 436 | * @oob_poi: "poison value buffer," used for laying out OOB data |
437 | * before writing | ||
444 | * @page_shift: [INTERN] number of address bits in a page (column | 438 | * @page_shift: [INTERN] number of address bits in a page (column |
445 | * address bits). | 439 | * address bits). |
446 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock | 440 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock |
@@ -449,6 +443,9 @@ struct nand_buffers { | |||
449 | * @options: [BOARDSPECIFIC] various chip options. They can partly | 443 | * @options: [BOARDSPECIFIC] various chip options. They can partly |
450 | * be set to inform nand_scan about special functionality. | 444 | * be set to inform nand_scan about special functionality. |
451 | * See the defines for further explanation. | 445 | * See the defines for further explanation. |
446 | * @bbt_options: [INTERN] bad block specific options. All options used | ||
447 | * here must come from bbm.h. By default, these options | ||
448 | * will be copied to the appropriate nand_bbt_descr's. | ||
452 | * @badblockpos: [INTERN] position of the bad block marker in the oob | 449 | * @badblockpos: [INTERN] position of the bad block marker in the oob |
453 | * area. | 450 | * area. |
454 | * @badblockbits: [INTERN] number of bits to left-shift the bad block | 451 | * @badblockbits: [INTERN] number of bits to left-shift the bad block |
@@ -464,7 +461,7 @@ struct nand_buffers { | |||
464 | * non 0 if ONFI supported. | 461 | * non 0 if ONFI supported. |
465 | * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is | 462 | * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is |
466 | * supported, 0 otherwise. | 463 | * supported, 0 otherwise. |
467 | * @ecclayout: [REPLACEABLE] the default ecc placement scheme | 464 | * @ecclayout: [REPLACEABLE] the default ECC placement scheme |
468 | * @bbt: [INTERN] bad block table pointer | 465 | * @bbt: [INTERN] bad block table pointer |
469 | * @bbt_td: [REPLACEABLE] bad block table descriptor for flash | 466 | * @bbt_td: [REPLACEABLE] bad block table descriptor for flash |
470 | * lookup. | 467 | * lookup. |
@@ -472,9 +469,9 @@ struct nand_buffers { | |||
472 | * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial | 469 | * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial |
473 | * bad block scan. | 470 | * bad block scan. |
474 | * @controller: [REPLACEABLE] a pointer to a hardware controller | 471 | * @controller: [REPLACEABLE] a pointer to a hardware controller |
475 | * structure which is shared among multiple independend | 472 | * structure which is shared among multiple independent |
476 | * devices. | 473 | * devices. |
477 | * @priv: [OPTIONAL] pointer to private chip date | 474 | * @priv: [OPTIONAL] pointer to private chip data |
478 | * @errstat: [OPTIONAL] hardware specific function to perform | 475 | * @errstat: [OPTIONAL] hardware specific function to perform |
479 | * additional error status checks (determine if errors are | 476 | * additional error status checks (determine if errors are |
480 | * correctable). | 477 | * correctable). |
@@ -509,6 +506,7 @@ struct nand_chip { | |||
509 | 506 | ||
510 | int chip_delay; | 507 | int chip_delay; |
511 | unsigned int options; | 508 | unsigned int options; |
509 | unsigned int bbt_options; | ||
512 | 510 | ||
513 | int page_shift; | 511 | int page_shift; |
514 | int phys_erase_shift; | 512 | int phys_erase_shift; |
@@ -536,8 +534,6 @@ struct nand_chip { | |||
536 | struct nand_buffers *buffers; | 534 | struct nand_buffers *buffers; |
537 | struct nand_hw_control hwcontrol; | 535 | struct nand_hw_control hwcontrol; |
538 | 536 | ||
539 | struct mtd_oob_ops ops; | ||
540 | |||
541 | uint8_t *bbt; | 537 | uint8_t *bbt; |
542 | struct nand_bbt_descr *bbt_td; | 538 | struct nand_bbt_descr *bbt_td; |
543 | struct nand_bbt_descr *bbt_md; | 539 | struct nand_bbt_descr *bbt_md; |
@@ -611,10 +607,9 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
611 | * @partitions: mtd partition list | 607 | * @partitions: mtd partition list |
612 | * @chip_delay: R/B delay value in us | 608 | * @chip_delay: R/B delay value in us |
613 | * @options: Option flags, e.g. 16bit buswidth | 609 | * @options: Option flags, e.g. 16bit buswidth |
614 | * @ecclayout: ecc layout info structure | 610 | * @bbt_options: BBT option flags, e.g. NAND_BBT_USE_FLASH |
611 | * @ecclayout: ECC layout info structure | ||
615 | * @part_probe_types: NULL-terminated array of probe types | 612 | * @part_probe_types: NULL-terminated array of probe types |
616 | * @set_parts: platform specific function to set partitions | ||
617 | * @priv: hardware controller specific settings | ||
618 | */ | 613 | */ |
619 | struct platform_nand_chip { | 614 | struct platform_nand_chip { |
620 | int nr_chips; | 615 | int nr_chips; |
@@ -624,9 +619,8 @@ struct platform_nand_chip { | |||
624 | struct nand_ecclayout *ecclayout; | 619 | struct nand_ecclayout *ecclayout; |
625 | int chip_delay; | 620 | int chip_delay; |
626 | unsigned int options; | 621 | unsigned int options; |
622 | unsigned int bbt_options; | ||
627 | const char **part_probe_types; | 623 | const char **part_probe_types; |
628 | void (*set_parts)(uint64_t size, struct platform_nand_chip *chip); | ||
629 | void *priv; | ||
630 | }; | 624 | }; |
631 | 625 | ||
632 | /* Keep gcc happy */ | 626 | /* Keep gcc happy */ |
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index 52b6f187bf49..4596503c9da9 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h | |||
@@ -184,6 +184,9 @@ struct onenand_chip { | |||
184 | #define ONENAND_IS_CACHE_PROGRAM(this) \ | 184 | #define ONENAND_IS_CACHE_PROGRAM(this) \ |
185 | (this->options & ONENAND_HAS_CACHE_PROGRAM) | 185 | (this->options & ONENAND_HAS_CACHE_PROGRAM) |
186 | 186 | ||
187 | #define ONENAND_IS_NOP_1(this) \ | ||
188 | (this->options & ONENAND_HAS_NOP_1) | ||
189 | |||
187 | /* Check byte access in OneNAND */ | 190 | /* Check byte access in OneNAND */ |
188 | #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) | 191 | #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) |
189 | 192 | ||
@@ -195,6 +198,7 @@ struct onenand_chip { | |||
195 | #define ONENAND_HAS_2PLANE (0x0004) | 198 | #define ONENAND_HAS_2PLANE (0x0004) |
196 | #define ONENAND_HAS_4KB_PAGE (0x0008) | 199 | #define ONENAND_HAS_4KB_PAGE (0x0008) |
197 | #define ONENAND_HAS_CACHE_PROGRAM (0x0010) | 200 | #define ONENAND_HAS_CACHE_PROGRAM (0x0010) |
201 | #define ONENAND_HAS_NOP_1 (0x0020) | ||
198 | #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) | 202 | #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) |
199 | #define ONENAND_PAGEBUF_ALLOC (0x1000) | 203 | #define ONENAND_PAGEBUF_ALLOC (0x1000) |
200 | #define ONENAND_OOBBUF_ALLOC (0x2000) | 204 | #define ONENAND_OOBBUF_ALLOC (0x2000) |
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index 3a6f0372fc96..2475228c1158 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
@@ -24,7 +24,9 @@ | |||
24 | * will extend to the end of the master MTD device. | 24 | * will extend to the end of the master MTD device. |
25 | * offset: absolute starting position within the master MTD device; if | 25 | * offset: absolute starting position within the master MTD device; if |
26 | * defined as MTDPART_OFS_APPEND, the partition will start where the | 26 | * defined as MTDPART_OFS_APPEND, the partition will start where the |
27 | * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block. | 27 | * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block; |
28 | * if MTDPART_OFS_RETAIN, consume as much as possible, leaving size | ||
29 | * after the end of partition. | ||
28 | * mask_flags: contains flags that have to be masked (removed) from the | 30 | * mask_flags: contains flags that have to be masked (removed) from the |
29 | * master MTD flag set for the corresponding MTD partition. | 31 | * master MTD flag set for the corresponding MTD partition. |
30 | * For example, to force a read-only partition, simply adding | 32 | * For example, to force a read-only partition, simply adding |
@@ -42,12 +44,25 @@ struct mtd_partition { | |||
42 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ | 44 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ |
43 | }; | 45 | }; |
44 | 46 | ||
47 | #define MTDPART_OFS_RETAIN (-3) | ||
45 | #define MTDPART_OFS_NXTBLK (-2) | 48 | #define MTDPART_OFS_NXTBLK (-2) |
46 | #define MTDPART_OFS_APPEND (-1) | 49 | #define MTDPART_OFS_APPEND (-1) |
47 | #define MTDPART_SIZ_FULL (0) | 50 | #define MTDPART_SIZ_FULL (0) |
48 | 51 | ||
49 | 52 | ||
50 | struct mtd_info; | 53 | struct mtd_info; |
54 | struct device_node; | ||
55 | |||
56 | /** | ||
57 | * struct mtd_part_parser_data - used to pass data to MTD partition parsers. | ||
58 | * @origin: for RedBoot, start address of MTD device | ||
59 | * @of_node: for OF parsers, device node containing partitioning information | ||
60 | */ | ||
61 | struct mtd_part_parser_data { | ||
62 | unsigned long origin; | ||
63 | struct device_node *of_node; | ||
64 | }; | ||
65 | |||
51 | 66 | ||
52 | /* | 67 | /* |
53 | * Functions dealing with the various ways of partitioning the space | 68 | * Functions dealing with the various ways of partitioning the space |
@@ -57,37 +72,12 @@ struct mtd_part_parser { | |||
57 | struct list_head list; | 72 | struct list_head list; |
58 | struct module *owner; | 73 | struct module *owner; |
59 | const char *name; | 74 | const char *name; |
60 | int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long); | 75 | int (*parse_fn)(struct mtd_info *, struct mtd_partition **, |
76 | struct mtd_part_parser_data *); | ||
61 | }; | 77 | }; |
62 | 78 | ||
63 | extern int register_mtd_parser(struct mtd_part_parser *parser); | 79 | extern int register_mtd_parser(struct mtd_part_parser *parser); |
64 | extern int deregister_mtd_parser(struct mtd_part_parser *parser); | 80 | extern int deregister_mtd_parser(struct mtd_part_parser *parser); |
65 | extern int parse_mtd_partitions(struct mtd_info *master, const char **types, | ||
66 | struct mtd_partition **pparts, unsigned long origin); | ||
67 | |||
68 | #define put_partition_parser(p) do { module_put((p)->owner); } while(0) | ||
69 | |||
70 | struct device; | ||
71 | struct device_node; | ||
72 | |||
73 | #ifdef CONFIG_MTD_OF_PARTS | ||
74 | int __devinit of_mtd_parse_partitions(struct device *dev, | ||
75 | struct device_node *node, | ||
76 | struct mtd_partition **pparts); | ||
77 | #else | ||
78 | static inline int of_mtd_parse_partitions(struct device *dev, | ||
79 | struct device_node *node, | ||
80 | struct mtd_partition **pparts) | ||
81 | { | ||
82 | return 0; | ||
83 | } | ||
84 | #endif | ||
85 | |||
86 | #ifdef CONFIG_MTD_CMDLINE_PARTS | ||
87 | static inline int mtd_has_cmdlinepart(void) { return 1; } | ||
88 | #else | ||
89 | static inline int mtd_has_cmdlinepart(void) { return 0; } | ||
90 | #endif | ||
91 | 81 | ||
92 | int mtd_is_partition(struct mtd_info *mtd); | 82 | int mtd_is_partition(struct mtd_info *mtd); |
93 | int mtd_add_partition(struct mtd_info *master, char *name, | 83 | int mtd_add_partition(struct mtd_info *master, char *name, |
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h index e5f21d293c70..04e018160e2b 100644 --- a/include/linux/mtd/physmap.h +++ b/include/linux/mtd/physmap.h | |||
@@ -32,21 +32,4 @@ struct physmap_flash_data { | |||
32 | struct mtd_partition *parts; | 32 | struct mtd_partition *parts; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | /* | ||
36 | * Board needs to specify the exact mapping during their setup time. | ||
37 | */ | ||
38 | void physmap_configure(unsigned long addr, unsigned long size, | ||
39 | int bankwidth, void (*set_vpp)(struct map_info *, int) ); | ||
40 | |||
41 | /* | ||
42 | * Machines that wish to do flash partition may want to call this function in | ||
43 | * their setup routine. | ||
44 | * | ||
45 | * physmap_set_partitions(mypartitions, num_parts); | ||
46 | * | ||
47 | * Note that one can always override this hard-coded partition with | ||
48 | * command line partition (you need to enable CONFIG_MTD_CMDLINE_PARTS). | ||
49 | */ | ||
50 | void physmap_set_partitions(struct mtd_partition *parts, int num_parts); | ||
51 | |||
52 | #endif /* __LINUX_MTD_PHYSMAP__ */ | 35 | #endif /* __LINUX_MTD_PHYSMAP__ */ |
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h index 2f7d45bcbd24..1a7e1d20adf9 100644 --- a/include/mtd/mtd-abi.h +++ b/include/mtd/mtd-abi.h | |||
@@ -45,6 +45,51 @@ struct mtd_oob_buf64 { | |||
45 | __u64 usr_ptr; | 45 | __u64 usr_ptr; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | /** | ||
49 | * MTD operation modes | ||
50 | * | ||
51 | * @MTD_OPS_PLACE_OOB: OOB data are placed at the given offset (default) | ||
52 | * @MTD_OPS_AUTO_OOB: OOB data are automatically placed at the free areas | ||
53 | * which are defined by the internal ecclayout | ||
54 | * @MTD_OPS_RAW: data are transferred as-is, with no error correction; | ||
55 | * this mode implies %MTD_OPS_PLACE_OOB | ||
56 | * | ||
57 | * These modes can be passed to ioctl(MEMWRITE) and are also used internally. | ||
58 | * See notes on "MTD file modes" for discussion on %MTD_OPS_RAW vs. | ||
59 | * %MTD_FILE_MODE_RAW. | ||
60 | */ | ||
61 | enum { | ||
62 | MTD_OPS_PLACE_OOB = 0, | ||
63 | MTD_OPS_AUTO_OOB = 1, | ||
64 | MTD_OPS_RAW = 2, | ||
65 | }; | ||
66 | |||
67 | /** | ||
68 | * struct mtd_write_req - data structure for requesting a write operation | ||
69 | * | ||
70 | * @start: start address | ||
71 | * @len: length of data buffer | ||
72 | * @ooblen: length of OOB buffer | ||
73 | * @usr_data: user-provided data buffer | ||
74 | * @usr_oob: user-provided OOB buffer | ||
75 | * @mode: MTD mode (see "MTD operation modes") | ||
76 | * @padding: reserved, must be set to 0 | ||
77 | * | ||
78 | * This structure supports ioctl(MEMWRITE) operations, allowing data and/or OOB | ||
79 | * writes in various modes. To write to OOB-only, set @usr_data == NULL, and to | ||
80 | * write data-only, set @usr_oob == NULL. However, setting both @usr_data and | ||
81 | * @usr_oob to NULL is not allowed. | ||
82 | */ | ||
83 | struct mtd_write_req { | ||
84 | __u64 start; | ||
85 | __u64 len; | ||
86 | __u64 ooblen; | ||
87 | __u64 usr_data; | ||
88 | __u64 usr_oob; | ||
89 | __u8 mode; | ||
90 | __u8 padding[7]; | ||
91 | }; | ||
92 | |||
48 | #define MTD_ABSENT 0 | 93 | #define MTD_ABSENT 0 |
49 | #define MTD_RAM 1 | 94 | #define MTD_RAM 1 |
50 | #define MTD_ROM 2 | 95 | #define MTD_ROM 2 |
@@ -59,13 +104,13 @@ struct mtd_oob_buf64 { | |||
59 | #define MTD_NO_ERASE 0x1000 /* No erase necessary */ | 104 | #define MTD_NO_ERASE 0x1000 /* No erase necessary */ |
60 | #define MTD_POWERUP_LOCK 0x2000 /* Always locked after reset */ | 105 | #define MTD_POWERUP_LOCK 0x2000 /* Always locked after reset */ |
61 | 106 | ||
62 | // Some common devices / combinations of capabilities | 107 | /* Some common devices / combinations of capabilities */ |
63 | #define MTD_CAP_ROM 0 | 108 | #define MTD_CAP_ROM 0 |
64 | #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) | 109 | #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) |
65 | #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE) | 110 | #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE) |
66 | #define MTD_CAP_NANDFLASH (MTD_WRITEABLE) | 111 | #define MTD_CAP_NANDFLASH (MTD_WRITEABLE) |
67 | 112 | ||
68 | /* ECC byte placement */ | 113 | /* Obsolete ECC byte placement modes (used with obsolete MEMGETOOBSEL) */ |
69 | #define MTD_NANDECC_OFF 0 // Switch off ECC (Not recommended) | 114 | #define MTD_NANDECC_OFF 0 // Switch off ECC (Not recommended) |
70 | #define MTD_NANDECC_PLACE 1 // Use the given placement in the structure (YAFFS1 legacy mode) | 115 | #define MTD_NANDECC_PLACE 1 // Use the given placement in the structure (YAFFS1 legacy mode) |
71 | #define MTD_NANDECC_AUTOPLACE 2 // Use the default placement scheme | 116 | #define MTD_NANDECC_AUTOPLACE 2 // Use the default placement scheme |
@@ -80,21 +125,18 @@ struct mtd_oob_buf64 { | |||
80 | struct mtd_info_user { | 125 | struct mtd_info_user { |
81 | __u8 type; | 126 | __u8 type; |
82 | __u32 flags; | 127 | __u32 flags; |
83 | __u32 size; // Total size of the MTD | 128 | __u32 size; /* Total size of the MTD */ |
84 | __u32 erasesize; | 129 | __u32 erasesize; |
85 | __u32 writesize; | 130 | __u32 writesize; |
86 | __u32 oobsize; // Amount of OOB data per block (e.g. 16) | 131 | __u32 oobsize; /* Amount of OOB data per block (e.g. 16) */ |
87 | /* The below two fields are obsolete and broken, do not use them | 132 | __u64 padding; /* Old obsolete field; do not use */ |
88 | * (TODO: remove at some point) */ | ||
89 | __u32 ecctype; | ||
90 | __u32 eccsize; | ||
91 | }; | 133 | }; |
92 | 134 | ||
93 | struct region_info_user { | 135 | struct region_info_user { |
94 | __u32 offset; /* At which this region starts, | 136 | __u32 offset; /* At which this region starts, |
95 | * from the beginning of the MTD */ | 137 | * from the beginning of the MTD */ |
96 | __u32 erasesize; /* For this region */ | 138 | __u32 erasesize; /* For this region */ |
97 | __u32 numblocks; /* Number of blocks in this region */ | 139 | __u32 numblocks; /* Number of blocks in this region */ |
98 | __u32 regionindex; | 140 | __u32 regionindex; |
99 | }; | 141 | }; |
100 | 142 | ||
@@ -104,29 +146,61 @@ struct otp_info { | |||
104 | __u32 locked; | 146 | __u32 locked; |
105 | }; | 147 | }; |
106 | 148 | ||
149 | /* | ||
150 | * Note, the following ioctl existed in the past and was removed: | ||
151 | * #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo) | ||
152 | * Try to avoid adding a new ioctl with the same ioctl number. | ||
153 | */ | ||
154 | |||
155 | /* Get basic MTD characteristics info (better to use sysfs) */ | ||
107 | #define MEMGETINFO _IOR('M', 1, struct mtd_info_user) | 156 | #define MEMGETINFO _IOR('M', 1, struct mtd_info_user) |
157 | /* Erase segment of MTD */ | ||
108 | #define MEMERASE _IOW('M', 2, struct erase_info_user) | 158 | #define MEMERASE _IOW('M', 2, struct erase_info_user) |
159 | /* Write out-of-band data from MTD */ | ||
109 | #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) | 160 | #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) |
161 | /* Read out-of-band data from MTD */ | ||
110 | #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) | 162 | #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) |
163 | /* Lock a chip (for MTD that supports it) */ | ||
111 | #define MEMLOCK _IOW('M', 5, struct erase_info_user) | 164 | #define MEMLOCK _IOW('M', 5, struct erase_info_user) |
165 | /* Unlock a chip (for MTD that supports it) */ | ||
112 | #define MEMUNLOCK _IOW('M', 6, struct erase_info_user) | 166 | #define MEMUNLOCK _IOW('M', 6, struct erase_info_user) |
167 | /* Get the number of different erase regions */ | ||
113 | #define MEMGETREGIONCOUNT _IOR('M', 7, int) | 168 | #define MEMGETREGIONCOUNT _IOR('M', 7, int) |
169 | /* Get information about the erase region for a specific index */ | ||
114 | #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) | 170 | #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) |
115 | #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo) | 171 | /* Get info about OOB modes (e.g., RAW, PLACE, AUTO) - legacy interface */ |
116 | #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo) | 172 | #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo) |
173 | /* Check if an eraseblock is bad */ | ||
117 | #define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t) | 174 | #define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t) |
175 | /* Mark an eraseblock as bad */ | ||
118 | #define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t) | 176 | #define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t) |
177 | /* Set OTP (One-Time Programmable) mode (factory vs. user) */ | ||
119 | #define OTPSELECT _IOR('M', 13, int) | 178 | #define OTPSELECT _IOR('M', 13, int) |
179 | /* Get number of OTP (One-Time Programmable) regions */ | ||
120 | #define OTPGETREGIONCOUNT _IOW('M', 14, int) | 180 | #define OTPGETREGIONCOUNT _IOW('M', 14, int) |
181 | /* Get all OTP (One-Time Programmable) info about MTD */ | ||
121 | #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) | 182 | #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) |
183 | /* Lock a given range of user data (must be in mode %MTD_FILE_MODE_OTP_USER) */ | ||
122 | #define OTPLOCK _IOR('M', 16, struct otp_info) | 184 | #define OTPLOCK _IOR('M', 16, struct otp_info) |
185 | /* Get ECC layout (deprecated) */ | ||
123 | #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user) | 186 | #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user) |
187 | /* Get statistics about corrected/uncorrected errors */ | ||
124 | #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) | 188 | #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) |
189 | /* Set MTD mode on a per-file-descriptor basis (see "MTD file modes") */ | ||
125 | #define MTDFILEMODE _IO('M', 19) | 190 | #define MTDFILEMODE _IO('M', 19) |
191 | /* Erase segment of MTD (supports 64-bit address) */ | ||
126 | #define MEMERASE64 _IOW('M', 20, struct erase_info_user64) | 192 | #define MEMERASE64 _IOW('M', 20, struct erase_info_user64) |
193 | /* Write data to OOB (64-bit version) */ | ||
127 | #define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64) | 194 | #define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64) |
195 | /* Read data from OOB (64-bit version) */ | ||
128 | #define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64) | 196 | #define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64) |
197 | /* Check if chip is locked (for MTD that supports it) */ | ||
129 | #define MEMISLOCKED _IOR('M', 23, struct erase_info_user) | 198 | #define MEMISLOCKED _IOR('M', 23, struct erase_info_user) |
199 | /* | ||
200 | * Most generic write interface; can write in-band and/or out-of-band in various | ||
201 | * modes (see "struct mtd_write_req") | ||
202 | */ | ||
203 | #define MEMWRITE _IOWR('M', 24, struct mtd_write_req) | ||
130 | 204 | ||
131 | /* | 205 | /* |
132 | * Obsolete legacy interface. Keep it in order not to break userspace | 206 | * Obsolete legacy interface. Keep it in order not to break userspace |
@@ -177,13 +251,27 @@ struct mtd_ecc_stats { | |||
177 | }; | 251 | }; |
178 | 252 | ||
179 | /* | 253 | /* |
180 | * Read/write file modes for access to MTD | 254 | * MTD file modes - for read/write access to MTD |
255 | * | ||
256 | * @MTD_FILE_MODE_NORMAL: OTP disabled, ECC enabled | ||
257 | * @MTD_FILE_MODE_OTP_FACTORY: OTP enabled in factory mode | ||
258 | * @MTD_FILE_MODE_OTP_USER: OTP enabled in user mode | ||
259 | * @MTD_FILE_MODE_RAW: OTP disabled, ECC disabled | ||
260 | * | ||
261 | * These modes can be set via ioctl(MTDFILEMODE). The mode mode will be retained | ||
262 | * separately for each open file descriptor. | ||
263 | * | ||
264 | * Note: %MTD_FILE_MODE_RAW provides the same functionality as %MTD_OPS_RAW - | ||
265 | * raw access to the flash, without error correction or autoplacement schemes. | ||
266 | * Wherever possible, the MTD_OPS_* mode will override the MTD_FILE_MODE_* mode | ||
267 | * (e.g., when using ioctl(MEMWRITE)), but in some cases, the MTD_FILE_MODE is | ||
268 | * used out of necessity (e.g., `write()', ioctl(MEMWRITEOOB64)). | ||
181 | */ | 269 | */ |
182 | enum mtd_file_modes { | 270 | enum mtd_file_modes { |
183 | MTD_MODE_NORMAL = MTD_OTP_OFF, | 271 | MTD_FILE_MODE_NORMAL = MTD_OTP_OFF, |
184 | MTD_MODE_OTP_FACTORY = MTD_OTP_FACTORY, | 272 | MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY, |
185 | MTD_MODE_OTP_USER = MTD_OTP_USER, | 273 | MTD_FILE_MODE_OTP_USER = MTD_OTP_USER, |
186 | MTD_MODE_RAW, | 274 | MTD_FILE_MODE_RAW, |
187 | }; | 275 | }; |
188 | 276 | ||
189 | #endif /* __MTD_ABI_H__ */ | 277 | #endif /* __MTD_ABI_H__ */ |