pmecc.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * © Copyright 2016 ATMEL
  4. * © Copyright 2016 Free Electrons
  5. *
  6. * Author: Boris Brezillon <[email protected]>
  7. *
  8. * Derived from the atmel_nand.c driver which contained the following
  9. * copyrights:
  10. *
  11. * Copyright © 2003 Rick Bronson
  12. *
  13. * Derived from drivers/mtd/nand/autcpu12.c (removed in v3.8)
  14. * Copyright © 2001 Thomas Gleixner ([email protected])
  15. *
  16. * Derived from drivers/mtd/spia.c (removed in v3.8)
  17. * Copyright © 2000 Steven J. Hill ([email protected])
  18. *
  19. *
  20. * Add Hardware ECC support for AT91SAM9260 / AT91SAM9263
  21. * Richard Genoud ([email protected]), Adeneo Copyright © 2007
  22. *
  23. * Derived from Das U-Boot source code
  24. * (u-boot-1.1.5/board/atmel/at91sam9263ek/nand.c)
  25. * © Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas
  26. *
  27. * Add Programmable Multibit ECC support for various AT91 SoC
  28. * © Copyright 2012 ATMEL, Hong Xu
  29. *
  30. * Add Nand Flash Controller support for SAMA5 SoC
  31. * © Copyright 2013 ATMEL, Josh Wu ([email protected])
  32. */
  33. #ifndef ATMEL_PMECC_H
  34. #define ATMEL_PMECC_H
  35. #define ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH 0
  36. #define ATMEL_PMECC_SECTOR_SIZE_AUTO 0
  37. #define ATMEL_PMECC_OOBOFFSET_AUTO -1
  38. struct atmel_pmecc_user_req {
  39. int pagesize;
  40. int oobsize;
  41. struct {
  42. int strength;
  43. int bytes;
  44. int sectorsize;
  45. int nsectors;
  46. int ooboffset;
  47. } ecc;
  48. };
  49. struct atmel_pmecc *devm_atmel_pmecc_get(struct device *dev);
  50. struct atmel_pmecc_user *
  51. atmel_pmecc_create_user(struct atmel_pmecc *pmecc,
  52. struct atmel_pmecc_user_req *req);
  53. void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user);
  54. void atmel_pmecc_reset(struct atmel_pmecc *pmecc);
  55. int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op);
  56. void atmel_pmecc_disable(struct atmel_pmecc_user *user);
  57. int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user);
  58. int atmel_pmecc_correct_sector(struct atmel_pmecc_user *user, int sector,
  59. void *data, void *ecc);
  60. bool atmel_pmecc_correct_erased_chunks(struct atmel_pmecc_user *user);
  61. void atmel_pmecc_get_generated_eccbytes(struct atmel_pmecc_user *user,
  62. int sector, void *ecc);
  63. #endif /* ATMEL_PMECC_H */