diff options
Diffstat (limited to 'include/linux/mtd/nand.h')
-rw-r--r-- | include/linux/mtd/nand.h | 315 |
1 files changed, 147 insertions, 168 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index acd0b500f55a..63e17d01fde9 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -253,61 +253,62 @@ struct nand_chip; | |||
253 | 253 | ||
254 | struct nand_onfi_params { | 254 | struct nand_onfi_params { |
255 | /* rev info and features block */ | 255 | /* rev info and features block */ |
256 | u8 sig[4]; /* 'O' 'N' 'F' 'I' */ | 256 | /* 'O' 'N' 'F' 'I' */ |
257 | __le16 revision; | 257 | u8 sig[4]; |
258 | __le16 features; | 258 | __le16 revision; |
259 | __le16 opt_cmd; | 259 | __le16 features; |
260 | u8 reserved[22]; | 260 | __le16 opt_cmd; |
261 | u8 reserved[22]; | ||
261 | 262 | ||
262 | /* manufacturer information block */ | 263 | /* manufacturer information block */ |
263 | char manufacturer[12]; | 264 | char manufacturer[12]; |
264 | char model[20]; | 265 | char model[20]; |
265 | u8 jedec_id; | 266 | u8 jedec_id; |
266 | __le16 date_code; | 267 | __le16 date_code; |
267 | u8 reserved2[13]; | 268 | u8 reserved2[13]; |
268 | 269 | ||
269 | /* memory organization block */ | 270 | /* memory organization block */ |
270 | __le32 byte_per_page; | 271 | __le32 byte_per_page; |
271 | __le16 spare_bytes_per_page; | 272 | __le16 spare_bytes_per_page; |
272 | __le32 data_bytes_per_ppage; | 273 | __le32 data_bytes_per_ppage; |
273 | __le16 spare_bytes_per_ppage; | 274 | __le16 spare_bytes_per_ppage; |
274 | __le32 pages_per_block; | 275 | __le32 pages_per_block; |
275 | __le32 blocks_per_lun; | 276 | __le32 blocks_per_lun; |
276 | u8 lun_count; | 277 | u8 lun_count; |
277 | u8 addr_cycles; | 278 | u8 addr_cycles; |
278 | u8 bits_per_cell; | 279 | u8 bits_per_cell; |
279 | __le16 bb_per_lun; | 280 | __le16 bb_per_lun; |
280 | __le16 block_endurance; | 281 | __le16 block_endurance; |
281 | u8 guaranteed_good_blocks; | 282 | u8 guaranteed_good_blocks; |
282 | __le16 guaranteed_block_endurance; | 283 | __le16 guaranteed_block_endurance; |
283 | u8 programs_per_page; | 284 | u8 programs_per_page; |
284 | u8 ppage_attr; | 285 | u8 ppage_attr; |
285 | u8 ecc_bits; | 286 | u8 ecc_bits; |
286 | u8 interleaved_bits; | 287 | u8 interleaved_bits; |
287 | u8 interleaved_ops; | 288 | u8 interleaved_ops; |
288 | u8 reserved3[13]; | 289 | u8 reserved3[13]; |
289 | 290 | ||
290 | /* electrical parameter block */ | 291 | /* electrical parameter block */ |
291 | u8 io_pin_capacitance_max; | 292 | u8 io_pin_capacitance_max; |
292 | __le16 async_timing_mode; | 293 | __le16 async_timing_mode; |
293 | __le16 program_cache_timing_mode; | 294 | __le16 program_cache_timing_mode; |
294 | __le16 t_prog; | 295 | __le16 t_prog; |
295 | __le16 t_bers; | 296 | __le16 t_bers; |
296 | __le16 t_r; | 297 | __le16 t_r; |
297 | __le16 t_ccs; | 298 | __le16 t_ccs; |
298 | __le16 src_sync_timing_mode; | 299 | __le16 src_sync_timing_mode; |
299 | __le16 src_ssync_features; | 300 | __le16 src_ssync_features; |
300 | __le16 clk_pin_capacitance_typ; | 301 | __le16 clk_pin_capacitance_typ; |
301 | __le16 io_pin_capacitance_typ; | 302 | __le16 io_pin_capacitance_typ; |
302 | __le16 input_pin_capacitance_typ; | 303 | __le16 input_pin_capacitance_typ; |
303 | u8 input_pin_capacitance_max; | 304 | u8 input_pin_capacitance_max; |
304 | u8 driver_strenght_support; | 305 | u8 driver_strenght_support; |
305 | __le16 t_int_r; | 306 | __le16 t_int_r; |
306 | __le16 t_ald; | 307 | __le16 t_ald; |
307 | u8 reserved4[7]; | 308 | u8 reserved4[7]; |
308 | 309 | ||
309 | /* vendor */ | 310 | /* vendor */ |
310 | u8 reserved5[90]; | 311 | u8 reserved5[90]; |
311 | 312 | ||
312 | __le16 crc; | 313 | __le16 crc; |
313 | } __attribute__((packed)); | 314 | } __attribute__((packed)); |
@@ -323,7 +324,7 @@ struct nand_onfi_params { | |||
323 | * when a hw controller is available. | 324 | * when a hw controller is available. |
324 | */ | 325 | */ |
325 | struct nand_hw_control { | 326 | struct nand_hw_control { |
326 | spinlock_t lock; | 327 | spinlock_t lock; |
327 | struct nand_chip *active; | 328 | struct nand_chip *active; |
328 | wait_queue_head_t wq; | 329 | wait_queue_head_t wq; |
329 | }; | 330 | }; |
@@ -353,44 +354,33 @@ struct nand_hw_control { | |||
353 | * @write_oob: function to write chip OOB data | 354 | * @write_oob: function to write chip OOB data |
354 | */ | 355 | */ |
355 | struct nand_ecc_ctrl { | 356 | struct nand_ecc_ctrl { |
356 | nand_ecc_modes_t mode; | 357 | nand_ecc_modes_t mode; |
357 | int steps; | 358 | int steps; |
358 | int size; | 359 | int size; |
359 | int bytes; | 360 | int bytes; |
360 | int total; | 361 | int total; |
361 | int prepad; | 362 | int prepad; |
362 | int postpad; | 363 | int postpad; |
363 | struct nand_ecclayout *layout; | 364 | struct nand_ecclayout *layout; |
364 | void (*hwctl)(struct mtd_info *mtd, int mode); | 365 | void (*hwctl)(struct mtd_info *mtd, int mode); |
365 | int (*calculate)(struct mtd_info *mtd, | 366 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, |
366 | const uint8_t *dat, | 367 | uint8_t *ecc_code); |
367 | uint8_t *ecc_code); | 368 | int (*correct)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc, |
368 | int (*correct)(struct mtd_info *mtd, uint8_t *dat, | 369 | uint8_t *calc_ecc); |
369 | uint8_t *read_ecc, | 370 | int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, |
370 | uint8_t *calc_ecc); | 371 | uint8_t *buf, int page); |
371 | int (*read_page_raw)(struct mtd_info *mtd, | 372 | void (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, |
372 | struct nand_chip *chip, | 373 | const uint8_t *buf); |
373 | uint8_t *buf, int page); | 374 | int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, |
374 | void (*write_page_raw)(struct mtd_info *mtd, | 375 | uint8_t *buf, int page); |
375 | struct nand_chip *chip, | 376 | int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, |
376 | const uint8_t *buf); | 377 | uint32_t offs, uint32_t len, uint8_t *buf); |
377 | int (*read_page)(struct mtd_info *mtd, | 378 | void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, |
378 | struct nand_chip *chip, | 379 | const uint8_t *buf); |
379 | uint8_t *buf, int page); | 380 | int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page, |
380 | int (*read_subpage)(struct mtd_info *mtd, | 381 | int sndcmd); |
381 | struct nand_chip *chip, | 382 | int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip, |
382 | uint32_t offs, uint32_t len, | 383 | int page); |
383 | uint8_t *buf); | ||
384 | void (*write_page)(struct mtd_info *mtd, | ||
385 | struct nand_chip *chip, | ||
386 | const uint8_t *buf); | ||
387 | int (*read_oob)(struct mtd_info *mtd, | ||
388 | struct nand_chip *chip, | ||
389 | int page, | ||
390 | int sndcmd); | ||
391 | int (*write_oob)(struct mtd_info *mtd, | ||
392 | struct nand_chip *chip, | ||
393 | int page); | ||
394 | }; | 384 | }; |
395 | 385 | ||
396 | /** | 386 | /** |
@@ -487,62 +477,55 @@ struct nand_buffers { | |||
487 | */ | 477 | */ |
488 | 478 | ||
489 | struct nand_chip { | 479 | struct nand_chip { |
490 | void __iomem *IO_ADDR_R; | 480 | void __iomem *IO_ADDR_R; |
491 | void __iomem *IO_ADDR_W; | 481 | void __iomem *IO_ADDR_W; |
492 | 482 | ||
493 | uint8_t (*read_byte)(struct mtd_info *mtd); | 483 | uint8_t (*read_byte)(struct mtd_info *mtd); |
494 | u16 (*read_word)(struct mtd_info *mtd); | 484 | u16 (*read_word)(struct mtd_info *mtd); |
495 | void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, | 485 | void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); |
496 | int len); | 486 | void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); |
497 | void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, | 487 | int (*verify_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); |
498 | int len); | 488 | void (*select_chip)(struct mtd_info *mtd, int chip); |
499 | int (*verify_buf)(struct mtd_info *mtd, const uint8_t *buf, | 489 | int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); |
500 | int len); | 490 | int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); |
501 | void (*select_chip)(struct mtd_info *mtd, int chip); | 491 | void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); |
502 | int (*block_bad)(struct mtd_info *mtd, loff_t ofs, | 492 | int (*init_size)(struct mtd_info *mtd, struct nand_chip *this, |
503 | int getchip); | 493 | u8 *id_data); |
504 | int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); | 494 | int (*dev_ready)(struct mtd_info *mtd); |
505 | void (*cmd_ctrl)(struct mtd_info *mtd, int dat, | 495 | void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, |
506 | unsigned int ctrl); | 496 | int page_addr); |
507 | int (*init_size)(struct mtd_info *mtd, | 497 | int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); |
508 | struct nand_chip *this, u8 *id_data); | 498 | void (*erase_cmd)(struct mtd_info *mtd, int page); |
509 | int (*dev_ready)(struct mtd_info *mtd); | 499 | int (*scan_bbt)(struct mtd_info *mtd); |
510 | void (*cmdfunc)(struct mtd_info *mtd, unsigned command, | 500 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, |
511 | int column, int page_addr); | 501 | int status, int page); |
512 | int (*waitfunc)(struct mtd_info *mtd, | 502 | int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, |
513 | struct nand_chip *this); | 503 | const uint8_t *buf, int page, int cached, int raw); |
514 | void (*erase_cmd)(struct mtd_info *mtd, int page); | 504 | |
515 | int (*scan_bbt)(struct mtd_info *mtd); | 505 | int chip_delay; |
516 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, | 506 | unsigned int options; |
517 | int state, int status, int page); | 507 | |
518 | int (*write_page)(struct mtd_info *mtd, | 508 | int page_shift; |
519 | struct nand_chip *chip, const uint8_t *buf, int page, | 509 | int phys_erase_shift; |
520 | int cached, int raw); | 510 | int bbt_erase_shift; |
521 | 511 | int chip_shift; | |
522 | int chip_delay; | 512 | int numchips; |
523 | unsigned int options; | 513 | uint64_t chipsize; |
524 | 514 | int pagemask; | |
525 | int page_shift; | 515 | int pagebuf; |
526 | int phys_erase_shift; | 516 | int subpagesize; |
527 | int bbt_erase_shift; | 517 | uint8_t cellinfo; |
528 | int chip_shift; | 518 | int badblockpos; |
529 | int numchips; | 519 | int badblockbits; |
530 | uint64_t chipsize; | 520 | |
531 | int pagemask; | 521 | int onfi_version; |
532 | int pagebuf; | ||
533 | int subpagesize; | ||
534 | uint8_t cellinfo; | ||
535 | int badblockpos; | ||
536 | int badblockbits; | ||
537 | |||
538 | int onfi_version; | ||
539 | struct nand_onfi_params onfi_params; | 522 | struct nand_onfi_params onfi_params; |
540 | 523 | ||
541 | flstate_t state; | 524 | flstate_t state; |
542 | 525 | ||
543 | uint8_t *oob_poi; | 526 | uint8_t *oob_poi; |
544 | struct nand_hw_control *controller; | 527 | struct nand_hw_control *controller; |
545 | struct nand_ecclayout *ecclayout; | 528 | struct nand_ecclayout *ecclayout; |
546 | 529 | ||
547 | struct nand_ecc_ctrl ecc; | 530 | struct nand_ecc_ctrl ecc; |
548 | struct nand_buffers *buffers; | 531 | struct nand_buffers *buffers; |
@@ -550,13 +533,13 @@ struct nand_chip { | |||
550 | 533 | ||
551 | struct mtd_oob_ops ops; | 534 | struct mtd_oob_ops ops; |
552 | 535 | ||
553 | uint8_t *bbt; | 536 | uint8_t *bbt; |
554 | struct nand_bbt_descr *bbt_td; | 537 | struct nand_bbt_descr *bbt_td; |
555 | struct nand_bbt_descr *bbt_md; | 538 | struct nand_bbt_descr *bbt_md; |
556 | 539 | ||
557 | struct nand_bbt_descr *badblock_pattern; | 540 | struct nand_bbt_descr *badblock_pattern; |
558 | 541 | ||
559 | void *priv; | 542 | void *priv; |
560 | }; | 543 | }; |
561 | 544 | ||
562 | /* | 545 | /* |
@@ -629,17 +612,16 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
629 | * @priv: hardware controller specific settings | 612 | * @priv: hardware controller specific settings |
630 | */ | 613 | */ |
631 | struct platform_nand_chip { | 614 | struct platform_nand_chip { |
632 | int nr_chips; | 615 | int nr_chips; |
633 | int chip_offset; | 616 | int chip_offset; |
634 | int nr_partitions; | 617 | int nr_partitions; |
635 | struct mtd_partition *partitions; | 618 | struct mtd_partition *partitions; |
636 | struct nand_ecclayout *ecclayout; | 619 | struct nand_ecclayout *ecclayout; |
637 | int chip_delay; | 620 | int chip_delay; |
638 | unsigned int options; | 621 | unsigned int options; |
639 | const char **part_probe_types; | 622 | const char **part_probe_types; |
640 | void (*set_parts)(uint64_t size, | 623 | void (*set_parts)(uint64_t size, struct platform_nand_chip *chip); |
641 | struct platform_nand_chip *chip); | 624 | void *priv; |
642 | void *priv; | ||
643 | }; | 625 | }; |
644 | 626 | ||
645 | /* Keep gcc happy */ | 627 | /* Keep gcc happy */ |
@@ -661,18 +643,15 @@ struct platform_device; | |||
661 | * All fields are optional and depend on the hardware driver requirements | 643 | * All fields are optional and depend on the hardware driver requirements |
662 | */ | 644 | */ |
663 | struct platform_nand_ctrl { | 645 | struct platform_nand_ctrl { |
664 | int (*probe)(struct platform_device *pdev); | 646 | int (*probe)(struct platform_device *pdev); |
665 | void (*remove)(struct platform_device *pdev); | 647 | void (*remove)(struct platform_device *pdev); |
666 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); | 648 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); |
667 | int (*dev_ready)(struct mtd_info *mtd); | 649 | int (*dev_ready)(struct mtd_info *mtd); |
668 | void (*select_chip)(struct mtd_info *mtd, int chip); | 650 | void (*select_chip)(struct mtd_info *mtd, int chip); |
669 | void (*cmd_ctrl)(struct mtd_info *mtd, int dat, | 651 | void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); |
670 | unsigned int ctrl); | 652 | void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); |
671 | void (*write_buf)(struct mtd_info *mtd, | 653 | void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); |
672 | const uint8_t *buf, int len); | 654 | void *priv; |
673 | void (*read_buf)(struct mtd_info *mtd, | ||
674 | uint8_t *buf, int len); | ||
675 | void *priv; | ||
676 | }; | 655 | }; |
677 | 656 | ||
678 | /** | 657 | /** |
@@ -681,8 +660,8 @@ struct platform_nand_ctrl { | |||
681 | * @ctrl: controller level device structure | 660 | * @ctrl: controller level device structure |
682 | */ | 661 | */ |
683 | struct platform_nand_data { | 662 | struct platform_nand_data { |
684 | struct platform_nand_chip chip; | 663 | struct platform_nand_chip chip; |
685 | struct platform_nand_ctrl ctrl; | 664 | struct platform_nand_ctrl ctrl; |
686 | }; | 665 | }; |
687 | 666 | ||
688 | /* Some helpers to access the data structures */ | 667 | /* Some helpers to access the data structures */ |