#!/bin/sh
#
# save_blenv: Save env variables of bootloader
#   Usage) save_blenv VARIABLE_NAME VALUE
#
# This script is for saving variables of bootloader which is required to be
# shared between bootloader and platform. (ex) display brightness level)
#
# Manufacturer SHOULD modify this file adapted to their target and bootloader.
# (If there is no shared variables, this file can be removed.)

usage () {
	echo "Not supported variable(s) or wrong usage"
	echo "Usage: $0 NAME VALUE"
	exit 1
}

_val="$2"
case "$1" in
# Supported variables for SLP : usbpath, uartpath, SLP_LCD_BRIGHT
	usbpath | uartpath)
		case "$2" in
			AP | ap)
				_val="ap"
				;;
			CP | cp)
				_val="cp"
				;;
			*)
				usage
				;;
		esac
		;;
	SLP_LCD_BRIGHT)
		if [ "z$2" == "z" ]; then
			usage
		fi
		;;
# NOT SUPPOTED
	*)
		usage
		;;
esac

# This is for uboot. If you don't use uboot, change following command.
/bin/fw_setenv $1 $_val

exit 0

