2019-06-04 15:11:33 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2010-08-09 02:58:20 +07:00
|
|
|
* Copyright (C) 2000-2010 Steven J. Hill <sjhill@realitydiluted.com>
|
|
|
|
* David Woodhouse <dwmw2@infradead.org>
|
|
|
|
* Thomas Gleixner <tglx@linutronix.de>
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* This file is the header for the ECC algorithm.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MTD_NAND_ECC_H__
|
|
|
|
#define __MTD_NAND_ECC_H__
|
|
|
|
|
2018-09-06 19:05:18 +07:00
|
|
|
struct nand_chip;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
2009-10-22 14:53:32 +07:00
|
|
|
* Calculate 3 byte ECC code for eccsize byte block
|
|
|
|
*/
|
|
|
|
void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,
|
2018-09-04 21:23:28 +07:00
|
|
|
u_char *ecc_code, bool sm_order);
|
2009-10-22 14:53:32 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate 3 byte ECC code for 256/512 byte block
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2018-09-06 19:05:18 +07:00
|
|
|
int nand_calculate_ecc(struct nand_chip *chip, const u_char *dat,
|
|
|
|
u_char *ecc_code);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-09-04 23:20:43 +07:00
|
|
|
/*
|
|
|
|
* Detect and correct a 1 bit error for eccsize byte block
|
|
|
|
*/
|
|
|
|
int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc,
|
2018-09-04 21:23:28 +07:00
|
|
|
unsigned int eccsize, bool sm_order);
|
2009-09-04 23:20:43 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2009-10-22 14:53:32 +07:00
|
|
|
* Detect and correct a 1 bit error for 256/512 byte block
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2018-09-06 19:05:19 +07:00
|
|
|
int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc,
|
|
|
|
u_char *calc_ecc);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif /* __MTD_NAND_ECC_H__ */
|