diff options
author | Koen Kooi <koen@openembedded.org> | 2010-04-29 14:41:49 +0200 |
---|---|---|
committer | Koen Kooi <koen@openembedded.org> | 2010-04-29 14:49:12 +0200 |
commit | 58fa34bf8aa9719f4dddfaf7d4f03614c1c6bc65 (patch) | |
tree | 58f08f1e004c3f261cff1b43610e347f1a56893d /recipes/i2c-tools | |
parent | e65d0117079c6399d4b6c648793d7945bfb6b62b (diff) |
overo-writeprom: rename to omap3-writeprom and make it work on both overo and beagleboard
Diffstat (limited to 'recipes/i2c-tools')
-rw-r--r-- | recipes/i2c-tools/omap3-writeprom.bb | 16 | ||||
-rwxr-xr-x | recipes/i2c-tools/omap3-writeprom/writeprom.sh | 103 |
2 files changed, 119 insertions, 0 deletions
diff --git a/recipes/i2c-tools/omap3-writeprom.bb b/recipes/i2c-tools/omap3-writeprom.bb new file mode 100644 index 0000000000..485d06fe43 --- /dev/null +++ b/recipes/i2c-tools/omap3-writeprom.bb @@ -0,0 +1,16 @@ +DESCRIPTION = "Writeprom script for omap3 boards with EEPROM on there expansionboard - see http://www.elinux.org/BeagleBoardPinMux#Vendor_and_Device_IDs" + + +SRC_URI = "file://writeprom.sh" + +S = "${WORKDIR}" + +do_install () { + install -d ${D}${bindir}/ + install -m 0755 ${WORKDIR}/writeprom.sh ${D}${bindir}/ +} + +PACKAGE_ARCH = "all" +RDEPENDS_${PN} = "i2c-tools" +FILES_${PN} = "${bindir}" + diff --git a/recipes/i2c-tools/omap3-writeprom/writeprom.sh b/recipes/i2c-tools/omap3-writeprom/writeprom.sh new file mode 100755 index 0000000000..d1e2b09dcc --- /dev/null +++ b/recipes/i2c-tools/omap3-writeprom/writeprom.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +machine_id() { # return the machine ID + awk 'BEGIN { FS=": " } /Hardware/ { gsub(" ", "_", $2); print tolower($2) } ' </proc/cpuinfo +} + +if [ $# -ne 4 ] && [ $# -ne 6 ]; +then + echo "Usage:" + echo "" + echo "writeprom.sh vendorid deviceid rev fab_rev [envvar envsetting]" + echo + echo " vendorid, deviceid - expansion board device number from http://www.elinux.org/BeagleBoardPinMux#Vendor_and_Device_IDs" + 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)" + echo + echo "Don't forget to make the EEPROM writeable if it has a writeprotect jumper!" + exit 1 +fi + +fabrevision=$4 +if [ ${#fabrevision} -ge 8 ]; then + echo "Error: fab revision string must less than 8 characters" + exit 1 +fi + +envvar=$5 +if [ ${#envar} -ge 16 ]; then + echo "Error: environment variable name string must less than 16 characters" + exit 1 +fi + +envsetting=$6 +if [ ${#ensetting} -ge 64 ]; then + echo "Error: environment setting string must less than 64 characters" + exit 1 +fi + +case `machine_id` in + "omap3_beagle_board") + bus=2 + device=0x50 + ;; + *) + bus=3 + device=0x51 + ;; +esac + +device=0x50 +vendorid=$1 +if [ ${#vendorid} -ge 6 ]; then + echo "Error: vendorid number must be less than 6 digits" + exit 1 +fi + +i2cset -y $bus $device 0x00 0x00 +i2cset -y $bus $device 0x01 $vendorid +i2cset -y $bus $device 0x02 0x00 +i2cset -y $bus $device 0x03 $2 +i2cset -y $bus $device 0x04 $3 +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 + |