enable_extension "marvell-tools"
ARCH=armhf
if [[ $BOARD == helios4 ]]; then
	source "${BASH_SOURCE%/*}/include/mvebu-helios4.inc"
	BOOTENV_FILE='helios4.txt'
else
	source "${BASH_SOURCE%/*}/include/mvebu-clearfog.inc"
	BOOTENV_FILE='clearfog.txt'
fi

case $BRANCH in
	legacy)

		KERNELBRANCH='tag:v4.19.167'

	;;

	current)

		KERNELBRANCH='branch:linux-5.15.y'

	;;

	edge)

		KERNELBRANCH='branch:linux-5.16.y'
		
		LINUXCONFIG='linux-mvebu-edge'
		KERNELPATCHDIR="mvebu-edge"

		#BOOTBRANCH='tag:v2019.04'
		#BOOTPATCHDIR='u-boot-mvebu-dev'
		#BOOTSCRIPT='boot-mvebu.cmd:boot.cmd'

		#UBOOT_TARGET_MAP=";sdhc;u-boot-spl.kwb:u-boot.mmc
		#		  ;spi;u-boot-spl.kwb:u-boot.flash
		#		  ;uart;u-boot-spl.kwb:u-boot.uart"

		

	;;
esac

CPUMIN=800000
CPUMAX=1600000
GOVERNOR=ondemand

write_uboot_platform()
{
	dd if=$1/u-boot.mmc of=$2 bs=512 seek=1 status=noxfer > /dev/null 2>&1
}

write_uboot_platform_mtd ()
{
	dd if=$1/u-boot.flash of=$2 status=noxfer > /dev/null 2>&1
}

family_tweaks()
{
	# execute specific tweaks function if present
	[[ $(type -t family_tweaks_s) == function ]] && family_tweaks_s

	# Tweak to force SYS time to be synced from RTC at startup
	install -m 755 $SRC/packages/bsp/mvebu/hwclock-set $SDCARD/lib/udev/

	if [[ $DISTRIBUTION == "Ubuntu" ]]; then
		chroot $SDCARD /bin/bash -c "apt-get -y -qq remove --auto-remove fake-hwclock linux-sound-base alsa-base alsa-utils bluez"
	else
		chroot $SDCARD /bin/bash -c "apt-get -y -qq remove --auto-remove fake-hwclock alsa-utils bluez"
	fi
}
