#@TYPE: Machine
#@NAME: Toradex Colibri iMX8X
#@DESCRIPTION: Toradex Colibri iMX8X powered by a i.MX 8X SoC
#@MAINTAINER: Max Krummenacher <max.krummenacherr@toradex.com>

MACHINE_NAME = "Colibri-iMX8X"

MACHINEOVERRIDES =. "mx8:mx8x:mx8qxp:"

MACHINE_EXTRA_RRECOMMENDS:append = " mwifiexconf"

IMX_DEFAULT_BSP = "nxp"

require conf/machine/include/imx-base.inc
# if one wants cortexa35-crypto, set DEFAULTTUNE accordingly
DEFAULTTUNE:mx8qxp-generic-bsp = "armv8a-crypto"
require conf/machine/include/arm/armv8a/tune-cortexa35.inc

# Don't include kernels in standard images
RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = ""

LOADADDR = ""

# we do not want to have getty running on tty1 as we run
# auto-serial-console there
USE_VT = "0"

KERNEL_DTB_PREFIX = "freescale/"
KERNEL_DEVICETREE = " \
    ${KERNEL_DTB_PREFIX}imx8dx-colibri-aster.dtb \
    ${KERNEL_DTB_PREFIX}imx8dx-colibri-eval-v3.dtb \
    ${KERNEL_DTB_PREFIX}imx8dx-colibri-iris.dtb \
    ${KERNEL_DTB_PREFIX}imx8dx-colibri-iris-v2.dtb \
    ${KERNEL_DTB_PREFIX}imx8qxp-colibri-aster.dtb \
    ${KERNEL_DTB_PREFIX}imx8qxp-colibri-eval-v3.dtb \
    ${KERNEL_DTB_PREFIX}imx8qxp-colibri-iris.dtb \
    ${KERNEL_DTB_PREFIX}imx8qxp-colibri-iris-v2.dtb \
"
KERNEL_DEVICETREE:use-mainline-bsp = "${KERNEL_DTB_PREFIX}imx8qxp-colibri-eval-v3.dtb"

KERNEL_IMAGETYPE:aarch64 = "Image.gz"

UBOOT_SUFFIX = "bin"
UBOOT_CONFIG ??= "sd"
UBOOT_CONFIG[sd] = "colibri-imx8x_defconfig,sdcard"

UBOOT_ENTRYPOINT = "0x96000000"
UBOOT_DTB_LOADADDRESS = "0x83100000"
UBOOT_DTBO_LOADADDRESS = "0x83200000"
UBOOT_RD_LOADADDRESS = "0xA0000000"

ATF_PLATFORM = "imx8qx"

BOOT_SPACE = "65536"
IMX_BOOT_SEEK = "32"

IMAGE_BOOT_FILES:append = " boot.scr-${MACHINE};boot.scr"
WKS_FILE_DEPENDS:append = " u-boot-default-script"
PREFERRED_PROVIDER_u-boot-default-script = "u-boot-distro-boot"

PREFERRED_PROVIDER_virtual/kernel = "linux-toradex"
PREFERRED_PROVIDER_virtual/kernel:preempt-rt = "linux-toradex"
PREFERRED_PROVIDER_virtual/kernel:use-mainline-bsp = "linux-toradex-mainline"
PREFERRED_PROVIDER_virtual/kernel:use-mainline-bsp:preempt-rt = "linux-toradex-mainline-rt"
PREFERRED_PROVIDER_virtual/dtb:use-mainline-bsp = "device-tree-overlays-mainline"

PREFERRED_PROVIDER_virtual/bootloader = "u-boot-toradex"
PREFERRED_PROVIDER_u-boot = "u-boot-toradex"
# Currently we use the nxp 2022.04 downstream for mx8
PREFERRED_VERSION_u-boot-toradex = "2022.04%"

MACHINE_FIRMWARE:append = " linux-firmware-pcie8997"

IMXBOOT_TARGETS = "flash"
IMX_BOOT_SOC_TARGET = "iMX8QX"

PREFERRED_PROVIDER_imx-sc-firmware = "imx-sc-firmware-toradex"
BOARD_TYPE = "colibri"

IMAGE_CLASSES:append = " image_type_tezi"
IMAGE_FSTYPES += "teziimg"

# The imx-boot container takes care for the i.MX 8 offset, so the container
# has to be flashed at offset 0 directly
UBOOT_BINARY_TEZI_EMMC = "imx-boot"
OFFSET_BOOTROM_PAYLOAD = "0"

TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT = "colibri-imx8x_vga-640x480_overlay.dtbo"

TORADEX_PRODUCT_IDS = "0038 0050 0051 0052"
TORADEX_PRODUCT_IDS[0038] = "imx8qxp-colibri-eval-v3.dtb"
TORADEX_PRODUCT_IDS[0050] = "imx8qxp-colibri-eval-v3.dtb"
TORADEX_PRODUCT_IDS[0051] = "imx8qxp-colibri-eval-v3.dtb"
TORADEX_PRODUCT_IDS[0052] = "imx8qxp-colibri-eval-v3.dtb"
