Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
David Woodhouse | a1452a3 | 2010-08-08 20:58:20 +0100 | [diff] [blame] | 3 | * Copyright (C) 2000-2010 Steven J. Hill <sjhill@realitydiluted.com> |
| 4 | * David Woodhouse <dwmw2@infradead.org> |
| 5 | * Thomas Gleixner <tglx@linutronix.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * 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 Brezillon | af37d2c | 2018-09-06 14:05:18 +0200 | [diff] [blame] | 13 | struct nand_chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | /* |
Akinobu Mita | 1c63aca | 2009-10-22 16:53:32 +0900 | [diff] [blame] | 16 | * Calculate 3 byte ECC code for eccsize byte block |
| 17 | */ |
| 18 | void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize, |
Boris Brezillon | 309600c | 2018-09-04 16:23:28 +0200 | [diff] [blame] | 19 | u_char *ecc_code, bool sm_order); |
Akinobu Mita | 1c63aca | 2009-10-22 16:53:32 +0900 | [diff] [blame] | 20 | |
| 21 | /* |
| 22 | * Calculate 3 byte ECC code for 256/512 byte block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | */ |
Boris Brezillon | af37d2c | 2018-09-06 14:05:18 +0200 | [diff] [blame] | 24 | int nand_calculate_ecc(struct nand_chip *chip, const u_char *dat, |
| 25 | u_char *ecc_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | /* |
Atsushi Nemoto | be2f092 | 2009-09-05 01:20:43 +0900 | [diff] [blame] | 28 | * Detect and correct a 1 bit error for eccsize byte block |
| 29 | */ |
| 30 | int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc, |
Boris Brezillon | 309600c | 2018-09-04 16:23:28 +0200 | [diff] [blame] | 31 | unsigned int eccsize, bool sm_order); |
Atsushi Nemoto | be2f092 | 2009-09-05 01:20:43 +0900 | [diff] [blame] | 32 | |
| 33 | /* |
Akinobu Mita | 1c63aca | 2009-10-22 16:53:32 +0900 | [diff] [blame] | 34 | * Detect and correct a 1 bit error for 256/512 byte block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | */ |
Boris Brezillon | 00da2ea | 2018-09-06 14:05:19 +0200 | [diff] [blame] | 36 | int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc, |
| 37 | u_char *calc_ecc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | #endif /* __MTD_NAND_ECC_H__ */ |