/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * (C) Copyright 2012
 * Texas Instruments, <www.ti.com>
 */
#ifndef	_SPL_H_
#define	_SPL_H_

#include <binman_sym.h>
#include <linker_lists.h>

/* Platform-specific defines */
#include <linux/compiler.h>
#include <asm/global_data.h>
#include <asm/spl.h>
#include <handoff.h>
#include <mmc.h>

struct blk_desc;
struct legacy_img_hdr;

/* Value in r0 indicates we booted from U-Boot */
#define UBOOT_NOT_LOADED_FROM_SPL	0x13578642

/* Boot type */
#define MMCSD_MODE_UNDEFINED	0
#define MMCSD_MODE_RAW		1
#define MMCSD_MODE_FS		2
#define MMCSD_MODE_EMMCBOOT	3

struct blk_desc;
struct legacy_img_hdr;
struct spl_boot_device;
enum boot_device;

/*
 * u_boot_first_phase() - check if this is the first U-Boot phase
 *
 * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on the
 * build flags we can determine whether the current build is for the first
 * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. If
 * there is SPL but no TPL, the the first phase is SPL. If there is TPL, then
 * it is the first phase.
 *
 * @returns true if this is the first phase of U-Boot
 *
 */
static inline bool u_boot_first_phase(void)
{
	if (IS_ENABLED(CONFIG_TPL)) {
		if (IS_ENABLED(CONFIG_TPL_BUILD))
			return true;
	} else if (IS_ENABLED(CONFIG_SPL)) {
		if (IS_ENABLED(CONFIG_SPL_BUILD))
			return true;
	} else {
		return true;
	}

	return false;
}

enum u_boot_phase {
	PHASE_NONE,	/* Invalid phase, signifying before U-Boot */
	PHASE_TPL,	/* Running in TPL */
	PHASE_VPL,	/* Running in VPL */
	PHASE_SPL,	/* Running in SPL */
	PHASE_BOARD_F,	/* Running in U-Boot before relocation */
	PHASE_BOARD_R,	/* Running in U-Boot after relocation */

	PHASE_COUNT,
};

/**
 * spl_phase() - Find out the phase of U-Boot
 *
 * This can be used to avoid #ifdef logic and use if() instead.
 *
 * For example, to include code only in TPL, you might do:
 *
 *    #ifdef CONFIG_TPL_BUILD
 *    ...
 *    #endif
 *
 * but with this you can use:
 *
 *    if (spl_phase() == PHASE_TPL) {
 *       ...
 *    }
 *
 * To include code only in SPL, you might do:
 *
 *    #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 *    ...
 *    #endif
 *
 * but with this you can use:
 *
 *    if (spl_phase() == PHASE_SPL) {
 *       ...
 *    }
 *
 * To include code only in U-Boot proper, you might do:
 *
 *    #ifndef CONFIG_SPL_BUILD
 *    ...
 *    #endif
 *
 * but with this you can use:
 *
 *    if (spl_phase() == PHASE_BOARD_F) {
 *       ...
 *    }
 *
 * Return: U-Boot phase
 */
static inline enum u_boot_phase spl_phase(void)
{
#ifdef CONFIG_TPL_BUILD
	return PHASE_TPL;
#elif defined(CONFIG_VPL_BUILD)
	return PHASE_VPL;
#elif defined(CONFIG_SPL_BUILD)
	return PHASE_SPL;
#else
	DECLARE_GLOBAL_DATA_PTR;

	if (!(gd->flags & GD_FLG_RELOC))
		return PHASE_BOARD_F;
	else
		return PHASE_BOARD_R;
#endif
}

/* returns true if in U-Boot proper, false if in SPL */
static inline bool spl_in_proper(void)
{
#ifdef CONFIG_SPL_BUILD
	return false;
#endif

	return true;
}

/**
 * spl_prev_phase() - Figure out the previous U-Boot phase
 *
 * Return: the previous phase from this one, e.g. if called in SPL this returns
 *	PHASE_TPL, if TPL is enabled
 */
static inline enum u_boot_phase spl_prev_phase(void)
{
#ifdef CONFIG_TPL_BUILD
	return PHASE_NONE;
#elif defined(CONFIG_VPL_BUILD)
	return PHASE_TPL;	/* VPL requires TPL */
#elif defined(CONFIG_SPL_BUILD)
	return IS_ENABLED(CONFIG_VPL) ? PHASE_VPL :
		IS_ENABLED(CONFIG_TPL) ? PHASE_TPL :
		PHASE_NONE;
#else
	return IS_ENABLED(CONFIG_SPL) ? PHASE_SPL :
		PHASE_NONE;
#endif
}

