overo-writeprom: add utility to write expansion board config eeproms
authorSteve Sakoman <steve@sakoman.com>
Tue, 16 Feb 2010 18:22:18 +0000 (10:22 -0800)
committerKoen Kooi <koen@openembedded.org>
Thu, 29 Apr 2010 12:49:12 +0000 (14:49 +0200)
recipes/overo-scripts/files/writeprom.sh [new file with mode: 0755]
recipes/overo-scripts/overo-writeprom.bb [new file with mode: 0644]

diff --git a/recipes/overo-scripts/files/writeprom.sh b/recipes/overo-scripts/files/writeprom.sh
new file mode 100755 (executable)
index 0000000..e18dcb0
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+if [ $# -ne 3 ] && [ $# -ne 5 ];
+then
+       echo "Usage:"
+       echo ""
+       echo "writeprom.sh deviceid rev fab_rev [envvar envsetting]"
+       echo    
+       echo " deviceid   - expansion board device number from table:"
+       echo 
+       echo "   Summit     0x01"
+       echo "   Tobi       0x02"
+       echo "   Tobi Duo   0x03"
+       echo "   Palo35     0x04"
+       echo "   Palo43     0x05"
+       echo "   Chestnut43 0x06"
+       echo "   Pinto      0x07"
+       echo
+       echo " rev          - board revision (e.g. 0x00)"
+       echo " fab_rev      - revision marking from pcb (e.g. R2411)"
+       echo " envvar       - optional u-boot env variable name"
+       echo "                (e.g. dvimode)"
+       echo " envsetting   - optional u-boot env variable setting"
+       echo "                (e.g. 1024x768MR-16@60)"
+       exit 1
+fi
+
+fabrevision=$3
+if [ ${#fabrevision} -ge 8 ]; then
+       echo "Error: fab revision string must less than 8 characters"
+       exit 1
+fi
+
+envvar=$4
+if [ ${#envar} -ge 16 ]; then
+       echo "Error: environment variable name string must less than 16 characters"
+       exit 1
+fi
+
+envsetting=$5
+if [ ${#ensetting} -ge 64 ]; then
+       echo "Error: environment setting string must less than 64 characters"
+       exit 1
+fi
+
+bus=3
+device=0x50
+vendorid=0x02
+
+i2cset -y $bus $device 0x00 0x00
+i2cset -y $bus $device 0x01 $vendorid
+i2cset -y $bus $device 0x02 0x00
+i2cset -y $bus $device 0x03 $1
+i2cset -y $bus $device 0x04 $2
+i2cset -y $bus $device 0x05 00
+
+let i=6
+hexdumpargs="'${#fabrevision}/1 \"0x%02x \"'"
+command="echo -n \"$fabrevision\" | hexdump -e $hexdumpargs"
+hex=$(eval $command)
+for character in $hex; do
+       i2cset -y $bus $device $i $character
+       let i=$i+1
+done
+i2cset -y $bus $device $i 0x00
+
+if [ $# -eq 5 ]
+then
+       i2cset -y $bus $device 0x05 0x01
+
+       let i=14
+       hexdumpargs="'${#envvar}/1 \"0x%02x \"'"
+       command="echo -n \"$envvar\" | hexdump -e $hexdumpargs"
+       hex=$(eval $command)
+       for character in $hex; do
+               i2cset -y $bus $device $i $character
+               let i=$i+1
+       done
+       i2cset -y $bus $device $i 0x00
+
+       let i=30
+       hexdumpargs="'${#envsetting}/1 \"0x%02x \"'"
+       command="echo -n \"$envsetting\" | hexdump -e $hexdumpargs"
+       hex=$(eval $command)
+       for character in $hex; do
+               i2cset -y $bus $device $i $character
+               let i=$i+1
+       done     
+       i2cset -y $bus $device $i 0x00
+fi
+
diff --git a/recipes/overo-scripts/overo-writeprom.bb b/recipes/overo-scripts/overo-writeprom.bb
new file mode 100644 (file)
index 0000000..c72c850
--- /dev/null
@@ -0,0 +1,16 @@
+DESCRIPTION = "writeprom script for overo"
+
+PR="r0"
+
+SRC_URI = "file://writeprom.sh"
+
+S = "${WORKDIR}"
+
+do_install () {
+  install -d ${D}${bindir}/
+  install -m 0755 ${WORKDIR}/writeprom.sh ${D}${bindir}/
+}
+
+PACKAGES = "${PN}"
+FILES_${PN} = "/*"
+