accel/qaic: Add AIC200 support
[drm/drm-misc.git] / include / linux / mtd / nand-ecc-sw-bch.h
blob9da9969505a817cdbb4f340ae5684ade9ad584e6
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com>
5 * This file is the header for the NAND BCH ECC implementation.
6 */
8 #ifndef __MTD_NAND_ECC_SW_BCH_H__
9 #define __MTD_NAND_ECC_SW_BCH_H__
11 #include <linux/mtd/nand.h>
12 #include <linux/bch.h>
14 /**
15 * struct nand_ecc_sw_bch_conf - private software BCH ECC engine structure
16 * @req_ctx: Save request context and tweak the original request to fit the
17 * engine needs
18 * @code_size: Number of bytes needed to store a code (one code per step)
19 * @calc_buf: Buffer to use when calculating ECC bytes
20 * @code_buf: Buffer to use when reading (raw) ECC bytes from the chip
21 * @bch: BCH control structure
22 * @errloc: error location array
23 * @eccmask: XOR ecc mask, allows erased pages to be decoded as valid
25 struct nand_ecc_sw_bch_conf {
26 struct nand_ecc_req_tweak_ctx req_ctx;
27 unsigned int code_size;
28 u8 *calc_buf;
29 u8 *code_buf;
30 struct bch_control *bch;
31 unsigned int *errloc;
32 unsigned char *eccmask;
35 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)
37 int nand_ecc_sw_bch_calculate(struct nand_device *nand,
38 const unsigned char *buf, unsigned char *code);
39 int nand_ecc_sw_bch_correct(struct nand_device *nand, unsigned char *buf,
40 unsigned char *read_ecc, unsigned char *calc_ecc);
41 int nand_ecc_sw_bch_init_ctx(struct nand_device *nand);
42 void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand);
43 struct nand_ecc_engine *nand_ecc_sw_bch_get_engine(void);
45 #else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
47 static inline int nand_ecc_sw_bch_calculate(struct nand_device *nand,
48 const unsigned char *buf,
49 unsigned char *code)
51 return -ENOTSUPP;
54 static inline int nand_ecc_sw_bch_correct(struct nand_device *nand,
55 unsigned char *buf,
56 unsigned char *read_ecc,
57 unsigned char *calc_ecc)
59 return -ENOTSUPP;
62 static inline int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
64 return -ENOTSUPP;
67 static inline void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand) {}
69 #endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
71 #endif /* __MTD_NAND_ECC_SW_BCH_H__ */