xref: /openbmc/u-boot/include/ubispl.h (revision 473af36a)
1 /*
2  * Copyright (c) Thomas Gleixner <tglx@linutronix.de>
3  *
4  * SPDX-License-Identifier: GPL 2.0+ BSD-3-Clause
5  */
6 #ifndef __UBOOT_UBISPL_H
7 #define __UBOOT_UBISPL_H
8 
9 /*
10  * The following CONFIG options are relevant for UBISPL
11  *
12  * #define CONFIG_SPL_UBI_MAX_VOL_LEBS		256
13  *
14  * Defines the maximum number of logical erase blocks per loadable
15  * (static) volume to size the ubispl internal arrays.
16  *
17  * #define CONFIG_SPL_UBI_MAX_PEB_SIZE		(256*1024)
18  *
19  * Defines the maximum physical erase block size to size the fastmap
20  * buffer for ubispl.
21  *
22  * #define CONFIG_SPL_UBI_MAX_PEBS		4096
23  *
24  * Define the maximum number of physical erase blocks to size the
25  * ubispl internal arrays.
26  *
27  * #define CONFIG_SPL_UBI_VOL_IDS		8
28  *
29  * Defines the maximum number of volumes in which UBISPL is
30  * interested. Limits the amount of memory for the scan data and
31  * speeds up the scan process as we simply ignore stuff which we dont
32  * want to load from the SPL anyway. So the volumes which can be
33  * loaded in the above example are ids 0 - 7
34  */
35 
36 /*
37  * The struct definition is in drivers/mtd/ubispl/ubispl.h. It does
38  * not fit into the BSS due to the large buffer requirement of the
39  * upstream fastmap code. So the caller of ubispl_load_volumes needs
40  * to hand in a pointer to a free memory area where ubispl will place
41  * its data. The area is not required to be initialized.
42  */
43 struct ubi_scan_info;
44 
45 typedef int (*ubispl_read_flash)(int pnum, int offset, int len, void *dst);
46 
47 /**
48  * struct ubispl_info - description structure for fast ubi scan
49  * @ubi:		Pointer to memory space for ubi scan info structure
50  * @peb_size:		Physical erase block size
51  * @vid_offset:		Offset of the VID header
52  * @leb_start:		Start of the logical erase block, i.e. offset of data
53  * @peb_count:		Number of physical erase blocks in the UBI FLASH area
54  *			aka MTD partition.
55  * @peb_offset:		Offset of PEB0 in the UBI FLASH area (aka MTD partition)
56  *			to the real start of the FLASH in erase blocks.
57  * @fastmap:		Enable fastmap attachment
58  * @read:		Read function to access the flash
59  */
60 struct ubispl_info {
61 	struct ubi_scan_info	*ubi;
62 	u32			peb_size;
63 	u32			vid_offset;
64 	u32			leb_start;
65 	u32			peb_count;
66 	u32			peb_offset;
67 	int			fastmap;
68 	ubispl_read_flash	read;
69 };
70 
71 /**
72  * struct ubispl_load - structure to describe a volume to load
73  * @vol_id:	Volume id
74  * @load_addr:	Load address of the volume
75  */
76 struct ubispl_load {
77 	int		vol_id;
78 	void		*load_addr;
79 };
80 
81 /**
82  * ubispl_load_volumes - Scan flash and load volumes
83  * @info:	Pointer to the ubi scan info structure
84  * @lovls:	Pointer to array of volumes to load
85  * @nrvols:	Array size of @lovls
86  */
87 int ubispl_load_volumes(struct ubispl_info *info,
88 			struct ubispl_load *lvols, int nrvols);
89 
90 #endif
91