/**
 * spl_next_phase() - Figure out the next U-Boot phase
 *
 * Return: the next phase from this one, e.g. if called in TPL this returns
 *	PHASE_SPL
 */
static inline enum u_boot_phase spl_next_phase(void)
{
#ifdef CONFIG_TPL_BUILD
	return IS_ENABLED(CONFIG_VPL) ? PHASE_VPL : PHASE_SPL;
#elif defined(CONFIG_VPL_BUILD)
	return PHASE_SPL;
#else
	return PHASE_BOARD_F;
#endif
}

/**
 * spl_phase_name() - Get the name of the current phase
 *
 * Return: phase name
 */
static inline const char *spl_phase_name(enum u_boot_phase phase)
{
	switch (phase) {
	case PHASE_TPL:
		return "TPL";
	case PHASE_VPL:
		return "VPL";
	case PHASE_SPL:
		return "SPL";
	case PHASE_BOARD_F:
	case PHASE_BOARD_R:
		return "U-Boot";
	default:
		return "phase?";
	}
}

/**
 * spl_phase_prefix() - Get the prefix  of the current phase
 *
 * @phase: Phase to look up
 * Return: phase prefix ("spl", "tpl", etc.)
 */
static inline const char *spl_phase_prefix(enum u_boot_phase phase)
{
	switch (phase) {
	case PHASE_TPL:
		return "tpl";
	case PHASE_VPL:
		return "vpl";
	case PHASE_SPL:
		return "spl";
	case PHASE_BOARD_F:
	case PHASE_BOARD_R:
		return "";
	default:
		return "phase?";
	}
}

/* A string name for SPL or TPL */
#ifdef CONFIG_SPL_BUILD
# ifdef CONFIG_TPL_BUILD
#  define SPL_TPL_NAME	"TPL"
# elif defined(CONFIG_VPL_BUILD)
#  define SPL_TPL_NAME	"VPL"
# else
#  define SPL_TPL_NAME	"SPL"
# endif
# define SPL_TPL_PROMPT	SPL_TPL_NAME ": "
#else
# define SPL_TPL_NAME	""
# define SPL_TPL_PROMPT	""
#endif

/**
 * enum spl_sandbox_flags - flags for sandbox's use of spl_image_info->flags
 *
 * @SPL_SANDBOXF_ARG_IS_FNAME: arg is the filename to jump to (default)
 * @SPL_SANDBOXF_ARG_IS_BUF: arg is the containing image to jump to, @offset is
 *	the start offset within the image, @size is the size of the image
 */
enum spl_sandbox_flags {
	SPL_SANDBOXF_ARG_IS_FNAME = 0,
	SPL_SANDBOXF_ARG_IS_BUF,
};

struct spl_image_info {
	const char *name;
	u8 os;
	uintptr_t load_addr;
	uintptr_t entry_point;
#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
	void *fdt_addr;
#endif
	u32 boot_device;
	u32 offset;
	u32 size;
	u32 flags;
	void *arg;
#ifdef CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK
	ulong dcrc_data;
	ulong dcrc_length;
	ulong dcrc;
#endif
};

static inline void *spl_image_fdt_addr(struct spl_image_info *info)
{
#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
	return info->fdt_addr;
#else
	return 0;
#endif
}

/**
 * Information required to load data from a device
 *
 * @priv: Private data for the device
 * @bl_len: Block length for reading in bytes
 * @read: Function to call to read from the device
 */
struct spl_load_info {
	void *priv;
	/**
	 * read() - Read from device
	 *
	 * @load: Information about the load state
	 * @offset: Offset to read from in bytes. This must be a multiple of
	 *          @load->bl_len.
	 * @count: Number of bytes to read. This must be a multiple of
	 *         @load->bl_len.
	 * @buf: Buffer to read into
	 * @return number of bytes read, 0 on error
	 */
	ulong (*read)(struct spl_load_info *load, ulong sector, ulong count,
		      void *buf);
#if IS_ENABLED(CONFIG_SPL_LOAD_BLOCK)
	int bl_len;
};

static inline int spl_get_bl_len(struct spl_load_info *info)
{
	return info->bl_len;
}

static inline void spl_set_bl_len(struct spl_load_info *info, int bl_len)
{
	info->bl_len = bl_len;
}
#else
};

static inline int spl_get_bl_len(struct spl_load_info *info)
{
	return 1;
}

