# Yocto-specifics
setenv bootpart 2
setenv bootdir /

setenv bootargs ''

if ${fs}load ${dtype} ${disk}:1 10800000 uEnv.txt ; then
    env import -t 10800000 $filesize
fi

if itest.s "x" == "x$dtbname" ; then
	dtbname=imx6dl-nit6xlite.dtb;
fi

if itest.s x == x${bootdir} ; then
	bootdir=/boot/
fi

setenv fdt_addr 0x12000000
if ${fs}load ${dtype} ${disk}:1 $fdt_addr ${bootdir}$dtbname ; then
	fdt addr $fdt_addr
	setenv fdt_high 0xffffffff
else
	echo "!!!! Error loading ${bootdir}$dtbname";
	exit;
fi

# ------------------- HDMI detection
i2c dev 1 ;
if i2c probe 0x50 ; then
	echo "------ have HDMI monitor";
	if itest.s x == x$allow_noncea ; then
		setenv bootargs $bootargs mxc_hdmi.only_cea=1;
		echo "only CEA modes allowed on HDMI port";
	else
		setenv bootargs $bootargs mxc_hdmi.only_cea=0;
		echo "non-CEA modes allowed on HDMI, audio may be affected";
	fi
else
	fdt rm hdmi_display
	echo "------ no HDMI monitor";
fi

# ------------------- LVDS detection
# -------- LVDS0
setenv have_lvds
i2c dev 2
if i2c probe 0x04 ; then
	echo "------ have Freescale display";
	setenv have_lvds 1
else
	echo "------ no Freescale display";
	fdt rm hannstar;
fi

if i2c probe 0x38 ; then
	if itest.s "xLDB-WXGA" == "x$panel"; then
		screenres=1280,800
		fdt rm okaya1024x600
	else
		screenres=1024,600
		fdt rm lg1280x800
	fi
	setenv have_lvds 1
	setenv bootargs $bootargs ft5x06_ts.screenres=$screenres
	if itest.s "x" -ne "x$calibration" ; then
		setenv bootargs $bootargs ft5x06_ts.calibration=$calibration
	fi
else
	echo "------ no ft5x06 touch controller";
	fdt rm okaya1024x600
	fdt rm lg1280x800
fi

if itest.s "x" == "x$have_lvds"; then
	fdt rm lvds_display;
fi

# ------------------- LCD detection
# since the Nitrogen6_Lite board has on-board TSC2004,
# we can't test for it.
#
# set ignore_lcd to 1 to disable the 480x272 display
#
if itest.s "x" != "x$ignore_lcd" ; then
	echo "------ ignoring LCD display";
	fdt rm lcd_display;
fi

setenv bootargs "$bootargs console=ttymxc1,115200 vmalloc=400M consoleblank=0 rootwait"

if itest.s x$bootpart == x ; then
	bootpart=1
fi

if test "usb" = "${dtype}" ; then
	setenv bootargs "$bootargs root=/dev/sda$bootpart" ;
elif itest 0 -eq ${disk}; then
	setenv bootargs "$bootargs root=/dev/mmcblk2p$bootpart" ;
else
	setenv bootargs "$bootargs root=/dev/mmcblk3p$bootpart" ;
fi

setenv bootargs $bootargs fec.disable_giga=1

if itest.s "x" != "x$show_fdt" ; then
	fdt print /
fi

if itest.s "x" != "x$show_env" ; then
	printenv
fi

if ${fs}load ${dtype} ${disk}:1 10800000 ${bootdir}uImage ; then
	bootm 10800000 - $fdt_addr
fi
echo "Error loading kernel image"
