blob: d423916b94f0a4d98c33a297eb68c6523fe57c42 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
David Woodhousea1452a32010-08-08 20:58:20 +01003 * Copyright (C) 2000-2010 Steven J. Hill <sjhill@realitydiluted.com>
4 * David Woodhouse <dwmw2@infradead.org>
5 * Thomas Gleixner <tglx@linutronix.de>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * This file is the header for the ECC algorithm.
8 */
9
10#ifndef __MTD_NAND_ECC_H__
11#define __MTD_NAND_ECC_H__
12
Boris Brezillonaf37d2c2018-09-06 14:05:18 +020013struct nand_chip;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15/*
Akinobu Mita1c63aca2009-10-22 16:53:32 +090016 * Calculate 3 byte ECC code for eccsize byte block
17 */
18void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,
Boris Brezillon309600c2018-09-04 16:23:28 +020019 u_char *ecc_code, bool sm_order);
Akinobu Mita1c63aca2009-10-22 16:53:32 +090020
21/*
22 * Calculate 3 byte ECC code for 256/512 byte block
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 */
Boris Brezillonaf37d2c2018-09-06 14:05:18 +020024int nand_calculate_ecc(struct nand_chip *chip, const u_char *dat,
25 u_char *ecc_code);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27/*
Atsushi Nemotobe2f0922009-09-05 01:20:43 +090028 * Detect and correct a 1 bit error for eccsize byte block
29 */
30int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc,
Boris Brezillon309600c2018-09-04 16:23:28 +020031 unsigned int eccsize, bool sm_order);
Atsushi Nemotobe2f0922009-09-05 01:20:43 +090032
33/*
Akinobu Mita1c63aca2009-10-22 16:53:32 +090034 * Detect and correct a 1 bit error for 256/512 byte block
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 */
Boris Brezillon00da2ea2018-09-06 14:05:19 +020036int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc,
37 u_char *calc_ecc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#endif /* __MTD_NAND_ECC_H__ */