static inline void spl_set_bl_len(struct spl_load_info *info, int bl_len)
{
	if (bl_len != 1)
		panic("CONFIG_SPL_LOAD_BLOCK not enabled");
}
#endif

/*
 * We need to know the position of U-Boot in memory so we can jump to it. We
 * allow any U-Boot binary to be used (u-boot.bin, u-boot-nodtb.bin,
 * u-boot.img), hence the '_any'. These is no checking here that the correct
 * image is found. For example if u-boot.img is used we don't check that
 * spl_parse_image_header() can parse a valid header.
 *
 * Similarly for SPL, so that TPL can jump to SPL.
 */
binman_sym_extern(ulong, u_boot_any, image_pos);
binman_sym_extern(ulong, u_boot_any, size);
binman_sym_extern(ulong, u_boot_spl_any, image_pos);
binman_sym_extern(ulong, u_boot_spl_any, size);
binman_sym_extern(ulong, u_boot_vpl_any, image_pos);
binman_sym_extern(ulong, u_boot_vpl_any, size);

/**
 * spl_get_image_pos() - get the image position of the next phase
 *
 * This returns the image position to use to load the next phase of U-Boot
 */
ulong spl_get_image_pos(void);

/**
 * spl_get_image_size() - get the size of the next phase
 *
 * This returns the size to use to load the next phase of U-Boot
 */
ulong spl_get_image_size(void);

/**
 * spl_get_image_text_base() - get the text base of the next phase
 *
 * This returns the address that the next stage is linked to run at, i.e.
 * CONFIG_SPL_TEXT_BASE or CONFIG_TEXT_BASE
 *
 * Return: text-base address
 */
ulong spl_get_image_text_base(void);

/**
 * spl_load_simple_fit_skip_processing() - Hook to allow skipping the FIT
 *	image processing during spl_load_simple_fit().
 *
 * Return true to skip FIT processing, false to preserve the full code flow
 * of spl_load_simple_fit().
 */
bool spl_load_simple_fit_skip_processing(void);

/**
 * spl_load_simple_fit_fix_load() - Hook to make fixes
 * after fit image header is loaded
 *
 * Returns pointer to fit
 */
void *spl_load_simple_fit_fix_load(const void *fit);

/**
 * spl_load_simple_fit() - Loads a fit image from a device.
 * @spl_image:	Image description to set up
 * @info:	Structure containing the information required to load data.
 * @offset:	Offset where FIT image is located in the device. Must be aligned
 *              to the device's bl_len.
 * @fdt:	Pointer to the copied FIT header.
 *
 * Reads the FIT image @sector in the device. Loads u-boot image to
 * specified load address and copies the dtb to end of u-boot image.
 * Returns 0 on success.
 */
int spl_load_simple_fit(struct spl_image_info *spl_image,
			struct spl_load_info *info, ulong offset, void *fdt);

#define SPL_COPY_PAYLOAD_ONLY	1
#define SPL_FIT_FOUND		2

/**
 * spl_load_legacy_lzma() - Load an LZMA-compressed legacy image
 * @spl_image:	Image description (already set up)
 * @load:	Structure containing the information required to load data.
 * @offset:	Pointer to image
 *
 * Load/decompress an LZMA-compressed legacy image from the device.
 *
 * Return: 0 on success, or a negative error on failure
 */
int spl_load_legacy_lzma(struct spl_image_info *spl_image,
			 struct spl_load_info *load, ulong offset);

/**
 * spl_load_legacy_img() - Loads a legacy image from a device.
 * @spl_image:	Image description to set up
 * @load:	Structure containing the information required to load data.
 * @offset:	Pointer to image
 * @hdr:	Pointer to image header
 *
 * Reads an legacy image from the device. Loads u-boot image to
 * specified load address.
 * Returns 0 on success.
 */
int spl_load_legacy_img(struct spl_image_info *spl_image,
			struct spl_boot_device *bootdev,
			struct spl_load_info *load, ulong offset,
			struct legacy_img_hdr *hdr);

/**
 * spl_load_imx_container() - Loads a imx container image from a device.
 * @spl_image:	Image description to set up
 * @info:	Structure containing the information required to load data.
 * @sector:	Offset where container image is located in the device. Must be
 *              aligned to the device block size.
 *
 * Reads the container image @sector in the device. Loads u-boot image to
 * specified load address.
 */
int spl_load_imx_container(struct spl_image_info *spl_image,
			   struct spl_load_info *info, ulong offset);

/* SPL common functions */
void preloader_console_init(void);
u32 spl_boot_device(void);

