1 /* Copyright 2015 IBM Corp.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * 	http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __EXTERNAL_ARCH_FLASH_H
18 #define __EXTERNAL_ARCH_FLASH_H
19 
20 #include <getopt.h>
21 #include <libflash/blocklevel.h>
22 
23 enum flash_access {
24 	PNOR_DIRECT,
25 	PNOR_MTD,
26 	BMC_DIRECT,
27 	BMC_MTD,
28 	ACCESS_INVAL
29 };
30 
31 int arch_flash_init(struct blocklevel_device **bl, const char *file,
32 		bool keep_alive);
33 
34 void arch_flash_close(struct blocklevel_device *bl, const char *file);
35 
36 /* Low level functions that an architecture may support */
37 
38 /*
39  * If called BEFORE init, then this dictates how the flash will be
40  * accessed.
41  * If called AFTER init, then this returns how the flash is being accessed.
42  */
43 enum flash_access arch_flash_access(struct blocklevel_device *bl,
44 		enum flash_access access);
45 
46 int arch_flash_erase_chip(struct blocklevel_device *bl);
47 int arch_flash_4b_mode(struct blocklevel_device *bl, int set_4b);
48 int arch_flash_set_wrprotect(struct blocklevel_device *bl, int set);
49 
50 #endif /* __EXTERNAL_ARCH_FLASH_H */
51