1*4549e789STom Rini /* SPDX-License-Identifier: GPL 2.0+ OR BSD-3-Clause */ 26f4e7d3cSThomas Gleixner /* 36f4e7d3cSThomas Gleixner * Copyright (c) Thomas Gleixner <tglx@linutronix.de> 46f4e7d3cSThomas Gleixner */ 56f4e7d3cSThomas Gleixner #ifndef __UBOOT_UBISPL_H 66f4e7d3cSThomas Gleixner #define __UBOOT_UBISPL_H 76f4e7d3cSThomas Gleixner 86f4e7d3cSThomas Gleixner /* 96f4e7d3cSThomas Gleixner * The following CONFIG options are relevant for UBISPL 106f4e7d3cSThomas Gleixner * 116f4e7d3cSThomas Gleixner * #define CONFIG_SPL_UBI_MAX_VOL_LEBS 256 126f4e7d3cSThomas Gleixner * 136f4e7d3cSThomas Gleixner * Defines the maximum number of logical erase blocks per loadable 146f4e7d3cSThomas Gleixner * (static) volume to size the ubispl internal arrays. 156f4e7d3cSThomas Gleixner * 166f4e7d3cSThomas Gleixner * #define CONFIG_SPL_UBI_MAX_PEB_SIZE (256*1024) 176f4e7d3cSThomas Gleixner * 186f4e7d3cSThomas Gleixner * Defines the maximum physical erase block size to size the fastmap 196f4e7d3cSThomas Gleixner * buffer for ubispl. 206f4e7d3cSThomas Gleixner * 216f4e7d3cSThomas Gleixner * #define CONFIG_SPL_UBI_MAX_PEBS 4096 226f4e7d3cSThomas Gleixner * 236f4e7d3cSThomas Gleixner * Define the maximum number of physical erase blocks to size the 246f4e7d3cSThomas Gleixner * ubispl internal arrays. 256f4e7d3cSThomas Gleixner * 266f4e7d3cSThomas Gleixner * #define CONFIG_SPL_UBI_VOL_IDS 8 276f4e7d3cSThomas Gleixner * 286f4e7d3cSThomas Gleixner * Defines the maximum number of volumes in which UBISPL is 296f4e7d3cSThomas Gleixner * interested. Limits the amount of memory for the scan data and 306f4e7d3cSThomas Gleixner * speeds up the scan process as we simply ignore stuff which we dont 316f4e7d3cSThomas Gleixner * want to load from the SPL anyway. So the volumes which can be 326f4e7d3cSThomas Gleixner * loaded in the above example are ids 0 - 7 336f4e7d3cSThomas Gleixner */ 346f4e7d3cSThomas Gleixner 356f4e7d3cSThomas Gleixner /* 366f4e7d3cSThomas Gleixner * The struct definition is in drivers/mtd/ubispl/ubispl.h. It does 376f4e7d3cSThomas Gleixner * not fit into the BSS due to the large buffer requirement of the 386f4e7d3cSThomas Gleixner * upstream fastmap code. So the caller of ubispl_load_volumes needs 396f4e7d3cSThomas Gleixner * to hand in a pointer to a free memory area where ubispl will place 406f4e7d3cSThomas Gleixner * its data. The area is not required to be initialized. 416f4e7d3cSThomas Gleixner */ 426f4e7d3cSThomas Gleixner struct ubi_scan_info; 436f4e7d3cSThomas Gleixner 446f4e7d3cSThomas Gleixner typedef int (*ubispl_read_flash)(int pnum, int offset, int len, void *dst); 456f4e7d3cSThomas Gleixner 466f4e7d3cSThomas Gleixner /** 476f4e7d3cSThomas Gleixner * struct ubispl_info - description structure for fast ubi scan 486f4e7d3cSThomas Gleixner * @ubi: Pointer to memory space for ubi scan info structure 496f4e7d3cSThomas Gleixner * @peb_size: Physical erase block size 506f4e7d3cSThomas Gleixner * @vid_offset: Offset of the VID header 516f4e7d3cSThomas Gleixner * @leb_start: Start of the logical erase block, i.e. offset of data 526f4e7d3cSThomas Gleixner * @peb_count: Number of physical erase blocks in the UBI FLASH area 536f4e7d3cSThomas Gleixner * aka MTD partition. 546f4e7d3cSThomas Gleixner * @peb_offset: Offset of PEB0 in the UBI FLASH area (aka MTD partition) 556f4e7d3cSThomas Gleixner * to the real start of the FLASH in erase blocks. 566f4e7d3cSThomas Gleixner * @fastmap: Enable fastmap attachment 576f4e7d3cSThomas Gleixner * @read: Read function to access the flash 586f4e7d3cSThomas Gleixner */ 596f4e7d3cSThomas Gleixner struct ubispl_info { 606f4e7d3cSThomas Gleixner struct ubi_scan_info *ubi; 616f4e7d3cSThomas Gleixner u32 peb_size; 626f4e7d3cSThomas Gleixner u32 vid_offset; 636f4e7d3cSThomas Gleixner u32 leb_start; 646f4e7d3cSThomas Gleixner u32 peb_count; 656f4e7d3cSThomas Gleixner u32 peb_offset; 666f4e7d3cSThomas Gleixner int fastmap; 676f4e7d3cSThomas Gleixner ubispl_read_flash read; 686f4e7d3cSThomas Gleixner }; 696f4e7d3cSThomas Gleixner 706f4e7d3cSThomas Gleixner /** 716f4e7d3cSThomas Gleixner * struct ubispl_load - structure to describe a volume to load 726f4e7d3cSThomas Gleixner * @vol_id: Volume id 736f4e7d3cSThomas Gleixner * @load_addr: Load address of the volume 746f4e7d3cSThomas Gleixner */ 756f4e7d3cSThomas Gleixner struct ubispl_load { 766f4e7d3cSThomas Gleixner int vol_id; 776f4e7d3cSThomas Gleixner void *load_addr; 786f4e7d3cSThomas Gleixner }; 796f4e7d3cSThomas Gleixner 806f4e7d3cSThomas Gleixner /** 816f4e7d3cSThomas Gleixner * ubispl_load_volumes - Scan flash and load volumes 826f4e7d3cSThomas Gleixner * @info: Pointer to the ubi scan info structure 836f4e7d3cSThomas Gleixner * @lovls: Pointer to array of volumes to load 846f4e7d3cSThomas Gleixner * @nrvols: Array size of @lovls 856f4e7d3cSThomas Gleixner */ 866f4e7d3cSThomas Gleixner int ubispl_load_volumes(struct ubispl_info *info, 876f4e7d3cSThomas Gleixner struct ubispl_load *lvols, int nrvols); 886f4e7d3cSThomas Gleixner 896f4e7d3cSThomas Gleixner #endif 90