Sergey Solomin | 11d63cf | 2016-11-28 15:03:24 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # ############################################################# |
| 3 | # script to disable UCD VCS rails. |
| 4 | # This REQUIRES unaltered/original UCD cfg file. |
| 5 | # 10/28/16 PGR - |
| 6 | # 11/10/16 PGR - unbind/bind UCD driver |
| 7 | |
Saqib Khan | c8c939e | 2017-03-13 12:37:16 -0500 | [diff] [blame] | 8 | ucd_retries=5 |
| 9 | |
Sergey Solomin | 11d63cf | 2016-11-28 15:03:24 -0600 | [diff] [blame] | 10 | # unbind ucd driver to permit i2cset |
| 11 | ucdpath="/sys/bus/i2c/drivers/ucd9000" |
| 12 | if [ -e $ucdpath ] |
| 13 | then |
Andrew Jeffery | b498e70 | 2017-03-24 11:55:07 +1030 | [diff] [blame^] | 14 | ucd=`ls $ucdpath | grep 64` |
Sergey Solomin | 11d63cf | 2016-11-28 15:03:24 -0600 | [diff] [blame] | 15 | echo $ucd > $ucdpath/unbind |
| 16 | fi |
| 17 | |
| 18 | # Setup UCD module (in standby) to disable VCS rails from power-on: |
| 19 | i2cset -y 11 0x64 0xF7 0x00 i |
| 20 | i2cset -y 11 0x64 0xF8 0x15 0x6E 0x80 0x0A 0x00 0x00 0x10 0x00 0x00 0x00 \ |
| 21 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i |
| 22 | i2cset -y 11 0x64 0xF7 0x01 i |
| 23 | i2cset -y 11 0x64 0xF8 0x15 0x16 0x80 0x14 0x00 0x00 0x20 0x00 0x00 0x00 \ |
| 24 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i |
| 25 | i2cset -y 11 0x64 0xD2 0x09 0x3F 0xFF 0x2F 0x0A 0x00 0x06 0x00 0x00 0x02 i |
| 26 | i2cset -y 11 0x64 0x00 0x0E i |
| 27 | i2cset -y 11 0x64 0x02 0x1A i |
| 28 | i2cset -y 11 0x64 0x00 0x0F i |
| 29 | i2cset -y 11 0x64 0x02 0x1A i |
| 30 | |
| 31 | # re-bind ucd driver |
Saqib Khan | e71ba0b | 2017-02-08 10:13:01 -0600 | [diff] [blame] | 32 | if [ -e $ucdpath ]; then |
Saqib Khan | c8c939e | 2017-03-13 12:37:16 -0500 | [diff] [blame] | 33 | j=0 |
| 34 | until [ $j -ge $ucd_retries ] || [ -e $ucdpath/$ucd ]; do |
| 35 | j=$((j+1)) |
Saqib Khan | e71ba0b | 2017-02-08 10:13:01 -0600 | [diff] [blame] | 36 | echo $ucd > $ucdpath/bind || ret=$? |
Saqib Khan | c8c939e | 2017-03-13 12:37:16 -0500 | [diff] [blame] | 37 | if [ $j -gt 1 ]; then |
| 38 | echo "rebinding UCD driver. Retry number $j" |
| 39 | sleep 1 |
| 40 | fi |
Saqib Khan | e71ba0b | 2017-02-08 10:13:01 -0600 | [diff] [blame] | 41 | done |
| 42 | if [ ! -e $ucdpath/$ucd ]; then exit $ret; fi |
Sergey Solomin | 11d63cf | 2016-11-28 15:03:24 -0600 | [diff] [blame] | 43 | fi |
Saqib Khan | e71ba0b | 2017-02-08 10:13:01 -0600 | [diff] [blame] | 44 | |