pmecc.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * © Copyright 2016 ATMEL
  3. * © Copyright 2016 Free Electrons
  4. *
  5. * Author: Boris Brezillon <boris.brezillon@free-electrons.com>
  6. *
  7. * Derived from the atmel_nand.c driver which contained the following
  8. * copyrights:
  9. *
  10. * Copyright © 2003 Rick Bronson
  11. *
  12. * Derived from drivers/mtd/nand/autcpu12.c (removed in v3.8)
  13. * Copyright © 2001 Thomas Gleixner (gleixner@autronix.de)
  14. *
  15. * Derived from drivers/mtd/spia.c (removed in v3.8)
  16. * Copyright © 2000 Steven J. Hill (sjhill@cotw.com)
  17. *
  18. *
  19. * Add Hardware ECC support for AT91SAM9260 / AT91SAM9263
  20. * Richard Genoud (richard.genoud@gmail.com), Adeneo Copyright © 2007
  21. *
  22. * Derived from Das U-Boot source code
  23. * (u-boot-1.1.5/board/atmel/at91sam9263ek/nand.c)
  24. * © Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas
  25. *
  26. * Add Programmable Multibit ECC support for various AT91 SoC
  27. * © Copyright 2012 ATMEL, Hong Xu
  28. *
  29. * Add Nand Flash Controller support for SAMA5 SoC
  30. * © Copyright 2013 ATMEL, Josh Wu (josh.wu@atmel.com)
  31. *
  32. * This program is free software; you can redistribute it and/or modify
  33. * it under the terms of the GNU General Public License version 2 as
  34. * published by the Free Software Foundation.
  35. *
  36. */
  37. #ifndef ATMEL_PMECC_H
  38. #define ATMEL_PMECC_H
  39. #define ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH 0
  40. #define ATMEL_PMECC_SECTOR_SIZE_AUTO 0
  41. #define ATMEL_PMECC_OOBOFFSET_AUTO -1
  42. struct atmel_pmecc_user_req {
  43. int pagesize;
  44. int oobsize;
  45. struct {
  46. int strength;
  47. int bytes;
  48. int sectorsize;
  49. int nsectors;
  50. int ooboffset;
  51. } ecc;
  52. };
  53. struct atmel_pmecc *devm_atmel_pmecc_get(struct device *dev);
  54. struct atmel_pmecc_user *
  55. atmel_pmecc_create_user(struct atmel_pmecc *pmecc,
  56. struct atmel_pmecc_user_req *req);
  57. void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user);
  58. void atmel_pmecc_reset(struct atmel_pmecc *pmecc);
  59. int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op);
  60. void atmel_pmecc_disable(struct atmel_pmecc_user *user);
  61. int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user);
  62. int atmel_pmecc_correct_sector(struct atmel_pmecc_user *user, int sector,
  63. void *data, void *ecc);
  64. bool atmel_pmecc_correct_erased_chunks(struct atmel_pmecc_user *user);
  65. void atmel_pmecc_get_generated_eccbytes(struct atmel_pmecc_user *user,
  66. int sector, void *ecc);
  67. #endif /* ATMEL_PMECC_H */