struct spi_flash;

/**
 * spl_spi_get_uboot_offs() - Lookup function for the SPI boot offset
 * @flash: The spi flash to boot from
 *
 * Return: The offset of U-Boot within the SPI flash
 */
unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash);

/**
 * spl_spi_boot_bus() - Lookup function for the SPI boot bus source.
 *
 * This function returns the SF bus to load from.
 * If not overridden, it is weakly defined in common/spl/spl_spi.c.
 */
u32 spl_spi_boot_bus(void);

/**
 * spl_spi_boot_cs() - Lookup function for the SPI boot CS source.
 *
 * This function returns the SF CS to load from.
 * If not overridden, it is weakly defined in common/spl/spl_spi.c.
 */
u32 spl_spi_boot_cs(void);

/**
 * spl_mmc_boot_mode() - Lookup function for the mode of an MMC boot source.
 * @boot_device:	ID of the device which the MMC driver wants to read
 *			from.  Common values are e.g. BOOT_DEVICE_MMC1,
 *			BOOT_DEVICE_MMC2, BOOT_DEVICE_MMC2_2.
 *
 * This function should return one of MMCSD_MODE_FS, MMCSD_MODE_EMMCBOOT, or
 * MMCSD_MODE_RAW for each MMC boot source which is defined for the target.  The
 * boot_device parameter tells which device the MMC driver is interested in.
 *
 * If not overridden, it is weakly defined in common/spl/spl_mmc.c.
 *
 * Note:  It is important to use the boot_device parameter instead of e.g.
 * spl_boot_device() as U-Boot is not always loaded from the same device as SPL.
 */
u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device);

/**
 * spl_mmc_boot_partition() - MMC partition to load U-Boot from.
 * @boot_device:	ID of the device which the MMC driver wants to load
 *			U-Boot from.
 *
 * This function should return the partition number which the SPL
 * should load U-Boot from (on the given boot_device) when
 * CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION is set.
 *
 * If not overridden, it is weakly defined in common/spl/spl_mmc.c.
 */
int spl_mmc_boot_partition(const u32 boot_device);

struct mmc;
/**
 * default_spl_mmc_emmc_boot_partition() - eMMC boot partition to load U-Boot from.
 * mmc:			Pointer for the mmc device structure
 *
 * This function should return the eMMC boot partition number which
 * the SPL should load U-Boot from (on the given boot_device).
 */
int default_spl_mmc_emmc_boot_partition(struct mmc *mmc);

/**
 * spl_mmc_emmc_boot_partition() - eMMC boot partition to load U-Boot from.
 * mmc:			Pointer for the mmc device structure
 *
 * This function should return the eMMC boot partition number which
 * the SPL should load U-Boot from (on the given boot_device).
 *
 * If not overridden, it is weakly defined in common/spl/spl_mmc.c
 * and calls default_spl_mmc_emmc_boot_partition();
 */
int spl_mmc_emmc_boot_partition(struct mmc *mmc);

void spl_set_bd(void);

/**
 * spl_mmc_get_uboot_raw_sector() - Provide raw sector of the start of U-Boot (architecture override)
 *
 * This is a weak function which by default will provide the raw sector that is
 * where the start of the U-Boot image has been written to.
 *
 * @mmc: struct mmc that describes the devie where U-Boot resides
 * @raw_sect: The raw sector number where U-Boot is by default.
 * Return: The raw sector location that U-Boot resides at
 */
unsigned long arch_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
						unsigned long raw_sect);

/**
 * spl_mmc_get_uboot_raw_sector() - Provide raw sector of the start of U-Boot (board override)
 *
 * This is a weak function which by default will provide the raw sector that is
 * where the start of the U-Boot image has been written to.
 *
 * @mmc: struct mmc that describes the devie where U-Boot resides
 * @raw_sect: The raw sector number where U-Boot is by default.
 * Return: The raw sector location that U-Boot resides at
 */
unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
						 unsigned long raw_sect);

/**
 * spl_mmc_get_uboot_raw_sector() - Provide raw sector of the start of U-Boot
 *
 * This is a weak function which by default will provide the raw sector that is
 * where the start of the U-Boot image has been written to.
 *
 * @mmc: struct mmc that describes the devie where U-Boot resides
 * @raw_sect: The raw sector number where U-Boot is by default.
 * Return: The raw sector location that U-Boot resides at
 */
unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
					   unsigned long raw_sect);

