# Determine root device
setexpr rootpart ${distro_bootpart} + 1
if test ${devtype} = mmc -a ${devnum} = 0; then
	setenv rootdev /dev/mmcblk0p${rootpart}
elif test ${devtype} = scsi -a ${devnum} = 0; then
	setenv rootdev /dev/sda${rootpart}
else
	# New U-Boot only
	part uuid ${devtype} ${devnum}:${rootpart} uuid
	setenv rootdev PARTUUID=${uuid}
fi
setenv bootargs earlyprintk console=ttyS0,115200 root=${rootdev} rootfstype=auto rootwait

# Load device tree and prepare for modification
load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} @DTB@.dtb
fdt addr ${fdt_addr_r}
fdt resize

# Enable SFP cage, if module is present
i2c dev 0
i2c mw 0x70 0.0 0xf
i2c read 0x71 0 1 0x00fffff1
setexpr.b mod_def0 *0x00fffff1 \& 0x10
if test ${mod_def0} -eq 0; then
	fdt set /sfp status okay
	fdt rm /soc/internal-regs/ethernet@34000 phy-handle
	fdt set /soc/internal-regs/ethernet@34000 managed in-band-status
fi

# Load kernel and boot
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} zImage
bootz ${kernel_addr_r} - ${fdt_addr_r}