#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
#
source "${BASH_SOURCE%/*}/include/meson64_common.inc"
ASOUND_STATE="${ASOUND_STATE:-"asound.state.meson64"}"

# Mainline u-boot, everything is done by meson64_common.inc, we just need to handle FIP blobs

# Handling of FIP blobs
function uboot_custom_postprocess() {
	# @TODO: these should come from FIP_TREE_BOARD/FIP_TREE_FAMILY vars in board.conf instead of hardcoded here
	if [[ $BOARD == odroidn2l ]]; then
		# The N2L (1608Mhz) has its own blobs.
		uboot_g12_postprocess "$SRC"/cache/sources/amlogic-boot-fip/odroid-n2l g12b
	elif [[ $BOARD == odroidn2* ]]; then
		# FIP trees 'odroid-n2-plus' and 'odroid-n2' are identical.
		uboot_g12_postprocess "$SRC"/cache/sources/amlogic-boot-fip/odroid-n2 g12b
	elif [[ $BOARD == khadas-vim3 ]]; then
		# do nothing. VIM3 has its own post_uboot_custom_postprocess hook, directly in the board file.
		:
	elif [[ $BOARD == radxa-zero2 ]]; then
		uboot_g12_postprocess "$SRC"/cache/sources/amlogic-boot-fip/radxa-zero2 g12b
	elif [[ $BOARD == bananapim2s ]]; then
		uboot_g12_postprocess "$SRC"/cache/sources/amlogic-boot-fip/bananapi-m2s g12b
	elif [[ $BOARD == bananapicm4io ]]; then
		uboot_g12_postprocess "$SRC"/cache/sources/amlogic-boot-fip/bananapi-m2s g12b
	else
		echo "Don't know how to handle FIP trees for board '${BOARD}'"
		exit 2
	fi
}