/**
 * spl_set_header_raw_uboot() - Set up a standard SPL image structure
 *
 * This sets up the given spl_image which the standard values obtained from
 * config options: CONFIG_SYS_MONITOR_LEN, CONFIG_SYS_UBOOT_START,
 * CONFIG_TEXT_BASE.
 *
 * @spl_image: Image description to set up
 */
void spl_set_header_raw_uboot(struct spl_image_info *spl_image);

/**
 * spl_parse_image_header() - parse the image header and set up info
 *
 * This parses the legacy image header information at @header and sets up
 * @spl_image according to what is found. If no image header is found, then
 * a raw image or bootz is assumed. If CONFIG_SPL_PANIC_ON_RAW_IMAGE is
 * enabled, then this causes a panic. If CONFIG_SPL_RAW_IMAGE_SUPPORT is not
 * enabled then U-Boot gives up. Otherwise U-Boot sets up the image using
 * spl_set_header_raw_uboot(), or possibly the bootz header.
 *
 * @spl_image: Image description to set up
 * @header image header to parse
 * Return: 0 if a header was correctly parsed, -ve on error
 */
int spl_parse_image_header(struct spl_image_info *spl_image,
			   const struct spl_boot_device *bootdev,
			   const struct legacy_img_hdr *header);

void spl_board_prepare_for_linux(void);

/**
 * spl_board_prepare_for_optee() - Prepare board for an OPTEE payload
 *
 * Prepares the board for booting an OP-TEE payload. Initialization is platform
 * specific, and may include configuring the TrustZone memory, and other
 * initialization steps required by OP-TEE.
 * Note that @fdt is not used directly by OP-TEE. OP-TEE passes this @fdt to
 * its normal world target. This target is not guaranteed to be u-boot, so @fdt
 * changes that would normally be done by u-boot should be done in this step.
 *
 * @fdt: Devicetree that will be passed on, or NULL
 */
void spl_board_prepare_for_optee(void *fdt);
void spl_board_prepare_for_boot(void);
int spl_board_ubi_load_image(u32 boot_device);
int spl_board_boot_device(enum boot_device boot_dev_spl);

/**
 * spl_board_loader_name() - Return a name for the loader
 *
 * This is a weak function which might be overridden by the board code. With
 * that a board specific value for the device where the U-Boot will be loaded
 * from can be set. By default it returns NULL.
 *
 * @boot_device:	ID of the device which SPL wants to load U-Boot from.
 */
const char *spl_board_loader_name(u32 boot_device);

/**
 * jump_to_image_linux() - Jump to a Linux kernel from SPL
 *
 * This jumps into a Linux kernel using the information in @spl_image.
 *
 * @spl_image: Image description to set up
 */
void __noreturn jump_to_image_linux(struct spl_image_info *spl_image);

/**
 * jump_to_image_optee() - Jump to OP-TEE OS from SPL
 *
 * This jumps into OP-TEE OS using the information in @spl_image.
 *
 * @spl_image: Image description to set up
 */
void __noreturn jump_to_image_optee(struct spl_image_info *spl_image);

/**
 * spl_start_uboot() - Check if SPL should start the kernel or U-Boot
 *
 * This is called by the various SPL loaders to determine whether the board
 * wants to load the kernel or U-Boot. This function should be provided by
 * the board.
 *
 * Return: 0 if SPL should start the kernel, 1 if U-Boot must be started
 */
int spl_start_uboot(void);

/**
 * spl_display_print() - Display a board-specific message in SPL
 *
 * If CONFIG_SPL_DISPLAY_PRINT is enabled, U-Boot will call this function
 * immediately after displaying the SPL console banner ("U-Boot SPL ...").
 * This function should be provided by the board.
 */
void spl_display_print(void);

/**
 * struct spl_boot_device - Describes a boot device used by SPL
 *
 * @boot_device: A number indicating the BOOT_DEVICE type. There are various
 * BOOT_DEVICE... #defines and enums in U-Boot and they are not consistently
 * numbered.
 * @boot_device_name: Named boot device, or NULL if none.
 *
 * Note: Additional fields can be added here, bearing in mind that SPL is
 * size-sensitive and common fields will be present on all boards. This
 * struct can also be used to return additional information about the load
 * process if that becomes useful.
 */
struct spl_boot_device {
	uint boot_device;
	const char *boot_device_name;
};

/**
 * Holds information about a way of loading an SPL image
 *
 * @name: User-friendly name for this method (e.g. "MMC")
 * @boot_device: Boot device that this loader supports
 * @load_image: Function to call to load image
 */
