aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 06:00:46 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 06:00:46 -0400
commit6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd (patch)
tree2be25b1e302eca5984a8ad5ed3e5bde77bafaabb /include
parent7aa65bfd6793a56cc3bbce8436abbfea3a7bdd1f (diff)
[MTD] NAND modularize ECC
First step of modularizing ECC support. - Move ECC related functionality into a seperate embedded data structure - Get rid of the hardware dependend constants to simplify new ECC models Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mtd/nand.h63
1 files changed, 33 insertions, 30 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 601c5c703a05..460525841a27 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -113,21 +113,12 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from,
113/* 113/*
114 * Constants for ECC_MODES 114 * Constants for ECC_MODES
115 */ 115 */
116 116typedef enum {
117/* No ECC. Usage is not recommended ! */ 117 NAND_ECC_NONE,
118#define NAND_ECC_NONE 0 118 NAND_ECC_SOFT,
119/* Software ECC 3 byte ECC per 256 Byte data */ 119 NAND_ECC_HW,
120#define NAND_ECC_SOFT 1 120 NAND_ECC_HW_SYNDROME,
121/* Hardware ECC 3 byte ECC per 256 Byte data */ 121} nand_ecc_modes_t;
122#define NAND_ECC_HW3_256 2
123/* Hardware ECC 3 byte ECC per 512 Byte data */
124#define NAND_ECC_HW3_512 3
125/* Hardware ECC 3 byte ECC per 512 Byte data */
126#define NAND_ECC_HW6_512 4
127/* Hardware ECC 8 byte ECC per 512 Byte data */
128#define NAND_ECC_HW8_512 6
129/* Hardware ECC 12 byte ECC per 2048 Byte data */
130#define NAND_ECC_HW12_2048 7
131 122
132/* 123/*
133 * Constants for Hardware ECC 124 * Constants for Hardware ECC
@@ -231,6 +222,31 @@ struct nand_hw_control {
231}; 222};
232 223
233/** 224/**
225 * struct nand_ecc_ctrl - Control structure for ecc
226 * @mode: ecc mode
227 * @steps: number of ecc steps per page
228 * @size: data bytes per ecc step
229 * @bytes: ecc bytes per step
230 * @hwctl: function to control hardware ecc generator. Must only
231 * be provided if an hardware ECC is available
232 * @calculate: function for ecc calculation or readback from ecc hardware
233 * @correct: function for ecc correction, matching to ecc generator (sw/hw)
234 */
235struct nand_ecc_ctrl {
236 nand_ecc_modes_t mode;
237 int steps;
238 int size;
239 int bytes;
240 int (*hwctl)(struct mtd_info *mtd, int mode);
241 int (*calculate)(struct mtd_info *mtd,
242 const uint8_t *dat,
243 uint8_t *ecc_code);
244 int (*correct)(struct mtd_info *mtd, uint8_t *dat,
245 uint8_t *read_ecc,
246 uint8_t *calc_ecc);
247};
248
249/**
234 * struct nand_chip - NAND Private Flash Chip Data 250 * struct nand_chip - NAND Private Flash Chip Data
235 * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the flash device 251 * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the flash device
236 * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the flash device 252 * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the flash device
@@ -250,16 +266,9 @@ struct nand_hw_control {
250 * is read from the chip status register 266 * is read from the chip status register
251 * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip 267 * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip
252 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready 268 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready
253 * @calculate_ecc: [REPLACEABLE] function for ecc calculation or readback from ecc hardware 269 * @ecc: [BOARDSPECIFIC] ecc control ctructure
254 * @correct_data: [REPLACEABLE] function for ecc correction, matching to ecc generator (sw/hw)
255 * @enable_hwecc: [BOARDSPECIFIC] function to enable (reset) hardware ecc generator. Must only
256 * be provided if a hardware ECC is available
257 * @erase_cmd: [INTERN] erase command write function, selectable due to AND support 270 * @erase_cmd: [INTERN] erase command write function, selectable due to AND support
258 * @scan_bbt: [REPLACEABLE] function to scan bad block table 271 * @scan_bbt: [REPLACEABLE] function to scan bad block table
259 * @eccmode: [BOARDSPECIFIC] mode of ecc, see defines
260 * @eccsize: [INTERN] databytes used per ecc-calculation
261 * @eccbytes: [INTERN] number of ecc bytes per ecc-calculation step
262 * @eccsteps: [INTERN] number of ecc calculation steps per page
263 * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR) 272 * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR)
264 * @wq: [INTERN] wait queue to sleep on if a NAND operation is in progress 273 * @wq: [INTERN] wait queue to sleep on if a NAND operation is in progress
265 * @state: [INTERN] the current state of the NAND device 274 * @state: [INTERN] the current state of the NAND device
@@ -309,15 +318,9 @@ struct nand_chip {
309 int (*dev_ready)(struct mtd_info *mtd); 318 int (*dev_ready)(struct mtd_info *mtd);
310 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); 319 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
311 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); 320 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state);
312 int (*calculate_ecc)(struct mtd_info *mtd, const uint8_t *dat, uint8_t *ecc_code);
313 int (*correct_data)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc);
314 void (*enable_hwecc)(struct mtd_info *mtd, int mode);
315 void (*erase_cmd)(struct mtd_info *mtd, int page); 321 void (*erase_cmd)(struct mtd_info *mtd, int page);
316 int (*scan_bbt)(struct mtd_info *mtd); 322 int (*scan_bbt)(struct mtd_info *mtd);
317 int eccmode; 323 struct nand_ecc_ctrl ecc;
318 int eccsize;
319 int eccbytes;
320 int eccsteps;
321 int chip_delay; 324 int chip_delay;
322 wait_queue_head_t wq; 325 wait_queue_head_t wq;
323 nand_state_t state; 326 nand_state_t state;