0001
0002 #ifndef __DRIVERS_MTD_NAND_INGENIC_ECC_INTERNAL_H__
0003 #define __DRIVERS_MTD_NAND_INGENIC_ECC_INTERNAL_H__
0004
0005 #include <linux/compiler_types.h>
0006 #include <linux/err.h>
0007 #include <linux/mutex.h>
0008 #include <linux/types.h>
0009 #include <uapi/asm-generic/errno-base.h>
0010
0011 struct clk;
0012 struct device;
0013 struct ingenic_ecc;
0014 struct platform_device;
0015
0016
0017
0018
0019
0020
0021
0022 struct ingenic_ecc_params {
0023 int size;
0024 int bytes;
0025 int strength;
0026 };
0027
0028 #if IS_ENABLED(CONFIG_MTD_NAND_INGENIC_ECC)
0029 int ingenic_ecc_calculate(struct ingenic_ecc *ecc,
0030 struct ingenic_ecc_params *params,
0031 const u8 *buf, u8 *ecc_code);
0032 int ingenic_ecc_correct(struct ingenic_ecc *ecc,
0033 struct ingenic_ecc_params *params, u8 *buf,
0034 u8 *ecc_code);
0035
0036 void ingenic_ecc_release(struct ingenic_ecc *ecc);
0037 struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np);
0038 #else
0039 int ingenic_ecc_calculate(struct ingenic_ecc *ecc,
0040 struct ingenic_ecc_params *params,
0041 const u8 *buf, u8 *ecc_code)
0042 {
0043 return -ENODEV;
0044 }
0045
0046 int ingenic_ecc_correct(struct ingenic_ecc *ecc,
0047 struct ingenic_ecc_params *params, u8 *buf,
0048 u8 *ecc_code)
0049 {
0050 return -ENODEV;
0051 }
0052
0053 void ingenic_ecc_release(struct ingenic_ecc *ecc)
0054 {
0055 }
0056
0057 struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np)
0058 {
0059 return ERR_PTR(-ENODEV);
0060 }
0061 #endif
0062
0063 struct ingenic_ecc_ops {
0064 void (*disable)(struct ingenic_ecc *ecc);
0065 int (*calculate)(struct ingenic_ecc *ecc,
0066 struct ingenic_ecc_params *params,
0067 const u8 *buf, u8 *ecc_code);
0068 int (*correct)(struct ingenic_ecc *ecc,
0069 struct ingenic_ecc_params *params,
0070 u8 *buf, u8 *ecc_code);
0071 };
0072
0073 struct ingenic_ecc {
0074 struct device *dev;
0075 const struct ingenic_ecc_ops *ops;
0076 void __iomem *base;
0077 struct clk *clk;
0078 struct mutex lock;
0079 };
0080
0081 int ingenic_ecc_probe(struct platform_device *pdev);
0082
0083 #endif