1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright © 2019 Macronix
4  * Author: Miquèl Raynal <miquel.raynal@bootlin.com>
5  *
6  * Header for the Macronix external ECC engine.
7  */
8 
9 #ifndef __MTD_NAND_ECC_MXIC_H__
10 #define __MTD_NAND_ECC_MXIC_H__
11 
12 #include <linux/platform_device.h>
13 #include <linux/device.h>
14 
15 struct mxic_ecc_engine;
16 
17 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_MXIC) && IS_REACHABLE(CONFIG_MTD_NAND_CORE)
18 
19 struct nand_ecc_engine_ops *mxic_ecc_get_pipelined_ops(void);
20 struct nand_ecc_engine *mxic_ecc_get_pipelined_engine(struct platform_device *spi_pdev);
21 void mxic_ecc_put_pipelined_engine(struct nand_ecc_engine *eng);
22 int mxic_ecc_process_data_pipelined(struct nand_ecc_engine *eng,
23 				    unsigned int direction, dma_addr_t dirmap);
24 
25 #else /* !CONFIG_MTD_NAND_ECC_MXIC */
26 
mxic_ecc_get_pipelined_ops(void)27 static inline struct nand_ecc_engine_ops *mxic_ecc_get_pipelined_ops(void)
28 {
29 	return NULL;
30 }
31 
32 static inline struct nand_ecc_engine *
mxic_ecc_get_pipelined_engine(struct platform_device * spi_pdev)33 mxic_ecc_get_pipelined_engine(struct platform_device *spi_pdev)
34 {
35 	return ERR_PTR(-EOPNOTSUPP);
36 }
37 
mxic_ecc_put_pipelined_engine(struct nand_ecc_engine * eng)38 static inline void mxic_ecc_put_pipelined_engine(struct nand_ecc_engine *eng) {}
39 
mxic_ecc_process_data_pipelined(struct nand_ecc_engine * eng,unsigned int direction,dma_addr_t dirmap)40 static inline int mxic_ecc_process_data_pipelined(struct nand_ecc_engine *eng,
41 						  unsigned int direction,
42 						  dma_addr_t dirmap)
43 {
44 	return -EOPNOTSUPP;
45 }
46 
47 #endif /* CONFIG_MTD_NAND_ECC_MXIC */
48 
49 #endif /* __MTD_NAND_ECC_MXIC_H__ */
50