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