#@TYPE: Machine
#@NAME: Boundary Devices Nitrogen8MM
#@SOC: i.MX8MM
#@DESCRIPTION: Machine configuration for Boundary Devices Nitrogen8MM
#@MAINTAINER: Chris Dimich <chris.dimich@boundarydevices.com>

MACHINEOVERRIDES =. "mx8mm:imx-boot-container:"

IMX_DEFAULT_BSP ?= "nxp"

require conf/machine/include/imx-base.inc
require conf/machine/include/arm/armv8a/tune-cortexa53.inc

# Kernel configuration
PREFERRED_PROVIDER_virtual/kernel ??= "linux-boundary"
KERNEL_DEVICETREE = "freescale/imx8mm-nitrogen8mm.dtb \
	freescale/imx8mm-nitrogen8mm_som.dtb \
	freescale/imx8mm-nitrogen8mm_rev2.dtb \
	freescale/imx8mm-nitrogen8mm_rev2-m4.dtb \
	freescale/imx8mm-nitrogen8mm_som-m4.dtb \
	freescale/imx8mm-nitrogen8mm-m4.dtb \
	freescale/imx8mm-nitrogen8mm-tc358743.dtb \
	freescale/imx8mm-nitrogen8mm_som-tc358743.dtb \
	freescale/imx8mm-nitrogen_smarc.dtb \
"
KERNEL_IMAGETYPE = "Image"
RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = ""

# U-Boot configuration
IMX_DEFAULT_BOOTLOADER:imx-nxp-bsp = "u-boot-boundary"
PREFERRED_PROVIDER_u-boot ??= "u-boot-boundary"
PREFERRED_PROVIDER_virtual/bootloader ??= "u-boot-boundary"
PREFERRED_PROVIDER_imx-atf ??= "imx-atf-boundary"
SPL_BINARY = "spl/u-boot-spl.bin"
UBOOT_SUFFIX = "bin"

UBOOT_CONFIG ??= "2g 2gr0 4g rev2_2g rev2_2gr0 rev2_4g som_1gr0 som_2g som_2gr0 som_4g smarc_2gr0"
UBOOT_CONFIG[2g]       = "${MACHINE}_2g_defconfig,sdcard"
UBOOT_CONFIG[2gr0]     = "${MACHINE}_2gr0_defconfig,sdcard"
UBOOT_CONFIG[4g]       = "${MACHINE}_4g_defconfig,sdcard"
UBOOT_CONFIG[rev2_2g]  = "${MACHINE}_rev2_2g_defconfig,sdcard"
UBOOT_CONFIG[rev2_2gr0]  = "${MACHINE}_rev2_4g_defconfig,sdcard"
UBOOT_CONFIG[rev2_4g]     = "${MACHINE}_2gr0_defconfig,sdcard"
UBOOT_CONFIG[som_1gr0] = "${MACHINE}_som_1gr0_defconfig,sdcard"
UBOOT_CONFIG[som_2g]   = "${MACHINE}_som_2g_defconfig,sdcard"
UBOOT_CONFIG[som_2gr0]   = "${MACHINE}_som_2g_defconfig,sdcard"
UBOOT_CONFIG[som_4g]   = "${MACHINE}_som_4g_defconfig,sdcard"
UBOOT_CONFIG[smarc_2gr0]   = "imx8mm_nitrogen_smarc_2gr0_defconfig,sdcard"

ATF_PLATFORM = "imx8mm"

# Set DDR FIRMWARE
DDR_FIRMWARE_NAME = "\
    lpddr4_pmu_train_1d_imem.bin \
    lpddr4_pmu_train_1d_dmem.bin \
    lpddr4_pmu_train_2d_imem.bin \
    lpddr4_pmu_train_2d_dmem.bin \
"

IMAGE_BOOT_FILES:append = " \
	boot.scr-${MACHINE};boot.scr \
	upgrade.scr-${MACHINE};upgrade.scr \
	flash.bin-${MACHINE}-2g;u-boot.${MACHINE}_2g \
	flash.bin-${MACHINE}-2gr0;u-boot.${MACHINE}_2gr0 \
	flash.bin-${MACHINE}-4g;u-boot.${MACHINE}_4g \
	flash.bin-${MACHINE}-rev2_2g;u-boot.${MACHINE}_rev2_2g \
	flash.bin-${MACHINE}-rev2_2gr0;u-boot.${MACHINE}_rev2_2gr0 \
	flash.bin-${MACHINE}-rev2_4g;u-boot.${MACHINE}_rev2_4g \
	flash.bin-${MACHINE}-som_1gr0;u-boot.${MACHINE}_som_1gr0 \
	flash.bin-${MACHINE}-som_2g;u-boot.${MACHINE}_som_2g \
	flash.bin-${MACHINE}-som_2gr0;u-boot.${MACHINE}_som_2gr0 \
	flash.bin-${MACHINE}-som_4g;u-boot.${MACHINE}_som_4g \
	flash.bin-${MACHINE}-smarc_2gr0;u-boot.imx8mm_nitrogen_smarc_2gr0 \
"

# wic support
WKS_FILE = "sdimage-bootpart.wks"
WKS_FILE_DEPENDS += "u-boot-script-boundary"

SERIAL_CONSOLES = "115200;ttymxc1"

MACHINE_FEATURES += " pci wifi bluetooth"