struct spl_image_loader {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
	const char *name;
#endif
	uint boot_device;
	/**
	 * load_image() - Load an SPL image
	 *
	 * @spl_image: place to put image information
	 * @bootdev: describes the boot device to load from
	 */
	int (*load_image)(struct spl_image_info *spl_image,
			  struct spl_boot_device *bootdev);
};

/* Helper function for accessing the name */
static inline const char *spl_loader_name(const struct spl_image_loader *loader)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
	const char *name;
	name = spl_board_loader_name(loader->boot_device);
	return name ?: loader->name;
#else
	return NULL;
#endif
}

/* Declare an SPL image loader */
#define SPL_LOAD_IMAGE(__name)					\
	ll_entry_declare(struct spl_image_loader, __name, spl_image_loader)

/*
 * _priority is the priority of this method, 0 meaning it will be the top
 * choice for this device, 9 meaning it is the bottom choice.
 * _boot_device is the BOOT_DEVICE_... value
 * _method is the load_image function to call
 */
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
#define SPL_LOAD_IMAGE_METHOD(_name, _priority, _boot_device, _method) \
	SPL_LOAD_IMAGE(_boot_device ## _priority ## _method) = { \
		.name = _name, \
		.boot_device = _boot_device, \
		.load_image = _method, \
	}
#else
#define SPL_LOAD_IMAGE_METHOD(_name, _priority, _boot_device, _method) \
	SPL_LOAD_IMAGE(_boot_device ## _priority ## _method) = { \
		.boot_device = _boot_device, \
		.load_image = _method, \
	}
#endif

#define SPL_LOAD_IMAGE_GET(_priority, _boot_device, _method) \
	ll_entry_get(struct spl_image_loader, \
		     _boot_device ## _priority ## _method, spl_image_loader)

/* SPL FAT image functions */

/**
 * spl_fat_force_reregister() - Force reregistration of FAT block devices
 *
 * To avoid repeatedly looking up block devices, spl_load_image_fat keeps track
 * of whether it has already registered a block device. This is fine for most
 * cases, but when running unit tests all devices are removed and recreated
 * in-between tests. This function will force re-registration of any block
 * devices, ensuring that we don't try to use an invalid block device.
 */
void spl_fat_force_reregister(void);

int spl_load_image_fat(struct spl_image_info *spl_image,
		       struct spl_boot_device *bootdev,
		       struct blk_desc *block_dev, int partition,
		       const char *filename);
int spl_load_image_fat_os(struct spl_image_info *spl_image,
			  struct spl_boot_device *bootdev,
			  struct blk_desc *block_dev, int partition);

void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);

/* SPL EXT image functions */
int spl_load_image_ext(struct spl_image_info *spl_image,
		       struct spl_boot_device *bootdev,
		       struct blk_desc *block_dev, int partition,
		       const char *filename);
int spl_load_image_ext_os(struct spl_image_info *spl_image,
			  struct spl_boot_device *bootdev,
			  struct blk_desc *block_dev, int partition);
int spl_blk_load_image(struct spl_image_info *spl_image,
		       struct spl_boot_device *bootdev,
		       enum uclass_id uclass_id, int devnum, int partnum);

/**
 * spl_early_init() - Set up device tree and driver model in SPL if enabled
 *
 * Call this function in board_init_f() if you want to use device tree and
 * driver model early, before board_init_r() is called.
 *
 * If this is not called, then driver model will be inactive in SPL's
 * board_init_f(), and no device tree will be available.
 */
int spl_early_init(void);

/**
 * spl_init() - Set up device tree and driver model in SPL if enabled
 *
 * You can optionally call spl_early_init(), then optionally call spl_init().
 * This function will be called from board_init_r() if not called earlier.
 *
 * Both spl_early_init() and spl_init() perform a similar function except that
 * the latter will not set up the malloc() area if
 * CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN is enabled, since it is assumed to
 * already be done by a calll to spl_relocate_stack_gd() before board_init_r()
 * is reached.
 *
 * This function will be called from board_init_r() if not called earlier.
 *
 * If this is not called, then driver model will be inactive in SPL's
 * board_init_f(), and no device tree will be available.
 */
int spl_init(void);

/*
 * spl_soc_init() - Do architecture-specific init in SPL
 *
 * If SPL_SOC_INIT is enabled, this is called from board_init_r() before
 * jumping to the next phase.
 */
void spl_soc_init(void);

/*
 * spl_board_init() - Do board-specific init in SPL
 *
 * If xPL_BOARD_INIT is enabled, this is called from board_init_r() before
 * jumping to the next phase.
 */
void spl_board_init(void);

