diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mtd/concat.h | 2 | ||||
-rw-r--r-- | include/linux/mtd/ftl.h | 38 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 75 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 7 | ||||
-rw-r--r-- | include/linux/mtd/partitions.h | 6 | ||||
-rw-r--r-- | include/linux/mtd/sharpsl.h | 20 |
6 files changed, 102 insertions, 46 deletions
diff --git a/include/linux/mtd/concat.h b/include/linux/mtd/concat.h index c02f3d264ecf..e80c674daeb3 100644 --- a/include/linux/mtd/concat.h +++ b/include/linux/mtd/concat.h | |||
@@ -13,7 +13,7 @@ | |||
13 | struct mtd_info *mtd_concat_create( | 13 | struct mtd_info *mtd_concat_create( |
14 | struct mtd_info *subdev[], /* subdevices to concatenate */ | 14 | struct mtd_info *subdev[], /* subdevices to concatenate */ |
15 | int num_devs, /* number of subdevices */ | 15 | int num_devs, /* number of subdevices */ |
16 | char *name); /* name for the new device */ | 16 | const char *name); /* name for the new device */ |
17 | 17 | ||
18 | void mtd_concat_destroy(struct mtd_info *mtd); | 18 | void mtd_concat_destroy(struct mtd_info *mtd); |
19 | 19 | ||
diff --git a/include/linux/mtd/ftl.h b/include/linux/mtd/ftl.h index 0be442f881dd..0555f7a0b9ed 100644 --- a/include/linux/mtd/ftl.h +++ b/include/linux/mtd/ftl.h | |||
@@ -32,25 +32,25 @@ | |||
32 | #define _LINUX_FTL_H | 32 | #define _LINUX_FTL_H |
33 | 33 | ||
34 | typedef struct erase_unit_header_t { | 34 | typedef struct erase_unit_header_t { |
35 | u_int8_t LinkTargetTuple[5]; | 35 | uint8_t LinkTargetTuple[5]; |
36 | u_int8_t DataOrgTuple[10]; | 36 | uint8_t DataOrgTuple[10]; |
37 | u_int8_t NumTransferUnits; | 37 | uint8_t NumTransferUnits; |
38 | u_int32_t EraseCount; | 38 | uint32_t EraseCount; |
39 | u_int16_t LogicalEUN; | 39 | uint16_t LogicalEUN; |
40 | u_int8_t BlockSize; | 40 | uint8_t BlockSize; |
41 | u_int8_t EraseUnitSize; | 41 | uint8_t EraseUnitSize; |
42 | u_int16_t FirstPhysicalEUN; | 42 | uint16_t FirstPhysicalEUN; |
43 | u_int16_t NumEraseUnits; | 43 | uint16_t NumEraseUnits; |
44 | u_int32_t FormattedSize; | 44 | uint32_t FormattedSize; |
45 | u_int32_t FirstVMAddress; | 45 | uint32_t FirstVMAddress; |
46 | u_int16_t NumVMPages; | 46 | uint16_t NumVMPages; |
47 | u_int8_t Flags; | 47 | uint8_t Flags; |
48 | u_int8_t Code; | 48 | uint8_t Code; |
49 | u_int32_t SerialNumber; | 49 | uint32_t SerialNumber; |
50 | u_int32_t AltEUHOffset; | 50 | uint32_t AltEUHOffset; |
51 | u_int32_t BAMOffset; | 51 | uint32_t BAMOffset; |
52 | u_int8_t Reserved[12]; | 52 | uint8_t Reserved[12]; |
53 | u_int8_t EndTuple[2]; | 53 | uint8_t EndTuple[2]; |
54 | } erase_unit_header_t; | 54 | } erase_unit_header_t; |
55 | 55 | ||
56 | /* Flags in erase_unit_header_t */ | 56 | /* Flags in erase_unit_header_t */ |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index eae26bb6430a..adef674855f3 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/mtd/compatmac.h> | 15 | #include <linux/mtd/compatmac.h> |
16 | #include <mtd/mtd-abi.h> | 16 | #include <mtd/mtd-abi.h> |
17 | 17 | ||
18 | #include <asm/div64.h> | ||
19 | |||
18 | #define MTD_CHAR_MAJOR 90 | 20 | #define MTD_CHAR_MAJOR 90 |
19 | #define MTD_BLOCK_MAJOR 31 | 21 | #define MTD_BLOCK_MAJOR 31 |
20 | #define MAX_MTD_DEVICES 32 | 22 | #define MAX_MTD_DEVICES 32 |
@@ -25,20 +27,20 @@ | |||
25 | #define MTD_ERASE_DONE 0x08 | 27 | #define MTD_ERASE_DONE 0x08 |
26 | #define MTD_ERASE_FAILED 0x10 | 28 | #define MTD_ERASE_FAILED 0x10 |
27 | 29 | ||
28 | #define MTD_FAIL_ADDR_UNKNOWN 0xffffffff | 30 | #define MTD_FAIL_ADDR_UNKNOWN -1LL |
29 | 31 | ||
30 | /* If the erase fails, fail_addr might indicate exactly which block failed. If | 32 | /* If the erase fails, fail_addr might indicate exactly which block failed. If |
31 | fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not | 33 | fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not |
32 | specific to any particular block. */ | 34 | specific to any particular block. */ |
33 | struct erase_info { | 35 | struct erase_info { |
34 | struct mtd_info *mtd; | 36 | struct mtd_info *mtd; |
35 | u_int32_t addr; | 37 | uint64_t addr; |
36 | u_int32_t len; | 38 | uint64_t len; |
37 | u_int32_t fail_addr; | 39 | uint64_t fail_addr; |
38 | u_long time; | 40 | u_long time; |
39 | u_long retries; | 41 | u_long retries; |
40 | u_int dev; | 42 | unsigned dev; |
41 | u_int cell; | 43 | unsigned cell; |
42 | void (*callback) (struct erase_info *self); | 44 | void (*callback) (struct erase_info *self); |
43 | u_long priv; | 45 | u_long priv; |
44 | u_char state; | 46 | u_char state; |
@@ -46,9 +48,9 @@ struct erase_info { | |||
46 | }; | 48 | }; |
47 | 49 | ||
48 | struct mtd_erase_region_info { | 50 | struct mtd_erase_region_info { |
49 | u_int32_t offset; /* At which this region starts, from the beginning of the MTD */ | 51 | uint64_t offset; /* At which this region starts, from the beginning of the MTD */ |
50 | u_int32_t erasesize; /* For this region */ | 52 | uint32_t erasesize; /* For this region */ |
51 | u_int32_t numblocks; /* Number of blocks of erasesize in this region */ | 53 | uint32_t numblocks; /* Number of blocks of erasesize in this region */ |
52 | unsigned long *lockmap; /* If keeping bitmap of locks */ | 54 | unsigned long *lockmap; /* If keeping bitmap of locks */ |
53 | }; | 55 | }; |
54 | 56 | ||
@@ -100,14 +102,14 @@ struct mtd_oob_ops { | |||
100 | 102 | ||
101 | struct mtd_info { | 103 | struct mtd_info { |
102 | u_char type; | 104 | u_char type; |
103 | u_int32_t flags; | 105 | uint32_t flags; |
104 | u_int32_t size; // Total size of the MTD | 106 | uint64_t size; // Total size of the MTD |
105 | 107 | ||
106 | /* "Major" erase size for the device. Naïve users may take this | 108 | /* "Major" erase size for the device. Naïve users may take this |
107 | * to be the only erase size available, or may use the more detailed | 109 | * to be the only erase size available, or may use the more detailed |
108 | * information below if they desire | 110 | * information below if they desire |
109 | */ | 111 | */ |
110 | u_int32_t erasesize; | 112 | uint32_t erasesize; |
111 | /* Minimal writable flash unit size. In case of NOR flash it is 1 (even | 113 | /* Minimal writable flash unit size. In case of NOR flash it is 1 (even |
112 | * though individual bits can be cleared), in case of NAND flash it is | 114 | * though individual bits can be cleared), in case of NAND flash it is |
113 | * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR | 115 | * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR |
@@ -115,10 +117,20 @@ struct mtd_info { | |||
115 | * Any driver registering a struct mtd_info must ensure a writesize of | 117 | * Any driver registering a struct mtd_info must ensure a writesize of |
116 | * 1 or larger. | 118 | * 1 or larger. |
117 | */ | 119 | */ |
118 | u_int32_t writesize; | 120 | uint32_t writesize; |
121 | |||
122 | uint32_t oobsize; // Amount of OOB data per block (e.g. 16) | ||
123 | uint32_t oobavail; // Available OOB bytes per block | ||
119 | 124 | ||
120 | u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) | 125 | /* |
121 | u_int32_t oobavail; // Available OOB bytes per block | 126 | * If erasesize is a power of 2 then the shift is stored in |
127 | * erasesize_shift otherwise erasesize_shift is zero. Ditto writesize. | ||
128 | */ | ||
129 | unsigned int erasesize_shift; | ||
130 | unsigned int writesize_shift; | ||
131 | /* Masks based on erasesize_shift and writesize_shift */ | ||
132 | unsigned int erasesize_mask; | ||
133 | unsigned int writesize_mask; | ||
122 | 134 | ||
123 | // Kernel-only stuff starts here. | 135 | // Kernel-only stuff starts here. |
124 | const char *name; | 136 | const char *name; |
@@ -190,8 +202,8 @@ struct mtd_info { | |||
190 | void (*sync) (struct mtd_info *mtd); | 202 | void (*sync) (struct mtd_info *mtd); |
191 | 203 | ||
192 | /* Chip-supported device locking */ | 204 | /* Chip-supported device locking */ |
193 | int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len); | 205 | int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); |
194 | int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len); | 206 | int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len); |
195 | 207 | ||
196 | /* Power Management functions */ | 208 | /* Power Management functions */ |
197 | int (*suspend) (struct mtd_info *mtd); | 209 | int (*suspend) (struct mtd_info *mtd); |
@@ -221,6 +233,35 @@ struct mtd_info { | |||
221 | void (*put_device) (struct mtd_info *mtd); | 233 | void (*put_device) (struct mtd_info *mtd); |
222 | }; | 234 | }; |
223 | 235 | ||
236 | static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) | ||
237 | { | ||
238 | if (mtd->erasesize_shift) | ||
239 | return sz >> mtd->erasesize_shift; | ||
240 | do_div(sz, mtd->erasesize); | ||
241 | return sz; | ||
242 | } | ||
243 | |||
244 | static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) | ||
245 | { | ||
246 | if (mtd->erasesize_shift) | ||
247 | return sz & mtd->erasesize_mask; | ||
248 | return do_div(sz, mtd->erasesize); | ||
249 | } | ||
250 | |||
251 | static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) | ||
252 | { | ||
253 | if (mtd->writesize_shift) | ||
254 | return sz >> mtd->writesize_shift; | ||
255 | do_div(sz, mtd->writesize); | ||
256 | return sz; | ||
257 | } | ||
258 | |||
259 | static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) | ||
260 | { | ||
261 | if (mtd->writesize_shift) | ||
262 | return sz & mtd->writesize_mask; | ||
263 | return do_div(sz, mtd->writesize); | ||
264 | } | ||
224 | 265 | ||
225 | /* Kernel-side ioctl definitions */ | 266 | /* Kernel-side ioctl definitions */ |
226 | 267 | ||
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 733d3f3b4eb8..db5b63da2a7e 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -335,17 +335,12 @@ struct nand_buffers { | |||
335 | * @erase_cmd: [INTERN] erase command write function, selectable due to AND support | 335 | * @erase_cmd: [INTERN] erase command write function, selectable due to AND support |
336 | * @scan_bbt: [REPLACEABLE] function to scan bad block table | 336 | * @scan_bbt: [REPLACEABLE] function to scan bad block table |
337 | * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR) | 337 | * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR) |
338 | * @wq: [INTERN] wait queue to sleep on if a NAND operation is in progress | ||
339 | * @state: [INTERN] the current state of the NAND device | 338 | * @state: [INTERN] the current state of the NAND device |
340 | * @oob_poi: poison value buffer | 339 | * @oob_poi: poison value buffer |
341 | * @page_shift: [INTERN] number of address bits in a page (column address bits) | 340 | * @page_shift: [INTERN] number of address bits in a page (column address bits) |
342 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock | 341 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock |
343 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry | 342 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry |
344 | * @chip_shift: [INTERN] number of address bits in one chip | 343 | * @chip_shift: [INTERN] number of address bits in one chip |
345 | * @datbuf: [INTERN] internal buffer for one page + oob | ||
346 | * @oobbuf: [INTERN] oob buffer for one eraseblock | ||
347 | * @oobdirty: [INTERN] indicates that oob_buf must be reinitialized | ||
348 | * @data_poi: [INTERN] pointer to a data buffer | ||
349 | * @options: [BOARDSPECIFIC] various chip options. They can partly be set to inform nand_scan about | 344 | * @options: [BOARDSPECIFIC] various chip options. They can partly be set to inform nand_scan about |
350 | * special functionality. See the defines for further explanation | 345 | * special functionality. See the defines for further explanation |
351 | * @badblockpos: [INTERN] position of the bad block marker in the oob area | 346 | * @badblockpos: [INTERN] position of the bad block marker in the oob area |
@@ -399,7 +394,7 @@ struct nand_chip { | |||
399 | int bbt_erase_shift; | 394 | int bbt_erase_shift; |
400 | int chip_shift; | 395 | int chip_shift; |
401 | int numchips; | 396 | int numchips; |
402 | unsigned long chipsize; | 397 | uint64_t chipsize; |
403 | int pagemask; | 398 | int pagemask; |
404 | int pagebuf; | 399 | int pagebuf; |
405 | int subpagesize; | 400 | int subpagesize; |
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index c92b4d439609..a45dd831b3f8 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
@@ -36,9 +36,9 @@ | |||
36 | 36 | ||
37 | struct mtd_partition { | 37 | struct mtd_partition { |
38 | char *name; /* identifier string */ | 38 | char *name; /* identifier string */ |
39 | u_int32_t size; /* partition size */ | 39 | uint64_t size; /* partition size */ |
40 | u_int32_t offset; /* offset within the master MTD space */ | 40 | uint64_t offset; /* offset within the master MTD space */ |
41 | u_int32_t mask_flags; /* master MTD flags to mask out for this partition */ | 41 | uint32_t mask_flags; /* master MTD flags to mask out for this partition */ |
42 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/ | 42 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/ |
43 | struct mtd_info **mtdp; /* pointer to store the MTD object */ | 43 | struct mtd_info **mtdp; /* pointer to store the MTD object */ |
44 | }; | 44 | }; |
diff --git a/include/linux/mtd/sharpsl.h b/include/linux/mtd/sharpsl.h new file mode 100644 index 000000000000..25f4d2a845c1 --- /dev/null +++ b/include/linux/mtd/sharpsl.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * SharpSL NAND support | ||
3 | * | ||
4 | * Copyright (C) 2008 Dmitry Baryshkov | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/mtd/nand.h> | ||
12 | #include <linux/mtd/nand_ecc.h> | ||
13 | #include <linux/mtd/partitions.h> | ||
14 | |||
15 | struct sharpsl_nand_platform_data { | ||
16 | struct nand_bbt_descr *badblock_pattern; | ||
17 | struct nand_ecclayout *ecc_layout; | ||
18 | struct mtd_partition *partitions; | ||
19 | unsigned int nr_partitions; | ||
20 | }; | ||