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