blob: e529049d56c0868ecba525afe093e7dcfca84a1c [file] [log] [blame]
Sergey Solomin11d63cf2016-11-28 15:03:24 -06001#!/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 Khanc8c939e2017-03-13 12:37:16 -05008ucd_retries=5
Andrew Jefferyf1c63222017-03-23 10:54:24 +10309ucd=
Saqib Khanc8c939e2017-03-13 12:37:16 -050010
Sergey Solomin11d63cf2016-11-28 15:03:24 -060011# unbind ucd driver to permit i2cset
12ucdpath="/sys/bus/i2c/drivers/ucd9000"
13if [ -e $ucdpath ]
14then
Andrew Jefferyf1c63222017-03-23 10:54:24 +103015 ucd=`ls -1 $ucdpath | grep 64`
16 if [ -n "$ucd" ]
17 then
18 echo $ucd > $ucdpath/unbind
19 fi
Sergey Solomin11d63cf2016-11-28 15:03:24 -060020fi
21
22# Setup UCD module (in standby) to disable VCS rails from power-on:
23i2cset -y 11 0x64 0xF7 0x00 i
24i2cset -y 11 0x64 0xF8 0x15 0x6E 0x80 0x0A 0x00 0x00 0x10 0x00 0x00 0x00 \
25 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i
26i2cset -y 11 0x64 0xF7 0x01 i
27i2cset -y 11 0x64 0xF8 0x15 0x16 0x80 0x14 0x00 0x00 0x20 0x00 0x00 0x00 \
28 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i
29i2cset -y 11 0x64 0xD2 0x09 0x3F 0xFF 0x2F 0x0A 0x00 0x06 0x00 0x00 0x02 i
30i2cset -y 11 0x64 0x00 0x0E i
31i2cset -y 11 0x64 0x02 0x1A i
32i2cset -y 11 0x64 0x00 0x0F i
33i2cset -y 11 0x64 0x02 0x1A i
34
Andrew Jefferyf1c63222017-03-23 10:54:24 +103035# re-bind ucd driver only if we unbound it (i.e. ucd has been set with a value)
36if [ -e $ucdpath -a -n "$ucd" ]; then
Saqib Khanc8c939e2017-03-13 12:37:16 -050037 j=0
38 until [ $j -ge $ucd_retries ] || [ -e $ucdpath/$ucd ]; do
39 j=$((j+1))
Saqib Khane71ba0b2017-02-08 10:13:01 -060040 echo $ucd > $ucdpath/bind || ret=$?
Saqib Khanc8c939e2017-03-13 12:37:16 -050041 if [ $j -gt 1 ]; then
42 echo "rebinding UCD driver. Retry number $j"
43 sleep 1
44 fi
Saqib Khane71ba0b2017-02-08 10:13:01 -060045 done
46 if [ ! -e $ucdpath/$ucd ]; then exit $ret; fi
Sergey Solomin11d63cf2016-11-28 15:03:24 -060047fi
Saqib Khane71ba0b2017-02-08 10:13:01 -060048