/**
 * spl_was_boot_source() - check if U-Boot booted from SPL
 *
 * This will normally be true, but if U-Boot jumps to second U-Boot, it will
 * be false. This should be implemented by board-specific code.
 *
 * Return: true if U-Boot booted from SPL, else false
 */
bool spl_was_boot_source(void);

/**
 * spl_dfu_cmd- run dfu command with chosen mmc device interface
 * @param usb_index - usb controller number
 * @param mmc_dev -  mmc device nubmer
 *
 * Return: 0 on success, otherwise error code
 */
int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr);

/**
 * spl_mmc_clear_cache() - Clear cached MMC devices
 *
 * To avoid reinitializing MMCs, spl_mmc_load caches the most-recently-used MMC
 * device. This is fine for most cases, but when running unit tests all devices
 * are removed and recreated in-between tests. This function will clear any
 * cached state, ensuring that we don't try to use an invalid MMC.
 */
void spl_mmc_clear_cache(void);

int spl_mmc_load_image(struct spl_image_info *spl_image,
		       struct spl_boot_device *bootdev);

/**
 * spl_mmc_load() - Load an image file from MMC/SD media
 *
 * @param spl_image	Image data filled in by loading process
 * @param bootdev	Describes which device to load from
 * @param filename	Name of file to load (in FS mode)
 * @param raw_part	Partition to load from (in RAW mode)
 * @param raw_sect	Sector to load from (in RAW mode)
 *
 * Return: 0 on success, otherwise error code
 */
int spl_mmc_load(struct spl_image_info *spl_image,
		 struct spl_boot_device *bootdev,
		 const char *filename,
		 int raw_part,
		 unsigned long raw_sect);

/**
 * spl_usb_load() - Load an image file from USB mass storage
 *
 * @param spl_image	Image data filled in by loading process
 * @param bootdev	Describes which device to load from
 * @param raw_part	Fat partition to load from
 * @param filename	Name of file to load
 *
 * Return: 0 on success, otherwise error code
 */
int spl_usb_load(struct spl_image_info *spl_image,
		 struct spl_boot_device *bootdev,
		 int partition, const char *filename);

int spl_ymodem_load_image(struct spl_image_info *spl_image,
			  struct spl_boot_device *bootdev);
/**
 * spl_reserve_video_from_ram_top() - Reserve framebuffer memory from end of RAM
 *
 * This enforces framebuffer reservation at SPL stage from end of RAM so that
 * next stage can directly skip this pre-reserved area before carrying out
 * further reservations. The allocation address is stored in struct video_uc_plat.
 *
 * Return: 0 on success, otherwise error code
 */
int spl_reserve_video_from_ram_top(void);

/**
 * spl_invoke_atf - boot using an ARM trusted firmware image
 */
void __noreturn spl_invoke_atf(struct spl_image_info *spl_image);

/**
 * bl2_plat_get_bl31_params() - return params for bl31.
 * @bl32_entry:	address of BL32 executable (secure)
 * @bl33_entry:	address of BL33 executable (non secure)
 * @fdt_addr:	address of Flat Device Tree
 *
 * This is a weak function which might be overridden by the board code. By
 * default it will just call bl2_plat_get_bl31_params_default().
 *
 * If you just want to manipulate or add some parameters, you can override
 * this function, call bl2_plat_get_bl31_params_default and operate on the
 * returned bl31 params.
 *
 * Return: bl31 params structure pointer
 */
struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
					     uintptr_t bl33_entry,
					     uintptr_t fdt_addr);

/**
 * bl2_plat_get_bl31_params_default() - prepare params for bl31.
 * @bl32_entry:	address of BL32 executable (secure)
 * @bl33_entry:	address of BL33 executable (non secure)
 * @fdt_addr:	address of Flat Device Tree
 *
 * This is the default implementation of bl2_plat_get_bl31_params(). It assigns
 * a pointer to the memory that the platform has kept aside to pass platform
 * specific and trusted firmware related information to BL31. This memory is
 * allocated by allocating memory to bl2_to_bl31_params_mem structure which is
 * a superset of all the structure whose information is passed to BL31
 *
 * NOTE: The memory is statically allocated, thus this function should be
 * called only once. All subsequent calls will overwrite any changes.
 *
 * Return: bl31 params structure pointer
 */
struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry,
						     uintptr_t bl33_entry,
						     uintptr_t fdt_addr);

