diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-27 22:40:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-27 22:40:56 -0400 |
commit | a17d47300b4042a3893217c0c3f2d806fe1faa3b (patch) | |
tree | 91964353354d358cbafc350421e2bddb9455c73c /include | |
parent | 04a6553f0766df3f56830c89b7da2f618b7ef0b0 (diff) | |
parent | 7bf7e370d5919112c223a269462cd0b546903829 (diff) |
Merge branch 'for-linus-1' of git://git.infradead.org/mtd-2.6
* 'for-linus-1' of git://git.infradead.org/mtd-2.6: (49 commits)
mtd: mtdswap: fix compilation warning
mtdswap: kill strict error handling option
mtd: nand: enable software BCH ECC in nand simulator
mtd: nand: add software BCH ECC support
mtd: fix printf format warnings, mostly lack of %zd for size_t, in mtdswap
mtd: sm_rtl: check kmalloc return value
mtd: cfi: add support for AMIC flashes (e.g. A29L160AT)
lib: add shared BCH ECC library
mtd: mxc_nand: fix OOB corruption when page size > 2KiB
mtd: DaVinci: Removed header file that is not required
mtd: pxa3xx_nand: clean the keep configure code
mtd: pxa3xx_nand: mtd scan id process could be defined by driver itself
mtd: pxa3xx_nand: unify prepare command
mtd: pxa3xx_nand: discard wait_for_event,write_cmd,__readid function
mtd: pxa3xx_nand: rework irq logic
mtd: pxa3xx_nand: make scan procedure more clear
mtd: speedtest: fix integer overflow
mtd: mxc_nand: fix read past buffer end
mtd: omap3: nand: report corrected ecc errors
jffs2: remove a trailing white space in commentaries
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/bch.h | 79 | ||||
-rw-r--r-- | include/linux/mtd/blktrans.h | 3 | ||||
-rw-r--r-- | include/linux/mtd/cfi.h | 1 | ||||
-rw-r--r-- | include/linux/mtd/latch-addr-flash.h | 29 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 3 | ||||
-rw-r--r-- | include/linux/mtd/nand_bch.h | 72 | ||||
-rw-r--r-- | include/linux/mtd/onenand.h | 1 |
7 files changed, 188 insertions, 0 deletions
diff --git a/include/linux/bch.h b/include/linux/bch.h new file mode 100644 index 000000000000..295b4ef153bb --- /dev/null +++ b/include/linux/bch.h | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * Generic binary BCH encoding/decoding library | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License version 2 as published by | ||
6 | * the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License along with | ||
14 | * this program; if not, write to the Free Software Foundation, Inc., 51 | ||
15 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
16 | * | ||
17 | * Copyright © 2011 Parrot S.A. | ||
18 | * | ||
19 | * Author: Ivan Djelic <ivan.djelic@parrot.com> | ||
20 | * | ||
21 | * Description: | ||
22 | * | ||
23 | * This library provides runtime configurable encoding/decoding of binary | ||
24 | * Bose-Chaudhuri-Hocquenghem (BCH) codes. | ||
25 | */ | ||
26 | #ifndef _BCH_H | ||
27 | #define _BCH_H | ||
28 | |||
29 | #include <linux/types.h> | ||
30 | |||
31 | /** | ||
32 | * struct bch_control - BCH control structure | ||
33 | * @m: Galois field order | ||
34 | * @n: maximum codeword size in bits (= 2^m-1) | ||
35 | * @t: error correction capability in bits | ||
36 | * @ecc_bits: ecc exact size in bits, i.e. generator polynomial degree (<=m*t) | ||
37 | * @ecc_bytes: ecc max size (m*t bits) in bytes | ||
38 | * @a_pow_tab: Galois field GF(2^m) exponentiation lookup table | ||
39 | * @a_log_tab: Galois field GF(2^m) log lookup table | ||
40 | * @mod8_tab: remainder generator polynomial lookup tables | ||
41 | * @ecc_buf: ecc parity words buffer | ||
42 | * @ecc_buf2: ecc parity words buffer | ||
43 | * @xi_tab: GF(2^m) base for solving degree 2 polynomial roots | ||
44 | * @syn: syndrome buffer | ||
45 | * @cache: log-based polynomial representation buffer | ||
46 | * @elp: error locator polynomial | ||
47 | * @poly_2t: temporary polynomials of degree 2t | ||
48 | */ | ||
49 | struct bch_control { | ||
50 | unsigned int m; | ||
51 | unsigned int n; | ||
52 | unsigned int t; | ||
53 | unsigned int ecc_bits; | ||
54 | unsigned int ecc_bytes; | ||
55 | /* private: */ | ||
56 | uint16_t *a_pow_tab; | ||
57 | uint16_t *a_log_tab; | ||
58 | uint32_t *mod8_tab; | ||
59 | uint32_t *ecc_buf; | ||
60 | uint32_t *ecc_buf2; | ||
61 | unsigned int *xi_tab; | ||
62 | unsigned int *syn; | ||
63 | int *cache; | ||
64 | struct gf_poly *elp; | ||
65 | struct gf_poly *poly_2t[4]; | ||
66 | }; | ||
67 | |||
68 | struct bch_control *init_bch(int m, int t, unsigned int prim_poly); | ||
69 | |||
70 | void free_bch(struct bch_control *bch); | ||
71 | |||
72 | void encode_bch(struct bch_control *bch, const uint8_t *data, | ||
73 | unsigned int len, uint8_t *ecc); | ||
74 | |||
75 | int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, | ||
76 | const uint8_t *recv_ecc, const uint8_t *calc_ecc, | ||
77 | const unsigned int *syn, unsigned int *errloc); | ||
78 | |||
79 | #endif /* _BCH_H */ | ||
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h index 26529ebd59cc..1bbd9f289245 100644 --- a/include/linux/mtd/blktrans.h +++ b/include/linux/mtd/blktrans.h | |||
@@ -36,6 +36,7 @@ struct mtd_blktrans_dev { | |||
36 | struct mtd_info *mtd; | 36 | struct mtd_info *mtd; |
37 | struct mutex lock; | 37 | struct mutex lock; |
38 | int devnum; | 38 | int devnum; |
39 | bool bg_stop; | ||
39 | unsigned long size; | 40 | unsigned long size; |
40 | int readonly; | 41 | int readonly; |
41 | int open; | 42 | int open; |
@@ -62,6 +63,7 @@ struct mtd_blktrans_ops { | |||
62 | unsigned long block, char *buffer); | 63 | unsigned long block, char *buffer); |
63 | int (*discard)(struct mtd_blktrans_dev *dev, | 64 | int (*discard)(struct mtd_blktrans_dev *dev, |
64 | unsigned long block, unsigned nr_blocks); | 65 | unsigned long block, unsigned nr_blocks); |
66 | void (*background)(struct mtd_blktrans_dev *dev); | ||
65 | 67 | ||
66 | /* Block layer ioctls */ | 68 | /* Block layer ioctls */ |
67 | int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); | 69 | int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); |
@@ -85,6 +87,7 @@ extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr); | |||
85 | extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); | 87 | extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); |
86 | extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); | 88 | extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
87 | extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); | 89 | extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
90 | extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev); | ||
88 | 91 | ||
89 | 92 | ||
90 | #endif /* __MTD_TRANS_H__ */ | 93 | #endif /* __MTD_TRANS_H__ */ |
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index a9baee6864af..0d823f2dd667 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
@@ -535,6 +535,7 @@ struct cfi_fixup { | |||
535 | #define CFI_MFR_CONTINUATION 0x007F | 535 | #define CFI_MFR_CONTINUATION 0x007F |
536 | 536 | ||
537 | #define CFI_MFR_AMD 0x0001 | 537 | #define CFI_MFR_AMD 0x0001 |
538 | #define CFI_MFR_AMIC 0x0037 | ||
538 | #define CFI_MFR_ATMEL 0x001F | 539 | #define CFI_MFR_ATMEL 0x001F |
539 | #define CFI_MFR_EON 0x001C | 540 | #define CFI_MFR_EON 0x001C |
540 | #define CFI_MFR_FUJITSU 0x0004 | 541 | #define CFI_MFR_FUJITSU 0x0004 |
diff --git a/include/linux/mtd/latch-addr-flash.h b/include/linux/mtd/latch-addr-flash.h new file mode 100644 index 000000000000..e94b8e128074 --- /dev/null +++ b/include/linux/mtd/latch-addr-flash.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Interface for NOR flash driver whose high address lines are latched | ||
3 | * | ||
4 | * Copyright © 2008 MontaVista Software, Inc. <source@mvista.com> | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public License | ||
7 | * version 2. This program is licensed "as is" without any warranty of any | ||
8 | * kind, whether express or implied. | ||
9 | */ | ||
10 | #ifndef __LATCH_ADDR_FLASH__ | ||
11 | #define __LATCH_ADDR_FLASH__ | ||
12 | |||
13 | struct map_info; | ||
14 | struct mtd_partition; | ||
15 | |||
16 | struct latch_addr_flash_data { | ||
17 | unsigned int width; | ||
18 | unsigned int size; | ||
19 | |||
20 | int (*init)(void *data, int cs); | ||
21 | void (*done)(void *data); | ||
22 | void (*set_window)(unsigned long offset, void *data); | ||
23 | void *data; | ||
24 | |||
25 | unsigned int nr_parts; | ||
26 | struct mtd_partition *parts; | ||
27 | }; | ||
28 | |||
29 | #endif | ||
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 1f489b247a29..ae67ef56a8f5 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -140,6 +140,7 @@ typedef enum { | |||
140 | NAND_ECC_HW, | 140 | NAND_ECC_HW, |
141 | NAND_ECC_HW_SYNDROME, | 141 | NAND_ECC_HW_SYNDROME, |
142 | NAND_ECC_HW_OOB_FIRST, | 142 | NAND_ECC_HW_OOB_FIRST, |
143 | NAND_ECC_SOFT_BCH, | ||
143 | } nand_ecc_modes_t; | 144 | } nand_ecc_modes_t; |
144 | 145 | ||
145 | /* | 146 | /* |
@@ -339,6 +340,7 @@ struct nand_hw_control { | |||
339 | * @prepad: padding information for syndrome based ecc generators | 340 | * @prepad: padding information for syndrome based ecc generators |
340 | * @postpad: padding information for syndrome based ecc generators | 341 | * @postpad: padding information for syndrome based ecc generators |
341 | * @layout: ECC layout control struct pointer | 342 | * @layout: ECC layout control struct pointer |
343 | * @priv: pointer to private ecc control data | ||
342 | * @hwctl: function to control hardware ecc generator. Must only | 344 | * @hwctl: function to control hardware ecc generator. Must only |
343 | * be provided if an hardware ECC is available | 345 | * be provided if an hardware ECC is available |
344 | * @calculate: function for ecc calculation or readback from ecc hardware | 346 | * @calculate: function for ecc calculation or readback from ecc hardware |
@@ -362,6 +364,7 @@ struct nand_ecc_ctrl { | |||
362 | int prepad; | 364 | int prepad; |
363 | int postpad; | 365 | int postpad; |
364 | struct nand_ecclayout *layout; | 366 | struct nand_ecclayout *layout; |
367 | void *priv; | ||
365 | void (*hwctl)(struct mtd_info *mtd, int mode); | 368 | void (*hwctl)(struct mtd_info *mtd, int mode); |
366 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, | 369 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, |
367 | uint8_t *ecc_code); | 370 | uint8_t *ecc_code); |
diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h new file mode 100644 index 000000000000..74acf5367556 --- /dev/null +++ b/include/linux/mtd/nand_bch.h | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This file is the header for the NAND BCH ECC implementation. | ||
9 | */ | ||
10 | |||
11 | #ifndef __MTD_NAND_BCH_H__ | ||
12 | #define __MTD_NAND_BCH_H__ | ||
13 | |||
14 | struct mtd_info; | ||
15 | struct nand_bch_control; | ||
16 | |||
17 | #if defined(CONFIG_MTD_NAND_ECC_BCH) | ||
18 | |||
19 | static inline int mtd_nand_has_bch(void) { return 1; } | ||
20 | |||
21 | /* | ||
22 | * Calculate BCH ecc code | ||
23 | */ | ||
24 | int nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | ||
25 | u_char *ecc_code); | ||
26 | |||
27 | /* | ||
28 | * Detect and correct bit errors | ||
29 | */ | ||
30 | int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, | ||
31 | u_char *calc_ecc); | ||
32 | /* | ||
33 | * Initialize BCH encoder/decoder | ||
34 | */ | ||
35 | struct nand_bch_control * | ||
36 | nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, | ||
37 | unsigned int eccbytes, struct nand_ecclayout **ecclayout); | ||
38 | /* | ||
39 | * Release BCH encoder/decoder resources | ||
40 | */ | ||
41 | void nand_bch_free(struct nand_bch_control *nbc); | ||
42 | |||
43 | #else /* !CONFIG_MTD_NAND_ECC_BCH */ | ||
44 | |||
45 | static inline int mtd_nand_has_bch(void) { return 0; } | ||
46 | |||
47 | static inline int | ||
48 | nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | ||
49 | u_char *ecc_code) | ||
50 | { | ||
51 | return -1; | ||
52 | } | ||
53 | |||
54 | static inline int | ||
55 | nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, | ||
56 | unsigned char *read_ecc, unsigned char *calc_ecc) | ||
57 | { | ||
58 | return -1; | ||
59 | } | ||
60 | |||
61 | static inline struct nand_bch_control * | ||
62 | nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, | ||
63 | unsigned int eccbytes, struct nand_ecclayout **ecclayout) | ||
64 | { | ||
65 | return NULL; | ||
66 | } | ||
67 | |||
68 | static inline void nand_bch_free(struct nand_bch_control *nbc) {} | ||
69 | |||
70 | #endif /* CONFIG_MTD_NAND_ECC_BCH */ | ||
71 | |||
72 | #endif /* __MTD_NAND_BCH_H__ */ | ||
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index ae418e41d8f5..52b6f187bf49 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h | |||
@@ -198,6 +198,7 @@ struct onenand_chip { | |||
198 | #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) | 198 | #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) |
199 | #define ONENAND_PAGEBUF_ALLOC (0x1000) | 199 | #define ONENAND_PAGEBUF_ALLOC (0x1000) |
200 | #define ONENAND_OOBBUF_ALLOC (0x2000) | 200 | #define ONENAND_OOBBUF_ALLOC (0x2000) |
201 | #define ONENAND_SKIP_INITIAL_UNLOCKING (0x4000) | ||
201 | 202 | ||
202 | #define ONENAND_IS_4KB_PAGE(this) \ | 203 | #define ONENAND_IS_4KB_PAGE(this) \ |
203 | (this->options & ONENAND_HAS_4KB_PAGE) | 204 | (this->options & ONENAND_HAS_4KB_PAGE) |