diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 13:20:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 13:20:31 -0500 |
commit | a8e98d6d51a3eb7bb061b1625193a129c8bd094f (patch) | |
tree | 0fa58b6e11e37023b024e55b8f0e7e01438706d4 /include | |
parent | f0f1b3364ae7f48084bdf2837fb979ff59622523 (diff) | |
parent | f9f7dd222364a6428d2ad99a515935dd1dd89d18 (diff) |
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (120 commits)
[MTD] Fix mtdoops.c compilation
[MTD] [NOR] fix startup lock when using multiple nor flash chips
[MTD] [DOC200x] eccbuf is statically defined and always evaluate to true
[MTD] Fix maps/physmap.c compilation with CONFIG_PM
[MTD] onenand: Add panic_write function to the onenand driver
[MTD] mtdoops: Use the panic_write function when present
[MTD] Add mtd panic_write function pointer
[MTD] [NAND] Freescale enhanced Local Bus Controller FCM NAND support.
[MTD] physmap.c: Add support for multiple resources
[MTD] [NAND] Fix misparenthesization introduced by commit 78b65179...
[MTD] [NAND] Fix Blackfin NFC ECC calculating bug with page size 512 bytes
[MTD] [NAND] Remove wrong operation in PM function of the BF54x NFC driver
[MTD] [NAND] Remove unused variable in plat_nand_remove
[MTD] Unlocking all Intel flash that is locked on power up.
[MTD] [NAND] at91_nand: Make mtdparts option can override board info
[MTD] mtdoops: Various minor cleanups
[MTD] mtdoops: Ensure sequential write to the buffer
[MTD] mtdoops: Perform write operations in a workqueue
[MTD] mtdoops: Add further error return code checking
[MTD] [NOR] Test devtype, not definition in flash_probe(), drivers/mtd/devices/lart.c
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mtd/cfi.h | 12 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 9 | ||||
-rw-r--r-- | include/linux/mtd/mtdram.h | 8 | ||||
-rw-r--r-- | include/linux/mtd/onenand_regs.h | 1 | ||||
-rw-r--r-- | include/linux/mtd/partitions.h | 9 | ||||
-rw-r--r-- | include/linux/mtd/ubi.h | 18 | ||||
-rw-r--r-- | include/mtd/mtd-abi.h | 2 | ||||
-rw-r--r-- | include/mtd/ubi-header.h | 47 | ||||
-rw-r--r-- | include/mtd/ubi-user.h | 127 |
9 files changed, 201 insertions, 32 deletions
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index e17c5343cf51..b0ddf4b25862 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
@@ -98,6 +98,18 @@ static inline int cfi_interleave_supported(int i) | |||
98 | #define CFI_DEVICETYPE_X32 (32 / 8) | 98 | #define CFI_DEVICETYPE_X32 (32 / 8) |
99 | #define CFI_DEVICETYPE_X64 (64 / 8) | 99 | #define CFI_DEVICETYPE_X64 (64 / 8) |
100 | 100 | ||
101 | |||
102 | /* Device Interface Code Assignments from the "Common Flash Memory Interface | ||
103 | * Publication 100" dated December 1, 2001. | ||
104 | */ | ||
105 | #define CFI_INTERFACE_X8_ASYNC 0x0000 | ||
106 | #define CFI_INTERFACE_X16_ASYNC 0x0001 | ||
107 | #define CFI_INTERFACE_X8_BY_X16_ASYNC 0x0002 | ||
108 | #define CFI_INTERFACE_X32_ASYNC 0x0003 | ||
109 | #define CFI_INTERFACE_X16_BY_X32_ASYNC 0x0005 | ||
110 | #define CFI_INTERFACE_NOT_ALLOWED 0xffff | ||
111 | |||
112 | |||
101 | /* NB: We keep these structures in memory in HOST byteorder, except | 113 | /* NB: We keep these structures in memory in HOST byteorder, except |
102 | * where individually noted. | 114 | * where individually noted. |
103 | */ | 115 | */ |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 783fc983417c..0a13bb35f044 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -152,6 +152,15 @@ struct mtd_info { | |||
152 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); | 152 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
153 | int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); | 153 | int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
154 | 154 | ||
155 | /* In blackbox flight recorder like scenarios we want to make successful | ||
156 | writes in interrupt context. panic_write() is only intended to be | ||
157 | called when its known the kernel is about to panic and we need the | ||
158 | write to succeed. Since the kernel is not going to be running for much | ||
159 | longer, this function can break locks and delay to ensure the write | ||
160 | succeeds (but not sleep). */ | ||
161 | |||
162 | int (*panic_write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); | ||
163 | |||
155 | int (*read_oob) (struct mtd_info *mtd, loff_t from, | 164 | int (*read_oob) (struct mtd_info *mtd, loff_t from, |
156 | struct mtd_oob_ops *ops); | 165 | struct mtd_oob_ops *ops); |
157 | int (*write_oob) (struct mtd_info *mtd, loff_t to, | 166 | int (*write_oob) (struct mtd_info *mtd, loff_t to, |
diff --git a/include/linux/mtd/mtdram.h b/include/linux/mtd/mtdram.h new file mode 100644 index 000000000000..04fdc07b7353 --- /dev/null +++ b/include/linux/mtd/mtdram.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __MTD_MTDRAM_H__ | ||
2 | #define __MTD_MTDRAM_H__ | ||
3 | |||
4 | #include <linux/mtd/mtd.h> | ||
5 | int mtdram_init_device(struct mtd_info *mtd, void *mapped_address, | ||
6 | unsigned long size, char *name); | ||
7 | |||
8 | #endif /* __MTD_MTDRAM_H__ */ | ||
diff --git a/include/linux/mtd/onenand_regs.h b/include/linux/mtd/onenand_regs.h index c46161f4eee3..d1b310c92eb4 100644 --- a/include/linux/mtd/onenand_regs.h +++ b/include/linux/mtd/onenand_regs.h | |||
@@ -67,6 +67,7 @@ | |||
67 | /* | 67 | /* |
68 | * Device ID Register F001h (R) | 68 | * Device ID Register F001h (R) |
69 | */ | 69 | */ |
70 | #define ONENAND_DEVICE_DENSITY_MASK (0xf) | ||
70 | #define ONENAND_DEVICE_DENSITY_SHIFT (4) | 71 | #define ONENAND_DEVICE_DENSITY_SHIFT (4) |
71 | #define ONENAND_DEVICE_IS_DDP (1 << 3) | 72 | #define ONENAND_DEVICE_IS_DDP (1 << 3) |
72 | #define ONENAND_DEVICE_IS_DEMUX (1 << 2) | 73 | #define ONENAND_DEVICE_IS_DEMUX (1 << 2) |
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index da6b3d6f12a7..7c37d7e55abc 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
@@ -71,5 +71,12 @@ extern int parse_mtd_partitions(struct mtd_info *master, const char **types, | |||
71 | 71 | ||
72 | #define put_partition_parser(p) do { module_put((p)->owner); } while(0) | 72 | #define put_partition_parser(p) do { module_put((p)->owner); } while(0) |
73 | 73 | ||
74 | #endif | 74 | struct device; |
75 | struct device_node; | ||
76 | |||
77 | int __devinit of_mtd_parse_partitions(struct device *dev, | ||
78 | struct mtd_info *mtd, | ||
79 | struct device_node *node, | ||
80 | struct mtd_partition **pparts); | ||
75 | 81 | ||
82 | #endif | ||
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index 3d967b6b120a..f71201d0f3e7 100644 --- a/include/linux/mtd/ubi.h +++ b/include/linux/mtd/ubi.h | |||
@@ -26,23 +26,6 @@ | |||
26 | #include <mtd/ubi-user.h> | 26 | #include <mtd/ubi-user.h> |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * UBI data type hint constants. | ||
30 | * | ||
31 | * UBI_LONGTERM: long-term data | ||
32 | * UBI_SHORTTERM: short-term data | ||
33 | * UBI_UNKNOWN: data persistence is unknown | ||
34 | * | ||
35 | * These constants are used when data is written to UBI volumes in order to | ||
36 | * help the UBI wear-leveling unit to find more appropriate physical | ||
37 | * eraseblocks. | ||
38 | */ | ||
39 | enum { | ||
40 | UBI_LONGTERM = 1, | ||
41 | UBI_SHORTTERM, | ||
42 | UBI_UNKNOWN | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | * enum ubi_open_mode - UBI volume open mode constants. | 29 | * enum ubi_open_mode - UBI volume open mode constants. |
47 | * | 30 | * |
48 | * UBI_READONLY: read-only mode | 31 | * UBI_READONLY: read-only mode |
@@ -167,6 +150,7 @@ int ubi_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf, | |||
167 | int len, int dtype); | 150 | int len, int dtype); |
168 | int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum); | 151 | int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum); |
169 | int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum); | 152 | int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum); |
153 | int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype); | ||
170 | int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum); | 154 | int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum); |
171 | 155 | ||
172 | /* | 156 | /* |
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h index f71dac420394..615072c4da04 100644 --- a/include/mtd/mtd-abi.h +++ b/include/mtd/mtd-abi.h | |||
@@ -29,7 +29,7 @@ struct mtd_oob_buf { | |||
29 | #define MTD_WRITEABLE 0x400 /* Device is writeable */ | 29 | #define MTD_WRITEABLE 0x400 /* Device is writeable */ |
30 | #define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ | 30 | #define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ |
31 | #define MTD_NO_ERASE 0x1000 /* No erase necessary */ | 31 | #define MTD_NO_ERASE 0x1000 /* No erase necessary */ |
32 | #define MTD_STUPID_LOCK 0x2000 /* Always locked after reset */ | 32 | #define MTD_POWERUP_LOCK 0x2000 /* Always locked after reset */ |
33 | 33 | ||
34 | // Some common devices / combinations of capabilities | 34 | // Some common devices / combinations of capabilities |
35 | #define MTD_CAP_ROM 0 | 35 | #define MTD_CAP_ROM 0 |
diff --git a/include/mtd/ubi-header.h b/include/mtd/ubi-header.h index 74efa7763479..292f916ea564 100644 --- a/include/mtd/ubi-header.h +++ b/include/mtd/ubi-header.h | |||
@@ -58,6 +58,43 @@ enum { | |||
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * Volume flags used in the volume table record. | ||
62 | * | ||
63 | * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume | ||
64 | * | ||
65 | * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume | ||
66 | * table. UBI automatically re-sizes the volume which has this flag and makes | ||
67 | * the volume to be of largest possible size. This means that if after the | ||
68 | * initialization UBI finds out that there are available physical eraseblocks | ||
69 | * present on the device, it automatically appends all of them to the volume | ||
70 | * (the physical eraseblocks reserved for bad eraseblocks handling and other | ||
71 | * reserved physical eraseblocks are not taken). So, if there is a volume with | ||
72 | * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical | ||
73 | * eraseblocks will be zero after UBI is loaded, because all of them will be | ||
74 | * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared | ||
75 | * after the volume had been initialized. | ||
76 | * | ||
77 | * The auto-resize feature is useful for device production purposes. For | ||
78 | * example, different NAND flash chips may have different amount of initial bad | ||
79 | * eraseblocks, depending of particular chip instance. Manufacturers of NAND | ||
80 | * chips usually guarantee that the amount of initial bad eraseblocks does not | ||
81 | * exceed certain percent, e.g. 2%. When one creates an UBI image which will be | ||
82 | * flashed to the end devices in production, he does not know the exact amount | ||
83 | * of good physical eraseblocks the NAND chip on the device will have, but this | ||
84 | * number is required to calculate the volume sized and put them to the volume | ||
85 | * table of the UBI image. In this case, one of the volumes (e.g., the one | ||
86 | * which will store the root file system) is marked as "auto-resizable", and | ||
87 | * UBI will adjust its size on the first boot if needed. | ||
88 | * | ||
89 | * Note, first UBI reserves some amount of physical eraseblocks for bad | ||
90 | * eraseblock handling, and then re-sizes the volume, not vice-versa. This | ||
91 | * means that the pool of reserved physical eraseblocks will always be present. | ||
92 | */ | ||
93 | enum { | ||
94 | UBI_VTBL_AUTORESIZE_FLG = 0x01, | ||
95 | }; | ||
96 | |||
97 | /* | ||
61 | * Compatibility constants used by internal volumes. | 98 | * Compatibility constants used by internal volumes. |
62 | * | 99 | * |
63 | * @UBI_COMPAT_DELETE: delete this internal volume before anything is written | 100 | * @UBI_COMPAT_DELETE: delete this internal volume before anything is written |
@@ -262,7 +299,9 @@ struct ubi_vid_hdr { | |||
262 | 299 | ||
263 | /* The layout volume contains the volume table */ | 300 | /* The layout volume contains the volume table */ |
264 | 301 | ||
265 | #define UBI_LAYOUT_VOL_ID UBI_INTERNAL_VOL_START | 302 | #define UBI_LAYOUT_VOLUME_ID UBI_INTERNAL_VOL_START |
303 | #define UBI_LAYOUT_VOLUME_TYPE UBI_VID_DYNAMIC | ||
304 | #define UBI_LAYOUT_VOLUME_ALIGN 1 | ||
266 | #define UBI_LAYOUT_VOLUME_EBS 2 | 305 | #define UBI_LAYOUT_VOLUME_EBS 2 |
267 | #define UBI_LAYOUT_VOLUME_NAME "layout volume" | 306 | #define UBI_LAYOUT_VOLUME_NAME "layout volume" |
268 | #define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT | 307 | #define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT |
@@ -289,7 +328,8 @@ struct ubi_vid_hdr { | |||
289 | * @upd_marker: if volume update was started but not finished | 328 | * @upd_marker: if volume update was started but not finished |
290 | * @name_len: volume name length | 329 | * @name_len: volume name length |
291 | * @name: the volume name | 330 | * @name: the volume name |
292 | * @padding2: reserved, zeroes | 331 | * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG) |
332 | * @padding: reserved, zeroes | ||
293 | * @crc: a CRC32 checksum of the record | 333 | * @crc: a CRC32 checksum of the record |
294 | * | 334 | * |
295 | * The volume table records are stored in the volume table, which is stored in | 335 | * The volume table records are stored in the volume table, which is stored in |
@@ -324,7 +364,8 @@ struct ubi_vtbl_record { | |||
324 | __u8 upd_marker; | 364 | __u8 upd_marker; |
325 | __be16 name_len; | 365 | __be16 name_len; |
326 | __u8 name[UBI_VOL_NAME_MAX+1]; | 366 | __u8 name[UBI_VOL_NAME_MAX+1]; |
327 | __u8 padding2[24]; | 367 | __u8 flags; |
368 | __u8 padding[23]; | ||
328 | __be32 crc; | 369 | __be32 crc; |
329 | } __attribute__ ((packed)); | 370 | } __attribute__ ((packed)); |
330 | 371 | ||
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index fe06ded0e6b8..a7421f130cc0 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
@@ -22,6 +22,21 @@ | |||
22 | #define __UBI_USER_H__ | 22 | #define __UBI_USER_H__ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * UBI device creation (the same as MTD device attachment) | ||
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
27 | * | ||
28 | * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI | ||
29 | * control device. The caller has to properly fill and pass | ||
30 | * &struct ubi_attach_req object - UBI will attach the MTD device specified in | ||
31 | * the request and return the newly created UBI device number as the ioctl | ||
32 | * return value. | ||
33 | * | ||
34 | * UBI device deletion (the same as MTD device detachment) | ||
35 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
36 | * | ||
37 | * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI | ||
38 | * control device. | ||
39 | * | ||
25 | * UBI volume creation | 40 | * UBI volume creation |
26 | * ~~~~~~~~~~~~~~~~~~~ | 41 | * ~~~~~~~~~~~~~~~~~~~ |
27 | * | 42 | * |
@@ -48,7 +63,7 @@ | |||
48 | * | 63 | * |
49 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the | 64 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the |
50 | * corresponding UBI volume character device. A pointer to a 64-bit update | 65 | * corresponding UBI volume character device. A pointer to a 64-bit update |
51 | * size should be passed to the IOCTL. After then, UBI expects user to write | 66 | * size should be passed to the IOCTL. After this, UBI expects user to write |
52 | * this number of bytes to the volume character device. The update is finished | 67 | * this number of bytes to the volume character device. The update is finished |
53 | * when the claimed number of bytes is passed. So, the volume update sequence | 68 | * when the claimed number of bytes is passed. So, the volume update sequence |
54 | * is something like: | 69 | * is something like: |
@@ -57,14 +72,24 @@ | |||
57 | * ioctl(fd, UBI_IOCVOLUP, &image_size); | 72 | * ioctl(fd, UBI_IOCVOLUP, &image_size); |
58 | * write(fd, buf, image_size); | 73 | * write(fd, buf, image_size); |
59 | * close(fd); | 74 | * close(fd); |
75 | * | ||
76 | * Atomic eraseblock change | ||
77 | * ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
78 | * | ||
79 | * Atomic eraseblock change operation is done via the %UBI_IOCEBCH IOCTL | ||
80 | * command of the corresponding UBI volume character device. A pointer to | ||
81 | * &struct ubi_leb_change_req has to be passed to the IOCTL. Then the user is | ||
82 | * expected to write the requested amount of bytes. This is similar to the | ||
83 | * "volume update" IOCTL. | ||
60 | */ | 84 | */ |
61 | 85 | ||
62 | /* | 86 | /* |
63 | * When a new volume is created, users may either specify the volume number they | 87 | * When a new UBI volume or UBI device is created, users may either specify the |
64 | * want to create or to let UBI automatically assign a volume number using this | 88 | * volume/device number they want to create or to let UBI automatically assign |
65 | * constant. | 89 | * the number using these constants. |
66 | */ | 90 | */ |
67 | #define UBI_VOL_NUM_AUTO (-1) | 91 | #define UBI_VOL_NUM_AUTO (-1) |
92 | #define UBI_DEV_NUM_AUTO (-1) | ||
68 | 93 | ||
69 | /* Maximum volume name length */ | 94 | /* Maximum volume name length */ |
70 | #define UBI_MAX_VOLUME_NAME 127 | 95 | #define UBI_MAX_VOLUME_NAME 127 |
@@ -80,6 +105,15 @@ | |||
80 | /* Re-size an UBI volume */ | 105 | /* Re-size an UBI volume */ |
81 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) | 106 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) |
82 | 107 | ||
108 | /* IOCTL commands of the UBI control character device */ | ||
109 | |||
110 | #define UBI_CTRL_IOC_MAGIC 'o' | ||
111 | |||
112 | /* Attach an MTD device */ | ||
113 | #define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req) | ||
114 | /* Detach an MTD device */ | ||
115 | #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) | ||
116 | |||
83 | /* IOCTL commands of UBI volume character devices */ | 117 | /* IOCTL commands of UBI volume character devices */ |
84 | 118 | ||
85 | #define UBI_VOL_IOC_MAGIC 'O' | 119 | #define UBI_VOL_IOC_MAGIC 'O' |
@@ -88,6 +122,28 @@ | |||
88 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) | 122 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) |
89 | /* An eraseblock erasure command, used for debugging, disabled by default */ | 123 | /* An eraseblock erasure command, used for debugging, disabled by default */ |
90 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) | 124 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) |
125 | /* An atomic eraseblock change command */ | ||
126 | #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) | ||
127 | |||
128 | /* Maximum MTD device name length supported by UBI */ | ||
129 | #define MAX_UBI_MTD_NAME_LEN 127 | ||
130 | |||
131 | /* | ||
132 | * UBI data type hint constants. | ||
133 | * | ||
134 | * UBI_LONGTERM: long-term data | ||
135 | * UBI_SHORTTERM: short-term data | ||
136 | * UBI_UNKNOWN: data persistence is unknown | ||
137 | * | ||
138 | * These constants are used when data is written to UBI volumes in order to | ||
139 | * help the UBI wear-leveling unit to find more appropriate physical | ||
140 | * eraseblocks. | ||
141 | */ | ||
142 | enum { | ||
143 | UBI_LONGTERM = 1, | ||
144 | UBI_SHORTTERM = 2, | ||
145 | UBI_UNKNOWN = 3, | ||
146 | }; | ||
91 | 147 | ||
92 | /* | 148 | /* |
93 | * UBI volume type constants. | 149 | * UBI volume type constants. |
@@ -97,22 +153,58 @@ | |||
97 | */ | 153 | */ |
98 | enum { | 154 | enum { |
99 | UBI_DYNAMIC_VOLUME = 3, | 155 | UBI_DYNAMIC_VOLUME = 3, |
100 | UBI_STATIC_VOLUME = 4 | 156 | UBI_STATIC_VOLUME = 4, |
157 | }; | ||
158 | |||
159 | /** | ||
160 | * struct ubi_attach_req - attach MTD device request. | ||
161 | * @ubi_num: UBI device number to create | ||
162 | * @mtd_num: MTD device number to attach | ||
163 | * @vid_hdr_offset: VID header offset (use defaults if %0) | ||
164 | * @padding: reserved for future, not used, has to be zeroed | ||
165 | * | ||
166 | * This data structure is used to specify MTD device UBI has to attach and the | ||
167 | * parameters it has to use. The number which should be assigned to the new UBI | ||
168 | * device is passed in @ubi_num. UBI may automatically assign the number if | ||
169 | * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in | ||
170 | * @ubi_num. | ||
171 | * | ||
172 | * Most applications should pass %0 in @vid_hdr_offset to make UBI use default | ||
173 | * offset of the VID header within physical eraseblocks. The default offset is | ||
174 | * the next min. I/O unit after the EC header. For example, it will be offset | ||
175 | * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or | ||
176 | * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages. | ||
177 | * | ||
178 | * But in rare cases, if this optimizes things, the VID header may be placed to | ||
179 | * a different offset. For example, the boot-loader might do things faster if the | ||
180 | * VID header sits at the end of the first 2KiB NAND page with 4 sub-pages. As | ||
181 | * the boot-loader would not normally need to read EC headers (unless it needs | ||
182 | * UBI in RW mode), it might be faster to calculate ECC. This is weird example, | ||
183 | * but it real-life example. So, in this example, @vid_hdr_offer would be | ||
184 | * 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes | ||
185 | * aligned, which is OK, as UBI is clever enough to realize this is 4th sub-page | ||
186 | * of the first page and add needed padding. | ||
187 | */ | ||
188 | struct ubi_attach_req { | ||
189 | int32_t ubi_num; | ||
190 | int32_t mtd_num; | ||
191 | int32_t vid_hdr_offset; | ||
192 | uint8_t padding[12]; | ||
101 | }; | 193 | }; |
102 | 194 | ||
103 | /** | 195 | /** |
104 | * struct ubi_mkvol_req - volume description data structure used in | 196 | * struct ubi_mkvol_req - volume description data structure used in |
105 | * volume creation requests. | 197 | * volume creation requests. |
106 | * @vol_id: volume number | 198 | * @vol_id: volume number |
107 | * @alignment: volume alignment | 199 | * @alignment: volume alignment |
108 | * @bytes: volume size in bytes | 200 | * @bytes: volume size in bytes |
109 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) | 201 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) |
110 | * @padding1: reserved for future, not used | 202 | * @padding1: reserved for future, not used, has to be zeroed |
111 | * @name_len: volume name length | 203 | * @name_len: volume name length |
112 | * @padding2: reserved for future, not used | 204 | * @padding2: reserved for future, not used, has to be zeroed |
113 | * @name: volume name | 205 | * @name: volume name |
114 | * | 206 | * |
115 | * This structure is used by userspace programs when creating new volumes. The | 207 | * This structure is used by user-space programs when creating new volumes. The |
116 | * @used_bytes field is only necessary when creating static volumes. | 208 | * @used_bytes field is only necessary when creating static volumes. |
117 | * | 209 | * |
118 | * The @alignment field specifies the required alignment of the volume logical | 210 | * The @alignment field specifies the required alignment of the volume logical |
@@ -139,7 +231,7 @@ struct ubi_mkvol_req { | |||
139 | int8_t padding1; | 231 | int8_t padding1; |
140 | int16_t name_len; | 232 | int16_t name_len; |
141 | int8_t padding2[4]; | 233 | int8_t padding2[4]; |
142 | char name[UBI_MAX_VOLUME_NAME+1]; | 234 | char name[UBI_MAX_VOLUME_NAME + 1]; |
143 | } __attribute__ ((packed)); | 235 | } __attribute__ ((packed)); |
144 | 236 | ||
145 | /** | 237 | /** |
@@ -158,4 +250,19 @@ struct ubi_rsvol_req { | |||
158 | int32_t vol_id; | 250 | int32_t vol_id; |
159 | } __attribute__ ((packed)); | 251 | } __attribute__ ((packed)); |
160 | 252 | ||
253 | /** | ||
254 | * struct ubi_leb_change_req - a data structure used in atomic logical | ||
255 | * eraseblock change requests. | ||
256 | * @lnum: logical eraseblock number to change | ||
257 | * @bytes: how many bytes will be written to the logical eraseblock | ||
258 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) | ||
259 | * @padding: reserved for future, not used, has to be zeroed | ||
260 | */ | ||
261 | struct ubi_leb_change_req { | ||
262 | int32_t lnum; | ||
263 | int32_t bytes; | ||
264 | uint8_t dtype; | ||
265 | uint8_t padding[7]; | ||
266 | } __attribute__ ((packed)); | ||
267 | |||
161 | #endif /* __UBI_USER_H__ */ | 268 | #endif /* __UBI_USER_H__ */ |