Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / mtd / nand / raw / ingenic / ingenic_ecc.h
blob2cda439b5e11bff0fc091a4ba31109b27cfdbb98
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __DRIVERS_MTD_NAND_INGENIC_ECC_INTERNAL_H__
3 #define __DRIVERS_MTD_NAND_INGENIC_ECC_INTERNAL_H__
5 #include <linux/compiler_types.h>
6 #include <linux/err.h>
7 #include <linux/mutex.h>
8 #include <linux/types.h>
9 #include <uapi/asm-generic/errno-base.h>
11 struct clk;
12 struct device;
13 struct ingenic_ecc;
14 struct platform_device;
16 /**
17 * struct ingenic_ecc_params - ECC parameters
18 * @size: data bytes per ECC step.
19 * @bytes: ECC bytes per step.
20 * @strength: number of correctable bits per ECC step.
22 struct ingenic_ecc_params {
23 int size;
24 int bytes;
25 int strength;
28 #if IS_ENABLED(CONFIG_MTD_NAND_INGENIC_ECC)
29 int ingenic_ecc_calculate(struct ingenic_ecc *ecc,
30 struct ingenic_ecc_params *params,
31 const u8 *buf, u8 *ecc_code);
32 int ingenic_ecc_correct(struct ingenic_ecc *ecc,
33 struct ingenic_ecc_params *params, u8 *buf,
34 u8 *ecc_code);
36 void ingenic_ecc_release(struct ingenic_ecc *ecc);
37 struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np);
38 #else /* CONFIG_MTD_NAND_INGENIC_ECC */
39 int ingenic_ecc_calculate(struct ingenic_ecc *ecc,
40 struct ingenic_ecc_params *params,
41 const u8 *buf, u8 *ecc_code)
43 return -ENODEV;
46 int ingenic_ecc_correct(struct ingenic_ecc *ecc,
47 struct ingenic_ecc_params *params, u8 *buf,
48 u8 *ecc_code)
50 return -ENODEV;
53 void ingenic_ecc_release(struct ingenic_ecc *ecc)
57 struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np)
59 return ERR_PTR(-ENODEV);
61 #endif /* CONFIG_MTD_NAND_INGENIC_ECC */
63 struct ingenic_ecc_ops {
64 void (*disable)(struct ingenic_ecc *ecc);
65 int (*calculate)(struct ingenic_ecc *ecc,
66 struct ingenic_ecc_params *params,
67 const u8 *buf, u8 *ecc_code);
68 int (*correct)(struct ingenic_ecc *ecc,
69 struct ingenic_ecc_params *params,
70 u8 *buf, u8 *ecc_code);
73 struct ingenic_ecc {
74 struct device *dev;
75 const struct ingenic_ecc_ops *ops;
76 void __iomem *base;
77 struct clk *clk;
78 struct mutex lock;
81 int ingenic_ecc_probe(struct platform_device *pdev);
83 #endif /* __DRIVERS_MTD_NAND_INGENIC_ECC_INTERNAL_H__ */