xref: /OK3568_Linux_fs/kernel/drivers/rkflash/rkflash_api.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Copyright (c) 2018 Rockchip Electronics Co. Ltd. */
4 
5 #ifndef __RK_FLASH_API_H
6 #define __RK_FLASH_API_H
7 
8 #ifdef CONFIG_RK_NANDC_NAND
9 #include "flash.h"
10 #endif
11 #ifdef CONFIG_RK_SFC_NAND
12 #include "sfc_nand.h"
13 #endif
14 #ifdef	CONFIG_RK_SFC_NOR
15 #include "sfc_nor.h"
16 #endif
17 
18 enum flash_con_type {
19 	FLASH_CON_TYPE_NANDC = 0,
20 	FLASH_CON_TYPE_SFC,
21 	FLASH_CON_TYPE_MAX,
22 };
23 
24 enum flash_type {
25 	FLASH_TYPE_NANDC_NAND = 0,
26 	FLASH_TYPE_SFC_NOR,
27 	FLASH_TYPE_SFC_NAND,
28 	FLASH_TYPE_MAX,
29 };
30 
31 struct flash_boot_ops {
32 	int (*init)(void __iomem *reg_addr);
33 	int (*read)(u32 sec, u32 n_sec, void *p_data);
34 	int (*write)(u32 sec, u32 n_sec, void *p_data);
35 	u32 (*get_capacity)(void);
36 	void (*deinit)(void);
37 	int (*resume)(void __iomem *reg_addr);
38 	int (*vendor_read)(u32 sec, u32 n_sec, void *p_data);
39 	int (*vendor_write)(u32 sec, u32 n_sec, void *p_data);
40 	int (*gc)(void);
41 	int (*discard)(u32 sec, u32 n_sec);
42 };
43 
44 #if IS_REACHABLE(CONFIG_RK_NANDC_NAND)
45 extern const struct flash_boot_ops nandc_nand_ops;
46 #endif
47 
48 #ifdef CONFIG_RK_SFC_NOR
49 extern struct SFNOR_DEV *sfnor_dev;
50 extern const struct flash_boot_ops sfc_nor_ops;
51 #endif
52 
53 #ifdef	CONFIG_RK_SFC_NAND
54 extern struct SFNAND_DEV *sfnand_dev;
55 extern const struct flash_boot_ops sfc_nand_ops;
56 #endif
57 
58 #endif
59