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>
7 #include <linux/mutex.h>
8 #include <linux/types.h>
9 #include <uapi/asm-generic/errno-base.h>
14 struct platform_device
;
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
{
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
,
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
)
46 int ingenic_ecc_correct(struct ingenic_ecc
*ecc
,
47 struct ingenic_ecc_params
*params
, u8
*buf
,
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
);
75 const struct ingenic_ecc_ops
*ops
;
81 int ingenic_ecc_probe(struct platform_device
*pdev
);
83 #endif /* __DRIVERS_MTD_NAND_INGENIC_ECC_INTERNAL_H__ */