/**
 * bl2_plat_get_bl31_params_v2() - return params for bl31
 * @bl32_entry:	address of BL32 executable (secure)
 * @bl33_entry:	address of BL33 executable (non secure)
 * @fdt_addr:	address of Flat Device Tree
 *
 * This function does the same as bl2_plat_get_bl31_params() except that is is
 * used for the new LOAD_IMAGE_V2 option, which uses a slightly different
 * method to pass the parameters.
 *
 * Return: bl31 params structure pointer
 */
struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry,
					      uintptr_t bl33_entry,
					      uintptr_t fdt_addr);

/**
 * bl2_plat_get_bl31_params_v2_default() - prepare params for bl31.
 * @bl32_entry:	address of BL32 executable (secure)
 * @bl33_entry:	address of BL33 executable (non secure)
 * @fdt_addr:	address of Flat Device Tree
 *
 * This is the default implementation of bl2_plat_get_bl31_params_v2(). It
 * prepares the linked list of the bl31 params, populates the image types and
 * set the entry points for bl32 and bl33 (if available).
 *
 * NOTE: The memory is statically allocated, thus this function should be
 * called only once. All subsequent calls will overwrite any changes.
 *
 * Return: bl31 params structure pointer
 */
struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry,
						      uintptr_t bl33_entry,
						      uintptr_t fdt_addr);
/**
 * spl_optee_entry - entry function for optee
 *
 * args defind in op-tee project
 * https://github.com/OP-TEE/optee_os/
 * core/arch/arm/kernel/generic_entry_a32.S
 * @arg0: pagestore
 * @arg1: (ARMv7 standard bootarg #1)
 * @arg2: device tree address, (ARMv7 standard bootarg #2)
 * @arg3: non-secure entry address (ARMv7 bootarg #0)
 */
void __noreturn spl_optee_entry(void *arg0, void *arg1, void *arg2, void *arg3);

/**
 * spl_invoke_opensbi - boot using a RISC-V OpenSBI image
 */
void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image);

/**
 * board_return_to_bootrom - allow for boards to continue with the boot ROM
 *
 * If a board (e.g. the Rockchip RK3368 boards) provide some
 * supporting functionality for SPL in their boot ROM and the SPL
 * stage wants to return to the ROM code to continue booting, boards
 * can implement 'board_return_to_bootrom'.
 */
int board_return_to_bootrom(struct spl_image_info *spl_image,
			    struct spl_boot_device *bootdev);

/**
 * board_spl_fit_size_align - specific size align before processing payload
 *
 */
ulong board_spl_fit_size_align(ulong size);

/**
 * spl_perform_fixups() - arch/board-specific callback before processing
 *                        the boot-payload
 */
void spl_perform_fixups(struct spl_image_info *spl_image);

/*
 * spl_get_load_buffer() - get buffer for loading partial image data
 *
 * Returns memory area which can be populated by partial image data,
 * ie. uImage or fitImage header.
 */
struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);

/**
 * board_spl_fit_append_fdt_skip(): test whether DTO application should be skipped
 * @name:	DTO node name within fitImage images node
 *
 * A board-specific function used to indicate whether a DTO from fitImage
 * configuration node 'fdt' property DT and DTO list should be applied onto
 * the base DT or not applied.
 *
 * This is useful in case of DTOs which implement e.g. different board revision
 * details, where such DTO should be applied on one board revision, and should
 * not be applied on another board revision.
 *
 * Return:	0 to indicate DTO is not skipped, all else to indicate DTO is skipped.
 */
int board_spl_fit_append_fdt_skip(const char *name);

void board_boot_order(u32 *spl_boot_list);
void spl_save_restore_data(void);

/**
 * spl_load_fit_image() - Fully parse and a FIT image in SPL
 *
 * @spl_image: SPL Image data to fill in
 * @header: Pointer to FIT image
 * Return 0 if OK, -ve on error
 */
int spl_load_fit_image(struct spl_image_info *spl_image,
		       const struct legacy_img_hdr *header);

/*
 * spl_decompression_enabled() - check decompression support is enabled for SPL build
 *
 * Returns  true  if decompression support is enabled, else False
 */
static inline bool spl_decompression_enabled(void)
{
	return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA);
}

/**
 * spl_write_upl_handoff() - Write a Universal Payload hand-off structure
 *
 * @spl_image: Information about the image being booted
 * Return: 0 if OK, -ve on error
 */
int spl_write_upl_handoff(struct spl_image_info *spl_image);

/**
 * spl_upl_init() - Get UPL ready for information to be added
 *
 * This must be called before upl_add_image(), etc.
 */
void spl_upl_init(void);

#endif
