#
# 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/
#
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)
		declare -g KERNEL_MAJOR_MINOR="6.1" # Major and minor versions of this kernel.
		;;

	current)

		declare -g KERNEL_MAJOR_MINOR="6.6" # Major and minor versions of this kernel.
		;;

	edge)

		declare -g KERNEL_MAJOR_MINOR="6.7" # Major and minor versions of this kernel.
		;;

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
	run_host_command_logged install -m 755 "${SRC}"/packages/bsp/mvebu/hwclock-set "${SDCARD}"/lib/udev/

	if [[ $DISTRIBUTION == "Ubuntu" ]]; then
		chroot_sdcard_apt_get_remove --auto-remove fake-hwclock linux-sound-base alsa-base alsa-utils bluez
	else
		chroot_sdcard_apt_get_remove --auto-remove fake-hwclock alsa-utils bluez
	fi
}
