# U-Boot Parameters
setenv initrd_high "0xffffffff"
setenv fdt_high "0xffffffff"

# setenv silent 1
setenv condev "console=tty1 console=ttySAC2,115200n8"
setenv verify 0
setenv bootlogo "false"

setenv kernel_addr_r "0x40008000"
setenv initramfs_addr_r "0x46000000"
setenv dtb_addr_r "0x44000000"

#---------------------------------
# Boots from memory.
# --------------------------------
setenv bootmem "root=/dev/ram0 ro"

# base kernel config options
setenv baseconfig "fsck.repair=yes consoleblank=0 net.ifnames=0 no_console_suspend"

#  TMDS data amplitude control.
setenv hdmi_tx_amp_lvl  "31"

#  TMDS data amplitude fine control for each channel.
setenv hdmi_tx_lvl_ch0      "3"
setenv hdmi_tx_lvl_ch1      "3"
setenv hdmi_tx_lvl_ch2      "3"

#  TMDS data pre-emphasis level control.
setenv hdmi_tx_emp_lvl      "6"

#  TMDS clock amplitude control.
setenv hdmi_clk_amp_lvl     "31"

#  TMDS data source termination resistor control.
setenv hdmi_tx_res      "0"

# DRAM Frequency
# Sets the LPDDR3 memory frequency
# Supported values: 933 825 728 633 (MHZ)
setenv ddr_freq 825

#------------------------------------------------------------------------------
#
# HDMI Hot Plug detection
#
#------------------------------------------------------------------------------
#
# Forces the HDMI subsystem to ignore the check if the cable is connected or 
# not.
# false : disable the detection and force it as connected.
# true : let cable, board and monitor decide the connection status.
# 
# default: true
# 
#------------------------------------------------------------------------------
setenv HPD "false"

setenv hdmi_phy_control "hdmi_tx_amp_lvl=${hdmi_tx_amp_lvl} hdmi_tx_lvl_ch0=${hdmi_tx_lvl_ch0} hdmi_tx_lvl_ch1=${hdmi_tx_lvl_ch1} hdmi_tx_lvl_ch2=${hdmi_tx_lvl_ch2} hdmi_tx_emp_lvl=${hdmi_tx_emp_lvl} hdmi_clk_amp_lvl=${hdmi_clk_amp_lvl} hdmi_tx_res=${hdmi_tx_res} HPD=${HPD}"

# Enable/Disable ODROID-VU7 Touchsreen
setenv disable_vu7 "true" # false

# CPU Governor Selection
# Available governos: conservative, userspace, powersave, ondemand, performance, schedutil
setenv governor "performance"

# External watchdog board enable
setenv external_watchdog "false"
# debounce time set to 3 ~ 10 sec, default 3 sec
setenv external_watchdog_debounce "3"

# Load kernel, initrd and dtb in that sequence
load mmc ${devnum}:1 ${kernel_addr_r} zImage
load mmc ${devnum}:1 ${initramfs_addr_r} rootfs.cpio.uboot


# NOTE: board_name is not set in more recent u-boot versions.
# The script will default to the xu4 DTS.
# This is compatible with all of the board variants.

# Uncomment the following line to set board_name to a specific version:
# setenv board_name "hc1"

setenv fdtloaded "false"
if test "x${board_name}" = "x"; then setenv board_name "xu4"; fi
if test "${board_name}" = "xu4"; then load mmc ${devnum}:1 ${dtb_addr_r} exynos5422-odroidxu4.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "xu3"; then load mmc ${devnum}:1 ${dtb_addr_r} exynos5422-odroidxu3.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "odroidxu3"; then load mmc ${devnum}:1 ${dtb_addr_r} exynos5422-odroidxu3.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "xu3l"; then load mmc ${devnum}:1 ${dtb_addr_r} exynos5422-odroidxu3-lite.dtb; setenv fdtloaded "true"; fi
if test "${board_name}" = "hc1"; then load mmc ${devnum}:1 ${dtb_addr_r} exynos5422-odroidhc1.dtb; setenv fdtloaded "true"; fi
if test "${fdtloaded}" != "true"; then load mmc ${devnum}:1 ${dtb_addr_r} exynos5422-odroidxu4.dtb; fi

fdt addr ${dtb_addr_r}

# if test "${cecenable}" = "false"; then fdt rm /cec@101B0000; fi
# if test "${disable_vu7}" = "false"; then setenv hid_quirks "usbhid.quirks=0x0eef:0x0005:0x0004"; fi
if test "${external_watchdog}" = "true"; then setenv external_watchdog "external_watchdog=${external_watchdog} external_watchdog_debounce=${external_watchdog_debounce}"; fi

# final boot args
setenv bootargs "${bootmem} ${condev} ${baseconfig} ${videoconfig} ${hdmi_phy_control} ${hid_quirks} ${macaddrconfig} ${external_watchdog} governor=${governor}"

# Boot the board
bootz ${kernel_addr_r} ${initramfs_addr_r} ${dtb_addr_r}
