1*6f4e7d3cSThomas Gleixner /* 2*6f4e7d3cSThomas Gleixner * The parts taken from the kernel implementation are: 3*6f4e7d3cSThomas Gleixner * 4*6f4e7d3cSThomas Gleixner * Copyright (c) International Business Machines Corp., 2006 5*6f4e7d3cSThomas Gleixner * 6*6f4e7d3cSThomas Gleixner * UBISPL specific defines: 7*6f4e7d3cSThomas Gleixner * 8*6f4e7d3cSThomas Gleixner * Copyright (c) Thomas Gleixner <tglx@linutronix.de> 9*6f4e7d3cSThomas Gleixner * 10*6f4e7d3cSThomas Gleixner * SPDX-License-Identifier: GPL 2.0+ BSD-3-Clause 11*6f4e7d3cSThomas Gleixner */ 12*6f4e7d3cSThomas Gleixner 13*6f4e7d3cSThomas Gleixner /* 14*6f4e7d3cSThomas Gleixner * Contains various defines copy&pasted from ubi.h and ubi-user.h to make 15*6f4e7d3cSThomas Gleixner * the upstream fastboot code happy. 16*6f4e7d3cSThomas Gleixner */ 17*6f4e7d3cSThomas Gleixner #ifndef __UBOOT_UBI_WRAPPER_H 18*6f4e7d3cSThomas Gleixner #define __UBOOT_UBI_WRAPPER_H 19*6f4e7d3cSThomas Gleixner 20*6f4e7d3cSThomas Gleixner /* 21*6f4e7d3cSThomas Gleixner * Error codes returned by the I/O sub-system. 22*6f4e7d3cSThomas Gleixner * 23*6f4e7d3cSThomas Gleixner * UBI_IO_FF: the read region of flash contains only 0xFFs 24*6f4e7d3cSThomas Gleixner * UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also also there was a data 25*6f4e7d3cSThomas Gleixner * integrity error reported by the MTD driver 26*6f4e7d3cSThomas Gleixner * (uncorrectable ECC error in case of NAND) 27*6f4e7d3cSThomas Gleixner * UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC) 28*6f4e7d3cSThomas Gleixner * UBI_IO_BAD_HDR_EBADMSG: the same as %UBI_IO_BAD_HDR, but also there was a 29*6f4e7d3cSThomas Gleixner * data integrity error reported by the MTD driver 30*6f4e7d3cSThomas Gleixner * (uncorrectable ECC error in case of NAND) 31*6f4e7d3cSThomas Gleixner * UBI_IO_BITFLIPS: bit-flips were detected and corrected 32*6f4e7d3cSThomas Gleixner * 33*6f4e7d3cSThomas Gleixner * UBI_FASTMAP_ANCHOR: u-boot SPL add on to tell the caller that the fastmap 34*6f4e7d3cSThomas Gleixner * anchor block has been found 35*6f4e7d3cSThomas Gleixner * 36*6f4e7d3cSThomas Gleixner * Note, it is probably better to have bit-flip and ebadmsg as flags which can 37*6f4e7d3cSThomas Gleixner * be or'ed with other error code. But this is a big change because there are 38*6f4e7d3cSThomas Gleixner * may callers, so it does not worth the risk of introducing a bug 39*6f4e7d3cSThomas Gleixner */ 40*6f4e7d3cSThomas Gleixner enum { 41*6f4e7d3cSThomas Gleixner UBI_IO_FF = 1, 42*6f4e7d3cSThomas Gleixner UBI_IO_FF_BITFLIPS, 43*6f4e7d3cSThomas Gleixner UBI_IO_BAD_HDR, 44*6f4e7d3cSThomas Gleixner UBI_IO_BAD_HDR_EBADMSG, 45*6f4e7d3cSThomas Gleixner UBI_IO_BITFLIPS, 46*6f4e7d3cSThomas Gleixner UBI_FASTMAP_ANCHOR, 47*6f4e7d3cSThomas Gleixner }; 48*6f4e7d3cSThomas Gleixner 49*6f4e7d3cSThomas Gleixner /* 50*6f4e7d3cSThomas Gleixner * UBI volume type constants. 51*6f4e7d3cSThomas Gleixner * 52*6f4e7d3cSThomas Gleixner * @UBI_DYNAMIC_VOLUME: dynamic volume 53*6f4e7d3cSThomas Gleixner * @UBI_STATIC_VOLUME: static volume 54*6f4e7d3cSThomas Gleixner */ 55*6f4e7d3cSThomas Gleixner enum { 56*6f4e7d3cSThomas Gleixner UBI_DYNAMIC_VOLUME = 3, 57*6f4e7d3cSThomas Gleixner UBI_STATIC_VOLUME = 4, 58*6f4e7d3cSThomas Gleixner }; 59*6f4e7d3cSThomas Gleixner 60*6f4e7d3cSThomas Gleixner /* 61*6f4e7d3cSThomas Gleixner * Return codes of the fastmap sub-system 62*6f4e7d3cSThomas Gleixner * 63*6f4e7d3cSThomas Gleixner * UBI_NO_FASTMAP: No fastmap super block was found 64*6f4e7d3cSThomas Gleixner * UBI_BAD_FASTMAP: A fastmap was found but it's unusable 65*6f4e7d3cSThomas Gleixner */ 66*6f4e7d3cSThomas Gleixner enum { 67*6f4e7d3cSThomas Gleixner UBI_NO_FASTMAP = 1, 68*6f4e7d3cSThomas Gleixner UBI_BAD_FASTMAP, 69*6f4e7d3cSThomas Gleixner }; 70*6f4e7d3cSThomas Gleixner 71*6f4e7d3cSThomas Gleixner /** 72*6f4e7d3cSThomas Gleixner * struct ubi_fastmap_layout - in-memory fastmap data structure. 73*6f4e7d3cSThomas Gleixner * @e: PEBs used by the current fastmap 74*6f4e7d3cSThomas Gleixner * @to_be_tortured: if non-zero tortured this PEB 75*6f4e7d3cSThomas Gleixner * @used_blocks: number of used PEBs 76*6f4e7d3cSThomas Gleixner * @max_pool_size: maximal size of the user pool 77*6f4e7d3cSThomas Gleixner * @max_wl_pool_size: maximal size of the pool used by the WL sub-system 78*6f4e7d3cSThomas Gleixner */ 79*6f4e7d3cSThomas Gleixner struct ubi_fastmap_layout { 80*6f4e7d3cSThomas Gleixner struct ubi_wl_entry *e[UBI_FM_MAX_BLOCKS]; 81*6f4e7d3cSThomas Gleixner int to_be_tortured[UBI_FM_MAX_BLOCKS]; 82*6f4e7d3cSThomas Gleixner int used_blocks; 83*6f4e7d3cSThomas Gleixner int max_pool_size; 84*6f4e7d3cSThomas Gleixner int max_wl_pool_size; 85*6f4e7d3cSThomas Gleixner }; 86*6f4e7d3cSThomas Gleixner 87*6f4e7d3cSThomas Gleixner /** 88*6f4e7d3cSThomas Gleixner * struct ubi_fm_pool - in-memory fastmap pool 89*6f4e7d3cSThomas Gleixner * @pebs: PEBs in this pool 90*6f4e7d3cSThomas Gleixner * @used: number of used PEBs 91*6f4e7d3cSThomas Gleixner * @size: total number of PEBs in this pool 92*6f4e7d3cSThomas Gleixner * @max_size: maximal size of the pool 93*6f4e7d3cSThomas Gleixner * 94*6f4e7d3cSThomas Gleixner * A pool gets filled with up to max_size. 95*6f4e7d3cSThomas Gleixner * If all PEBs within the pool are used a new fastmap will be written 96*6f4e7d3cSThomas Gleixner * to the flash and the pool gets refilled with empty PEBs. 97*6f4e7d3cSThomas Gleixner * 98*6f4e7d3cSThomas Gleixner */ 99*6f4e7d3cSThomas Gleixner struct ubi_fm_pool { 100*6f4e7d3cSThomas Gleixner int pebs[UBI_FM_MAX_POOL_SIZE]; 101*6f4e7d3cSThomas Gleixner int used; 102*6f4e7d3cSThomas Gleixner int size; 103*6f4e7d3cSThomas Gleixner int max_size; 104*6f4e7d3cSThomas Gleixner }; 105*6f4e7d3cSThomas Gleixner 106*6f4e7d3cSThomas Gleixner #endif 107