xref: /openbmc/linux/include/linux/platform_data/elm.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1c942fddfSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2bf224335SPhilip Avinash /*
3bf224335SPhilip Avinash  * BCH Error Location Module
4bf224335SPhilip Avinash  *
5*7f317d34SAlexander A. Klimov  * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
6bf224335SPhilip Avinash  */
7bf224335SPhilip Avinash 
8bf224335SPhilip Avinash #ifndef __ELM_H
9bf224335SPhilip Avinash #define __ELM_H
10bf224335SPhilip Avinash 
11bf224335SPhilip Avinash enum bch_ecc {
12bf224335SPhilip Avinash 	BCH4_ECC = 0,
13bf224335SPhilip Avinash 	BCH8_ECC,
142be589e4Spekon gupta 	BCH16_ECC,
15bf224335SPhilip Avinash };
16bf224335SPhilip Avinash 
17bf224335SPhilip Avinash /* ELM support 8 error syndrome process */
18bf224335SPhilip Avinash #define ERROR_VECTOR_MAX		8
19bf224335SPhilip Avinash 
20bf224335SPhilip Avinash /**
21bf224335SPhilip Avinash  * struct elm_errorvec - error vector for elm
22bf224335SPhilip Avinash  * @error_reported:		set true for vectors error is reported
23bf224335SPhilip Avinash  * @error_uncorrectable:	number of uncorrectable errors
24bf224335SPhilip Avinash  * @error_count:		number of correctable errors in the sector
25bf224335SPhilip Avinash  * @error_loc:			buffer for error location
26bf224335SPhilip Avinash  *
27bf224335SPhilip Avinash  */
28bf224335SPhilip Avinash struct elm_errorvec {
29bf224335SPhilip Avinash 	bool error_reported;
30bf224335SPhilip Avinash 	bool error_uncorrectable;
31bf224335SPhilip Avinash 	int error_count;
322be589e4Spekon gupta 	int error_loc[16];
33bf224335SPhilip Avinash };
34bf224335SPhilip Avinash 
3593af53b8SEzequiel García #if IS_ENABLED(CONFIG_MTD_NAND_OMAP_BCH)
36bf224335SPhilip Avinash void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
37bf224335SPhilip Avinash 		struct elm_errorvec *err_vec);
383f4eb14bSPekon Gupta int elm_config(struct device *dev, enum bch_ecc bch_type,
393f4eb14bSPekon Gupta 	int ecc_steps, int ecc_step_size, int ecc_syndrome_size);
4093af53b8SEzequiel García #else
4193af53b8SEzequiel García static inline void
elm_decode_bch_error_page(struct device * dev,u8 * ecc_calc,struct elm_errorvec * err_vec)4293af53b8SEzequiel García elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
4393af53b8SEzequiel García 			  struct elm_errorvec *err_vec)
4493af53b8SEzequiel García {
4593af53b8SEzequiel García }
4693af53b8SEzequiel García 
elm_config(struct device * dev,enum bch_ecc bch_type,int ecc_steps,int ecc_step_size,int ecc_syndrome_size)4793af53b8SEzequiel García static inline int elm_config(struct device *dev, enum bch_ecc bch_type,
4893af53b8SEzequiel García 			     int ecc_steps, int ecc_step_size,
4993af53b8SEzequiel García 			     int ecc_syndrome_size)
5093af53b8SEzequiel García {
5193af53b8SEzequiel García 	return -ENOSYS;
5293af53b8SEzequiel García }
53e90a619fSMiquel Raynal #endif /* CONFIG_MTD_NAND_OMAP_BCH */
5493af53b8SEzequiel García 
55bf224335SPhilip Avinash #endif /* __ELM_H */
56